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
@@ -32,6 +32,15 @@ module Gapic
32
32
  # @return [Gapic::Presenters::MethodRestPresenter]
33
33
  attr_accessor :rest
34
34
 
35
+ # @return [Gapic::Model::Method::Routing]
36
+ attr_accessor :routing
37
+
38
+ # @return [Gapic::Model::Method::HttpAnnotation]
39
+ attr_accessor :http
40
+
41
+ # @return [Gapic::Model::Method::AipLro, Gapic::Model::Method::NonStandardLro, Gapic::Model::Method::NoLro]
42
+ attr_accessor :lro
43
+
35
44
  ##
36
45
  # @param service_presenter [Gapic::Presenters::ServicePresenter]
37
46
  # @param api [Gapic::Schema::Api]
@@ -40,6 +49,10 @@ module Gapic
40
49
  @service_presenter = service_presenter
41
50
  @api = api
42
51
  @method = method
52
+ @http = Gapic::Model::Method::HttpAnnotation.new @method
53
+ @routing = Gapic::Model::Method::Routing.new @method.routing, http
54
+ @lro = Gapic::Model::Method.parse_lro @method, api
55
+
43
56
  @rest = MethodRestPresenter.new self, api
44
57
  end
45
58
 
@@ -50,6 +63,9 @@ module Gapic
50
63
  @service_presenter
51
64
  end
52
65
 
66
+ ##
67
+ # @return [Gapic::Presenters::SnippetPresenter]
68
+ #
53
69
  def snippet
54
70
  SnippetPresenter.new self, @api
55
71
  end
@@ -183,12 +199,36 @@ module Gapic
183
199
  sample_configs.map { |sample_config| SamplePresenter.new @api, sample_config }
184
200
  end
185
201
 
202
+ ##
203
+ # Whether this method uses standard (AIP-151) LROs
204
+ #
205
+ # @return [Boolean]
206
+ #
186
207
  def lro?
187
208
  return paged_response_type == "::Google::Longrunning::Operation" if paged?
188
209
 
189
210
  return_type == "::Google::Longrunning::Operation"
190
211
  end
191
212
 
213
+ ##
214
+ # Whether this method uses nonstandard LROs
215
+ #
216
+ # @return [Boolean]
217
+ #
218
+ def nonstandard_lro?
219
+ @lro.nonstandard_lro?
220
+ end
221
+
222
+ ##
223
+ # The presenter for the nonstandard LRO client of the kind this method uses
224
+ #
225
+ # @return [Gapic::Presenters::Service::LroClientPresenter, nil]
226
+ #
227
+ def nonstandard_lro_client
228
+ return unless nonstandard_lro?
229
+ service.nonstandard_lros.find { |model| model.service == @lro.service_full_name }
230
+ end
231
+
192
232
  def client_streaming?
193
233
  @method.client_streaming
194
234
  end
@@ -233,7 +273,7 @@ module Gapic
233
273
  # @return [Boolean] Whether any routing params are present
234
274
  #
235
275
  def routing_params?
236
- rest.routing_params?
276
+ @routing.routing_params?
237
277
  end
238
278
 
239
279
  def grpc_service_config
@@ -243,8 +283,8 @@ module Gapic
243
283
  end
244
284
  end
245
285
 
246
- def service_config_presenter
247
- ServiceConfigPresenter.new grpc_service_config
286
+ def grpc_service_config_presenter
287
+ GrpcServiceConfigPresenter.new grpc_service_config
248
288
  end
249
289
 
250
290
  def grpc_method_name
@@ -15,7 +15,6 @@
15
15
  # limitations under the License.
16
16
 
17
17
  require "gapic/presenters/method/rest_pagination_info"
18
- require "gapic/uri_template"
19
18
 
20
19
  module Gapic
21
20
  module Presenters
@@ -34,6 +33,7 @@ module Gapic
34
33
  @api = api
35
34
  @main_method = main_method
