gapic-generator 0.10.1 → 0.11.0

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.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +34 -0
  3. data/lib/gapic/generator/version.rb +1 -1
  4. data/lib/gapic/generators/default_generator.rb +2 -0
  5. data/lib/gapic/generators/default_generator_parameters.rb +3 -1
  6. data/lib/gapic/grpc_service_config/{service_config.rb → config.rb} +2 -2
  7. data/lib/gapic/grpc_service_config/parser.rb +8 -8
  8. data/lib/gapic/model/method/http_annotation.rb +123 -0
  9. data/lib/gapic/model/method/lro.rb +160 -0
  10. data/lib/gapic/model/method/routing.rb +263 -0
  11. data/lib/gapic/model/mixins.rb +181 -0
  12. data/lib/gapic/model/model_error.rb +26 -0
  13. data/lib/gapic/model/service/nonstandard_lro_provider.rb +293 -0
  14. data/lib/gapic/model.rb +22 -0
  15. data/lib/gapic/path_pattern/pattern.rb +46 -0
  16. data/lib/gapic/path_pattern/segment.rb +97 -9
  17. data/lib/gapic/presenters/gem_presenter.rb +34 -2
  18. data/lib/gapic/presenters/{service_config_presenter.rb → grpc_service_config_presenter.rb} +1 -1
  19. data/lib/gapic/presenters/method_presenter.rb +43 -3
  20. data/lib/gapic/presenters/method_rest_presenter.rb +33 -55
  21. data/lib/gapic/presenters/service/lro_client_presenter.rb +90 -0
  22. data/lib/gapic/presenters/service_presenter.rb +185 -3
  23. data/lib/gapic/presenters/service_rest_presenter.rb +81 -0
  24. data/lib/gapic/presenters/snippet_presenter.rb +1 -0
  25. data/lib/gapic/presenters.rb +3 -1
  26. data/lib/gapic/schema/api.rb +56 -2
  27. data/lib/gapic/schema/loader.rb +4 -1
  28. data/lib/gapic/schema/service_config_parser.rb +118 -0
  29. data/lib/gapic/schema/wrappers.rb +124 -1
  30. data/lib/google/api/auth.pb.rb +75 -0
  31. data/lib/google/api/backend.pb.rb +59 -0
  32. data/lib/google/api/billing.pb.rb +53 -0
  33. data/lib/google/api/context.pb.rb +47 -0
  34. data/lib/google/api/control.pb.rb +38 -0
  35. data/lib/google/api/documentation.pb.rb +56 -0
  36. data/lib/google/api/endpoint.pb.rb +42 -0
  37. data/lib/google/api/label.pb.rb +49 -0
  38. data/lib/google/api/launch_stage.pb.rb +37 -0
  39. data/lib/google/api/log.pb.rb +47 -0
  40. data/lib/google/api/logging.pb.rb +48 -0
  41. data/lib/google/api/metric.pb.rb +90 -0
  42. data/lib/google/api/monitored_resource.pb.rb +68 -0
  43. data/lib/google/api/monitoring.pb.rb +48 -0
  44. data/lib/google/api/quota.pb.rb +63 -0
  45. data/lib/google/api/routing.pb.rb +58 -0
  46. data/lib/google/api/service.pb.rb +90 -0
  47. data/lib/google/api/source_info.pb.rb +44 -0
  48. data/lib/google/api/system_parameter.pb.rb +51 -0
  49. data/lib/google/api/usage.pb.rb +47 -0
  50. data/lib/google/cloud/extended_operations.pb.rb +57 -0
  51. data/lib/google/protobuf/any.pb.rb +1 -1
  52. data/lib/google/protobuf/api.pb.rb +69 -0
  53. data/lib/google/protobuf/descriptor.pb.rb +1 -1
  54. data/lib/google/protobuf/duration.pb.rb +41 -0
  55. data/lib/google/protobuf/source_context.pb.rb +39 -0
  56. data/lib/google/protobuf/struct.pb.rb +65 -0
  57. data/lib/google/protobuf/type.pb.rb +128 -0
  58. data/lib/google/protobuf/wrappers.pb.rb +80 -0
  59. data/templates/default/gem/yardopts.erb +1 -1
  60. data/templates/default/lib/_package.erb +4 -0
  61. data/templates/default/lib/_service.erb +6 -0
  62. data/templates/default/service/client/_client.erb +20 -8
  63. data/templates/default/service/client/_nonstandard_lro.erb +57 -0
  64. data/templates/default/service/client/_self_configure_defaults.erb +2 -2
  65. data/templates/default/service/client/method/def/_options_defaults.erb +1 -8
  66. data/templates/default/service/client/method/def/_response.erb +2 -0
  67. data/templates/default/service/client/method/def/_response_nonstandard_lro.erb +23 -0
  68. data/templates/default/service/client/method/def/_routing_params.erb +36 -0
  69. data/templates/default/service/nonstandard_lro.erb +6 -0
  70. data/templates/default/service/rest/client/_client.erb +32 -5
  71. data/templates/default/service/rest/client/method/def/_response.erb +2 -2
  72. data/templates/default/service/rest/client/method/def/_response_nonstandard_lro.erb +23 -0
  73. data/templates/default/service/test/method/_assert_response.erb +3 -0
  74. metadata +61 -7
  75. data/templates/default/service/rest/client/method/def/_response_lro.erb +0 -7
