gapic-common 0.9.0 → 0.11.1

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: 4187157fccf115d742dc9e5b074feccf9b65a5dc241bab8214810b4c257288a8
4
- data.tar.gz: 7160ec37659fd5bbffc3e517bd40a65295da42fad7743b38869b58d59a34b09f
3
+ metadata.gz: 4362fc972a82bd5c92fdf8172a0ad005f371ecfaf968d251e19bc64b73681652
4
+ data.tar.gz: 85ebd85fef5f54aecfec53ffba4a83e2d7b03ecc26c474ffe64f2644241ae74f
5
5
  SHA512:
6
- metadata.gz: 71cdc0f8c19c10a51dee060c3048b8b13b8223c0e527e103629058504b60013180e24232ae729014943e1d4b66ba98563796f35558d0d2b5fd955a49f0abf720
7
- data.tar.gz: 31b53d85d36746f58b17e778f8fd4b5469a782ae9a68c3847eee309dcb5b2b4ae068785e295763ac17d081518656427408142426cfa7b0f128287599df3e2c47
6
+ metadata.gz: c1b4b4844fbc1380ccb5e82098c9e8647437da5cbfea789d0eb94543c020b10e97187faf5ac600b6b83d8091172b14f29d9cf05bb93017369b8126af21e49415
7
+ data.tar.gz: d046faba797ec8b2d76ec66cc2deb12fca86c570a090c05e97ecb844c1aebe8591d56d84a3910a226a8895f0171b1d060ede34a8879c103a76a0ec7da5ad7c7d
data/CHANGELOG.md CHANGED
@@ -1,5 +1,32 @@
1
1
  # Release History
2
2
 