36
35
  @proto_method = main_method.method
36
+ @http = main_method.http
37
37
 
38
38
  @pagination = Gapic::Presenters::Method::RestPaginationInfo.new @proto_method, api
39
39
  end
@@ -42,59 +42,42 @@ module Gapic
42
42
  # @return [Boolean] Whether a http verb is present for this method
43
43
  #
44
44
  def verb?
45
- !verb.nil?
45
+ @http.verb?
46
46
  end
47
47
 
48
48
  ##
49
49
  # @return [Symbol] a http verb for this method
50
50
  #
51
51
  def verb
52
- return nil if @proto_method.http.nil?
53
-
54
- method = {
55
- get: @proto_method.http.get,
56
- post: @proto_method.http.post,
57
- put: @proto_method.http.put,
58
- patch: @proto_method.http.patch,
59
- delete: @proto_method.http.delete
60
- }.find { |_, value| !value.empty? }
61
-
62
- method[0] unless method.nil?
52
+ @http.verb
63
53
  end
64
54
 
65
55
  ##
66
56
  # @return [Boolean] Whether a method path is present and non-empty
67
57
  #
68
58
  def path?
69
- !path.empty?
70
- end
71
-
72
- ##
73
- # @return [String] A method path or an empty string if not present
74
- #
75
- def path
76
- return "" if @proto_method.http.nil?
77
-
78
- verb_path = [
79
- @proto_method.http.get, @proto_method.http.post, @proto_method.http.put,
80
- @proto_method.http.patch, @proto_method.http.delete
81
- ].find { |x| !x.empty? }
82
-
83
- verb_path || @proto_method.http.custom&.path || ""
59
+ @http.path?
84
60
  end
85
61
 
86
62
  ##
87
63
  # @return [Boolean] Whether any routing params are present
88
64
  #
89
65
  def routing_params?
90
- routing_params.any?
66
+ @http.routing_params?
91
67
  end
92
68
 
93
69
  ##
94
70
  # @return [Array<String>] The segment key names.
95
71
  #
96
72
  def routing_params
97
- Gapic::UriTemplate.parse_arguments path
73
+ @http.routing_params
74
+ end
75
+
76
+ ##
77
+ # @return [Boolean] Whether method has body specified in proto
78
+ #
79
+ def body?
80
+ @http.body?
98
81
  end
99
82
 
100
83
  ##
@@ -114,15 +97,6 @@ module Gapic
114
97
  end
115
98
  end
116
99
 
117
- ##
118
- # @return [Boolean] Whether method has body specified in proto
119
- #
120
- def body?
121
- return false if @proto_method.http.nil?
122
-
123
- !@proto_method.http.body.empty?
124
- end
125
-
126
100
  ##
127
101
  # Name of the variable to use for storing the body result of the transcoding call
128
102
  # Normally "body" but use "_body" for discarding the result for
@@ -132,13 +106,6 @@ module Gapic
132
106
  body? ? "body" : "_body"
133
107
  end
134
108
 
135
- ##
136
- # @return [String] A body specified for the given method in proto or an empty string if not specified
137
- #
138
- def body
139
- @proto_method.http&.body || ""
140
- end
141
-
142
109
  ##
143
110
  # @return [Boolean] True if body contains full request object (`*` in the annotation), false otherwise
144
111
  #
@@ -236,7 +203,7 @@ module Gapic
236
203
  #
237
204
  def doc_response_type
238
205
  return "::Gapic::Rest::PagedEnumerable<#{pagination.paged_element_doc_type}>" if paged?
239
- return "::Gapic::Rest::BaseOperation" if lro?
206
+ return "::Gapic::GenericLRO::Operation" if nonstandard_lro?
240
207
  return_type
241
208
  end
242
209
 
@@ -250,17 +217,28 @@ module Gapic
250
217
  end
251
218
 
252
219
  ##