@@ -0,0 +1,293 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2021 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ module Gapic
18
+ module Model
19
+ ##
20
+ # Service-level models
21
+ #
22
+ module Service
23
+ ##
24
+ # Nonstandard (AIP-151 nonconforming) long-running operation service-level model
25
+ # for the services that are LRO providers (contain polling methods for long-running operations)
26
+ #
27
+ # @!attribute [r] service_full_name
28
+ # @return [String] Full grpc name of this service. E.g. `google.example.LroProvider`.
29
+ #
30
+ # @!attribute [r] polling_method_name
31
+ # @return [String] Name of the method that is used to poll for LROs. E.g. `Poll`
32
+ #
33
+ # @!attribute [r] lro_object_full_name
34
+ # @return [String] Full grpc name of the object that is returned by the polling method.
35
+ # E.g. `google.cloud.compute.v1.Operation`
36
+ #
37
+ # @!attribute [r] operation_status_field
38
+ # @return [String] In the Operation message for this service, the name of the `status` field.
39
+ # The `status` field signals that the operation has finished. It should either contain symbols, and
40
+ # be set to `:DONE` when finished or contain a boolean and be set to `true` when finished.
41
+ #
42
+ # @!attribute [r] operation_name_field
43
+ # @return [String, nil] In the Operation message for this service, the name of the `name` field.
44
+ #
45
+ # @!attribute [r] operation_err_code_field
46
+ # @return [String, nil] In the Operation message for this service, the name of the `error code` field.
47
+ #
48
+ # @!attribute [r] operation_err_msg_field
49
+ # @return [String, nil] In the Operation message for this service, the name of the `error message` field.
50
+ #
51
+ # @!attribute [r] operation_response_fields
52
+ # @return [Hash<String, String>] The map of the fields that need to be copied from the
53
+ # long-running operation object that the polling method returns to the polling request.
54
+ # The format is `name of the operation object field` -> `name of the polling request field` (`from -> to`).
55
+ # E.g. `{"foo" => "bar"}` means that when constructing a polling request,
56
+ # the following assignment should be carried out:
57
+ # `lro_polling_request.bar = operation_object.foo`.
58
+ #
59
+ class NonstandardLroProvider
60
+ attr_reader :service_full_name
61
+ attr_reader :polling_method_name
62
+ attr_reader :lro_object_full_name
63
+ attr_reader :operation_status_field
64
+ attr_reader :operation_name_field
65
+ attr_reader :operation_err_code_field
66
+ attr_reader :operation_err_msg_field
67
+ attr_reader :operation_response_fields
68
+
69
+ ##
70
+ # @return [Boolean] Whether this is a model for a nonstandard LRO provider service
71
+ #
72
+ def nonstandard_lro?
73
+ true
74
+ end
75
+
76
+ ##
77
+ # @param service_full_name [String]
78
+ # Full grpc name of this service. E.g. `google.example.LroProvider`.
79
+ #
80
+ # @param polling_method_name [String]
81
+ # Name of the method that is used to poll for LROs. E.g. `Poll`
82
+ #
83
+ # @param lro_object_full_name
84
+ # Full grpc name of the object that is returned by the polling method.
85
+ # E.g. `google.cloud.compute.v1.Operation`
86
+ #
87
+ # @param operation_status_field [String]
88
+ # In the Operation message for this service, the name of the `status` field.
89
+ # The `status` field signals that the operation has finished. It should either contain symbols, and
90
+ # be set to `:DONE` when finished or contain a boolean and be set to `true` when finished.
91
+ #
92
+ # @param operation_name_field [String, nil]
93
+ # In the Operation message for this service, the name of the `name` field.
94
+ #
95
+ # @param operation_err_code_field [String, nil]
96
+ # In the Operation message for this service, the name of the `error code` field.
97
+ #
98
+ # @param operation_err_msg_field [String, nil]
99
+ # In the Operation message for this service, the name of the `error message` field.
100
+ #
101
+ # @param operation_response_fields [Hash<String, String>]
102
+ # The map of the fields that need to be copied from the
103
+ # long-running operation object that the polling method returns to the polling request.
104
+ # The format is `name of the operation object field` -> `name of the polling request field` (`from -> to`).
105
+ # E.g. `{"foo" => "bar"}` means that when constructing a polling request,
106
+ # the following assignment should be carried out:
107
+ # `lro_polling_request.bar = operation_object.foo`.
108
+ #
109
+ def initialize service_full_name,
110
+ polling_method_name,
111
+ lro_object_full_name,
112
+ operation_status_field,
113
+ operation_name_field,
114
+ operation_err_code_field,
115
+ operation_err_msg_field,
116
+ operation_response_fields
117
+
118
+ @service_full_name = service_full_name
119
+ @polling_method_name = polling_method_name
120
+ @lro_object_full_name = lro_object_full_name
121
+ @operation_status_field = operation_status_field
122
+ @operation_name_field = operation_name_field
123
+ @operation_err_code_field = operation_err_code_field
124
+ @operation_err_msg_field = operation_err_msg_field
125
+ @operation_response_fields = operation_response_fields
126
+ end
127
+ end
128
+
129
+ ##
130
+ # Service does not provide nonstandard LRO polling capabilities
131
+ #
132
+ class NoNonstandardLro
133
+ include Singleton
134
+
135
+ ##
136
+ # @return [Boolean] Whether this is a model for a nonstandard LRO provider service
137
+ #
138
+ def nonstandard_lro?
139
+ false
140
+ end
141
+ end
142
+
143
+ class << self
144
+ ##
145
+ # Parses the service proto information to determine, whether it is
146
+ # a provider for nonstandard long-running operations polling
147
+ #
148
+ # @param service [Gapic::Schema::Service]
149
+ #
150
+ # @raises [Gapic::Model::ModelError]
151
+ #
152
+ # @return [NonstandardLroProvider, nil]
153
+ def parse_nonstandard_lro service
154
+ polling_method = find_polling_method service
155
+ return unless polling_method
156
+
157
+ # There should not be any methods that have the `operation_service` annotation
158
+ # in the LRO provider service.
159
+ # In theory there is nothing wrong with one LRO polling service using another
160
+ # LRO polling service, in practice there is potential for service intialization cycles
161
+ # Until we have a real usecase it's safer to assume an error in proto.
162
+ nonstandard_lro_candidates = service.methods.find_all do |m|
163
+ !m.operation_service.nil? && !m.operation_service.empty?
164
+ end
165
+
166
+ if nonstandard_lro_candidates.length.positive?
167
+ ops_service_method = nonstandard_lro_candidates[0]
168
+ error_text = "A service `#{service.name}` has a method annotated " \
169
+ "with `polling_method` (`#{polling_method.name}`), and also a method annotated " \
170
+ "with `operation_service` (`#{ops_service_method.name}`). "\
171
+ "This means a grpc service tries to be a client " \
172
+ "and a provider of the nonstandard LRO at the same time. " \
173
+ "This is not supported."
174
+ raise ModelError, error_text
175
+ end
176
+
177
+ lro_object_full_name = polling_method.output.full_name
178
+
179
+ status_field = find_status_field service, polling_method
180
+ operation_status_field = status_field.name
181
+
182
+ operation_name_field = name_of_operation_field polling_method, ::Google::Cloud::OperationResponseMapping::NAME
183
+ operation_err_code_field = name_of_operation_field polling_method,
184
+ ::Google::Cloud::OperationResponseMapping::ERROR_CODE
185
+ operation_err_msg_field = name_of_operation_field polling_method,
186
+ ::Google::Cloud::OperationResponseMapping::ERROR_MESSAGE
187
+
188
+ # optionally, there might be fields in the polling method's input object
189
+ # that should be filled with information from the LRO object
190
+ ops_response_fields = polling_method.input.fields.find_all do |f|
191
+ !f.operation_response_field.nil? && !f.operation_response_field.empty?
192
+ end
193
+
194
+ operation_response_fields = ops_response_fields.map do |field|
195
+ [field.name, field.operation_response_field]
196
+ end.to_h
197
+
198
+ NonstandardLroProvider.new service.full_name,
199
+ polling_method.name,
200
+ lro_object_full_name,
201
+ operation_status_field,
202
+ operation_name_field,
203
+ operation_err_code_field,
204
+ operation_err_msg_field,
205
+ operation_response_fields
206
+ end
207
+
208
+ private
209
+
210
+ ##
211
+ # Returns a name of the polling method's output object (presumed to be LRO object)'s field
212
+ # that is marked with a given `operation_response_field` annotation,
213
+ # or nil if no such field exists.
214
+ #
215
+ # @param polling_method [Gapic::Schema::Method] the polling method
216
+ # @param ops_response_field [Integer] the value of the `operation_response_field` annotation
217
+ #
218
+ # @return [String]
219
+ #
220
+ def name_of_operation_field polling_method, ops_response_field
221
+ name_candidate = polling_method.output.fields.find do |f|
222
+ f.operation_field == ops_response_field
223
+ end
224
+ return name_candidate.name if name_candidate
225
+ end
226
+
227
+ ##
228
+ # If this service is provider for a nonstandard LRO,
229
+ # find the polling method.
230
+ # Otherwise returns nil.
231
+ #
232
+ # @param service [Gapic::Schema::Service]
233
+ #
234
+ # @raises [Gapic::Model::ModelError]
235
+ #
236
+ # @returns [Gapic::Schema::Method, nil]
237
+ #
238
+ def find_polling_method service
239
+ # On a LRO service, one method should be marked as 'polling'
240
+ polling_method_candidates = service.methods.find_all do |m|
241
+ !m.polling_method.nil? && m.polling_method
242
+ end
243
+ if polling_method_candidates.length > 1
244
+ error_text = "A service #{service.name} has more than one method annotated " \
245
+ "with `operation_polling_method`. This should not happen."
246
+ raise ModelError, error_text
247
+ end
248
+
249
+ return unless polling_method_candidates.length == 1
250
+
251
+ polling_method_candidates[0]
252
+ end
253
+
254
+ ##
255
+ # Find the `status` field in the LRO message that this service provides a
256
+ # polling functionality for
257
+ #
258
+ # @param service [Gapic::Schema::Service]
259
+ # @param polling_method [Gapic::Schema::Method]
260
+ #
261
+ # @raises [Gapic::Model::ModelError]
262
+ #
263
+ # @returns [Gapic::Schema::Field]
264
+ #
265
+ def find_status_field service, polling_method
266
+ # The output of the polling method is an Operation, which should have at least
267
+ # a Status field
268
+ status_candidates = polling_method.output.fields.find_all do |f|
269
+ f.operation_field == ::Google::Cloud::OperationResponseMapping::STATUS
270
+ end
271
+
272
+ if status_candidates.length > 1
273
+ error_text = "A nonstandard LRO provider service `#{service.name}`'s " \
274
+ "polling method `#{polling_method.name}`'s output message " \
275
+ "`#{polling_method.output.name}` has more than one field annotated " \
276
+ "with `google.cloud.operation_field = STATUS`. This is not supported."
277
+ raise ModelError, error_text
278
+ end
279
+
280
+ if status_candidates.length.zero?
281
+ error_text = "A nonstandard LRO provider service `#{service.name}`'s " \
282
+ "polling method `#{polling_method.name}`'s output message " \
283
+ "`#{polling_method.output.name}` does not have any fields annotated " \
284
+ "with `google.cloud.operation_field = STATUS`. This is not supported."
285
+ raise ModelError, error_text
286
+ end
287
+
288
+ status_candidates[0]
289
+ end
290
+ end
291
+ end
292
+ end
293
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2021 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ require "gapic/model/method/http_annotation"
18
+ require "gapic/model/method/lro"
19
+ require "gapic/model/method/routing"
20
+ require "gapic/model/mixins"
21
+ require "gapic/model/model_error"
22
+ require "gapic/model/service/nonstandard_lro_provider"
@@ -44,6 +44,43 @@ module Gapic
44
44
  @segments.select(&:provides_arguments?).map(&:arguments).flatten
