gapic-generator 0.45.1 → 0.45.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0c44ace94e73e85dad3b7b20373016a28f46181631709dd52fe19672b7da80a6
4
- data.tar.gz: 2f8bdc5d63b8253687711ff7bc6d139e536cc3f5d096be9c8f1546676db60aa4
3
+ metadata.gz: 2f2a5263485263873c059ce342f1cd26c800bab3349b7b191132b57f79d986ea
4
+ data.tar.gz: eda4ecd48fe183ffd4f98927f80c6500fc7b1d578fd8a45f4d539c5e0cecc9bd
5
5
  SHA512:
6
- metadata.gz: 3f24b95f72f3a26e89190694fff115e8b6e5206b430676fda14ef6d3669b6b2de1eefdada75d2420607f63d31789491acfb11f419cbdce237deaa1fa597fb667
7
- data.tar.gz: b88884b59cc8d3d426f793a97696617e2314b81c4c38e61fa3a507270a2d9e20e67c631fdefad2cf2cd793f5c1bae06577dd4381157a33b64092ad7c7f77ee97
6
+ metadata.gz: a49ad3a37ed0d730ef3bed251a2d58f06a4f9686d9fb4d65bcc163e1074ff76d427396798e3e9223a9b2d0d4d82be27c712f9c079f3379f573fe7026bfebbd29
7
+ data.tar.gz: 84dd1fd882a77ff2c659d3d17e56722bb0f80240dc8a644c282290c321a090352ff315c415d4f0e74172830560868f143b9e48fe0b319ae8a56a36680b0f5089
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Release History for gapic-generator
2
2
 
3
+ ### 0.45.2 / 2025-06-04
4
+
5
+ * Fix: update Ruby prebuilt binary, version 3.4.3
6
+
3
7
  ### 0.45.1 / 2025-05-01
4
8
 
5
9
  No significant changes
@@ -102,7 +102,8 @@ module Gapic
102
102
 
103
103
  def line_indent line
104
104
  m = /^( *)\S/.match line
105
- m.nil? ? nil : m[1].length
105
+ return nil unless m
106
+ m[1].length
106
107
  end
107
108
 
108
109
  def escape_line_braces line
@@ -16,6 +16,6 @@
16
16
 
17
17
  module Gapic
18
18
  module Generator
19
- VERSION = "0.45.1"
19
+ VERSION = "0.45.2"
20
20
  end
21
21
  end
@@ -20,7 +20,7 @@ module Gapic
20
20
  ##
21
21
  # Pagination info determined from the proto method
22
22
  #
23
- class RestPaginationInfo
23
+ class ComputePaginationInfo
24
24
  include Gapic::Helpers::NamespaceHelper
25
25
  ##
26
26
  # @param proto_method [Gapic::Schema::Method] the method to derive pagination info from
@@ -78,7 +78,9 @@ module Gapic
78
78
 
79
79
  private
80
80
 
81
+ ##
81
82
  # Whether the underlying proto rpc is a server streaming rpc
83
+ #
82
84
  # @return [Boolean]
83
85
  attr_accessor :server_streaming
84
86
 
@@ -105,7 +107,7 @@ module Gapic
105
107
  ##
106
108
  # The field in the request that holds a page_token
107
109
  #
108
- # @return[Gapic::Schema::Field, nil]
110
+ # @return [Gapic::Schema::Field, nil]
109
111
  def request_page_token_field
110
112
  # Has a String page_token field which specifies the actual (next) page to retrieve.
111
113
  @request_page_token_field ||= @request.fields.find do |f|
@@ -117,7 +119,7 @@ module Gapic
117
119
  # The field in the request that holds a page_size
118
120
  # For Regapic can have a name of either `page_size` or `max_results`
119
121
  #
120
- # @return[Gapic::Schema::Field, nil]
122
+ # @return [Gapic::Schema::Field, nil]
121
123
  def request_page_size_field
122
124
  @request_page_size_field ||=
123
125
  begin
@@ -149,7 +151,7 @@ module Gapic
149
151
  ##
150
152
  # The field in the response that holds a next page_token
151
153
  #
152
- # @return[Gapic::Schema::Field, nil]
154
+ # @return [Gapic::Schema::Field, nil]
153
155
  def response_next_page_token_field
154
156
  # Has the string next_page_token field to be used in the next request as page_token to retrieve the next page.
155
157
  @response_next_page_token_field ||= @response.fields.find do |f|
@@ -14,7 +14,7 @@
14
14
  # See the License for the specific language governing permissions and
15
15
  # limitations under the License.
16
16
 
17
- require "gapic/presenters/method/rest_pagination_info"
17
+ require "gapic/presenters/method/compute_pagination_info"
18
18
 
19
19
  module Gapic
20
20
  module Presenters
@@ -22,9 +22,14 @@ module Gapic
22
22
  # A presenter for rpc methods (REST submethods)
23
23
  #
24
24
  class MethodRestPresenter
25
- # @return [Gapic::Presenters::Method::RestPaginationInfo]
25
+ # @return [Gapic::Presenters::Method::ComputePaginationInfo] Special pagination presenter for Compute
26
26
  attr_reader :compute_pagination
27
27
 
28
+ ##
29
+ # Presenters for HTTP bindings, used to check whether this method should be generated in REST client
30
+ #
31
+ # @return [Array<Gapic::Presenters::Method::HttpBindingsPresenter>]
32
+ #
28
33
  attr_reader :http_bindings
29
34
 
30
35
  # @return [String] String representation of this presenter type.
@@ -39,7 +44,7 @@ module Gapic
39
44
  @http_bindings = main_method.http_bindings
40
45
  @compute_pagination =
41
46
  if @main_method.service.special_compute_behavior?