253
- # Whether the REGAPIC method should be rendered as LRO
254
- # [TODO (virost, 2021-08) Update this when DiReGapic LRO annotations are added to the Compute protos]
220
+ # Whether this method uses nonstandard LROs
255
221
  #
256
222
  # @return [Boolean]
257
223
  #
258
- def lro?
259
- return_type == "::Google::Cloud::Compute::V1::Operation" &&
260
- @main_method.service.name != "ZoneOperations" &&
261
- @main_method.service.name != "RegionOperations" &&
262
- @main_method.service.name != "GlobalOperations" &&
263
- @main_method.service.name != "GlobalOrganizationOperations"
224
+ def nonstandard_lro?
225
+ @main_method.nonstandard_lro?
226
+ end
227
+
228
+ private
229
+
230
+ ##
231
+ # @return [String] A method path or an empty string if not present
232
+ #
233
+ def path
234
+ @http.path
235
+ end
236
+
237
+ ##
238
+ # @return [String] A body specified for the given method in proto or an empty string if not specified
239
+ #
240
+ def body
241
+ @http.body
264
242
  end
265
243
  end
266
244
  end
@@ -0,0 +1,90 @@
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 Presenters
19
+ module Service
20
+ ##
21
+ # Presenter for the generation of the client for nonstandard LROs
22
+ #
23
+ # @!attribute [r] service
24
+ # Full name of the service providing the nonstandard LRO functionality
25
+ # @return [String]
26
+ # @!attribute [r] client_class_name
27
+ # Full name of the class of the client of the service
28
+ # @return [String]
29
+ # @!attribute [r] client_class_docname
30
+ # Name of the class as it should appear in the documentation
31
+ # @return [String]
32
+ # @!attribute [r] client_var_name
33
+ # Name for the variable for the client of the service
34
+ # @return [String]
35
+ # @!attribute [r] require_str
36
+ # Path to `require` the client of the service
37
+ # @return [String]
38
+ # @!attribute [r] service_description
39
+ # The description to place in the comments to this client's
40
+ # attribute in the library services's client class
41
+ # @return [String]
42
+ # @!attribute [r] helper_type
43
+ # The type of a helper generated for this service if any
44
+ # @return [String. nil]
45
+ #
46
+ class LroClientPresenter
47
+ attr_reader :service
48
+ attr_reader :client_class_name
49
+ attr_reader :client_class_docname
50
+ attr_reader :client_var_name
51
+ attr_reader :require_str
52
+ attr_reader :service_description
53
+ attr_reader :helper_type
54
+
55
+ ##
56
+ # @param service [String]
57
+ # Full name of the service providing the nonstandard LRO functionality
58
+ # @param client_class_name [String]
59
+ # Full name of the class of the client of the service
60
+ # @param client_class_docname [String]
61
+ # Name of the class as it should appear in the documentation
62
+ # @param client_var_name [String]
63
+ # Name for the variable for the client of the service
64
+ # @param require_str [String]
65
+ # Path to `require` the client of the service
66
+ # @param service_description [String]
67
+ # The description to place in the comments to this client's
68
+ # attribute in the library services's client class
69
+ # @param helper_type [String, nil]
70
+ # The type of a helper generated for this service if any
71
+ #
72
+ def initialize service:,
73
+ client_class_name:,
74
+ client_class_docname:,
75
+ client_var_name:,
76
+ require_str:,
77
+ service_description:,
78
+ helper_type: nil
79
+ @service = service
80
+ @client_class_name = client_class_name
81
+ @client_class_docname = client_class_docname
82
+ @client_var_name = client_var_name
83
+ @require_str = require_str
84
+ @service_description = service_description
85
+ @helper_type = helper_type
86
+ end
87
+ end
88
+ end
89
+ end
90
+ end
@@ -36,6 +36,7 @@ module Gapic
36
36
  @service = service
37
37
  @parent_service = parent_service
38
38
  @rest = ServiceRestPresenter.new self, api