45
45
  end
46
46
 
47
+ ##
48
+ # Whether this is a basic single-star ("*") pattern
49
+ # @return [Boolean]
50
+ def star_pattern?
51
+ @segments.length == 1 && @segments[0].pattern == "*"
52
+ end
53
+
54
+ ##
55
+ # Whether this is a basic double-star ("**") pattern
56
+ # @return [Boolean]
57
+ def double_star_pattern?
58
+ @segments.length == 1 && @segments[0].pattern == "**"
59
+ end
60
+
61
+ ##
62
+ # Converts the PathPattern into a regex string
63
+ # @return [String]
64
+ def to_regex_str
65
+ regex_str = segments.first.to_regex_str
66
+
67
+ # for double wildcards the leading `/`` is optional
68
+ # e.g. `foo/**` should match `foo`
69
+ # this is why segments 'bring' the leading separator
70
+ # with them as they build the pattern
71
+ segments.drop(1).each_with_index do |segment, _index|
72
+ is_double_wildcard = segment.pattern == "**"
73
+
74
+ regex_str = if is_double_wildcard
75
+ "#{regex_str}(?:/.*)?"
76
+ else
77
+ "#{regex_str}/#{segment.to_regex_str}"
78
+ end
79
+ end
80
+
81
+ regex_str
82
+ end
83
+
47
84
  ##