42
- Gapic::Presenters::Method::RestPaginationInfo.new main_method.method, api
47
+ Gapic::Presenters::Method::ComputePaginationInfo.new main_method.method, api
43
48
  end
44
49
  @type = "method"
45
50
  end
@@ -54,7 +59,7 @@ module Gapic
54
59
  end
55
60
 
56
61
  ##
57
- # Method name
62
+ # Method's name
58
63
  #
59
64
  # @return [String]
60
65
  #
@@ -62,8 +67,11 @@ module Gapic
62
67
  @main_method.name
63
68
  end
64
69
 
70
+ ##
65
71
  # Fully qualified proto name of the method (namespace.PascalCase)
72
+ #
66
73
  # @return [String]
74
+ #
67
75
  def grpc_full_name
68
76
  @main_method.grpc.full_name
69
77
  end
@@ -103,7 +111,10 @@ module Gapic
103
111
  end
104
112
 
105
113
  ##
106
- # @return [String] The name of the repeated field in paginated responses
114
+ # Name of the repeated field in paginated responses
115
+ # For Compute the pagination is different from GRPC and cannot be looked up in GRPC method presenter
116
+ #
117
+ # @return [String]
107
118
  #
108
119
  def paged_response_repeated_field_name
109
120
  if compute_pagination
@@ -168,7 +179,9 @@ module Gapic
168
179
  end
169
180
 
170
181
  ##
171
- # @return [Boolean] Whether the method is marked as deprecated.
182
+ # Whether the method is marked as deprecated.
183
+ #
184
+ # @return [Boolean]
172
185
  #
173
186
  def is_deprecated?
174
187
  @main_method.is_deprecated?
@@ -95,7 +95,7 @@ module Gapic
95
95
 
96
96
  def render_complex proto, json
97
97
  lines = ["{"]
98
- proto.each do |key, value_expr|
98
+ proto.sort_by { |key, _| key.to_s }.each do |key, value_expr|
99
99
  value_presenter = ExpressionPresenter.new value_expr, json[key]
100
100
  value_lines = value_presenter.render_lines
101
101
  next unless value_lines
@@ -107,9 +107,12 @@ module Gapic
107
107
  end
108
108
 
109
109
  def render_list proto, json
110
+ exprs = proto.map.with_index do |item, index|
111
+ ExpressionPresenter.new item, json[index]
112
+ end
113
+
110
114
  lines = ["["]
111
- proto.each_with_index do |item, index|
112
- expr = ExpressionPresenter.new item, json[index]
115
+ exprs.sort_by(&:render).each do |expr|
113
116
  value_lines = expr.render_lines
114
117
  lines[lines.size - 1] = "#{lines.last}," if lines.size > 1
115
118
  lines += value_lines.map { |line| " #{line}" }
@@ -118,17 +121,33 @@ module Gapic
118
121
  end
119
122
 
120
123
  def render_map proto, json
124
+ key_to_kvlines = get_key_to_kvlines proto, json
125
+
121
126
  lines = ["{"]
122
- proto.keys.zip(proto.values).each_with_index do |(key, value), index|
123
- key_lines = ExpressionPresenter.new(key, json["keys"][index]).render_lines
124
- value_lines = ExpressionPresenter.new(value, json["values"][index]).render_lines
125
- next unless key_lines && value_lines
127
+ key_to_kvlines.sort_by { |key, _| key }.each do |_, key_val_lines|
128
+ key_lines = key_val_lines[0]
129
+ value_lines = key_val_lines[1]
126
130
  elem_lines = key_lines[0..-2] + ["#{key_lines.last} => #{value_lines.first}"] + value_lines[1..]
127
131
  lines[lines.size - 1] = "#{lines.last}," if lines.size > 1
128
132
  lines += elem_lines.map { |line| " #{line}" }
129
133
  end
130
134
  lines + ["}"]
131
135
  end
136
+
137
+ # Helper method to render_map.
138
+ # Returns a map from a key rendered as a string
139
+ # to the array of key and value rendered as lines.
140
+ def get_key_to_kvlines proto, json
141
+ key_to_kvlines = {}
142
+ proto.keys.zip(proto.values).each_with_index do |(key, value), index|
143
+ key_expr = ExpressionPresenter.new key, json["keys"][index]
144
+ value_expr = ExpressionPresenter.new value, json["values"][index]
145
+ next unless key_expr.render_lines && value_expr.render_lines
146
+
147
+ key_to_kvlines[key_expr.render] = [key_expr.render_lines, value_expr.render_lines]
148
+ end
149
+ key_to_kvlines
150
+ end
132
151
  end
133
152
  end
134
153
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gapic-generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.45.1
4
+ version: 0.45.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ernest Landrito
@@ -167,8 +167,8 @@ files:
167
167
  - lib/gapic/presenters/gem_presenter.rb
168
168
  - lib/gapic/presenters/grpc_service_config_presenter.rb
169
169
  - lib/gapic/presenters/message_presenter.rb
170
+ - lib/gapic/presenters/method/compute_pagination_info.rb
170
171
  - lib/gapic/presenters/method/http_binding_presenter.rb
171
- - lib/gapic/presenters/method/rest_pagination_info.rb
172
172
  - lib/gapic/presenters/method_presenter.rb
173
173
  - lib/gapic/presenters/method_rest_presenter.rb
174
174
  - lib/gapic/presenters/package_presenter.rb
@@ -365,7 +365,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
365
365
  - !ruby/object:Gem::Version
366
366
  version: '0'
367
367
  requirements: []
368
- rubygems_version: 3.6.8
368
+ rubygems_version: 3.6.9
369
369
  specification_version: 4
370
370
  summary: An API Client Generator for Ruby in Ruby!
371
371
  test_files: []