3
+ ### 0.11.1 (2022-08-03)
4
+
5
+ #### Bug Fixes
6
+
7
+ * error code of 0 is not an error, body template field can be nil ([#805](https://github.com/googleapis/gapic-generator-ruby/issues/805))
8
+
9
+ ### 0.11.0 (2022-07-27)
10
+
11
+ #### Features
12
+
13
+ * Add CallOptions#merge and CallOptions equality checking ([#802](https://github.com/googleapis/gapic-generator-ruby/issues/802))
14
+
15
+ #### Bug Fixes
16
+
17
+ * transcoder should always preserve slashes ([#795](https://github.com/googleapis/gapic-generator-ruby/issues/795))
18
+
19
+ ### 0.10.0 (2022-06-20)
20
+
21
+ #### Features
22
+
23
+ * Require at least Ruby 2.6
24
+ * Support faraday 2.0
25
+ #### Bug Fixes
26
+
27
+ * Fix precision issues in protobuf timestamp conversion
28
+ * Fix some Ruby 3.0 keyword argument usage errors
29
+
3
30
  ### 0.9.0 (2022-05-18)
4
31
 
5
32
  #### Features
data/README.md CHANGED
@@ -15,11 +15,11 @@ convenient and idiomatic API surface to callers.
15
15
 
16
16
  ## Supported Ruby Versions
17
17
 
18
- This library is supported on Ruby 2.4+.
18
+ This library is supported on Ruby 2.6+.
19
19
 
20
20
  Google provides official support for Ruby versions that are actively supported
21
21
  by Ruby Core—that is, Ruby versions that are either in normal maintenance or in
22
- security maintenance, and not end of life. Currently, this means Ruby 2.4 and
22
+ security maintenance, and not end of life. Currently, this means Ruby 2.6 and
23
23
  later. Older versions of Ruby _may_ still work, but are unsupported and not
24
24
  recommended. See https://www.ruby-lang.org/en/downloads/branches/ for details
25
25
  about the Ruby support schedule.
@@ -74,6 +74,7 @@ module Gapic
74
74
  #
75
75
  # @param retry_policy [Hash] The policy for error retry. keys must match the arguments for
76
76
  # {RpcCall::RetryPolicy.new}.
77
+ #
77
78
  def apply_defaults retry_policy
78
79
  return unless retry_policy.is_a? Hash
79
80
 
@@ -85,6 +86,21 @@ module Gapic
85
86
  self
86
87
  end
87
88
 
89
+ # @private Equality test
90
+ def eql? other
91
+ other.is_a?(RetryPolicy) &&
92
+ other.retry_codes == retry_codes &&
93
+ other.initial_delay == initial_delay &&
94
+ other.multiplier == multiplier &&
95
+ other.max_delay == max_delay
96
+ end
97
+ alias == eql?
98
+
99
+ # @private Hash code
100
+ def hash
101
+ [retry_codes, initial_delay, multiplier, max_delay].hash
102
+ end
103
+
88
104
  # @private
89
105
  # See https://grpc.github.io/grpc/core/md_doc_statuscodes.html for a
90
106
  # list of error codes.
@@ -61,12 +61,18 @@ module Gapic
61
61
  # @param retry_policy [Hash] the policy for error retry.
62
62
  # @param retry_policy [Hash] The policy for error retry. keys must match the arguments for
63
63
  # {RetryPolicy.new}.
64
+ #
64
65
  def apply_defaults timeout: nil, metadata: nil, retry_policy: nil
65
66
  @timeout ||= timeout
66
67
  @metadata = metadata.merge @metadata if metadata
67
68
  @retry_policy.apply_defaults retry_policy if @retry_policy.respond_to? :apply_defaults
68
69
  end
69
70
 
71
+ ##
72
+ # Convert to hash form.
73
+ #
74
+ # @return [Hash]
75
+ #
70
76
  def to_h
71
77
  {
72
78
  timeout: timeout,
@@ -74,5 +80,31 @@ module Gapic
74
80
  retry_policy: retry_policy
75
81
  }
76
82
  end
83
+
84
+ ##
85
+ # Return a new CallOptions with the given modifications. The current object
86
+ # is not modified.
87
+ #
88
+ # @param kwargs [keywords] Updated fields. See {#initialize} for details.
89
+ # @return [CallOptions] A new CallOptions object.
90
+ #
91
+ def merge **kwargs
92
+ kwargs = to_h.merge kwargs
93
+ CallOptions.new(**kwargs)
94
+ end
95
+
96
+ # @private Equality test
97
+ def eql? other
98
+ other.is_a?(CallOptions) &&
99
+ other.timeout == timeout &&
100
+ other.metadata == metadata &&
101
+ other.retry_policy == retry_policy
102
+ end
103
+ alias == eql?
104
+
105
+ # @private Hash code
106
+ def hash
107
+ to_h.hash
108
+ end
77
109
  end
78
110
  end
@@ -14,6 +14,6 @@
14
14
 
15
15
  module Gapic
16
16
  module Common
17
- VERSION = "0.9.0".freeze
17
+ VERSION = "0.11.1".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
  ##
@@ -198,7 +199,7 @@ module Gapic
198
199
  # @yield operation [Gapic::GenericLRO::Operation] Yields the finished Operation.
199
200
  #
200
201
  def wait_until_done! retry_policy: nil
201
- retry_policy = ::Gapic::Operation::RetryPolicy.new retry_policy if retry_policy.is_a? Hash
202
+ retry_policy = ::Gapic::Operation::RetryPolicy.new(**retry_policy) if retry_policy.is_a? Hash
202
203
  retry_policy ||= ::Gapic::Operation::RetryPolicy.new
203
204
 
204
205
  until done?
@@ -253,7 +253,7 @@ module Gapic
253
253
  # @yield operation [Gapic::Operation] Yields the finished Operation.
254
254
  #
255
255
  def wait_until_done! retry_policy: nil
256
- retry_policy = RetryPolicy.new retry_policy if retry_policy.is_a? Hash
256
+ retry_policy = RetryPolicy.new(**retry_policy) if retry_policy.is_a? Hash
257
257
  retry_policy ||= RetryPolicy.new
258
258
 
259
259
  until done?
@@ -181,8 +181,7 @@ module Gapic
181
181
 
182
182
  min_repeated_field_number = fields.map(&:number).min
183
183
  if min_repeated_field_number != repeated_field.number
184
- raise ArgumentError, "#{@response.class} must have one primary repeated field " \
185
- "by both position and number"
184
+ raise ArgumentError, "#{@response.class} must have one primary repeated field by both position and number"
186
185
  end
187
186
 
188
187
  # We have the correct repeated field, save the field's name
@@ -134,7 +134,7 @@ module Gapic
134
134
  #
135
135
  # @return [Time] The converted Time.
136
136
  def self.timestamp_to_time timestamp
137
- Time.at timestamp.nanos * 10**-9 + timestamp.seconds
137
+ Time.at timestamp.seconds, timestamp.nanos, :nanosecond
138
138
  end
139
139
 
140
140
  ##
@@ -14,6 +14,7 @@
14
14
 
15
15
  require "googleauth"
16
16
  require "gapic/rest/faraday_middleware"
17
+ require "faraday/retry"
17
18
 
18
19
  module Gapic
19
20
  module Rest
@@ -49,8 +49,8 @@ module Gapic
49
49
  matches.each do |name, _regex, _preserve_slashes|
50
50
  unless uri_template =~ /({#{Regexp.quote name}})/
51
51
  err_msg = "Binding configuration is incorrect: missing parameter in the URI template.\n" \
52
- "Parameter `#{name}` is specified for matching but there is no corresponding parameter" \
53
- " `{#{name}}` in the URI template."
52
+ "Parameter `#{name}` is specified for matching but there is no corresponding parameter " \
53
+ "`{#{name}}` in the URI template."
54
54
  raise ::Gapic::Common::Error, err_msg
55
55
  end
56
56
 
@@ -60,8 +60,8 @@ module Gapic
60
60
  if template =~ /{([a-zA-Z_.]+)}/
61
61
  err_name = Regexp.last_match[1]
62
62
  err_msg = "Binding configuration is incorrect: missing match configuration.\n" \
63
- "Parameter `{#{err_name}}` is specified in the URI template but there is no" \
64
- " corresponding match configuration for `#{err_name}`."
63
+ "Parameter `{#{err_name}}` is specified in the URI template but there is no " \
64
+ "corresponding match configuration for `#{err_name}`."
65
65
  raise ::Gapic::Common::Error, err_msg
66
66
  end
67
67
 
@@ -108,12 +108,9 @@ module Gapic
108
108
  uri_values = bind_uri_values! http_binding, request_hash
109
109
  next if uri_values.any? { |_, value| value.nil? }
110
110
 
111
- if http_binding.body && http_binding.body != "*"
112
- # Note that the body template can only point to a top-level field,
113
- # so there is no need to split the path.
114
- body_binding_camel = camel_name_for http_binding.body
115
- next unless request_hash.key? body_binding_camel
116
- end
111
+ # Note that the body template can only point to a top-level field,
112
+ # so there is no need to split the path.
113
+ next if http_binding.body && http_binding.body != "*" && !(request.respond_to? http_binding.body.to_sym)
117
114
 
118
115
  method = http_binding.method
119
116
  uri = expand_template http_binding.template, uri_values
@@ -140,20 +137,16 @@ module Gapic
140
137
  # Name to value hash of the variables for the uri template expansion.
141
138
  # The values are percent-escaped with slashes potentially preserved.
142
139
  def bind_uri_values! http_binding, request_hash
143
- http_binding.field_bindings.map do |field_binding|
140
+ http_binding.field_bindings.to_h do |field_binding|
144
141
  field_path_camel = field_binding.field_path.split(".").map { |part| camel_name_for part }.join(".")
145
142
  field_value = extract_scalar_value! request_hash, field_path_camel, field_binding.regex
146
143
 
147
144
  if field_value
148
- field_value = if field_binding.preserve_slashes
149
- field_value.split("/").map { |segment| percent_escape(segment) }.join("/")
150
- else
151
- percent_escape field_value
152
- end
145
+ field_value = field_value.split("/").map { |segment| percent_escape(segment) }.join("/")
153
146
  end
154
147
 
155
148
  [field_binding.field_path, field_value]
156
- end.to_h
149
+ end
157
150
  end
158
151
 
159
152
  # Percent-escapes a string.
@@ -186,9 +179,15 @@ module Gapic
186
179
  #
187
180
  # The `request_hash_without_uri` at this point was mutated to delete these fields.
188
181
  #
189
- # Note that the body template can only point to a top-level field
190
- request_hash_without_uri.delete camel_name_for body_template
191
- body = request.send(body_template.to_sym).to_json(emit_defaults: true)
182
+ # Note 1: body template can only point to a top-level field.
183
+ # Note 2: The field that body template points to can be null, in which case
184
+ # an empty string should be sent. E.g. `Compute.Projects.SetUsageExportBucket`.
185
+ request_body_field = request.send body_template.to_sym if request.respond_to? body_template.to_sym
186
+ if request_body_field
187
+ request_hash_without_uri.delete camel_name_for body_template
188
+ body = request_body_field.to_json emit_defaults: true
189
+ end
190
+
192
191
  query_params = build_query_params request_hash_without_uri
193
192
  else
194
193
  query_params = build_query_params request_hash_without_uri
@@ -289,7 +288,7 @@ module Gapic
289
288
  def camel_name_for attr_name
290
289
  parts = attr_name.split "_"
291
290
  first_part = parts[0]
292
- other_parts = parts[1..-1]
291
+ other_parts = parts[1..]
293
292
  other_parts_pascal = other_parts.map(&:capitalize).join
294
293
  "#{first_part}#{other_parts_pascal}"
295
294
  end
metadata CHANGED
@@ -1,56 +1,62 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gapic-common
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.11.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Google API Authors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-18 00:00:00.000000000 Z
11
+ date: 2022-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '1.9'
20
+ - - "<"
18
21
  - !ruby/object:Gem::Version
19
- version: '1.3'
22
+ version: 3.a
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '1.9'
30
+ - - "<"
25
31
  - !ruby/object:Gem::Version
26
- version: '1.3'
32
+ version: 3.a
27
33
  - !ruby/object:Gem::Dependency
28
- name: googleapis-common-protos
34
+ name: faraday-retry
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
37
  - - ">="
32
38
  - !ruby/object:Gem::Version
33
- version: 1.3.11
39
+ version: '1.0'
34
40
  - - "<"
35
41
  - !ruby/object:Gem::Version
36
- version: 2.a
42
+ version: 3.a
37
43
  type: :runtime
38
44
  prerelease: false
39
45
  version_requirements: !ruby/object:Gem::Requirement
40
46
  requirements:
41
47
  - - ">="
42
48
  - !ruby/object:Gem::Version
43
- version: 1.3.11
49
+ version: '1.0'
44
50
  - - "<"
45
51
  - !ruby/object:Gem::Version
46
- version: 2.a
52
+ version: 3.a
47
53
  - !ruby/object:Gem::Dependency
48
- name: googleapis-common-protos-types
54
+ name: googleapis-common-protos
49
55
  requirement: !ruby/object:Gem::Requirement
50
56
  requirements:
51
57
  - - ">="
52
58
  - !ruby/object:Gem::Version
53
- version: 1.0.6
59
+ version: 1.3.12
54
60
  - - "<"
55
61
  - !ruby/object:Gem::Version
56
62
  version: 2.a
@@ -60,17 +66,17 @@ dependencies:
60
66
  requirements:
61
67
  - - ">="
62
68
  - !ruby/object:Gem::Version
63
- version: 1.0.6
69
+ version: 1.3.12
64
70
  - - "<"
65
71
  - !ruby/object:Gem::Version
66
72
  version: 2.a
67
73
  - !ruby/object:Gem::Dependency
68
- name: googleauth
74
+ name: googleapis-common-protos-types
69
75
  requirement: !ruby/object:Gem::Requirement
70
76
  requirements:
71
77
  - - ">="
72
78
  - !ruby/object:Gem::Version
73
- version: 0.17.0
79
+ version: 1.3.1
74
80
  - - "<"
75
81
  - !ruby/object:Gem::Version
76
82
  version: 2.a
@@ -80,10 +86,24 @@ dependencies:
80
86
  requirements:
81
87
  - - ">="
82
88
  - !ruby/object:Gem::Version
83
- version: 0.17.0
89
+ version: 1.3.1
84
90
  - - "<"
85
91
  - !ruby/object:Gem::Version
86
92
  version: 2.a
93
+ - !ruby/object:Gem::Dependency
94
+ name: googleauth
95
+ requirement: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - "~>"
98
+ - !ruby/object:Gem::Version
99
+ version: '1.0'
100
+ type: :runtime
101
+ prerelease: false
102
+ version_requirements: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - "~>"
105
+ - !ruby/object:Gem::Version
106
+ version: '1.0'
87
107
  - !ruby/object:Gem::Dependency
88
108
  name: google-protobuf
89
109
  requirement: !ruby/object:Gem::Requirement
@@ -132,28 +152,28 @@ dependencies:
132
152
  requirements:
133
153
  - - "~>"
134
154
  - !ruby/object:Gem::Version
135
- version: 1.25.1
155
+ version: 1.26.0
136
156
  type: :development
137
157
  prerelease: false
138
158
  version_requirements: !ruby/object:Gem::Requirement
139
159
  requirements:
140
160
  - - "~>"
141
161
  - !ruby/object:Gem::Version
142
- version: 1.25.1
162
+ version: 1.26.0
143
163
  - !ruby/object:Gem::Dependency
144
164
  name: minitest
145
165
  requirement: !ruby/object:Gem::Requirement
146
166
  requirements:
147
167
  - - "~>"
148
168
  - !ruby/object:Gem::Version
149
- version: '5.14'
169
+ version: '5.16'
150
170
  type: :development
151
171
  prerelease: false
152
172
  version_requirements: !ruby/object:Gem::Requirement
153
173
  requirements:
154
174
  - - "~>"
155
175
  - !ruby/object:Gem::Version
156
- version: '5.14'
176
+ version: '5.16'
157
177
  - !ruby/object:Gem::Dependency
158
178
  name: minitest-autotest
159
179
  requirement: !ruby/object:Gem::Requirement
@@ -306,14 +326,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
306
326
  requirements:
307
327
  - - ">="
308
328
  - !ruby/object:Gem::Version
309
- version: '2.5'
329
+ version: '2.6'
310
330
  required_rubygems_version: !ruby/object:Gem::Requirement
311
331
  requirements:
312
332
  - - ">="
313
333
  - !ruby/object:Gem::Version
314
334
  version: '0'
315
335
  requirements: []
316
- rubygems_version: 3.3.5
336
+ rubygems_version: 3.3.14
317
337
  signing_key:
318
338
  specification_version: 4
319
339
  summary: Common code for GAPIC-generated API clients