48
85
  # Whether pattern contains a positional segment
49
86
  # @return [Boolean]
@@ -76,6 +113,15 @@ module Gapic
76
113
  parent_pattern_segments = last_segment.provides_arguments? ? segments[0...-2] : segments[0...-1]
77
114
  parent_pattern_segments.map(&:pattern_template).join("/")
78
115
  end
116
+
117
+ ##
118
+ # The pattern with the resource names stripped
119
+ # from the ResourceId segments
120
+ # (e.g. `collections/{resource_id=foo/*}` => `collections/foo/*`)
121
+ #
122
+ def simplified_pattern
123
+ @segments.map(&:simplified_pattern).join("/")
124
+ end
79
125
  end
80
126
  end
81
127
  end
@@ -97,6 +97,32 @@ module Gapic
97
97
  pattern
98
98
  end
99
99
 
100
+ ##
101
+ # Whether the segment is a resource id segment
102
+ # @return [Boolean]
103
+ def resource_id_segment?
104
+ false
105
+ end
106
+
107
+ ##
108
+ # The difference between `simplified_pattern` and `pattern`
109
+ # does not exist for the Positional segments
110
+ # @return [String]
111
+ def simplified_pattern
112
+ pattern
113
+ end
114
+
115
+ ##
116
+ # Creates a string with a regex representation of this segment's pattern
117
+ # @return [String]
118
+ def to_regex_str
119
+ if pattern == "**"
120
+ ".*"
121
+ else
122
+ "[^/]+"
123
+ end
124
+ end
125
+
100
126
  # @private
