gapic-generator 0.6.12 → 0.7.1
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 +4 -4
- data/CHANGELOG.md +23 -0
- data/bin/protoc-gen-ruby_gapic +6 -6
- data/lib/gapic/file_formatter.rb +2 -1
- data/lib/gapic/formatting_utils.rb +6 -5
- data/lib/gapic/generator/version.rb +1 -1
- data/lib/gapic/generators/default_generator.rb +13 -12
- data/lib/gapic/grpc_service_config/method_config.rb +2 -1
- data/lib/gapic/grpc_service_config/retry_policy.rb +4 -1
- data/lib/gapic/grpc_service_config/service_config.rb +2 -1
- data/lib/gapic/path_pattern/parser.rb +1 -1
- data/lib/gapic/path_pattern/pattern.rb +2 -1
- data/lib/gapic/path_pattern/segment.rb +10 -3
- data/lib/gapic/presenters/gem_presenter.rb +23 -0
- data/lib/gapic/presenters/package_presenter.rb +21 -3
- data/lib/gapic/presenters/resource_presenter.rb +2 -1
- data/lib/gapic/presenters/sample_presenter.rb +6 -1
- data/lib/gapic/presenters/service_presenter.rb +36 -6
- data/lib/gapic/schema/api.rb +4 -3
- data/lib/gapic/schema/parameter_schema.rb +4 -1
- data/lib/gapic/schema/request_parameter.rb +5 -1
- data/lib/gapic/schema/wrappers.rb +31 -18
- data/lib/gapic/uri_template/parser.rb +4 -6
- data/templates/default/gem/gapic_metadata_json.erb +2 -0
- data/templates/default/gem/gemspec.erb +2 -2
- data/templates/default/gem/readme.erb +2 -2
- data/templates/default/gem/rubocop.erb +2 -12
- data/templates/default/service/client/_config.erb +2 -2
- data/templates/default/service/test/method/_normal.erb +1 -1
- data/templates/default/service/test/method/_server.erb +1 -1
- metadata +9 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a5cfd7100b78e532d61c6cbb0e1fdc26e4e52235d0838c887a3ee951f642513
|
4
|
+
data.tar.gz: 42ca94ca019ed994efc8beb90bbb3e88921b2b128b346551f1ae7acc8999b5e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 963c359acc6f8d5ebba562d8e151394e95db7db61cc203a05a14b7e941ef22849a3d9bf7ca1d517548ec7aaaa817339557dfa90592dfc54c9628c193d49ab928
|
7
|
+
data.tar.gz: 0a955e4cfcd87eb3c112d8acb3bf58b1db10f224f22bbf0422af76876e58d01f1b3a5d65543c8909e005787e7ded93554bcc62887fc3e60625091bc254cf1d81
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,28 @@
|
|
1
1
|
# Release History for gapic-generator
|
2
2
|
|
3
|
+
### 0.7.1 / 2021-02-27
|
4
|
+
|
5
|
+
* Update generated readmes to reflect that Ruby 2.5 or later is now required.
|
6
|
+
|
7
|
+
### 0.7.0 / 2021-02-27
|
8
|
+
|
9
|
+
* Update minimum Ruby version to 2.5 for generated libraries.
|
10
|
+
* Update supported Rubocop to 1.x for generated libraries.
|
11
|
+
|
12
|
+
### 0.6.15 / 2021-02-22
|
13
|
+
|
14
|
+
* Really fixed encoding arguments in executable entrypoints
|
15
|
+
|
16
|
+
### 0.6.14 / 2021-02-22
|
17
|
+
|
18
|
+
* Fixed encoding arguments in executable entrypoints
|
19
|
+
|
20
|
+
### 0.6.13 / 2021-02-22
|
21
|
+
|
22
|
+
* Remove InputOnly and OutputOnly proto tags from docs to avoid confusing YARD.
|
23
|
+
* Generate drift manifest.
|
24
|
+
* Executable entrypoints set the default external locale to utf-8.
|
25
|
+
|
3
26
|
### 0.6.12 / 2021-02-01
|
4
27
|
|
5
28
|
* No changes.
|
data/bin/protoc-gen-ruby_gapic
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
1
|
+
#!/usr/bin/env -S ruby -EUTF-8
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
# Copyright 2018 Google LLC
|
@@ -15,19 +15,19 @@
|
|
15
15
|
# See the License for the specific language governing permissions and
|
16
16
|
# limitations under the License.
|
17
17
|
|
18
|
-
$LOAD_PATH.unshift ::File.expand_path("
|
18
|
+
$LOAD_PATH.unshift ::File.expand_path("../lib", __dir__)
|
19
19
|
require "gapic/runner"
|
20
20
|
require "google/protobuf/compiler/plugin.pb"
|
21
21
|
|
22
22
|
# Ensure that no encoding conversions are done on STDIN and STDOUT
|
23
23
|
# since we are passing binary data back and forth. Otherwise these
|
24
24
|
# streams will be mangled on Windows.
|
25
|
-
|
26
|
-
|
25
|
+
$stdin.binmode
|
26
|
+
$stdout.binmode
|
27
27
|
|
28
|
-
request = Google::Protobuf::Compiler::CodeGeneratorRequest.decode
|
28
|
+
request = Google::Protobuf::Compiler::CodeGeneratorRequest.decode $stdin.read
|
29
29
|
|
30
30
|
# Run the request
|
31
31
|
response = Gapic::Runner.run request
|
32
32
|
|
33
|
-
|
33
|
+
$stdout.print response.serialize
|
data/lib/gapic/file_formatter.rb
CHANGED
@@ -21,9 +21,10 @@ module Gapic
|
|
21
21
|
# Various string formatting utils
|
22
22
|
#
|
23
23
|
module FormattingUtils
|
24
|
-
@brace_detector = /\A(?<pre>[^`]*(
|
25
|
-
@xref_detector = /\A(?<pre>[^`]*(
|
26
|
-
@list_element_detector = /\A\s*(
|
24
|
+
@brace_detector = /\A(?<pre>[^`]*(?:`[^`]*`[^`]*)*[^`\\])?\{(?<inside>[^\s][^}]*)\}(?<post>.*)\z/m
|
25
|
+
@xref_detector = /\A(?<pre>[^`]*(?:`[^`]*`[^`]*)*)?\[(?<text>[\w. `-]+)\]\[(?<addr>[\w.]+)\](?<post>.*)\z/m
|
26
|
+
@list_element_detector = /\A\s*(?:\*|\+|-|[0-9a-zA-Z]+\.)\s/
|
27
|
+
@omit_lines = ["@InputOnly\n", "@OutputOnly\n"]
|
27
28
|
|
28
29
|
class << self
|
29
30
|
##
|
@@ -49,7 +50,7 @@ module Gapic
|
|
49
50
|
# preformatted.
|
50
51
|
in_block = nil
|
51
52
|
base_indent = 0
|
52
|
-
lines.map do |line|
|
53
|
+
(lines - @omit_lines).map do |line|
|
53
54
|
indent = line_indent line
|
54
55
|
if indent.nil?
|
55
56
|
in_block = nil
|
@@ -75,7 +76,7 @@ module Gapic
|
|
75
76
|
def format_number value
|
76
77
|
return value.to_s if value.abs < 10_000
|
77
78
|
str = value.is_a?(Integer) ? value.to_s : BigDecimal(value.to_f.to_s).to_s("F")
|
78
|
-
re = /^(-?\d+)(\d\d\d)([_
|
79
|
+
re = /^(-?\d+)(\d\d\d)([_.][_.\d]+)?$/
|
79
80
|
while (m = re.match str)
|
80
81
|
str = "#{m[1]}_#{m[2]}#{m[3]}"
|
81
82
|
end
|
@@ -65,18 +65,19 @@ module Gapic
|
|
65
65
|
end
|
66
66
|
|
67
67
|
# Gem level files
|
68
|
-
files << g("gem/gitignore.erb",
|
69
|
-
files << g("gem/version.erb",
|
70
|
-
files << g("gem/test_helper.erb",
|
71
|
-
files << g("gem/gemspec.erb",
|
72
|
-
files << g("gem/gemfile.erb",
|
73
|
-
files << g("gem/rakefile.erb",
|
74
|
-
files << g("gem/readme.erb",
|
75
|
-
files << g("gem/changelog.erb",
|
76
|
-
files << g("gem/rubocop.erb",
|
77
|
-
files << g("gem/yardopts.erb",
|
78
|
-
files << g("gem/license.erb",
|
79
|
-
files << g("gem/entrypoint.erb",
|
68
|
+
files << g("gem/gitignore.erb", ".gitignore", gem: gem)
|
69
|
+
files << g("gem/version.erb", "lib/#{gem.version_file_path}", gem: gem)
|
70
|
+
files << g("gem/test_helper.erb", "test/helper.rb", gem: gem)
|
71
|
+
files << g("gem/gemspec.erb", "#{gem.name}.gemspec", gem: gem)
|
72
|
+
files << g("gem/gemfile.erb", "Gemfile", gem: gem)
|
73
|
+
files << g("gem/rakefile.erb", "Rakefile", gem: gem)
|
74
|
+
files << g("gem/readme.erb", "README.md", gem: gem)
|
75
|
+
files << g("gem/changelog.erb", "CHANGELOG.md", gem: gem)
|
76
|
+
files << g("gem/rubocop.erb", ".rubocop.yml", gem: gem)
|
77
|
+
files << g("gem/yardopts.erb", ".yardopts", gem: gem)
|
78
|
+
files << g("gem/license.erb", "LICENSE.md", gem: gem)
|
79
|
+
files << g("gem/entrypoint.erb", "lib/#{gem.name}.rb", gem: gem)
|
80
|
+
files << g("gem/gapic_metadata_json.erb", "gapic_metadata.json", gem: gem)
|
80
81
|
|
81
82
|
gem.proto_files.each do |proto_file|
|
82
83
|
files << g("proto_docs/proto_file.erb", "proto_docs/#{proto_file.docs_file_path}", file: proto_file)
|
@@ -21,7 +21,10 @@ module Gapic
|
|
21
21
|
# for the GRPC method invocation. It is embedded into the MethodConfig
|
22
22
|
#
|
23
23
|
class RetryPolicy
|
24
|
-
attr_reader :initial_delay_seconds
|
24
|
+
attr_reader :initial_delay_seconds
|
25
|
+
attr_reader :max_delay_seconds
|
26
|
+
attr_reader :multiplier
|
27
|
+
attr_reader :status_codes
|
25
28
|
|
26
29
|
##
|
27
30
|
# Create new ParsedRetryPolicy.
|
@@ -22,7 +22,8 @@ module Gapic
|
|
22
22
|
# applied to the specific methods
|
23
23
|
#
|
24
24
|
class ServiceConfig
|
25
|
-
attr_reader :service_level_configs
|
25
|
+
attr_reader :service_level_configs
|
26
|
+
attr_reader :service_method_level_configs
|
26
27
|
|
27
28
|
##
|
28
29
|
# Create new ServiceConfig.
|
@@ -87,7 +87,7 @@ module Gapic
|
|
87
87
|
# @private
|
88
88
|
def self.try_capture_complex_resource_id_segment url_pattern
|
89
89
|
complex_resource_id_regex =
|
90
|
-
%r/^(?<segment_pattern>{(?<name_first>[^\/}]+?)}(?:(?<separator>[_
|
90
|
+
%r/^(?<segment_pattern>{(?<name_first>[^\/}]+?)}(?:(?<separator>[_\-~.]){(?<name_seq>[^\/}]+?)})+)(?:\/|$)/
|
91
91
|
|
92
92
|
return nil, url_pattern unless complex_resource_id_regex.match? url_pattern
|
93
93
|
|
@@ -29,7 +29,8 @@ module Gapic
|
|
29
29
|
# @return [Array<PositionalSegment|ResourceIdSegment|CollectionIdSegment>]
|
30
30
|
# The parsed segments of the path pattern
|
31
31
|
class Pattern
|
32
|
-
attr_reader :path_pattern
|
32
|
+
attr_reader :path_pattern
|
33
|
+
attr_reader :segments
|
33
34
|
|
34
35
|
def initialize path_pattern, segments
|
35
36
|
@path_pattern = path_pattern
|
@@ -29,7 +29,10 @@ module Gapic
|
|
29
29
|
# @return [String] The pattern of the segment, for the positional segment it is also
|
30
30
|
# a pattern of its resource
|
31
31
|
class PositionalSegment
|
32
|
-
attr_reader :type
|
32
|
+
attr_reader :type
|
33
|
+
attr_reader :position
|
34
|
+
attr_reader :pattern
|
35
|
+
|
33
36
|
def initialize position, pattern
|
34
37
|
@type = :positional
|
35
38
|
@position = position
|
@@ -117,7 +120,10 @@ module Gapic
|
|
117
120
|
# @return [Array<String>] The resource patterns associated with
|
118
121
|
# the resource_names of this segment
|
119
122
|
class ResourceIdSegment
|
120
|
-
attr_reader :type
|
123
|
+
attr_reader :type
|
124
|
+
attr_reader :pattern
|
125
|
+
attr_reader :resource_names
|
126
|
+
attr_reader :resource_patterns
|
121
127
|
|
122
128
|
def initialize type, pattern, resource_names, resource_patterns = []
|
123
129
|
@type = type
|
@@ -216,7 +222,8 @@ module Gapic
|
|
216
222
|
# @return [String] The pattern of the segment, for the positional segment it is also
|
217
223
|
# a pattern of its resource
|
218
224
|
class CollectionIdSegment
|
219
|
-
attr_reader :type
|
225
|
+
attr_reader :type
|
226
|
+
attr_reader :pattern
|
220
227
|
|
221
228
|
def initialize pattern
|
222
229
|
@type = :collection_id
|
@@ -17,6 +17,8 @@
|
|
17
17
|
require "gapic/helpers/filepath_helper"
|
18
18
|
require "gapic/helpers/namespace_helper"
|
19
19
|
|
20
|
+
require "json"
|
21
|
+
|
20
22
|
module Gapic
|
21
23
|
module Presenters
|
22
24
|
##
|
@@ -191,6 +193,27 @@ module Gapic
|
|
191
193
|
.sort_by { |name, _requirements| name }
|
192
194
|
end
|
193
195
|
|
196
|
+
##
|
197
|
+
# Returns a hash with a drift_manifest of
|
198
|
+
# a first package in this gem
|
199
|
+
# (while the behaviour in case of multiple packages is clarified).
|
200
|
+
# See https://github.com/googleapis/googleapis/blob/master/gapic/metadata/gapic_metadata.proto
|
201
|
+
#
|
202
|
+
# @return [Hash]
|
203
|
+
def first_package_drift_manifest
|
204
|
+
return {} unless packages?
|
205
|
+
packages[0].drift_manifest
|
206
|
+
end
|
207
|
+
|
208
|
+
##
|
209
|
+
# Returns a drift manifest of the first package in
|
210
|
+
# a pretty JSON string form
|
211
|
+
#
|
212
|
+
# @return [String]
|
213
|
+
def first_package_drift_json
|
214
|
+
JSON.pretty_generate first_package_drift_manifest
|
215
|
+
end
|
216
|
+
|
194
217
|
private
|
195
218
|
|
196
219
|
def gem_config key
|
@@ -77,7 +77,7 @@ module Gapic
|
|
77
77
|
end
|
78
78
|
|
79
79
|
def package_file_path
|
80
|
-
package_require
|
80
|
+
"#{package_require}.rb"
|
81
81
|
end
|
82
82
|
|
83
83
|
def package_directory_name
|
@@ -89,7 +89,7 @@ module Gapic
|
|
89
89
|
end
|
90
90
|
|
91
91
|
def helpers_file_path
|
92
|
-
helpers_require
|
92
|
+
"#{helpers_require}.rb"
|
93
93
|
end
|
94
94
|
|
95
95
|
def helpers_file_name
|
@@ -97,7 +97,25 @@ module Gapic
|
|
97
97
|
end
|
98
98
|
|
99
99
|
def helpers_require
|
100
|
-
package_require
|
100
|
+
"#{package_require}/_helpers"
|
101
|
+
end
|
102
|
+
|
103
|
+
##
|
104
|
+
# Returns a hash with a drift_manifest of this package
|
105
|
+
# describing correspondence between the proto description
|
106
|
+
# of the package with the generated code for the package.
|
107
|
+
# See https://github.com/googleapis/googleapis/blob/master/gapic/metadata/gapic_metadata.proto
|
108
|
+
#
|
109
|
+
# @return [Hash]
|
110
|
+
def drift_manifest
|
111
|
+
{
|
112
|
+
schema: "1.0",
|
113
|
+
comment: "This file maps proto services/RPCs to the corresponding library clients/methods",
|
114
|
+
language: "ruby",
|
115
|
+
protoPackage: name,
|
116
|
+
libraryPackage: namespace,
|
117
|
+
services: services.map { |s| [s.grpc_service_name, s.drift_manifest] }.to_h
|
118
|
+
}
|
101
119
|
end
|
102
120
|
end
|
103
121
|
end
|
@@ -59,7 +59,8 @@ module Gapic
|
|
59
59
|
@path_string = build_path_string
|
60
60
|
end
|
61
61
|
|
62
|
-
attr_reader :pattern
|
62
|
+
attr_reader :pattern
|
63
|
+
attr_reader :path_string
|
63
64
|
|
64
65
|
def useful_for_helpers?
|
65
66
|
!@parsed_pattern.positional_segments? && !@parsed_pattern.nontrivial_pattern_segments?
|
@@ -58,7 +58,12 @@ module Gapic
|
|
58
58
|
# Representation of a request field.
|
59
59
|
#
|
60
60
|
class RequestField
|
61
|
-
attr_reader :field
|
61
|
+
attr_reader :field
|
62
|
+
attr_reader :value
|
63
|
+
attr_reader :input_parameter
|
64
|
+
attr_reader :comment
|
65
|
+
attr_reader :value_is_file
|
66
|
+
|
62
67
|
def initialize field
|
63
68
|
@field = field["field"]
|
64
69
|
@value = convert field["value"]
|
@@ -144,7 +144,7 @@ module Gapic
|
|
144
144
|
end
|
145
145
|
|
146
146
|
def service_file_path
|
147
|
-
service_require
|
147
|
+
"#{service_require}.rb"
|
148
148
|
end
|
149
149
|
|
150
150
|
def service_file_name
|
@@ -180,7 +180,7 @@ module Gapic
|
|
180
180
|
end
|
181
181
|
|
182
182
|
def client_file_path
|
183
|
-
client_require
|
183
|
+
"#{client_require}.rb"
|
184
184
|
end
|
185
185
|
|
186
186
|
def client_file_name
|
@@ -220,7 +220,7 @@ module Gapic
|
|
220
220
|
end
|
221
221
|
|
222
222
|
def credentials_file_path
|
223
|
-
credentials_require
|
223
|
+
"#{credentials_require}.rb"
|
224
224
|
end
|
225
225
|
|
226
226
|
def credentials_file_name
|
@@ -232,7 +232,7 @@ module Gapic
|
|
232
232
|
end
|
233
233
|
|
234
234
|
def helpers_file_path
|
235
|
-
helpers_require
|
235
|
+
"#{helpers_require}.rb"
|
236
236
|
end
|
237
237
|
|
238
238
|
def helpers_file_name
|
@@ -260,7 +260,7 @@ module Gapic
|
|
260
260
|
end
|
261
261
|
|
262
262
|
def paths_file_path
|
263
|
-
paths_require
|
263
|
+
"#{paths_require}.rb"
|
264
264
|
end
|
265
265
|
|
266
266
|
def paths_file_name
|
@@ -308,7 +308,7 @@ module Gapic
|
|
308
308
|
end
|
309
309
|
|
310
310
|
def operations_file_path
|
311
|
-
operations_require
|
311
|
+
"#{operations_require}.rb"
|
312
312
|
end
|
313
313
|
|
314
314
|
def operations_file_name
|
@@ -333,10 +333,40 @@ module Gapic
|
|
333
333
|
@api.grpc_service_config.service_level_configs[grpc_full_name]
|
334
334
|
end
|
335
335
|
|
336
|
+
##
|
337
|
+
# The short proto name for this service
|
338
|
+
#
|
339
|
+
# @return [String]
|
340
|
+
def grpc_service_name
|
341
|
+
@service.name
|
342
|
+
end
|
343
|
+
|
336
344
|
def grpc_full_name
|
337
345
|
@service.address.join "."
|
338
346
|
end
|
339
347
|
|
348
|
+
##
|
349
|
+
# Returns a hash with a drift_manifest of this service,
|
350
|
+
# describing correspondence between the proto description
|
351
|
+
# of the service with the generated code for the service.
|
352
|
+
# See https://github.com/googleapis/googleapis/blob/master/gapic/metadata/gapic_metadata.proto
|
353
|
+
#
|
354
|
+
# @return [Hash]
|
355
|
+
def drift_manifest
|
356
|
+
{
|
357
|
+
clients: {
|
358
|
+
grpc: {
|
359
|
+
libraryClient: client_name_full,
|
360
|
+
# The methods should grouped by grpc_method_name and then
|
361
|
+
# their names are returned together in an array.
|
362
|
+
# For Ruby currently we have 1:1 proto to code
|
363
|
+
# correspondence for methods, so our generation is easier
|
364
|
+
methods: methods.map { |m| [m.grpc_method_name, [m.name]] }.to_h
|
365
|
+
}
|
366
|
+
}
|
367
|
+
}
|
368
|
+
end
|
369
|
+
|
340
370
|
private
|
341
371
|
|
342
372
|
def default_config key
|
data/lib/gapic/schema/api.rb
CHANGED
@@ -39,7 +39,8 @@ module Gapic
|
|
39
39
|
# @return [Array<Enum>] The top level enums seen across all files in
|
40
40
|
# this API.
|
41
41
|
class Api
|
42
|
-
attr_accessor :request
|
42
|
+
attr_accessor :request
|
43
|
+
attr_accessor :files
|
43
44
|
|
44
45
|
# Initializes an API object with the file descriptors that represent the
|
45
46
|
# API.
|
@@ -50,7 +51,7 @@ module Gapic
|
|
50
51
|
# The request parameters schema to use
|
51
52
|
# @param error_output [IO] An IO to write any errors/warnings to.
|
52
53
|
# @param configuration [Hash] Optional override of configuration.
|
53
|
-
def initialize request, parameter_schema: nil, error_output:
|
54
|
+
def initialize request, parameter_schema: nil, error_output: $stderr, configuration: nil
|
54
55
|
@request = request
|
55
56
|
loader = Loader.new
|
56
57
|
@files = request.proto_file.map do |fd|
|
@@ -359,7 +360,7 @@ module Gapic
|
|
359
360
|
# split the string on periods, but map backslash-escaped periods to
|
360
361
|
# literal periods.
|
361
362
|
def parse_key str
|
362
|
-
str.scan(/\.|\\.|[
|
363
|
+
str.scan(/\.|\\.|[^.\\]+/)
|
363
364
|
.each_with_object([String.new]) do |tok, arr|
|
364
365
|
if tok == "."
|
365
366
|
arr.append String.new
|
@@ -19,7 +19,10 @@ module Gapic
|
|
19
19
|
# Contains information about known parameter names
|
20
20
|
# and the types expected to be parsed from the request options string
|
21
21
|
class ParameterSchema
|
22
|
-
attr_accessor :bool_params
|
22
|
+
attr_accessor :bool_params
|
23
|
+
attr_accessor :string_params
|
24
|
+
attr_accessor :array_params
|
25
|
+
attr_accessor :map_params
|
23
26
|
|
24
27
|
# Creates a schema with given alias-parameter maps
|
25
28
|
# @param bool_params [Hash{String => String}]
|
@@ -19,7 +19,11 @@ module Gapic
|
|
19
19
|
# Encapsulates information that is parsed from a single command line parameter
|
20
20
|
# from the plugin_opt command line
|
21
21
|
class RequestParameter
|
22
|
-
attr_reader :input_str
|
22
|
+
attr_reader :input_str
|
23
|
+
attr_reader :input_name
|
24
|
+
attr_reader :input_value
|
25
|
+
attr_reader :config_name
|
26
|
+
attr_reader :config_value
|
23
27
|
|
24
28
|
# @param input_str [String] the input string containing parameter and value
|
25
29
|
# that the parameter and value were parsed from
|
@@ -80,7 +80,11 @@ module Gapic
|
|
80
80
|
# of locations could be recorded in the future.
|
81
81
|
class Proto
|
82
82
|
extend Forwardable
|
83
|
-
|
83
|
+
|
84
|
+
attr_reader :descriptor
|
85
|
+
attr_reader :address
|
86
|
+
attr_reader :docs
|
87
|
+
|
84
88
|
attr_accessor :parent
|
85
89
|
|
86
90
|
# Initializes a Proto object.
|
@@ -228,6 +232,7 @@ module Gapic
|
|
228
232
|
# @ return [Enumerable<Method>] The methods of this service.
|
229
233
|
class Service < Proto
|
230
234
|
extend Forwardable
|
235
|
+
|
231
236
|
attr_reader :methods
|
232
237
|
|
233
238
|
# Initializes a Service object.
|
@@ -292,7 +297,9 @@ module Gapic
|
|
292
297
|
# @ return [Message] The output message of this method.
|
293
298
|
class Method < Proto
|
294
299
|
extend Forwardable
|
295
|
-
|
300
|
+
|
301
|
+
attr_reader :input
|
302
|
+
attr_reader :output
|
296
303
|
|
297
304
|
# Initializes a method object.
|
298
305
|
# @param descriptor [Google::Protobuf::MethodDescriptorProto] the
|
@@ -370,7 +377,12 @@ module Gapic
|
|
370
377
|
# this file.
|
371
378
|
class File < Proto
|
372
379
|
extend Forwardable
|
373
|
-
|
380
|
+
|
381
|
+
attr_reader :messages
|
382
|
+
attr_reader :enums
|
383
|
+
attr_reader :services
|
384
|
+
attr_reader :resources
|
385
|
+
attr_reader :registry
|
374
386
|
|
375
387
|
# Initializes a message object.
|
376
388
|
# @param descriptor [Google::Protobuf::DescriptorProto] the protobuf
|
@@ -447,6 +459,7 @@ module Gapic
|
|
447
459
|
# @ return [EnumValue] the EnumValues contained in this file.
|
448
460
|
class Enum < Proto
|
449
461
|
extend Forwardable
|
462
|
+
|
450
463
|
attr_reader :values
|
451
464
|
|
452
465
|
# Initializes a message object.
|
@@ -479,17 +492,6 @@ module Gapic
|
|
479
492
|
class EnumValue < Proto
|
480
493
|
extend Forwardable
|
481
494
|
|
482
|
-
# Initializes a message object.
|
483
|
-
# @param descriptor [Google::Protobuf::DescriptorProto] the protobuf
|
484
|
-
# representation of this service.
|
485
|
-
# @param address [Enumerable<String>] The address of the proto. See
|
486
|
-
# #address for more info.
|
487
|
-
# @param docs [Google::Protobuf::SourceCodeInfo::Location] The docs
|
488
|
-
# of the proto. See #docs for more info.
|
489
|
-
def initialize descriptor, address, docs
|
490
|
-
super descriptor, address, docs
|
491
|
-
end
|
492
|
-
|
493
495
|
# @!method name
|
494
496
|
# @return [String] the unqualified name of the EnumValue
|
495
497
|
# @!method number
|
@@ -520,7 +522,12 @@ module Gapic
|
|
520
522
|
# @ return [Enumerable<Enum>] The nested enum declarations of a message.
|
521
523
|
class Message < Proto
|
522
524
|
extend Forwardable
|
523
|
-
|
525
|
+
|
526
|
+
attr_reader :fields
|
527
|
+
attr_reader :extensions
|
528
|
+
attr_reader :resource
|
529
|
+
attr_reader :nested_messages
|
530
|
+
attr_reader :nested_enums
|
524
531
|
|
525
532
|
# Initializes a message object.
|
526
533
|
# @param descriptor [Google::Protobuf::DescriptorProto] the protobuf
|
@@ -583,8 +590,9 @@ module Gapic
|
|
583
590
|
# otherwise.
|
584
591
|
class Field < Proto
|
585
592
|
extend Forwardable
|
586
|
-
|
587
|
-
|
593
|
+
|
594
|
+
attr_accessor :message
|
595
|
+
attr_accessor :enum
|
588
596
|
|
589
597
|
# Initializes a message object.
|
590
598
|
# @param descriptor [Google::Protobuf::FieldDescriptorProto] the
|
@@ -784,7 +792,12 @@ module Gapic
|
|
784
792
|
# @return [Array<Gapic::Schema::Resource>] Parent resources
|
785
793
|
class Resource
|
786
794
|
extend Forwardable
|
787
|
-
|
795
|
+
|
796
|
+
attr_reader :descriptor
|
797
|
+
attr_reader :parsed_patterns
|
798
|
+
attr_reader :parsed_parent_patterns
|
799
|
+
attr_reader :parent_resources
|
800
|
+
|
788
801
|
attr_accessor :parent
|
789
802
|
|
790
803
|
# Initializes a resource object.
|
@@ -25,13 +25,11 @@ module Gapic
|
|
25
25
|
# @return [Array<Segment|String>] The segments of the parsed path pattern.
|
26
26
|
module Parser
|
27
27
|
# @private
|
28
|
-
#
|
28
|
+
# `/(?<positional>\*\*?)|{(?<name>[^\/]+?)(?:=(?<template>.+?))?}/`
|
29
29
|
URI_TEMPLATE = %r{
|
30
|
-
(
|
31
|
-
|
32
|
-
|
33
|
-
{(?<name>[^\/]+?)(?:=(?<template>.+?))?}
|
34
|
-
)
|
30
|
+
(?<positional>\*\*?)
|
31
|
+
|
|
32
|
+
{(?<name>[^/]+?)(?:=(?<template>.+?))?}
|
35
33
|
}x.freeze
|
36
34
|
|
37
35
|
def self.parse_arguments uri_template
|
@@ -21,13 +21,13 @@ Gem::Specification.new do |gem|
|
|
21
21
|
<%= gem.extra_files.inspect %>
|
22
22
|
gem.require_paths = ["lib"]
|
23
23
|
|
24
|
-
gem.required_ruby_version = ">= 2.
|
24
|
+
gem.required_ruby_version = ">= 2.5"
|
25
25
|
|
26
26
|
<%- gem.dependency_list.each do |name, requirements| -%>
|
27
27
|
gem.add_dependency <%= name.inspect %>, <%= requirements.map { |v| v.inspect }.join ", " %>
|
28
28
|
<%- end -%>
|
29
29
|
|
30
|
-
gem.add_development_dependency "google-style", "~> 1.
|
30
|
+
gem.add_development_dependency "google-style", "~> 1.25.1"
|
31
31
|
gem.add_development_dependency "minitest", "~> 5.14"
|
32
32
|
gem.add_development_dependency "minitest-focus", "~> 1.1"
|
33
33
|
gem.add_development_dependency "minitest-rg", "~> 5.2"
|
@@ -28,11 +28,11 @@ response = client.<%= method.name %> request
|
|
28
28
|
|
29
29
|
## Supported Ruby Versions
|
30
30
|
|
31
|
-
This library is supported on Ruby 2.
|
31
|
+
This library is supported on Ruby 2.5+.
|
32
32
|
|
33
33
|
Google provides official support for Ruby versions that are actively supported
|
34
34
|
by Ruby Core—that is, Ruby versions that are either in normal maintenance or
|
35
|
-
in security maintenance, and not end of life. Currently, this means Ruby 2.
|
35
|
+
in security maintenance, and not end of life. Currently, this means Ruby 2.5
|
36
36
|
and later. Older versions of Ruby _may_ still work, but are unsupported and not
|
37
37
|
recommended. See https://www.ruby-lang.org/en/downloads/branches/ for details
|
38
38
|
about the Ruby support schedule.
|
@@ -8,14 +8,14 @@ AllCops:
|
|
8
8
|
- "proto_docs/**/*"
|
9
9
|
- "test/**/*"
|
10
10
|
|
11
|
+
Layout/LineLength:
|
12
|
+
Enabled: false
|
11
13
|
Metrics/AbcSize:
|
12
14
|
Enabled: false
|
13
15
|
Metrics/ClassLength:
|
14
16
|
Enabled: false
|
15
17
|
Metrics/CyclomaticComplexity:
|
16
18
|
Enabled: false
|
17
|
-
Metrics/LineLength:
|
18
|
-
Enabled: false
|
19
19
|
Metrics/MethodLength:
|
20
20
|
Enabled: false
|
21
21
|
Metrics/ModuleLength:
|
@@ -25,13 +25,3 @@ Metrics/PerceivedComplexity:
|
|
25
25
|
Naming/FileName:
|
26
26
|
Exclude:
|
27
27
|
- "lib/<%= gem.name %>.rb"
|
28
|
-
Naming/PredicateName:
|
29
|
-
Enabled: false
|
30
|
-
Style/AsciiComments:
|
31
|
-
Enabled: false
|
32
|
-
Style/CaseEquality:
|
33
|
-
Enabled: false
|
34
|
-
Style/IfUnlessModifier:
|
35
|
-
Enabled: false
|
36
|
-
Style/ModuleFunction:
|
37
|
-
Enabled: false
|
@@ -115,7 +115,7 @@ class Configuration
|
|
115
115
|
def rpcs
|
116
116
|
@rpcs ||= begin
|
117
117
|
parent_rpcs = nil
|
118
|
-
parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config
|
118
|
+
parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
|
119
119
|
Rpcs.new parent_rpcs
|
120
120
|
end
|
121
121
|
end
|
@@ -149,7 +149,7 @@ class Configuration
|
|
149
149
|
# @private
|
150
150
|
def initialize parent_rpcs = nil
|
151
151
|
<%- method_service.methods.each do |method| -%>
|
152
|
-
<%= method.name %>_config = parent_rpcs
|
152
|
+
<%= method.name %>_config = parent_rpcs.<%= method.name %> if parent_rpcs.respond_to? :<%= method.name %>
|
153
153
|
@<%= method.name %> = ::Gapic::Config::Method.new <%= method.name %>_config
|
154
154
|
<%- end -%>
|
155
155
|
|
@@ -65,7 +65,7 @@ def test_<%= method.name %>
|
|
65
65
|
end
|
66
66
|
|
67
67
|
# Use protobuf object with options
|
68
|
-
client.<%= method.name %>
|
68
|
+
client.<%= method.name %>(<%= method.request_type %>.new(<%= fields.map(&:as_kwarg).join ", " %>), grpc_options) do |response, operation|
|
69
69
|
<%= indent_tail render(partial: "service/test/method/assert_response", locals: { method: method }), 6 %>
|
70
70
|
end
|
71
71
|
|
@@ -79,7 +79,7 @@ def test_<%= method.name %>
|
|
79
79
|
end
|
80
80
|
|
81
81
|
# Use protobuf object with options
|
82
|
-
client.<%= method.name %>
|
82
|
+
client.<%= method.name %>(<%= method.request_type %>.new(<%= fields.map(&:as_kwarg).join ", " %>), grpc_options) do |response, operation|
|
83
83
|
assert_kind_of Enumerable, response
|
84
84
|
response.to_a.each do |r|
|
85
85
|
assert_kind_of <%= method.return_type %>, r
|
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.
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ernest Landrito
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2021-02-
|
13
|
+
date: 2021-02-27 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: actionpack
|
@@ -46,28 +46,28 @@ dependencies:
|
|
46
46
|
requirements:
|
47
47
|
- - "~>"
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: 1.
|
49
|
+
version: 1.25.1
|
50
50
|
type: :development
|
51
51
|
prerelease: false
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
54
|
- - "~>"
|
55
55
|
- !ruby/object:Gem::Version
|
56
|
-
version: 1.
|
56
|
+
version: 1.25.1
|
57
57
|
- !ruby/object:Gem::Dependency
|
58
58
|
name: grpc-tools
|
59
59
|
requirement: !ruby/object:Gem::Requirement
|
60
60
|
requirements:
|
61
61
|
- - "~>"
|
62
62
|
- !ruby/object:Gem::Version
|
63
|
-
version: 1.
|
63
|
+
version: 1.36.0
|
64
64
|
type: :development
|
65
65
|
prerelease: false
|
66
66
|
version_requirements: !ruby/object:Gem::Requirement
|
67
67
|
requirements:
|
68
68
|
- - "~>"
|
69
69
|
- !ruby/object:Gem::Version
|
70
|
-
version: 1.
|
70
|
+
version: 1.36.0
|
71
71
|
- !ruby/object:Gem::Dependency
|
72
72
|
name: minitest
|
73
73
|
requirement: !ruby/object:Gem::Requirement
|
@@ -246,6 +246,7 @@ files:
|
|
246
246
|
- templates/default/gem/_version.erb
|
247
247
|
- templates/default/gem/changelog.erb
|
248
248
|
- templates/default/gem/entrypoint.erb
|
249
|
+
- templates/default/gem/gapic_metadata_json.erb
|
249
250
|
- templates/default/gem/gemfile.erb
|
250
251
|
- templates/default/gem/gemspec.erb
|
251
252
|
- templates/default/gem/gitignore.erb
|
@@ -340,14 +341,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
340
341
|
requirements:
|
341
342
|
- - ">="
|
342
343
|
- !ruby/object:Gem::Version
|
343
|
-
version: '
|
344
|
+
version: '2.5'
|
344
345
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
345
346
|
requirements:
|
346
347
|
- - ">="
|
347
348
|
- !ruby/object:Gem::Version
|
348
349
|
version: '0'
|
349
350
|
requirements: []
|
350
|
-
rubygems_version: 3.
|
351
|
+
rubygems_version: 3.2.11
|
351
352
|
signing_key:
|
352
353
|
specification_version: 4
|
353
354
|
summary: An API Client Generator for Ruby in Ruby!
|