39
+ @nonstandard_lro = api.nonstandard_lro_model_for service.full_name
39
40
  end
40
41
 
41
42
  def gem
@@ -350,18 +351,44 @@ module Gapic
350
351
  "#{ActiveSupport::Inflector.underscore name}_stub"
351
352
  end
352
353
 
354
+ ##
355
+ # Whether an AIP-151 LRO subclient needs to be generated for this service
356
+ #
357
+ # @return [Boolean]
353
358
  def lro?
354
359
  methods.find(&:lro?)
355
360
  end
356
361
 
362
+ ##
363
+ # A variable name used for the AIP-151 LRO subclients
364
+ #
365
+ # @return [String]
357
366
  def lro_client_var
358
367
  "operations_client"
359
368
  end
360
369
 
370
+ ##
371
+ # An instance variable name used for the AIP-151 LRO subclients
372
+ #
373
+ # @return [String]
361
374
  def lro_client_ivar
362
375
  "@#{lro_client_var}"
363
376
  end
364
377
 
378
+ ##
379
+ # A presenter for the LRO subclient if needed
380
+ #
381
+ # @return [Gapic::Presenters::Service::LroClientPresenter, nil]
382
+ def lro_client_presenter
383
+ return nil unless lro?
384
+ Gapic::Presenters::Service::LroClientPresenter.new service: "google.longrunning.operations",
385
+ client_class_name: "Operations",
386
+ client_class_docname: operations_name_full,
387
+ client_var_name: lro_client_var,
388
+ require_str: operations_file_path,
389
+ service_description: "long-running operations"
390
+ end
391
+
365
392
  def operations_name
366
393
  "Operations"
367
394
  end
@@ -396,8 +423,8 @@ module Gapic
396
423
  @api.grpc_service_config.service_level_configs[grpc_full_name]
397
424
  end
398
425
 
399
- def service_config_presenter
400
- ServiceConfigPresenter.new grpc_service_config
426
+ def grpc_service_config_presenter
427
+ GrpcServiceConfigPresenter.new grpc_service_config
401
428
  end
402
429
 
403
430
  ##
@@ -408,8 +435,12 @@ module Gapic
408
435
  @service.name
409
436
  end
410
437
 
438
+ ##
439
+ # The full proto name for this service
440
+ #
441
+ # @return [String]
411
442
  def grpc_full_name
412
- @service.address.join "."
443
+ @service.full_name
413
444
  end
414
445
 
415
446
  ##
@@ -474,8 +505,159 @@ module Gapic
474
505
  end
475
506
  end
476
507
 