101
127
  def == other
102
128
  return false unless other.is_a? self.class
@@ -129,6 +155,12 @@ module Gapic
129
155
  @type = type
130
156
  @pattern = pattern
131
157
  @resource_names = resource_names
158
+
159
+ # For the segments specified like `{foo}`, the implied resource pattern is `*`
160
+ # `{foo}` === `{foo=*}`
161
+ if resource_patterns.empty?
162
+ resource_patterns = ["*"]
163
+ end
132
164
  @resource_patterns = resource_patterns
133
165
  end
134
166
 
@@ -139,15 +171,9 @@ module Gapic
139
171
  false
140
172
  end
141
173
 
142
- ##
143
- # Whether the segment provides a resource pattern
144
- # @return [Boolean]
145
- def resource_pattern?
146
- resource_patterns.any?
147
- end
148
-
149
174
  ##
150
175
  # Whether the segment provides a nontrivial resource pattern
176
+ # (not `*` or `**`)
151
177
  # @return [Boolean]
152
178
  def nontrivial_resource_pattern?
153
179
  resource_patterns.any? { |res_pattern| !res_pattern.match?(/^\*+$/) }
@@ -168,8 +194,8 @@ module Gapic
168
194
  end
169
195
 
170
196
  ##
171
- # Returns a segment's pattern filled with dummy values
172
- # names of the values are generated starting from the index provided
197
+ # Returns a segment's pattern filled with dummy values.
198
+ # Names of the values are generated starting from the index provided.
173
199
  # @param start_index [Integer] a starting index for dummy value generation
