Class: Gapic::Presenters::ServicePresenter
Overview
A presenter for proto services.
Instance Attribute Summary collapse
Instance Method Summary
collapse
-
#address ⇒ Object
-
#client_endpoint ⇒ Object
-
#client_file_name ⇒ Object
-
#client_file_path ⇒ Object
-
#client_name ⇒ Object
-
#client_name_full ⇒ Object
-
#client_require ⇒ Object
-
#client_scopes ⇒ Object
-
#common_service_delegate ⇒ Object
Returns a presenter for this service's delegate (if it is a common service) otherwise returns nil.
-
#config_channel_args ⇒ Object
-
#configure_client_call ⇒ Object
-
#create_client_call ⇒ Object
-
#credentials_class_xref ⇒ Object
-
#credentials_file_name ⇒ Object
-
#credentials_file_path ⇒ Object
-
#credentials_name ⇒ Object
-
#credentials_name_full ⇒ Object
-
#credentials_require ⇒ Object
-
#deduped_references ⇒ Object
Deduplicate resource presenters by combining resources with the same name.
-
#doc_description(disable_xrefs: false) ⇒ Object
-
#drift_manifest ⇒ Hash
Returns a hash with a drift_manifest of this service, describing correspondence between the proto description of the service with the generated code for the service.
-
#file ⇒ Object
-
#gem ⇒ Object
-
#generate_grpc_clients? ⇒ Boolean
-
#generate_rest_clients? ⇒ Boolean
-
#generic_endpoint? ⇒ Boolean
-
#grpc_client_designation ⇒ String
How comments in the generated libraries refer to the GRPC client if no REST code is generated, this should just be "client", if REST code is generated, this should be disambiguated into the "GRPC client".
-
#grpc_full_name ⇒ String
The full proto name for this service.
-
#grpc_service_config ⇒ Object
-
#grpc_service_config_presenter ⇒ Object
-
#grpc_service_name ⇒ String
The short proto name for this service.
-
#helpers_file_name ⇒ Object
-
#helpers_file_path ⇒ Object
-
#helpers_require ⇒ Object
-
#initialize(gem_presenter, api, service, parent_service: nil) ⇒ ServicePresenter
constructor
A new instance of ServicePresenter.
-
#is_deprecated? ⇒ Boolean
-
#lro? ⇒ Boolean
Whether an AIP-151 LRO subclient needs to be generated for this service.
-
#lro_client_ivar ⇒ String
An instance variable name used for the AIP-151 LRO subclients.
-
#lro_client_presenter ⇒ Gapic::Presenters::Service::LroClientPresenter?
A presenter for the LRO subclient if needed.
-
#lro_client_var ⇒ String
A variable name used for the AIP-151 LRO subclients.
-
#lro_service ⇒ Object
-
#methods ⇒ Enumerable<Gapic::Presenters::MethodPresenter>
-
#methods_rest_bindings ⇒ Enumerable<Gapic::Presenters::MethodPresenter>
List of mods for which REST bindings are present and REST methods can be generated.
-
#methods_rest_bindings? ⇒ Boolean
Whether this service contains any methods with REST bindings.
-
#mixins ⇒ Enumerable<Gapic::Model::Mixins::Mixin>
The mixin services that should be referenced in the client for this service.
-
#mixins? ⇒ Boolean
Whether there are mixin services that should be referenced in the client for this service.
-
#module_name ⇒ Object
-
#name ⇒ Object
-
#namespace ⇒ Object
The namespace of the client.
-
#nonstandard_lro ⇒ Gapic::Model::Service::NonstandardLro, Gapic::Model::Service::NoLro
Nonstandard lro model for this service.
-
#nonstandard_lro_consumer? ⇒ Boolean
Whether one or more methods of this service use the nonstandard LRO functionality.
-
#nonstandard_lro_file_name ⇒ String
File name of the nonstandard LRO module.
-
#nonstandard_lro_file_path ⇒ String
Full file path to the nonstandard LRO module.
-
#nonstandard_lro_name ⇒ String
Name of the nonstandard LRO module.
-
#nonstandard_lro_name_full ⇒ String
Full name of the nonstandard LRO module.
-
#nonstandard_lro_polling_method_name ⇒ String
The Ruby name for the polling method of the nonstandard LRO provided by this service.
-
#nonstandard_lro_provider? ⇒ Boolean
Whether this service is a provider of the nonstandard LRO functionality.
-
#nonstandard_lro_require ⇒ String
The require string for the nonstandard LRO module.
-
#nonstandard_lros ⇒ Enumerable<Gapic::Presenters::Service::LroClientPresenter>
The client presenters of the nonstandard LROs that are used by the methods of this service.
-
#operations_file_name ⇒ Object
-
#operations_file_path ⇒ Object
-
#operations_name ⇒ Object
-
#operations_name_full ⇒ Object
-
#operations_require ⇒ Object
-
#package ⇒ Object
-
#paths? ⇒ Boolean
-
#paths_file_name ⇒ Object
-
#paths_file_path ⇒ Object
-
#paths_name ⇒ Object
-
#paths_name_full ⇒ Object
-
#paths_require ⇒ Object
-
#proto_namespace ⇒ Object
The namespace of the protos.
-
#proto_service_file_name ⇒ Object
-
#proto_service_file_path ⇒ Object
-
#proto_service_name_full ⇒ Object
-
#proto_service_require ⇒ Object
-
#proto_service_stub_name_full ⇒ Object
-
#proto_services_file_name ⇒ Object
-
#proto_services_file_path ⇒ Object
-
#proto_services_require ⇒ Object
-
#quick_start_method ⇒ Gapic::Presenters::MethodPresenter
The method to use for quick start samples.
-
#references ⇒ Object
-
#service_directory_name ⇒ Object
-
#service_file_name ⇒ Object
-
#service_file_path ⇒ Object
-
#service_name_full ⇒ Object
-
#service_require ⇒ Object
-
#stub_name ⇒ Object
-
#subclients ⇒ Enumerable<Gapic::Presenters::Service::LroClientPresenter, Gapic::Model::Mixins::Mixin>
Subclients for this service Subclients are the clients to other services (e.g. an LRO provider service).
-
#subclients? ⇒ Boolean
Whether there are any subclients to generate with this service.
-
#test_client_file_path ⇒ Object
-
#test_client_operations_file_path ⇒ Object
-
#test_paths_file_path ⇒ Object
-
#usable_service_presenter ⇒ ServicePresenter, ...
Returns this service presenter if there is a grpc client.
-
#version ⇒ Object
#ensure_absolute_namespace, #fix_namespace, #ruby_namespace, #ruby_namespace_for_address
#fix_file_path, #ruby_file_path, #ruby_file_path_for_namespace
Constructor Details
#initialize(gem_presenter, api, service, parent_service: nil) ⇒ ServicePresenter
Returns a new instance of ServicePresenter.
33
34
35
36
37
38
39
40
|
# File 'lib/gapic/presenters/service_presenter.rb', line 33
def initialize gem_presenter, api, service, parent_service: nil
@gem_presenter = gem_presenter
@api = api
@service = service
@parent_service = parent_service
@rest = ServiceRestPresenter.new self, api
@nonstandard_lro = api.nonstandard_lro_model_for service.full_name
end
|
Instance Attribute Details
31
32
33
|
# File 'lib/gapic/presenters/service_presenter.rb', line 31
def rest
@rest
end
|
Instance Method Details
#address ⇒ Object
68
69
70
|
# File 'lib/gapic/presenters/service_presenter.rb', line 68
def address
@service.address
end
|
#client_endpoint ⇒ Object
203
204
205
206
207
208
209
210
|
# File 'lib/gapic/presenters/service_presenter.rb', line 203
def client_endpoint
return nil if generic_endpoint?
@parent_service&.client_endpoint ||
common_service_delegate&.client_endpoint ||
@service.host ||
default_config(:default_host) ||
"localhost"
end
|
#client_file_name ⇒ Object
199
200
201
|
# File 'lib/gapic/presenters/service_presenter.rb', line 199
def client_file_name
client_file_path.split("/").last
end
|
#client_file_path ⇒ Object
195
196
197
|
# File 'lib/gapic/presenters/service_presenter.rb', line 195
def client_file_path
"#{client_require}.rb"
end
|
#client_name ⇒ Object
175
176
177
|
# File 'lib/gapic/presenters/service_presenter.rb', line 175
def client_name
"Client"
end
|
#client_name_full ⇒ Object
179
180
181
|
# File 'lib/gapic/presenters/service_presenter.rb', line 179
def client_name_full
fix_namespace @api, "#{service_name_full}::#{client_name}"
end
|
#client_require ⇒ Object
191
192
193
|
# File 'lib/gapic/presenters/service_presenter.rb', line 191
def client_require
ruby_file_path @api, client_name_full
end
|
#client_scopes ⇒ Object
216
217
218
219
220
221
|
# File 'lib/gapic/presenters/service_presenter.rb', line 216
def client_scopes
common_service_delegate&.client_scopes ||
@service.scopes ||
default_config(:oauth_scopes) ||
[]
end
|
#common_service_delegate ⇒ Object
Returns a presenter for this service's delegate (if it is a common service)
otherwise returns nil.
74
75
76
77
78
79
80
|
# File 'lib/gapic/presenters/service_presenter.rb', line 74
def common_service_delegate
unless defined? @common_service_delegate
delegate = @api.delegate_service_for @service
@common_service_delegate = delegate ? ServicePresenter.new(@gem_presenter, @api, delegate) : nil
end
@common_service_delegate
end
|
#config_channel_args ⇒ Object
417
418
419
|
# File 'lib/gapic/presenters/service_presenter.rb', line 417
def config_channel_args
{ "grpc.service_config_disable_resolution" => 1 }
end
|
187
188
189
|
# File 'lib/gapic/presenters/service_presenter.rb', line 187
def configure_client_call
"#{client_name_full}.configure"
end
|
#create_client_call ⇒ Object
183
184
185
|
# File 'lib/gapic/presenters/service_presenter.rb', line 183
def create_client_call
"#{client_name_full}.new"
end
|
#credentials_class_xref ⇒ Object
231
232
233
|
# File 'lib/gapic/presenters/service_presenter.rb', line 231
def credentials_class_xref
"{#{credentials_name_full}}"
end
|
#credentials_file_name ⇒ Object
239
240
241
|
# File 'lib/gapic/presenters/service_presenter.rb', line 239
def credentials_file_name
credentials_file_path.split("/").last
end
|
#credentials_file_path ⇒ Object
235
236
237
|
# File 'lib/gapic/presenters/service_presenter.rb', line 235
def credentials_file_path
"#{credentials_require}.rb"
end
|
#credentials_name ⇒ Object
223
224
225
|
# File 'lib/gapic/presenters/service_presenter.rb', line 223
def credentials_name
"Credentials"
end
|
#credentials_name_full ⇒ Object
227
228
229
|
# File 'lib/gapic/presenters/service_presenter.rb', line 227
def credentials_name_full
fix_namespace @api, "#{service_name_full}::#{credentials_name}"
end
|
#credentials_require ⇒ Object
243
244
245
|
# File 'lib/gapic/presenters/service_presenter.rb', line 243
def credentials_require
ruby_file_path @api, credentials_name_full
end
|
#deduped_references ⇒ Object
Deduplicate resource presenters by combining resources with the same
name. If multiple resources have the same name (though possibly
different namespaces, e.g. location.googleapis.com/Location vs
documentai.googleapis.com/Location), this combines (and dedups) their
patterns into a single resource presenter.
Used for generating path helpers while avoiding duplicate method names.
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
|
# File 'lib/gapic/presenters/service_presenter.rb', line 272
def deduped_references
@deduped_references ||= begin
hash = {}
references.each do |resource|
if hash.key? resource.name
existing = hash[resource.name]
resource.patterns.each do |pat|
unless existing.patterns.any? { |epat| epat.pattern_template == pat.pattern_template }
existing.patterns << pat
end
end
else
hash[resource.name] = resource.dup
end
end
hash.values
end
end
|
#doc_description(disable_xrefs: false) ⇒ Object
101
102
103
|
# File 'lib/gapic/presenters/service_presenter.rb', line 101
def doc_description disable_xrefs: false
@service. disable_xrefs: disable_xrefs
end
|
#drift_manifest ⇒ Hash
453
454
455
456
457
458
459
460
461
462
463
464
465
466
|
# File 'lib/gapic/presenters/service_presenter.rb', line 453
def drift_manifest
{
clients: {
grpc: {
libraryClient: client_name_full,
rpcs: methods.map { |m| [m.grpc_method_name, m.drift_manifest] }.to_h
}
}
}
end
|
#file ⇒ Object
46
47
48
|
# File 'lib/gapic/presenters/service_presenter.rb', line 46
def file
FilePresenter.new @api, @service.parent
end
|
#gem ⇒ Object
42
43
44
|
# File 'lib/gapic/presenters/service_presenter.rb', line 42
def gem
@gem_presenter
end
|
#generate_grpc_clients? ⇒ Boolean
319
320
321
|
# File 'lib/gapic/presenters/service_presenter.rb', line 319
def generate_grpc_clients?
@api.generate_grpc_clients?
end
|
#generate_rest_clients? ⇒ Boolean
315
316
317
|
# File 'lib/gapic/presenters/service_presenter.rb', line 315
def generate_rest_clients?
@api.generate_rest_clients?
end
|
#generic_endpoint? ⇒ Boolean
212
213
214
|
# File 'lib/gapic/presenters/service_presenter.rb', line 212
def generic_endpoint?
gem.generic_endpoint?
end
|
#grpc_client_designation ⇒ String
How comments in the generated libraries refer to the GRPC client
if no REST code is generated, this should just be "client",
if REST code is generated, this should be disambiguated into the "GRPC client"
474
475
476
|
# File 'lib/gapic/presenters/service_presenter.rb', line 474
def grpc_client_designation
generate_rest_clients? ? "GRPC client" : "client"
end
|
#grpc_full_name ⇒ String
The full proto name for this service
442
443
444
|
# File 'lib/gapic/presenters/service_presenter.rb', line 442
def grpc_full_name
@service.full_name
end
|
#grpc_service_config ⇒ Object
421
422
423
424
|
# File 'lib/gapic/presenters/service_presenter.rb', line 421
def grpc_service_config
return unless @api.grpc_service_config&.service_level_configs&.key? grpc_full_name
@api.grpc_service_config.service_level_configs[grpc_full_name]
end
|
#grpc_service_config_presenter ⇒ Object
426
427
428
|
# File 'lib/gapic/presenters/service_presenter.rb', line 426
def grpc_service_config_presenter
GrpcServiceConfigPresenter.new grpc_service_config
end
|
#grpc_service_name ⇒ String
The short proto name for this service
434
435
436
|
# File 'lib/gapic/presenters/service_presenter.rb', line 434
def grpc_service_name
@service.name
end
|
#helpers_file_name ⇒ Object
251
252
253
|
# File 'lib/gapic/presenters/service_presenter.rb', line 251
def helpers_file_name
"helpers.rb"
end
|
#helpers_file_path ⇒ Object
247
248
249
|
# File 'lib/gapic/presenters/service_presenter.rb', line 247
def helpers_file_path
"#{helpers_require}.rb"
end
|
#helpers_require ⇒ Object
255
256
257
|
# File 'lib/gapic/presenters/service_presenter.rb', line 255
def helpers_require
ruby_file_path @api, "#{service_name_full}::Helpers"
end
|
#is_deprecated? ⇒ Boolean
57
58
59
|
# File 'lib/gapic/presenters/service_presenter.rb', line 57
def is_deprecated?
@service.is_deprecated?
end
|
#lro? ⇒ Boolean
Whether an AIP-151 LRO subclient needs to be generated for this service
358
359
360
|
# File 'lib/gapic/presenters/service_presenter.rb', line 358
def lro?
methods.find(&:lro?)
end
|
#lro_client_ivar ⇒ String
An instance variable name used for the AIP-151 LRO subclients
374
375
376
|
# File 'lib/gapic/presenters/service_presenter.rb', line 374
def lro_client_ivar
"@#{lro_client_var}"
end
|
A presenter for the LRO subclient if needed
382
383
384
385
386
387
388
389
390
|
# File 'lib/gapic/presenters/service_presenter.rb', line 382
def lro_client_presenter
return nil unless lro?
Gapic::Presenters::Service::LroClientPresenter.new service: "google.longrunning.operations",
client_class_name: "Operations",
client_class_docname: operations_name_full,
client_var_name: lro_client_var,
require_str: operations_file_path,
service_description: "long-running operations"
end
|
#lro_client_var ⇒ String
A variable name used for the AIP-151 LRO subclients
366
367
368
|
# File 'lib/gapic/presenters/service_presenter.rb', line 366
def lro_client_var
"operations_client"
end
|
#lro_service ⇒ Object
412
413
414
415
|
# File 'lib/gapic/presenters/service_presenter.rb', line 412
def lro_service
lro = @service.parent.parent.files.find { |file| file.name == "google/longrunning/operations.proto" }
return ServicePresenter.new @gem_presenter, @api, lro.services.first, parent_service: self unless lro.nil?
end
|
64
65
66
|
# File 'lib/gapic/presenters/service_presenter.rb', line 64
def methods
@methods ||= @service.methods.map { |m| MethodPresenter.new self, @api, m }
end
|
Returns List of mods for which REST bindings are present and REST methods can be generated.
334
335
336
|
# File 'lib/gapic/presenters/service_presenter.rb', line 334
def methods_rest_bindings
methods.select { |method| method.rest.path? && method.rest.verb? }
end
|
#methods_rest_bindings? ⇒ Boolean
Returns whether this service contains any methods with REST bindings.
326
327
328
|
# File 'lib/gapic/presenters/service_presenter.rb', line 326
def methods_rest_bindings?
methods_rest_bindings.any?
end
|
The mixin services that should be referenced
in the client for this service
524
525
526
|
# File 'lib/gapic/presenters/service_presenter.rb', line 524
def mixins
@gem_presenter.mixins_model.mixins
end
|
#mixins? ⇒ Boolean
Whether there are mixin services that should be referenced
in the client for this service
514
515
516
|
# File 'lib/gapic/presenters/service_presenter.rb', line 514
def mixins?
@gem_presenter.mixins?
end
|
#module_name ⇒ Object
123
124
125
|
# File 'lib/gapic/presenters/service_presenter.rb', line 123
def module_name
service_name_full.split("::").last
end
|
#name ⇒ Object
105
106
107
|
# File 'lib/gapic/presenters/service_presenter.rb', line 105
def name
@api.fix_service_name @service.name
end
|
#namespace ⇒ Object
The namespace of the client. Normally this is the version module. This
may be different from the proto namespace for a common service.
84
85
86
87
88
89
90
91
92
93
94
95
|
# File 'lib/gapic/presenters/service_presenter.rb', line 84
def namespace
return common_service_delegate.namespace if common_service_delegate
return ensure_absolute_namespace @service.ruby_package if @service.ruby_package.present?
namespace = ruby_namespace_for_address @service.address[0...-1]
fix_namespace @api, namespace
end
|
#nonstandard_lro ⇒ Gapic::Model::Service::NonstandardLro, Gapic::Model::Service::NoLro
Nonstandard lro model for this service
577
578
579
|
# File 'lib/gapic/presenters/service_presenter.rb', line 577
def nonstandard_lro
@nonstandard_lro
end
|
#nonstandard_lro_consumer? ⇒ Boolean
Whether one or more methods of this service use the nonstandard LRO functionality
602
603
604
|
# File 'lib/gapic/presenters/service_presenter.rb', line 602
def nonstandard_lro_consumer?
methods.find(&:nonstandard_lro?) || false
end
|
#nonstandard_lro_file_name ⇒ String
File name of the nonstandard LRO module
560
561
562
|
# File 'lib/gapic/presenters/service_presenter.rb', line 560
def nonstandard_lro_file_name
nonstandard_lro_file_path.split("/").last
end
|
#nonstandard_lro_file_path ⇒ String
Full file path to the nonstandard LRO module
551
552
553
|
# File 'lib/gapic/presenters/service_presenter.rb', line 551
def nonstandard_lro_file_path
"#{nonstandard_lro_require}.rb"
end
|
#nonstandard_lro_name ⇒ String
Name of the nonstandard LRO module
533
534
535
|
# File 'lib/gapic/presenters/service_presenter.rb', line 533
def nonstandard_lro_name
"NonstandardLro"
end
|
#nonstandard_lro_name_full ⇒ String
Full name of the nonstandard LRO module
542
543
544
|
# File 'lib/gapic/presenters/service_presenter.rb', line 542
def nonstandard_lro_name_full
fix_namespace @api, "#{service_name_full}::#{nonstandard_lro_name}"
end
|
#nonstandard_lro_polling_method_name ⇒ String
The Ruby name for the polling method of the nonstandard LRO provided by this service
585
586
587
588
|
# File 'lib/gapic/presenters/service_presenter.rb', line 585
def nonstandard_lro_polling_method_name
return unless nonstandard_lro_provider?
methods.find { |m| m.grpc_method_name == nonstandard_lro.polling_method_name }.name
end
|
#nonstandard_lro_provider? ⇒ Boolean
Whether this service is a provider of the nonstandard LRO functionality
594
595
596
|
# File 'lib/gapic/presenters/service_presenter.rb', line 594
def nonstandard_lro_provider?
@nonstandard_lro.nonstandard_lro?
end
|
#nonstandard_lro_require ⇒ String
The require string for the nonstandard LRO module
569
570
571
|
# File 'lib/gapic/presenters/service_presenter.rb', line 569
def nonstandard_lro_require
ruby_file_path @api, "#{service_name_full}::#{nonstandard_lro_name}"
end
|
The client presenters of the nonstandard LROs that are used by the methods of this service
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
|
# File 'lib/gapic/presenters/service_presenter.rb', line 610
def nonstandard_lros
return [] unless nonstandard_lro_consumer?
nonstandard_lros_models.map do |lro|
lro_wrapper = @api.lookup lro.service_full_name
lro_service = ServicePresenter.new(@gem_presenter, @api, lro_wrapper).usable_service_presenter
service_description = "long-running operations via #{lro_service.name}"
Gapic::Presenters::Service::LroClientPresenter.new service: lro.service_full_name,
client_class_name: lro_service.client_name_full,
client_class_docname: lro_service.client_name_full,
client_var_name: lro_service.service_directory_name,
require_str: lro_service.service_require,
service_description: service_description,
helper_type: lro_service.nonstandard_lro_name_full
end
end
|
#operations_file_name ⇒ Object
404
405
406
|
# File 'lib/gapic/presenters/service_presenter.rb', line 404
def operations_file_name
operations_file_path.split("/").last
end
|
#operations_file_path ⇒ Object
400
401
402
|
# File 'lib/gapic/presenters/service_presenter.rb', line 400
def operations_file_path
"#{operations_require}.rb"
end
|
#operations_name ⇒ Object
392
393
394
|
# File 'lib/gapic/presenters/service_presenter.rb', line 392
def operations_name
"Operations"
end
|
#operations_name_full ⇒ Object
396
397
398
|
# File 'lib/gapic/presenters/service_presenter.rb', line 396
def operations_name_full
fix_namespace @api, "#{service_name_full}::#{operations_name}"
end
|
#operations_require ⇒ Object
408
409
410
|
# File 'lib/gapic/presenters/service_presenter.rb', line 408
def operations_require
ruby_file_path @api, "#{service_name_full}::#{operations_name}"
end
|
#package ⇒ Object
50
51
52
|
# File 'lib/gapic/presenters/service_presenter.rb', line 50
def package
PackagePresenter.new @gem_presenter, @api, @service.parent.package
end
|
#paths? ⇒ Boolean
291
292
293
|
# File 'lib/gapic/presenters/service_presenter.rb', line 291
def paths?
references.any?
end
|
#paths_file_name ⇒ Object
307
308
309
|
# File 'lib/gapic/presenters/service_presenter.rb', line 307
def paths_file_name
paths_file_path.split("/").last
end
|
#paths_file_path ⇒ Object
303
304
305
|
# File 'lib/gapic/presenters/service_presenter.rb', line 303
def paths_file_path
"#{paths_require}.rb"
end
|
#paths_name ⇒ Object
295
296
297
|
# File 'lib/gapic/presenters/service_presenter.rb', line 295
def paths_name
"Paths"
end
|
#paths_name_full ⇒ Object
299
300
301
|
# File 'lib/gapic/presenters/service_presenter.rb', line 299
def paths_name_full
fix_namespace @api, "#{service_name_full}::#{paths_name}"
end
|
#paths_require ⇒ Object
311
312
313
|
# File 'lib/gapic/presenters/service_presenter.rb', line 311
def paths_require
ruby_file_path @api, "#{service_name_full}::#{paths_name}"
end
|
#proto_namespace ⇒ Object
The namespace of the protos. This may be different from the client
namespace for a common service.
111
112
113
114
115
116
|
# File 'lib/gapic/presenters/service_presenter.rb', line 111
def proto_namespace
return ensure_absolute_namespace @service.ruby_package if @service.ruby_package.present?
namespace = ruby_namespace_for_address @service.address[0...-1]
@api.override_proto_namespaces? ? fix_namespace(@api, namespace) : namespace
end
|
#proto_service_file_name ⇒ Object
131
132
133
|
# File 'lib/gapic/presenters/service_presenter.rb', line 131
def proto_service_file_name
proto_service_file_path.split("/").last
end
|
#proto_service_file_path ⇒ Object
127
128
129
|
# File 'lib/gapic/presenters/service_presenter.rb', line 127
def proto_service_file_path
@service.parent.name.sub ".proto", "_pb.rb"
end
|
#proto_service_name_full ⇒ Object
118
119
120
121
|
# File 'lib/gapic/presenters/service_presenter.rb', line 118
def proto_service_name_full
name_full = "#{proto_namespace}::#{@service.name}"
@api.override_proto_namespaces? ? fix_namespace(@api, name_full) : name_full
end
|
#proto_service_require ⇒ Object
135
136
137
|
# File 'lib/gapic/presenters/service_presenter.rb', line 135
def proto_service_require
proto_service_file_path.sub ".rb", ""
end
|
#proto_service_stub_name_full ⇒ Object
151
152
153
|
# File 'lib/gapic/presenters/service_presenter.rb', line 151
def proto_service_stub_name_full
"#{proto_service_name_full}::Stub"
end
|
#proto_services_file_name ⇒ Object
143
144
145
|
# File 'lib/gapic/presenters/service_presenter.rb', line 143
def proto_services_file_name
proto_services_file_path.split("/").last
end
|
#proto_services_file_path ⇒ Object
139
140
141
|
# File 'lib/gapic/presenters/service_presenter.rb', line 139
def proto_services_file_path
@service.parent.name.sub ".proto", "_services_pb.rb"
end
|
#proto_services_require ⇒ Object
147
148
149
|
# File 'lib/gapic/presenters/service_presenter.rb', line 147
def proto_services_require
proto_services_file_path.sub ".rb", ""
end
|
The method to use for quick start samples. Normally this is simply the
first non-client-streaming method defined, but it can be overridden via
a gem config.
485
486
487
488
489
490
|
# File 'lib/gapic/presenters/service_presenter.rb', line 485
def quick_start_method
gem_config = @api.configuration[:gem]
preferred_method = gem_config[:quick_start_method] if gem_config
result = methods.find { |meth| meth.name == preferred_method } if preferred_method
result || methods.find { |meth| !meth.client_streaming? }
end
|
#references ⇒ Object
259
260
261
|
# File 'lib/gapic/presenters/service_presenter.rb', line 259
def references
@references ||= @service.resources.map { |resource| ResourcePresenter.new resource }.sort_by(&:name)
end
|
#service_directory_name ⇒ Object
167
168
169
|
# File 'lib/gapic/presenters/service_presenter.rb', line 167
def service_directory_name
service_require.split("/").last
end
|
#service_file_name ⇒ Object
163
164
165
|
# File 'lib/gapic/presenters/service_presenter.rb', line 163
def service_file_name
service_file_path.split("/").last
end
|
#service_file_path ⇒ Object
159
160
161
|
# File 'lib/gapic/presenters/service_presenter.rb', line 159
def service_file_path
"#{service_require}.rb"
end
|
#service_name_full ⇒ Object
155
156
157
|
# File 'lib/gapic/presenters/service_presenter.rb', line 155
def service_name_full
fix_namespace @api, "#{namespace}::#{name}"
end
|
#service_require ⇒ Object
171
172
173
|
# File 'lib/gapic/presenters/service_presenter.rb', line 171
def service_require
ruby_file_path @api, service_name_full
end
|
#stub_name ⇒ Object
350
351
352
|
# File 'lib/gapic/presenters/service_presenter.rb', line 350
def stub_name
"#{ActiveSupport::Inflector.underscore name}_stub"
end
|
Subclients for this service
Subclients are the clients to other services (e.g. an LRO provider service).
The following is typically generated for a subclient:
- a require statement for the subclient's class
- a class-level variable in the host service's client
- a code to initialize this variable with a subclient's class instance in the host service's constructor
646
647
648
|
# File 'lib/gapic/presenters/service_presenter.rb', line 646
def subclients
([] << lro_client_presenter << mixins << nonstandard_lros).flatten.compact
end
|
#subclients? ⇒ Boolean
Whether there are any subclients to generate with this service.
Subclients are the clients to other services (e.g. an LRO provider service).
632
633
634
|
# File 'lib/gapic/presenters/service_presenter.rb', line 632
def subclients?
subclients.any?
end
|
#test_client_file_path ⇒ Object
338
339
340
|
# File 'lib/gapic/presenters/service_presenter.rb', line 338
def test_client_file_path
service_file_path.sub ".rb", "_test.rb"
end
|
#test_client_operations_file_path ⇒ Object
346
347
348
|
# File 'lib/gapic/presenters/service_presenter.rb', line 346
def test_client_operations_file_path
service_file_path.sub ".rb", "_operations_test.rb"
end
|
#test_paths_file_path ⇒ Object
342
343
344
|
# File 'lib/gapic/presenters/service_presenter.rb', line 342
def test_paths_file_path
service_file_path.sub ".rb", "_paths_test.rb"
end
|
#usable_service_presenter ⇒ ServicePresenter, ...
Returns this service presenter if there is a grpc client. Otherwise,
returns the corresponding rest service presenter if there isn't a grpc
client but there is a rest client. Otherwise, returns nil if there is
neither client.
500
501
502
503
504
505
506
|
# File 'lib/gapic/presenters/service_presenter.rb', line 500
def usable_service_presenter
if @api.generate_grpc_clients?
self
elsif @api.generate_rest_clients? && methods_rest_bindings?
rest
end
end
|
#version ⇒ Object
97
98
99
|
# File 'lib/gapic/presenters/service_presenter.rb', line 97
def version
ActiveSupport::Inflector.camelize @service.address[-2]
end
|