@@ -75,12 +75,8 @@ DeduceLongrunningOperationResponseType(
7575} // namespace
7676
7777bool IsLongrunningOperation (MethodDescriptor const & method) {
78- bool grpc_lro =
79- method.output_type ()->full_name () == " google.longrunning.Operation" ;
80- auto operation_service_extension =
81- method.options ().GetExtension (google::cloud::operation_service);
82- bool http_lro = !operation_service_extension.empty ();
83- return grpc_lro || http_lro;
78+ return IsGRPCLongrunningOperation (method) ||
79+ IsHttpLongrunningOperation (method);
8480}
8581
8682bool IsLongrunningMetadataTypeUsedAsResponse (MethodDescriptor const & method) {
@@ -95,10 +91,11 @@ bool IsLongrunningMetadataTypeUsedAsResponse(MethodDescriptor const& method) {
9591void SetLongrunningOperationMethodVars (
9692 google::protobuf::MethodDescriptor const & method,
9793 VarsDictionary& method_vars) {
94+ if (!IsLongrunningOperation (method)) return ;
9895 method_vars[" longrunning_operation_type" ] =
9996 ProtoNameToCppName (method.output_type ()->full_name ());
10097
101- if (method. output_type ()-> full_name () == " google.longrunning.Operation " ) {
98+ if (IsGRPCLongrunningOperation (method) ) {
10299 auto operation_info =
103100 method.options ().GetExtension (google::longrunning::operation_info);
104101 method_vars[" longrunning_metadata_type" ] = ProtoNameToCppName (absl::visit (
@@ -118,9 +115,7 @@ void SetLongrunningOperationMethodVars(
118115 return ;
119116 }
120117
121- auto operation_service_extension =
122- method.options ().GetExtension (google::cloud::operation_service);
123- if (!operation_service_extension.empty ()) {
118+ if (IsHttpLongrunningOperation (method)) {
124119 method_vars[" longrunning_response_type" ] = ProtoNameToCppName (absl::visit (
125120 FullyQualifiedMessageTypeVisitor (),
126121 FullyQualifyMessageType (method, method.output_type ()->full_name ())));
@@ -136,7 +131,8 @@ void SetLongrunningOperationMethodVars(
136131}
137132
138133bool IsGRPCLongrunningOperation (MethodDescriptor const & method) {
139- return method.output_type ()->full_name () == " google.longrunning.Operation" ;
134+ return method.output_type ()->full_name () == " google.longrunning.Operation" &&
135+ method.options ().HasExtension (google::longrunning::operation_info);
140136}
141137
142138bool IsHttpLongrunningOperation (MethodDescriptor const & method) {
@@ -150,7 +146,7 @@ void SetLongrunningOperationServiceVars(
150146 VarsDictionary& service_vars) {
151147 for (int i = 0 ; i != service.method_count (); ++i) {
152148 auto const * method = service.method (i);
153- if (method-> output_type ()-> full_name () == " google.longrunning.Operation " ) {
149+ if (IsGRPCLongrunningOperation (*method) ) {
154150 service_vars[" longrunning_operation_include_header" ] =
155151 " google/longrunning/operations.pb.h" ;
156152 service_vars[" longrunning_response_type" ] =
@@ -169,9 +165,7 @@ void SetLongrunningOperationServiceVars(
169165 R"""( absl::StrCat("/", rest_internal::DetermineApiVersion("v1", *options) ,"/", request.name(), ":cancel"))""" ;
170166 return ;
171167 }
172- if (!method->options ()
173- .GetExtension (google::cloud::operation_service)
174- .empty ()) {
168+ if (IsHttpLongrunningOperation (*method)) {
175169 service_vars[" longrunning_response_type" ] = ProtoNameToCppName (
176170 absl::visit (FullyQualifiedMessageTypeVisitor (),
177171 FullyQualifyMessageType (
0 commit comments