174
200
  # @return [String] a pattern filled with dummy values
175
201
  def expected_path_for_dummy_values start_index
@@ -194,6 +220,46 @@ module Gapic
194
220
  "*"
195
221
  end
196
222
 
223
+ ##
224
+ # Whether the segment is a resource id segment
225
+ # @return [Boolean]
226
+ def resource_id_segment?
227
+ true
228
+ end
229
+
230
+ ##
231
+ # The pattern with the resource name
232
+ # (e.g. `foo` in `{foo=bar/*}`) stripped.
233
+ # So `{foo=bar/*}` -> `bar/*`.
234
+ #
235
+ # Not implemented for multivariate segments
236
+ # (e.g `{foo}~{bar}`).
237
+ #
238
+ # @return [String]
239
+ def simplified_pattern
240
+ if resource_patterns.count > 1
241
+ raise "Not implemented for multivariate ResourceId segments"
242
+ end
243
+ resource_patterns[0]
244
+ end
245
+
246
+ ##
247
+ # Creates a string with a regex representation of this segment's pattern
248
+ # @return [String]
249
+ def to_regex_str
250
+ raise "Not implemented for multivariate ResourceId segments" if resource_patterns.count > 1
251
+
252
+ resource_pattern = if resource_patterns[0].nil?
253
+ "*"
254
+ else
255
+ resource_patterns[0]
256
+ end
257
+
258
+ resource_pattern_regex = Gapic::PathPattern::Parser.parse(resource_pattern).to_regex_str
259
+
260
+ "(?<#{resource_names[0]}>#{resource_pattern_regex})"
261
+ end
262
+
197
263
  ##
198
264
  # Initialization helper to create a simple resource without a pattern
199
265
  # @param name [String] resource name
@@ -272,6 +338,28 @@ module Gapic
272
338
  pattern