508
+ ##
509
+ # Whether there are mixin services that should be referenced
510
+ # in the client for this service
511
+ #
512
+ # @return [Boolean]
513
+ #
514
+ def mixins?
515
+ @gem_presenter.mixins?
516
+ end
517
+
518
+ ##
519
+ # The mixin services that should be referenced
520
+ # in the client for this service
521
+ #
522
+ # @return [Enumerable<Gapic::Model::Mixins::Mixin>]
523
+ #
524
+ def mixins
525
+ @gem_presenter.mixins_model.mixins
526
+ end
527
+
528
+ ##
529
+ # Name of the nonstandard LRO module
530
+ #
531
+ # @return [String]
532
+ #
533
+ def nonstandard_lro_name
534
+ "NonstandardLro"
535
+ end
536
+
537
+ ##
538
+ # Full name of the nonstandard LRO module
539
+ #
540
+ # @return [String]
541
+ #
542
+ def nonstandard_lro_name_full
543
+ fix_namespace @api, "#{service_name_full}::#{nonstandard_lro_name}"
544
+ end
545
+
546
+ ##
547
+ # Full file path to the nonstandard LRO module
548
+ #
549
+ # @return [String]
550
+ #
551
+ def nonstandard_lro_file_path
552
+ "#{nonstandard_lro_require}.rb"
553
+ end
554
+
555
+ ##
556
+ # File name of the nonstandard LRO module
557
+ #
558
+ # @return [String]
559
+ #
560
+ def nonstandard_lro_file_name
561
+ nonstandard_lro_file_path.split("/").last
562
+ end
563
+
564
+ ##
565
+ # The require string for the nonstandard LRO module
566
+ #
567
+ # @return [String]
568
+ #
569
+ def nonstandard_lro_require
570
+ ruby_file_path @api, "#{service_name_full}::#{nonstandard_lro_name}"
571
+ end
572
+
573
+ ##
574
+ # Nonstandard lro model for this service
575
+ #
576
+ # @return [Gapic::Model::Service::NonstandardLro, Gapic::Model::Service::NoLro]
577
+ def nonstandard_lro
578
+ @nonstandard_lro
579
+ end
580
+
581
+ ##
582
+ # The Ruby name for the polling method of the nonstandard LRO provided by this service
583
+ #
584
+ # @return [String]
585
+ def nonstandard_lro_polling_method_name
586
+ return unless nonstandard_lro_provider?
587
+ methods.find { |m| m.grpc_method_name == nonstandard_lro.polling_method_name }.name
588
+ end
589
+
590
+ ##
591
+ # Whether this service is a provider of the nonstandard LRO functionality
592
+ #
593
+ # @return [Boolean]
594
+ def nonstandard_lro_provider?
595
+ @nonstandard_lro.nonstandard_lro?
596
+ end
597
+
598
+ ##
599
+ # Whether one or more methods of this service use the nonstandard LRO functionality
600
+ #
601
+ # @return [Boolean]
602
+ def nonstandard_lro_consumer?
603
+ methods.find(&:nonstandard_lro?) || false
604
+ end
605
+
606
+ ##
607
+ # The client presenters of the nonstandard LROs that are used by the methods of this service
608
+ #
609
+ # @return [Enumerable<Gapic::Presenters::Service::LroClientPresenter>]
610
+ def nonstandard_lros
611
+ return [] unless nonstandard_lro_consumer?
612
+ nonstandard_lros_models.map do |lro|
613
+ lro_wrapper = @api.lookup lro.service_full_name
614
+ lro_service = ServicePresenter.new(@gem_presenter, @api, lro_wrapper).usable_service_presenter
615
+
616
+ service_description = "long-running operations via #{lro_service.name}"
617
+ Gapic::Presenters::Service::LroClientPresenter.new service: lro.service_full_name,
618
+ client_class_name: lro_service.client_name_full,
619
+ client_class_docname: lro_service.client_name_full,
620
+ client_var_name: lro_service.service_directory_name,
621
+ require_str: lro_service.service_require,
622
+ service_description: service_description,
623
+ helper_type: lro_service.nonstandard_lro_name_full
624
+ end
625
+ end
626
+
627
+ ##
628
+ # Whether there are any subclients to generate with this service.
629
+ # Subclients are the clients to other services (e.g. an LRO provider service).
630
+ #
631
+ # @return [Boolean]
632
+ def subclients?
633
+ subclients.any?
634
+ end
635
+
636
+ ##
637
+ # Subclients for this service
638
+ # Subclients are the clients to other services (e.g. an LRO provider service).
639
+ #
640
+ # The following is typically generated for a subclient:
641
+ # - a require statement for the subclient's class
642
+ # - a class-level variable in the host service's client
643
+ # - a code to initialize this variable with a subclient's class instance in the host service's constructor
644
+ #
645
+ # @return [Enumerable<Gapic::Presenters::Service::LroClientPresenter, Gapic::Model::Mixins::Mixin>]
646
+ def subclients
647
+ ([] << lro_client_presenter << mixins << nonstandard_lros).flatten.compact
648
+ end
649
+
477
650
  private
478
651
 
