gapic-common 0.10.0 → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5962314c78d1864ee6b768003c887d15af76619c8644a96392f0931ad6f2712c
4
- data.tar.gz: 89920288c50070f089949eb11ff94010a52b69d1919b5e4ab6eb50cd9a3610ad
3
+ metadata.gz: 5902b53f0f5a46b4682ff855fb89a6a3162af38523fa273f273abeeeed0d3a3d
4
+ data.tar.gz: a1e9bb69d31725768f00b152efcaf29042657fbb304c2ba2f25de485831fe187
5
5
  SHA512:
6
- metadata.gz: 02c0113ca2287b79558c698393b3315b85c4359b15b90bf54929ea7e7f04a5189769559a69d22f35cebcedb99d62d1a02b2a7ca16739ea724565ace848a89279
7
- data.tar.gz: cf43e6bedb320bc4f91f22e4b0354c87583b92e5734ea4d5d40d280bd9ffeaf0d272eda97e1e9bae2ce7e507e8a56a76c4a5c26ca5156326e7edd1bc88dfc5d9
6
+ metadata.gz: 84d77cc3d943714b8a3578ecabf3fea3a321dfe0929ee108233d4dcd8fede90a37be21a81e121142739aa3dca102ffff0826a003906bec16f03749beddf59ab2
7
+ data.tar.gz: 27e2815be724399a4c01ca1d47c7b2e9291ee4583018251f45a2a0162f1d5cd8298d0ca3b8a4cf90fc4ba6f2e410240439e61a22a66fbeae89c5a3e9dc223879
data/CHANGELOG.md CHANGED
@@ -1,5 +1,55 @@
1
1
  # Release History
2
2
 