273
339
  end
274
340
 
341
+ ##
342
+ # Whether the segment is a resource id segment
343
+ # @return [Boolean]
344
+ def resource_id_segment?
345
+ false
346
+ end
347
+
348
+ ##
349
+ # The difference between `simplified_pattern` and `pattern`
350
+ # does not exist for the CollectionId segments
351
+ # @return [String]
352
+ def simplified_pattern
353
+ pattern
354
+ end
355
+
356
+ ##
357
+ # Creates a string with a regex representation of this segment's pattern
358
+ # @return [String]
359
+ def to_regex_str
360
+ pattern
361
+ end
362
+
275
363
  # @private
276
364
  def == other
277
365
  return false unless other.is_a? self.class
@@ -30,6 +30,7 @@ module Gapic
30
30
 
31
31
  def initialize api
32
32
  @api = api
33
+ @mixins_model = Gapic::Model::Mixins.new api.services.map(&:full_name), api.service_config
33
34
  end
34
35
 
35
36
  ##
@@ -46,6 +47,9 @@ module Gapic
46
47
  !packages.empty?
47
48
  end
48
49
 
50
+ ##
51
+ # @return [Enumerable<Gapic::Presenters::ServicePresenter>]
52
+ #
49
53
  def services
50
54
  @services ||= begin
51
55
  files = @api.generate_files
@@ -135,7 +139,7 @@ module Gapic
135
139
  end
136
140
 
137
141
  def library_documentation_url
138
- gem_config(:library_documentation_url) || "https://googleapis.dev/ruby/#{name}/latest"
142
+ gem_config(:library_documentation_url) || "https://rubydoc.info/gems/#{name}"
139
143
  end
140
144
 
141
145
  def product_documentation_url
@@ -178,7 +182,15 @@ module Gapic
178
182
  gem_config(:generic_endpoint) || false
179
183
  end
180
184
 
185
+ ##
186
+ # @return [Boolean]
187
+ #
188
+ def generate_rest_clients?
189
+ @api.generate_rest_clients?
190
+ end
191
+
181
192
  def entrypoint_require
193
+ return "" unless packages?
182
194
  packages.first.package_require
183
195
  end
184
196
 
@@ -196,6 +208,7 @@ module Gapic
196
208
  deps["grpc-google-iam-v1"] = [">= 0.6.10", "< 2.a"] if iam_dependency?
197
209
  extra_deps = gem_config_dependencies
198
210
  deps.merge! extra_deps if extra_deps
211
+ deps.merge! mixins_model.dependencies if mixins_model.mixins?
199
212
  deps
200
213
  end
201
214
  end
@@ -215,7 +228,7 @@ module Gapic
215
228
  # @return [Hash]
216
229
  def first_package_drift_manifest
217
230
  return {} unless packages?
218
- packages[0].drift_manifest
231
+ packages.first.drift_manifest
219
232
  end
220
233
 
221
234
  ##
@@ -250,6 +263,25 @@ module Gapic
250
263
  packages? && quick_start_service.usable_service_presenter.is_a?(ServicePresenter)
251
264
  end
252
265
 
266
+ ##
267
+ # Whether there are mixin services that should be referenced
268
+ # in the services for this gem
269
+ #
270
+ # @return [Boolean]
271
+ #
272
+ def mixins?
273
+ @mixins_model.mixins?
274
+ end
275
+
276
+ ##
277
+ # The model for the mixin services
278
+ #
279
+ # @return [Gapic::Model::Mixins]
280
+ #
281
+ def mixins_model
282
+ @mixins_model
283
+ end
284
+
253
285
  private
254
286
 
255
287
  def gem_config key
@@ -19,7 +19,7 @@ module Gapic
19
19
  ##
20
20
  # A presenter for grpc service config.
21
21
  #
22
- class ServiceConfigPresenter
22
+ class GrpcServiceConfigPresenter
23
23
  def initialize grpc_service_config
24
24
  @grpc_service_config = grpc_service_config
25
25
  end