652
+ ##
653
+ # The nonstandard LRO models for the nonstandard LROs that are used by the methods of this service
654
+ #
655
+ # @return [Enumerable<Gapic::Model::Method::Lro>]
656
+ def nonstandard_lros_models
657
+ return [] unless nonstandard_lro_consumer?
658
+ methods.select(&:nonstandard_lro?).map(&:lro).uniq(&:service_full_name)
659
+ end
660
+
479
661
  def default_config key
480
662
  return unless @service.parent.parent.configuration[:defaults]
481
663
  return unless @service.parent.parent.configuration[:defaults][:service]
@@ -37,12 +37,41 @@ module Gapic
37
37
  end
38
38
 
39
39
  ##
40
+ # Ruby name of this service
41
+ #
42
+ # @return [String]
43
+ #
44
+ def name
45
+ main_service.name
46
+ end
47
+
48
+ ##
49
+ # Full Ruby name of this service
50
+ #
40
51
  # @return [String]
41
52
  #
42
53
  def service_name_full
43
54
  fix_namespace api, "#{main_service.service_name_full}::Rest"
44
55
  end
45
56
 
57
+ ##
58
+ # Require path for this service
59
+ #
60
+ # @return [String]
61
+ #
62
+ def service_require
63
+ ruby_file_path @api, service_name_full
64
+ end
65
+
66
+ ##
67
+ # Folder name for this service
68
+ #
69
+ # @return [String]
70
+ #
71
+ def service_directory_name
72
+ service_require.split("/")[-2]
73
+ end
74
+
46
75
  ##
47
76
  # @return [String]
48
77
  #
@@ -141,6 +170,51 @@ module Gapic
141
170
  "#{client_name_full}.configure"
142
171
  end
143
172
 
173
+ ##
174
+ # Name of the nonstandard LRO module
175
+ #
176
+ # @return [String]
177
+ #
178
+ def nonstandard_lro_name
179
+ "NonstandardLro"
180
+ end
181
+
182
+ ##
183
+ # Full name of the nonstandard LRO module
184
+ #
185
+ # @return [String]
186
+ #
187
+ def nonstandard_lro_name_full
188
+ fix_namespace @api, "#{service_name_full}::#{nonstandard_lro_name}"
189
+ end
190
+
191
+ ##
192
+ # Full file path to the nonstandard LRO module
193
+ #
194
+ # @return [String]
195
+ #
196
+ def nonstandard_lro_file_path
197
+ "#{nonstandard_lro_require}.rb"
198
+ end
199
+
200
+ ##
201
+ # File name of the nonstandard LRO module
202
+ #
203
+ # @return [String]
204
+ #
205
+ def nonstandard_lro_file_name
206
+ nonstandard_lro_file_path.split("/").last
207
+ end
208
+
209
+ ##
210
+ # The require string for the nonstandard LRO module
211
+ #
212
+ # @return [String]
213
+ #
214
+ def nonstandard_lro_require
215
+ ruby_file_path @api, "#{service_name_full}::#{nonstandard_lro_name}"
216
+ end
217
+
144
218
  ##
145
219
  # The method to use for quick start samples. Normally this is simply the
146
220
  # first non-client-streaming method defined, but it can be overridden via
@@ -154,6 +228,13 @@ module Gapic
154
228
  main_service.quick_start_method&.rest
155
229
  end
156
230
 
231
+ ##
232
+ # @return [Enumerable<Gapic::Presenters::MethodPresenter>]
233
+ #
234
+ def methods
235
+ main_service.methods
236
+ end
237
+
157
238
  private
158
239
 
159
240
  # @return [Gapic::Presenters::ServicePresenter]
@@ -94,6 +94,7 @@ module Gapic
94
94
  api_id ||= final_name
95
95
  api_version = "v0"
96
96
  end
97
+ api_id = api_id.downcase.gsub(/[^a-z0-9]/, "")
97
98
  service_name = @method_presenter.service.module_name
98
99
  method_name = @method_presenter.method.name
99
100
  "#{api_id}_#{api_version}_generated_#{service_name}_#{method_name}_sync"