3
+ ### 0.15.0 (2022-11-17)
4
+
5
+ #### Features
6
+
7
+ * retry policy now works for REST calls
8
+
9
+ ### 0.14.0 (2022-11-08)
10
+
11
+ #### Features
12
+
13
+ * add support for different types of credentials to REST
14
+ #### Bug Fixes
15
+
16
+ * deadlock fix ([#845](https://github.com/googleapis/gapic-generator-ruby/issues/845))
17
+
18
+ ### 0.13.0 (2022-10-26)
19
+
20
+ #### Features
21
+
22
+ * Implement server-side streaming support for REST calls in gapic-common ([#826](https://github.com/googleapis/gapic-generator-ruby/issues/826))
23
+
24
+ ### 0.12.0 (2022-09-15)
25
+
26
+ #### Features
27
+
28
+ * Support numeric_enums in the ClientStub ([#817](https://github.com/googleapis/gapic-generator-ruby/issues/817))
29
+ * parse details information from REST errors ([#815](https://github.com/googleapis/gapic-generator-ruby/issues/815))
30
+ * send protobuf version in headers ([#816](https://github.com/googleapis/gapic-generator-ruby/issues/816))
31
+
32
+ #### Bug Fixes
33
+
34
+ * rewrap certain grpc errors ([#810](https://github.com/googleapis/gapic-generator-ruby/issues/810))
35
+ This will rewrap some GRPC::Unavailable errors that were caused by authentication failing as Gapic::GRPC::AuthorizationError which inherits from ::GRPC::Unauthenticated
36
+
37
+ ### 0.11.1 (2022-08-03)
38
+
39
+ #### Bug Fixes
40
+
41
+ * error code of 0 is not an error, body template field can be nil ([#805](https://github.com/googleapis/gapic-generator-ruby/issues/805))
42
+
43
+ ### 0.11.0 (2022-07-27)
44
+
45
+ #### Features
46
+
47
+ * Add CallOptions#merge and CallOptions equality checking ([#802](https://github.com/googleapis/gapic-generator-ruby/issues/802))
48
+
49
+ #### Bug Fixes
50
+
51
+ * transcoder should always preserve slashes ([#795](https://github.com/googleapis/gapic-generator-ruby/issues/795))
52
+
3
53
  ### 0.10.0 (2022-06-20)
4
54
 
5
55
  #### Features
@@ -0,0 +1,71 @@
1
+ # Copyright 2019 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ module Gapic
16
+ class CallOptions
17
+ ##
18
+ # @private
19
+ # The gRPC error codes and their HTTP mapping
20
+ #
21
+ module ErrorCodes
22
+ # @private
23
+ # See https://grpc.github.io/grpc/core/md_doc_statuscodes.html for a
24
+ # list of error codes.
25
+ error_code_mapping = [
26
+ "OK",
27
+ "CANCELLED",
28
+ "UNKNOWN",
29
+ "INVALID_ARGUMENT",
30
+ "DEADLINE_EXCEEDED",
31
+ "NOT_FOUND",
32
+ "ALREADY_EXISTS",
33
+ "PERMISSION_DENIED",
34
+ "RESOURCE_EXHAUSTED",
35
+ "FAILED_PRECONDITION",
36
+ "ABORTED",
37
+ "OUT_OF_RANGE",
38
+ "UNIMPLEMENTED",
39
+ "INTERNAL",
40
+ "UNAVAILABLE",
41
+ "DATA_LOSS",
42
+ "UNAUTHENTICATED"
43
+ ].freeze
44
+
45
+ # @private
46
+ ERROR_STRING_MAPPING = error_code_mapping.each_with_index.to_h.freeze
47
+
48
+ # @private
49
+ # Converts http error codes into corresponding gRPC ones
50
+ def self.grpc_error_for http_error_code
51
+ return 2 unless http_error_code
52
+
53
+ # The http status codes mapped to their error classes.
54
+ {
55
+ 400 => 3, # InvalidArgumentError
56
+ 401 => 16, # UnauthenticatedError
57
+ 403 => 7, # PermissionDeniedError
58
+ 404 => 5, # NotFoundError
59
+ 409 => 6, # AlreadyExistsError
60
+ 412 => 9, # FailedPreconditionError
61
+ 429 => 8, # ResourceExhaustedError
62
+ 499 => 1, # CanceledError
63
+ 500 => 13, # InternalError
64
+ 501 => 12, # UnimplementedError
65
+ 503 => 14, # UnavailableError
66
+ 504 => 4 # DeadlineExceededError
67
+ }[http_error_code] || 2 # UnknownError
68
+ end
69
+ end
70
+ end
71
+ end
@@ -12,6 +12,8 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ require "gapic/call_options/error_codes"
16
+
15
17
  module Gapic
16
18
  class CallOptions
17
19
  ##
@@ -74,6 +76,7 @@ module Gapic
74
76
  #
75
77
  # @param retry_policy [Hash] The policy for error retry. keys must match the arguments for
76
78
  # {RpcCall::RetryPolicy.new}.
79
+ #
77
80
  def apply_defaults retry_policy
78
81
  return unless retry_policy.is_a? Hash
79
82
 
@@ -85,38 +88,27 @@ module Gapic
85
88
  self
86
89
  end
87
90
 
88
- # @private
89
- # See https://grpc.github.io/grpc/core/md_doc_statuscodes.html for a
90
- # list of error codes.
91
- ERROR_CODE_MAPPING = [
92
- "OK",
93
- "CANCELLED",
94
- "UNKNOWN",
95
- "INVALID_ARGUMENT",
96
- "DEADLINE_EXCEEDED",
97
- "NOT_FOUND",
98
- "ALREADY_EXISTS",
99
- "PERMISSION_DENIED",
100
- "RESOURCE_EXHAUSTED",
101
- "FAILED_PRECONDITION",
102
- "ABORTED",
103
- "OUT_OF_RANGE",
104
- "UNIMPLEMENTED",
105
- "INTERNAL",
106
- "UNAVAILABLE",
107
- "DATA_LOSS",
108
- "UNAUTHENTICATED"
109
- ].freeze
91
+ # @private Equality test
92
+ def eql? other
93
+ other.is_a?(RetryPolicy) &&
94
+ other.retry_codes == retry_codes &&
95
+ other.initial_delay == initial_delay &&
96
+ other.multiplier == multiplier &&
97
+ other.max_delay == max_delay
98
+ end
99
+ alias == eql?
110
100
 
111
- # @private
112
- ERROR_STRING_MAPPING = ERROR_CODE_MAPPING.each_with_index.each_with_object({}) do |(str, num), hash|
113
- hash[str] = num
114
- end.freeze
101
+ # @private Hash code
102
+ def hash
103
+ [retry_codes, initial_delay, multiplier, max_delay].hash
104
+ end
115
105
 
116
106
  private
117
107
 
118
108
  def retry? error
119
- error.is_a?(GRPC::BadStatus) && retry_codes.include?(error.code)
109
+ (error.is_a?(::GRPC::BadStatus) && retry_codes.include?(error.code)) ||
110
+ (error.respond_to?(:response_status) &&
111
+ retry_codes.include?(ErrorCodes.grpc_error_for(error.response_status)))
120
112
  end
121
113
 
122
114
  def delay!
@@ -129,7 +121,7 @@ module Gapic
129
121
  Array(input_codes).map do |obj|
130
122
  case obj
131
123
  when String
132
- ERROR_STRING_MAPPING[obj]
124
+ ErrorCodes::ERROR_STRING_MAPPING[obj]
133
125
  when Integer
134
126
  obj
135
127
  end
@@ -12,6 +12,7 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ require "gapic/call_options/error_codes"
15
16
  require "gapic/call_options/retry_policy"
16
17
 
17
18
  module Gapic
@@ -61,12 +62,18 @@ module Gapic
61
62
  # @param retry_policy [Hash] the policy for error retry.
62
63
  # @param retry_policy [Hash] The policy for error retry. keys must match the arguments for
63
64
  # {RetryPolicy.new}.
65
+ #
64
66
  def apply_defaults timeout: nil, metadata: nil, retry_policy: nil
65
67
  @timeout ||= timeout
66
68
  @metadata = metadata.merge @metadata if metadata
67
69
  @retry_policy.apply_defaults retry_policy if @retry_policy.respond_to? :apply_defaults
68
70
  end
69
71
 
72
+ ##
73
+ # Convert to hash form.
74
+ #
75
+ # @return [Hash]
76
+ #
70
77
  def to_h
71
78
  {
72
79
  timeout: timeout,
@@ -74,5 +81,31 @@ module Gapic
74
81
  retry_policy: retry_policy
75
82
  }
76
83
  end
84
+
85
+ ##
86
+ # Return a new CallOptions with the given modifications. The current object
87
+ # is not modified.
88
+ #
89
+ # @param kwargs [keywords] Updated fields. See {#initialize} for details.
90
+ # @return [CallOptions] A new CallOptions object.
91
+ #
92
+ def merge **kwargs
93
+ kwargs = to_h.merge kwargs
94
+ CallOptions.new(**kwargs)
95
+ end
96
+
97
+ # @private Equality test
98
+ def eql? other
99
+ other.is_a?(CallOptions) &&
100
+ other.timeout == timeout &&
101
+ other.metadata == metadata &&
102
+ other.retry_policy == retry_policy
103
+ end
104
+ alias == eql?
105
+
106
+ # @private Hash code
107
+ def hash
108
+ to_h.hash
109
+ end
77
110
  end
78
111
  end
@@ -14,6 +14,6 @@
14
14
 
15
15
  module Gapic
16
16
  module Common
17
- VERSION = "0.10.0".freeze
17
+ VERSION = "0.15.0".freeze
18
18
  end
19
19
  end
@@ -140,7 +140,8 @@ module Gapic
140
140
  # @return [Boolean] Whether an error has been returned.
141
141
  #
142
142
  def error?
143
- done? && (!err.nil? || !error_code.nil?)
143
+ no_error_code = error_code.nil? || error_code.zero?
144
+ done? && !(err.nil? && no_error_code)
144
145
  end
145
146
 
146
147
  ##
@@ -0,0 +1,60 @@
1
+ # Copyright 2019 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require "googleauth"
16
+ require "gapic/common/error"
17
+
18
+ module Gapic
19
+ module GRPC
20
+ ##
21
+ # An error class to represent the Authorization Error.
22
+ # The GRPC layer wraps auth plugin errors in ::GRPC::Unavailable.
23
+ # This class rewraps those GRPC layer errors, presenting a correct status code.
24
+ #
25
+ class AuthorizationError < ::GRPC::Unauthenticated
26
+ end
27
+
28
+ ##
29
+ # An error class that represents Deadline Exceeded error with an optional
30
+ # retry root cause.
31
+ #
32
+ # The GRPC layer throws ::GRPC::DeadlineExceeded without any context.
33
+ # If the deadline was exceeded while retrying another exception (e.g.
34
+ # ::GRPC::Unavailable), that exception could be useful for understanding
35
+ # the readon for the timeout.
36
+ #
37
+ # This exception rewraps ::GRPC::DeadlineExceeded, adding an exception
38
+ # that was being retried until the deadline was exceeded (if any) as a
39
+ # `root_cause` attribute.
40
+ #
41
+ # @!attribute [r] root_cause
42
+ # @return [Object, nil] The exception that was being retried
43
+ # when the DeadlineExceeded error occured.
44
+ #
45
+ class DeadlineExceededError < ::GRPC::DeadlineExceeded
46
+ attr_reader :root_cause
47
+
48
+ ##
49
+ # @param message [String] The error message.
50
+ #
51
+ # @param root_cause [Object, nil] The exception that was being retried
52
+ # when the DeadlineExceeded error occured.
53
+ #
54
+ def initialize message, root_cause: nil
55
+ super message
56
+ @root_cause = root_cause
57
+ end
58
+ end
59
+ end
60
+ end
@@ -13,6 +13,7 @@
13
13
  # limitations under the License.
14
14
 
15
15
  require "gapic/call_options"
16
+ require "grpc/errors"
16
17
 
17
18
  module Gapic
18
19
  class ServiceStub
@@ -45,7 +46,7 @@ module Gapic
45
46
  #
46
47
  # @yield [response, operation] Access the response along with the RPC operation.
47
48
  # @yieldparam response [Object] The response object.
48
- # @yieldparam operation [GRPC::ActiveCall::Operation] The RPC operation for the response.
49
+ # @yieldparam operation [::GRPC::ActiveCall::Operation] The RPC operation for the response.
49
50
  #
50
51
  # @return [Object] The response object.
51
52
  #
@@ -55,7 +56,7 @@ module Gapic
55
56
  # require "gapic"
56
57
  # require "gapic/grpc"
57
58
  #
58
- # echo_channel = GRPC::Core::Channel.new(
59
+ # echo_channel = ::GRPC::Core::Channel.new(
59
60
  # "localhost:7469", nil, :this_channel_is_insecure
60
61
  # )
61
62
  # echo_stub = Gapic::ServiceStub.new(
@@ -73,7 +74,7 @@ module Gapic
73
74
  # require "gapic"
74
75
  # require "gapic/grpc"
75
76
  #
76
- # echo_channel = GRPC::Core::Channel.new(
77
+ # echo_channel = ::GRPC::Core::Channel.new(
77
78
  # "localhost:7469", nil, :this_channel_is_insecure
78
79
  # )
79
80
  # echo_stub = Gapic::ServiceStub.new(
@@ -85,7 +86,7 @@ module Gapic
85
86
  # request = Google::Showcase::V1beta1::EchoRequest.new
86
87
  # options = Gapic::CallOptions.new(
87
88
  # retry_policy = {
88
- # retry_codes: [GRPC::Core::StatusCodes::UNAVAILABLE]
89
+ # retry_codes: [::GRPC::Core::StatusCodes::UNAVAILABLE]
89
90
  # }
90
91
  # )
91
92
  # response = echo_call.call request, options: options
@@ -96,7 +97,7 @@ module Gapic
96
97
  # require "gapic"
97
98
  # require "gapic/grpc"
98
99
  #
99
- # echo_channel = GRPC::Core::Channel.new(
100
+ # echo_channel = ::GRPC::Core::Channel.new(
100
101
  # "localhost:7469", nil, :this_channel_is_insecure
101
102
  # )
102
103
  # echo_stub = Gapic::ServiceStub.new(
@@ -116,13 +117,23 @@ module Gapic
116
117
  deadline = calculate_deadline options
117
118
  metadata = options.metadata
118
119
 
120
+ retried_exception = nil
119
121
  begin
120
122
  operation = stub_method.call request, deadline: deadline, metadata: metadata, return_op: true
121
123
  response = operation.execute
122
124
  yield response, operation if block_given?
123
125
  response
126
+ rescue ::GRPC::DeadlineExceeded => e
127
+ raise Gapic::GRPC::DeadlineExceededError.new e.message, root_cause: retried_exception
124
128
  rescue StandardError => e
125
- retry if check_retry?(deadline) && options.retry_policy.call(e)
129
+ if e.is_a?(::GRPC::Unavailable) && /Signet::AuthorizationError/ =~ e.message
130
+ e = Gapic::GRPC::AuthorizationError.new e.message.gsub(%r{^\d+:}, "")
131
+ end
132
+
133
+ if check_retry?(deadline) && options.retry_policy.call(e)
134
+ retried_exception = e
135
+ retry
136
+ end
126
137
 
127
138
  raise e
128
139
  end
@@ -34,20 +34,20 @@ module Gapic
34
34
  # @param grpc_stub_class [Class] gRPC stub class to create a new instance of.
35
35
  # @param endpoint [String] The endpoint of the API.
36
36
  # @param credentials [Google::Auth::Credentials, Signet::OAuth2::Client, String, Hash, Proc,
37
- # GRPC::Core::Channel, GRPC::Core::ChannelCredentials] Provides the means for authenticating requests made by
37
+ # ::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] Provides the means for authenticating requests made by
38
38
  # the client. This parameter can be many types:
39
39
  #
40
40
  # * A `Google::Auth::Credentials` uses a the properties of its represented keyfile for authenticating requests
41
41
  # made by this client.
42
42
  # * A `Signet::OAuth2::Client` object used to apply the OAuth credentials.
43
- # * A `GRPC::Core::Channel` will be used to make calls through.
44
- # * A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials should
45
- # already be composed with a `GRPC::Core::CallCredentials` object.
43
+ # * A `::GRPC::Core::Channel` will be used to make calls through.
44
+ # * A `::GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials should
45
+ # already be composed with a `::GRPC::Core::CallCredentials` object.
46
46
  # * A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the metadata for
47
47
  # requests, generally, to give OAuth credentials.
48
48
  # @param channel_args [Hash] The channel arguments. (This argument is ignored when `credentials` is
49
- # provided as a `GRPC::Core::Channel`.)
50
- # @param interceptors [Array<GRPC::ClientInterceptor>] An array of {GRPC::ClientInterceptor} objects that will
49
+ # provided as a `::GRPC::Core::Channel`.)
50
+ # @param interceptors [Array<::GRPC::ClientInterceptor>] An array of {::GRPC::ClientInterceptor} objects that will
51
51
  # be used for intercepting calls before they are executed Interceptors are an EXPERIMENTAL API.
52
52
  #
53
53
  def initialize grpc_stub_class, endpoint:, credentials:, channel_args: nil, interceptors: nil
@@ -59,10 +59,10 @@ module Gapic
59
59
  interceptors = Array interceptors
60
60
 
61
61
  @grpc_stub = case credentials
62
- when GRPC::Core::Channel
62
+ when ::GRPC::Core::Channel
63
63
  grpc_stub_class.new endpoint, nil, channel_override: credentials,
64
64
  interceptors: interceptors
65
- when GRPC::Core::ChannelCredentials, Symbol
65
+ when ::GRPC::Core::ChannelCredentials, Symbol
66
66
  grpc_stub_class.new endpoint, credentials, channel_args: channel_args,
67
67
  interceptors: interceptors
68
68
  else
@@ -70,8 +70,8 @@ module Gapic
70
70
  updater_proc ||= credentials if credentials.is_a? Proc
71
71
  raise ArgumentError, "invalid credentials (#{credentials.class})" if updater_proc.nil?
72
72
 
73
- call_creds = GRPC::Core::CallCredentials.new updater_proc
74
- chan_creds = GRPC::Core::ChannelCredentials.new.compose call_creds
73
+ call_creds = ::GRPC::Core::CallCredentials.new updater_proc
74
+ chan_creds = ::GRPC::Core::ChannelCredentials.new.compose call_creds
75
75
  grpc_stub_class.new endpoint, chan_creds, channel_args: channel_args,
76
76
  interceptors: interceptors
77
77
  end
@@ -88,7 +88,7 @@ module Gapic
88
88
  #
89
89
  # @yield [response, operation] Access the response along with the RPC operation.
90
90
  # @yieldparam response [Object] The response object.
91
- # @yieldparam operation [GRPC::ActiveCall::Operation] The RPC operation for the response.
91
+ # @yieldparam operation [::GRPC::ActiveCall::Operation] The RPC operation for the response.
92
92
  #
93
93
  # @return [Object] The response object.
94
94
  #
@@ -98,7 +98,7 @@ module Gapic
98
98
  # require "gapic"
99
99
  # require "gapic/grpc"
100
100
  #
101
- # echo_channel = GRPC::Core::Channel.new(
101
+ # echo_channel = ::GRPC::Core::Channel.new(
102
102
  # "localhost:7469", nil, :this_channel_is_insecure
103
103
  # )
104
104
  # echo_stub = Gapic::ServiceStub.new(
@@ -115,7 +115,7 @@ module Gapic
115
115
  # require "gapic"
116
116
  # require "gapic/grpc"
117
117
  #
118
- # echo_channel = GRPC::Core::Channel.new(
118
+ # echo_channel = ::GRPC::Core::Channel.new(
119
119
  # "localhost:7469", nil, :this_channel_is_insecure
120
120
  # )
121
121
  # echo_stub = Gapic::ServiceStub.new(
@@ -126,7 +126,7 @@ module Gapic
126
126
  # request = Google::Showcase::V1beta1::EchoRequest.new
127
127
  # options = Gapic::CallOptions.new(
128
128
  # retry_policy = {
129
- # retry_codes: [GRPC::Core::StatusCodes::UNAVAILABLE]
129
+ # retry_codes: [::GRPC::Core::StatusCodes::UNAVAILABLE]
130
130
  # }
131
131
  # )
132
132
  # response = echo_stub.call_rpc :echo, request
@@ -138,7 +138,7 @@ module Gapic
138
138
  # require "gapic"
139
139
  # require "gapic/grpc"
140
140
  #
141
- # echo_channel = GRPC::Core::Channel.new(
141
+ # echo_channel = ::GRPC::Core::Channel.new(
142
142
  # "localhost:7469", nil, :this_channel_is_insecure
143
143
  # )
144
144
  # echo_stub = Gapic::ServiceStub.new(
data/lib/gapic/grpc.rb CHANGED
@@ -13,5 +13,6 @@
13
13
  # limitations under the License.
14
14
 
15
15
  require "grpc"
16
+ require "gapic/grpc/errors"
16
17
  require "gapic/grpc/service_stub"
17
18
  require "gapic/grpc/status_details"
data/lib/gapic/headers.rb CHANGED
@@ -25,7 +25,7 @@ module Gapic
25
25
  # @param lib_version [String] The client library version.
26
26
  # @param gax_version [String] The Gapic version. Defaults to `Gapic::Common::VERSION`.
27
27
  # @param gapic_version [String] The Gapic version.
28
- # @param grpc_version [String] The GRPC version. Defaults to `GRPC::VERSION`.
28
+ # @param grpc_version [String] The GRPC version. Defaults to `::GRPC::VERSION`.
29
29
  # @param rest_version [String] The Rest Library (Faraday) version. Defaults to `Faraday::VERSION`.
30
30
  # @param transports_version_send [Array] Which transports to send versions for.
31
31
  # Allowed values to contain are:
@@ -33,13 +33,14 @@ module Gapic
33
33
  # `:rest` to send the REST library version (if defined)
34
34
  # Defaults to `[:grpc]`
35
35
  def self.x_goog_api_client ruby_version: nil, lib_name: nil, lib_version: nil, gax_version: nil,
36
- gapic_version: nil, grpc_version: nil, rest_version: nil,
36
+ gapic_version: nil, grpc_version: nil, rest_version: nil, protobuf_version: nil,
37
37
  transports_version_send: [:grpc]
38
38
 
39
39
  ruby_version ||= ::RUBY_VERSION
40
40
  gax_version ||= ::Gapic::Common::VERSION
41
41
  grpc_version ||= ::GRPC::VERSION if defined? ::GRPC::VERSION
42
- rest_version ||= ::Faraday::VERSION if defined? ::Faraday
42
+ rest_version ||= ::Faraday::VERSION if defined? ::Faraday::VERSION
43
+ protobuf_version ||= Gem.loaded_specs["google-protobuf"].version.to_s if Gem.loaded_specs.key? "google-protobuf"
43
44
 
44
45
  x_goog_api_client_header = ["gl-ruby/#{ruby_version}"]
45
46
  x_goog_api_client_header << "#{lib_name}/#{lib_version}" if lib_name
@@ -47,6 +48,7 @@ module Gapic
47
48
  x_goog_api_client_header << "gapic/#{gapic_version}" if gapic_version
48
49
  x_goog_api_client_header << "grpc/#{grpc_version}" if grpc_version && transports_version_send.include?(:grpc)
49
50
  x_goog_api_client_header << "rest/#{rest_version}" if rest_version && transports_version_send.include?(:rest)
51
+ x_goog_api_client_header << "pb/#{protobuf_version}" if protobuf_version
50
52
  x_goog_api_client_header.join " ".freeze
51
53
  end
52
54
  end
@@ -53,7 +53,7 @@ module Gapic
53
53
  # @param method_name [Symbol] The RPC method name.
54
54
  # @param request [Object] The request object.
55
55
  # @param response [Object] The response object.
56
- # @param operation [GRPC::ActiveCall::Operation] The RPC operation for the response.
56
+ # @param operation [::GRPC::ActiveCall::Operation] The RPC operation for the response.
57
57
  # @param options [Gapic::CallOptions] The options for making the RPC call.
58
58
  # @param format_resource [Proc] A Proc object to format the resource object. The Proc should accept response as an
59
59
  # argument, and return a formatted resource object. Optional.
@@ -195,7 +195,7 @@ module Gapic
195
195
  # @attribute [r] response
196
196
  # @return [Object] the response object for the page.
197
197
  # @attribute [r] operation
198
- # @return [GRPC::ActiveCall::Operation] the RPC operation for the page.
198
+ # @return [::GRPC::ActiveCall::Operation] the RPC operation for the page.
199
199
  class Page
200
200
  include Enumerable
201
201
  attr_reader :response
@@ -205,7 +205,7 @@ module Gapic
205
205
  # @private
206
206
  # @param response [Object] The response object for the page.
207
207
  # @param resource_field [String] The name of the field in response which holds the resources.
208
- # @param operation [GRPC::ActiveCall::Operation] the RPC operation for the page.
208
+ # @param operation [::GRPC::ActiveCall::Operation] the RPC operation for the page.
209
209
  # @param format_resource [Proc] A Proc object to format the resource object. The Proc should accept response as an
210
210
  # argument, and return a formatted resource object. Optional.
211
211
  #