Class: Gapic::Presenters::ServicePresenter
Overview
A presenter for proto services.
Instance Attribute Summary collapse
Instance Method Summary
collapse
-
#address ⇒ Array<String>
The address of this service split into an array.
-
#api_version ⇒ String
The api_version for this service, or empty if not defined.
-
#autogenerates_uuid? ⇒ Boolean
Whether this service autogenerates UUID fields.
-
#client_endpoint ⇒ Object
-
#client_endpoint_template ⇒ String
Returns a template for the endpoint, with the universe domain component of the url replaced with the string $UNIVERSE_DOMAIN$
.
-
#client_file_name ⇒ Object
-
#client_file_path ⇒ Object
-
#client_name ⇒ Object
-
#client_name_full ⇒ Object
-
#client_require ⇒ Object
-
#client_scopes ⇒ Object
-
#client_suffix_for_default_transport ⇒ 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, transport: nil) ⇒ String
The description as it should appear in YARD docs.
-
#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
Whether the generation of gRPC clients is requested.
-
#generate_rest_clients? ⇒ Boolean
Whether the generation of REST clients is requested and can be done because at least one method has rest bindings.
-
#generic_endpoint? ⇒ Boolean
-
#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
Whether the service is marked as deprecated.
-
#is_hosted_mixin? ⇒ Boolean
Whether this service presenter is a mixin inside a host service's gem (and not in its own gem).
-
#is_main_mixin_service? ⇒ Boolean
Whether this service presenter is a mixin inside it's own gem (and not in another service's gem).
-
#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
-
#lro_subclients ⇒ Object
-
#methods ⇒ Enumerable<Gapic::Presenters::MethodPresenter>
-
#methods_rest_bindings ⇒ Enumerable<Gapic::Presenters::MethodPresenter>
List of methods 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.
-
#mixin_binding_overrides? ⇒ Boolean
Whether there are mixin services that this package has http binding overrides for.
-
#mixin_models ⇒ Enumerable<::Gapic::Model::Mixins::Mixin>
The models for the mixins.
-
#mixin_presenters ⇒ Enumerable<Gapic::Presenters::Service::MixinClientPresenter>
The mixin services that should be referenced in the client for this service.
-
#mixin_should_generate_override_config? ⇒ Boolean
Whether config for this service should include the bindings_override
field.
-
#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
-
#special_compute_behavior? ⇒ Boolean
-
#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.
-
#supports_multiple_transports? ⇒ Boolean
-
#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.
42
43
44
45
46
47
48
49
50
|
# File 'lib/gapic/presenters/service_presenter.rb', line 42
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
@type = "service"
end
|
Instance Attribute Details
31
32
33
|
# File 'lib/gapic/presenters/service_presenter.rb', line 31
def rest
@rest
end
|
#type ⇒ String
Returns String representation of this presenter type.
34
35
36
|
# File 'lib/gapic/presenters/service_presenter.rb', line 34
def type
@type
end
|
Instance Method Details
#address ⇒ Array<String>
The address of this service split into an array
93
94
95
|
# File 'lib/gapic/presenters/service_presenter.rb', line 93
def address
@service.address
end
|
#api_version ⇒ String
Returns The api_version for this service, or empty if not defined.
259
260
261
|
# File 'lib/gapic/presenters/service_presenter.rb', line 259
def api_version
@service.api_version.to_s
end
|
#autogenerates_uuid? ⇒ Boolean
Returns Whether this service autogenerates UUID fields.
85
86
87
|
# File 'lib/gapic/presenters/service_presenter.rb', line 85
def autogenerates_uuid?
@methods.any? { |method| method.auto_populated_fields.length.positive? }
end
|
#client_endpoint ⇒ Object
235
236
237
238
239
240
241
242
|
# File 'lib/gapic/presenters/service_presenter.rb', line 235
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_endpoint_template ⇒ String
Returns a template for the endpoint, with the universe domain component
of the url replaced with the string $UNIVERSE_DOMAIN$
.
250
251
252
|
# File 'lib/gapic/presenters/service_presenter.rb', line 250
def client_endpoint_template
client_endpoint&.sub(/.googleapis.com$/, ".$UNIVERSE_DOMAIN$")
end
|
#client_file_name ⇒ Object
231
232
233
|
# File 'lib/gapic/presenters/service_presenter.rb', line 231
def client_file_name
client_file_path.split("/").last
end
|
#client_file_path ⇒ Object
227
228
229
|
# File 'lib/gapic/presenters/service_presenter.rb', line 227
def client_file_path
"#{client_require}.rb"
end
|
#client_name ⇒ Object
207
208
209
|
# File 'lib/gapic/presenters/service_presenter.rb', line 207
def client_name
"Client"
end
|
#client_name_full ⇒ Object
211
212
213
|
# File 'lib/gapic/presenters/service_presenter.rb', line 211
def client_name_full
fix_namespace @api, "#{service_name_full}::#{client_name}"
end
|
#client_require ⇒ Object
223
224
225
|
# File 'lib/gapic/presenters/service_presenter.rb', line 223
def client_require
ruby_file_path @api, client_name_full
end
|
#client_scopes ⇒ Object
263
264
265
266
267
268
269
270
271
272
273
274
|
# File 'lib/gapic/presenters/service_presenter.rb', line 263
def client_scopes
scopes = Array(common_service_delegate&.client_scopes)
return scopes unless scopes.empty?
scopes = Array(@service.scopes)
return scopes unless scopes.empty?
scopes = Array(default_config(:oauth_scopes))
return scopes unless scopes.empty?
[]
end
|
#client_suffix_for_default_transport ⇒ Object
390
391
392
393
394
395
396
|
# File 'lib/gapic/presenters/service_presenter.rb', line 390
def client_suffix_for_default_transport
if @api.default_transport == :grpc
"#{module_name}::#{client_name}"
else
"#{module_name}::Rest::#{client_name}"
end
end
|
#common_service_delegate ⇒ Object
Returns a presenter for this service's delegate (if it is a common service)
otherwise returns nil
.
99
100
101
102
103
104
105
|
# File 'lib/gapic/presenters/service_presenter.rb', line 99
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
492
493
494
|
# File 'lib/gapic/presenters/service_presenter.rb', line 492
def config_channel_args
{ "grpc.service_config_disable_resolution" => 1 }
end
|
219
220
221
|
# File 'lib/gapic/presenters/service_presenter.rb', line 219
def configure_client_call
"#{client_name_full}.configure"
end
|
#create_client_call ⇒ Object
215
216
217
|
# File 'lib/gapic/presenters/service_presenter.rb', line 215
def create_client_call
"#{client_name_full}.new"
end
|
#credentials_class_xref ⇒ Object
284
285
286
|
# File 'lib/gapic/presenters/service_presenter.rb', line 284
def credentials_class_xref
"{#{credentials_name_full}}"
end
|
#credentials_file_name ⇒ Object
292
293
294
|
# File 'lib/gapic/presenters/service_presenter.rb', line 292
def credentials_file_name
credentials_file_path.split("/").last
end
|
#credentials_file_path ⇒ Object
288
289
290
|
# File 'lib/gapic/presenters/service_presenter.rb', line 288
def credentials_file_path
"#{credentials_require}.rb"
end
|
#credentials_name ⇒ Object
276
277
278
|
# File 'lib/gapic/presenters/service_presenter.rb', line 276
def credentials_name
"Credentials"
end
|
#credentials_name_full ⇒ Object
280
281
282
|
# File 'lib/gapic/presenters/service_presenter.rb', line 280
def credentials_name_full
fix_namespace @api, "#{service_name_full}::#{credentials_name}"
end
|
#credentials_require ⇒ Object
296
297
298
|
# File 'lib/gapic/presenters/service_presenter.rb', line 296
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.
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
|
# File 'lib/gapic/presenters/service_presenter.rb', line 325
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, transport: nil) ⇒ String
The description as it should appear in YARD docs.
133
134
135
|
# File 'lib/gapic/presenters/service_presenter.rb', line 133
def doc_description disable_xrefs: false, transport: nil
@service. disable_xrefs: disable_xrefs, transport: transport
end
|
#drift_manifest ⇒ Hash
528
529
530
531
532
533
534
535
536
537
538
539
540
541
|
# File 'lib/gapic/presenters/service_presenter.rb', line 528
def drift_manifest
{
clients: {
grpc: {
libraryClient: client_name_full,
rpcs: methods.to_h { |m| [m.grpc_method_name, m.drift_manifest] }
}
}
}
end
|
#file ⇒ Object
56
57
58
|
# File 'lib/gapic/presenters/service_presenter.rb', line 56
def file
FilePresenter.new @api, @service.parent
end
|
#gem ⇒ Object
52
53
54
|
# File 'lib/gapic/presenters/service_presenter.rb', line 52
def gem
@gem_presenter
end
|
#generate_grpc_clients? ⇒ Boolean
Returns Whether the generation of gRPC clients is requested.
379
380
381
|
# File 'lib/gapic/presenters/service_presenter.rb', line 379
def generate_grpc_clients?
@api.generate_grpc_clients?
end
|
#generate_rest_clients? ⇒ Boolean
Returns Whether the generation of REST clients is requested
and can be done because at least one method has rest bindings.
372
373
374
|
# File 'lib/gapic/presenters/service_presenter.rb', line 372
def generate_rest_clients?
@api.generate_rest_clients? && methods_rest_bindings?
end
|
#generic_endpoint? ⇒ Boolean
254
255
256
|
# File 'lib/gapic/presenters/service_presenter.rb', line 254
def generic_endpoint?
gem.generic_endpoint?
end
|
#grpc_full_name ⇒ String
The full proto name for this service
517
518
519
|
# File 'lib/gapic/presenters/service_presenter.rb', line 517
def grpc_full_name
@service.full_name
end
|
#grpc_service_config ⇒ Object
496
497
498
499
|
# File 'lib/gapic/presenters/service_presenter.rb', line 496
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
501
502
503
|
# File 'lib/gapic/presenters/service_presenter.rb', line 501
def grpc_service_config_presenter
GrpcServiceConfigPresenter.new grpc_service_config
end
|
#grpc_service_name ⇒ String
The short proto name for this service
509
510
511
|
# File 'lib/gapic/presenters/service_presenter.rb', line 509
def grpc_service_name
@service.name
end
|
#helpers_file_name ⇒ Object
304
305
306
|
# File 'lib/gapic/presenters/service_presenter.rb', line 304
def helpers_file_name
"helpers.rb"
end
|
#helpers_file_path ⇒ Object
300
301
302
|
# File 'lib/gapic/presenters/service_presenter.rb', line 300
def helpers_file_path
"#{helpers_require}.rb"
end
|
#helpers_require ⇒ Object
308
309
310
|
# File 'lib/gapic/presenters/service_presenter.rb', line 308
def helpers_require
ruby_file_path @api, "#{service_name_full}::Helpers"
end
|
#is_deprecated? ⇒ Boolean
Returns Whether the service is marked as deprecated.
71
72
73
|
# File 'lib/gapic/presenters/service_presenter.rb', line 71
def is_deprecated?
@service.is_deprecated?
end
|
#is_hosted_mixin? ⇒ Boolean
Whether this service presenter is a mixin inside a host service's gem
(and not in its own gem)
#is_main_mixin_service? ⇒ Boolean
Whether this service presenter is a mixin inside it's own gem
(and not in another service's gem)
#lro? ⇒ Boolean
Whether an AIP-151 LRO subclient needs to be generated for this service
433
434
435
|
# File 'lib/gapic/presenters/service_presenter.rb', line 433
def lro?
methods.find(&:lro?)
end
|
#lro_client_ivar ⇒ String
An instance variable name used for the AIP-151 LRO subclients
449
450
451
|
# File 'lib/gapic/presenters/service_presenter.rb', line 449
def lro_client_ivar
"@#{lro_client_var}"
end
|
#lro_client_presenter ⇒ Gapic::Presenters::Service::LroClientPresenter?
A presenter for the LRO subclient if needed
457
458
459
460
461
462
463
464
465
|
# File 'lib/gapic/presenters/service_presenter.rb', line 457
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
441
442
443
|
# File 'lib/gapic/presenters/service_presenter.rb', line 441
def lro_client_var
"operations_client"
end
|
#lro_service ⇒ Object
487
488
489
490
|
# File 'lib/gapic/presenters/service_presenter.rb', line 487
def lro_service
lro = @service.parent.parent.files.find { |file| file.name == "google/longrunning/operations.proto" }
ServicePresenter.new @gem_presenter, @api, lro.services.first, parent_service: self unless lro.nil?
end
|
#lro_subclients ⇒ Object
797
798
799
|
# File 'lib/gapic/presenters/service_presenter.rb', line 797
def lro_subclients
[lro_client_presenter, nonstandard_lros].flatten.compact
end
|
78
79
80
|
# File 'lib/gapic/presenters/service_presenter.rb', line 78
def methods
@methods ||= @service.methods.map { |m| MethodPresenter.new self, @api, m }
end
|
Returns List of methods for which REST bindings are present and REST methods can be generated.
409
410
411
|
# File 'lib/gapic/presenters/service_presenter.rb', line 409
def methods_rest_bindings
methods.select(&:can_generate_rest?)
end
|
#methods_rest_bindings? ⇒ Boolean
Returns whether this service contains any methods with REST bindings.
401
402
403
|
# File 'lib/gapic/presenters/service_presenter.rb', line 401
def methods_rest_bindings?
methods_rest_bindings.any?
end
|
#mixin_binding_overrides? ⇒ Boolean
Whether there are mixin services that this package has http binding overrides for.
618
619
620
|
# File 'lib/gapic/presenters/service_presenter.rb', line 618
def mixin_binding_overrides?
mixin_presenters.any? { |mixin| !mixin.bindings_override.empty? }
end
|
The models for the mixins
609
610
611
|
# File 'lib/gapic/presenters/service_presenter.rb', line 609
def mixin_models
@gem_presenter.mixins_model.mixins
end
|
#mixin_presenters ⇒ Enumerable<Gapic::Presenters::Service::MixinClientPresenter>
The mixin services that should be referenced
in the client for this service
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
|
# File 'lib/gapic/presenters/service_presenter.rb', line 642
def mixin_presenters
return [] unless mixins?
mixin_models.map do |model|
bindings_override = begin
if @api.service_config&.http.nil?
{}
else
service_http_rules = @api.service_config.http.rules.select do |http_rule|
http_rule.selector.include? model.service
end
service_http_rules.to_h do |http_rule|
bindings = Gapic::Model::Method::HttpAnnotation.new(http_rule).bindings.map do |binding|
Gapic::Presenters::Method::HttpBindingPresenter.new binding
end
[http_rule.selector, bindings]
end
end
end
Gapic::Presenters::Service::MixinClientPresenter.new service: model.service,
client_class_name: model.client_class_name,
client_class_docname: model.client_class_docname,
client_var_name: model.client_var_name,
require_str: model.require_str,
service_description: model.service_description,
bindings_override: bindings_override
end
end
|
#mixin_should_generate_override_config? ⇒ Boolean
Whether config for this service should include the bindings_override
field.
This field is needed:
- if a service is a mixin in it's own package, e.g.
google.Cloud.Location
- if a service hosts a mixin and has bindings overrides for it
but the generated Operations clients should not have it since override for
their bindings are generated instead of set during runtime.
GRPC clients should not have this for now, since the overrides are not currently used.
632
633
634
|
# File 'lib/gapic/presenters/service_presenter.rb', line 632
def mixin_should_generate_override_config?
false
end
|
#mixins? ⇒ Boolean
Whether there are mixin services that should be referenced
in the client for this service
600
601
602
|
# File 'lib/gapic/presenters/service_presenter.rb', line 600
def mixins?
@gem_presenter.mixins?
end
|
#module_name ⇒ Object
155
156
157
|
# File 'lib/gapic/presenters/service_presenter.rb', line 155
def module_name
service_name_full.split("::").last
end
|
#name ⇒ Object
137
138
139
|
# File 'lib/gapic/presenters/service_presenter.rb', line 137
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.
109
110
111
112
113
114
115
116
117
118
119
120
|
# File 'lib/gapic/presenters/service_presenter.rb', line 109
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
723
724
725
|
# File 'lib/gapic/presenters/service_presenter.rb', line 723
def nonstandard_lro
@nonstandard_lro
end
|
#nonstandard_lro_consumer? ⇒ Boolean
Whether one or more methods of this service use the nonstandard LRO functionality
748
749
750
|
# File 'lib/gapic/presenters/service_presenter.rb', line 748
def nonstandard_lro_consumer?
methods.find(&:nonstandard_lro?) || false
end
|
#nonstandard_lro_file_name ⇒ String
File name of the nonstandard LRO module
706
707
708
|
# File 'lib/gapic/presenters/service_presenter.rb', line 706
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
697
698
699
|
# File 'lib/gapic/presenters/service_presenter.rb', line 697
def nonstandard_lro_file_path
"#{nonstandard_lro_require}.rb"
end
|
#nonstandard_lro_name ⇒ String
Name of the nonstandard LRO module
679
680
681
|
# File 'lib/gapic/presenters/service_presenter.rb', line 679
def nonstandard_lro_name
"NonstandardLro"
end
|
#nonstandard_lro_name_full ⇒ String
Full name of the nonstandard LRO module
688
689
690
|
# File 'lib/gapic/presenters/service_presenter.rb', line 688
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
731
732
733
734
|
# File 'lib/gapic/presenters/service_presenter.rb', line 731
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
740
741
742
|
# File 'lib/gapic/presenters/service_presenter.rb', line 740
def nonstandard_lro_provider?
@nonstandard_lro.nonstandard_lro?
end
|
#nonstandard_lro_require ⇒ String
The require string for the nonstandard LRO module
715
716
717
|
# File 'lib/gapic/presenters/service_presenter.rb', line 715
def nonstandard_lro_require
ruby_file_path @api, "#{service_name_full}::#{nonstandard_lro_name}"
end
|
#nonstandard_lros ⇒ Enumerable<Gapic::Presenters::Service::LroClientPresenter>
The client presenters of the nonstandard LROs that are used by the methods of this service
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
|
# File 'lib/gapic/presenters/service_presenter.rb', line 756
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
service_description = "long-running operations via #{lro_service.name}"
client_var_name = ruby_file_path_for_namespace 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: client_var_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
479
480
481
|
# File 'lib/gapic/presenters/service_presenter.rb', line 479
def operations_file_name
operations_file_path.split("/").last
end
|
#operations_file_path ⇒ Object
475
476
477
|
# File 'lib/gapic/presenters/service_presenter.rb', line 475
def operations_file_path
"#{operations_require}.rb"
end
|
#operations_name ⇒ Object
467
468
469
|
# File 'lib/gapic/presenters/service_presenter.rb', line 467
def operations_name
"Operations"
end
|
#operations_name_full ⇒ Object
471
472
473
|
# File 'lib/gapic/presenters/service_presenter.rb', line 471
def operations_name_full
fix_namespace @api, "#{service_name_full}::#{operations_name}"
end
|
#operations_require ⇒ Object
483
484
485
|
# File 'lib/gapic/presenters/service_presenter.rb', line 483
def operations_require
ruby_file_path @api, "#{service_name_full}::#{operations_name}"
end
|
#package ⇒ Object
60
61
62
|
# File 'lib/gapic/presenters/service_presenter.rb', line 60
def package
PackagePresenter.new @gem_presenter, @api, @service.parent.package
end
|
#paths? ⇒ Boolean
344
345
346
|
# File 'lib/gapic/presenters/service_presenter.rb', line 344
def paths?
references.any?
end
|
#paths_file_name ⇒ Object
360
361
362
|
# File 'lib/gapic/presenters/service_presenter.rb', line 360
def paths_file_name
paths_file_path.split("/").last
end
|
#paths_file_path ⇒ Object
356
357
358
|
# File 'lib/gapic/presenters/service_presenter.rb', line 356
def paths_file_path
"#{paths_require}.rb"
end
|
#paths_name ⇒ Object
348
349
350
|
# File 'lib/gapic/presenters/service_presenter.rb', line 348
def paths_name
"Paths"
end
|
#paths_name_full ⇒ Object
352
353
354
|
# File 'lib/gapic/presenters/service_presenter.rb', line 352
def paths_name_full
fix_namespace @api, "#{service_name_full}::#{paths_name}"
end
|
#paths_require ⇒ Object
364
365
366
|
# File 'lib/gapic/presenters/service_presenter.rb', line 364
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.
143
144
145
146
147
148
|
# File 'lib/gapic/presenters/service_presenter.rb', line 143
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
163
164
165
|
# File 'lib/gapic/presenters/service_presenter.rb', line 163
def proto_service_file_name
proto_service_file_path.split("/").last
end
|
#proto_service_file_path ⇒ Object
159
160
161
|
# File 'lib/gapic/presenters/service_presenter.rb', line 159
def proto_service_file_path
@service.parent.name.sub ".proto", "_pb.rb"
end
|
#proto_service_name_full ⇒ Object
150
151
152
153
|
# File 'lib/gapic/presenters/service_presenter.rb', line 150
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
167
168
169
|
# File 'lib/gapic/presenters/service_presenter.rb', line 167
def proto_service_require
proto_service_file_path.sub ".rb", ""
end
|
#proto_service_stub_name_full ⇒ Object
183
184
185
|
# File 'lib/gapic/presenters/service_presenter.rb', line 183
def proto_service_stub_name_full
"#{proto_service_name_full}::Stub"
end
|
#proto_services_file_name ⇒ Object
175
176
177
|
# File 'lib/gapic/presenters/service_presenter.rb', line 175
def proto_services_file_name
proto_services_file_path.split("/").last
end
|
#proto_services_file_path ⇒ Object
171
172
173
|
# File 'lib/gapic/presenters/service_presenter.rb', line 171
def proto_services_file_path
@service.parent.name.sub ".proto", "_services_pb.rb"
end
|
#proto_services_require ⇒ Object
179
180
181
|
# File 'lib/gapic/presenters/service_presenter.rb', line 179
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.
550
551
552
553
554
555
|
# File 'lib/gapic/presenters/service_presenter.rb', line 550
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
312
313
314
|
# File 'lib/gapic/presenters/service_presenter.rb', line 312
def references
@references ||= @service.resources.map { |resource| ResourcePresenter.new resource }.sort_by(&:name)
end
|
#service_directory_name ⇒ Object
199
200
201
|
# File 'lib/gapic/presenters/service_presenter.rb', line 199
def service_directory_name
service_require.split("/").last
end
|
#service_file_name ⇒ Object
195
196
197
|
# File 'lib/gapic/presenters/service_presenter.rb', line 195
def service_file_name
service_file_path.split("/").last
end
|
#service_file_path ⇒ Object
191
192
193
|
# File 'lib/gapic/presenters/service_presenter.rb', line 191
def service_file_path
"#{service_require}.rb"
end
|
#service_name_full ⇒ Object
187
188
189
|
# File 'lib/gapic/presenters/service_presenter.rb', line 187
def service_name_full
fix_namespace @api, "#{namespace}::#{name}"
end
|
#service_require ⇒ Object
203
204
205
|
# File 'lib/gapic/presenters/service_presenter.rb', line 203
def service_require
ruby_file_path @api, service_name_full
end
|
#special_compute_behavior? ⇒ Boolean
64
65
66
|
# File 'lib/gapic/presenters/service_presenter.rb', line 64
def special_compute_behavior?
address[0] == "google" && address[1] == "cloud" && address[2] == "compute" && !address[3].to_s.empty?
end
|
#stub_name ⇒ Object
425
426
427
|
# File 'lib/gapic/presenters/service_presenter.rb', line 425
def stub_name
"#{ActiveSupport::Inflector.underscore name}_stub"
end
|
#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).
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
793
794
795
|
# File 'lib/gapic/presenters/service_presenter.rb', line 793
def subclients
[lro_client_presenter, mixin_presenters, 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).
779
780
781
|
# File 'lib/gapic/presenters/service_presenter.rb', line 779
def subclients?
subclients.any?
end
|
#supports_multiple_transports? ⇒ Boolean
386
387
388
|
# File 'lib/gapic/presenters/service_presenter.rb', line 386
def supports_multiple_transports?
generate_rest_clients? && generate_grpc_clients?
end
|
#test_client_file_path ⇒ Object
413
414
415
|
# File 'lib/gapic/presenters/service_presenter.rb', line 413
def test_client_file_path
service_file_path.sub ".rb", "_test.rb"
end
|
#test_client_operations_file_path ⇒ Object
421
422
423
|
# File 'lib/gapic/presenters/service_presenter.rb', line 421
def test_client_operations_file_path
service_file_path.sub ".rb", "_operations_test.rb"
end
|
#test_paths_file_path ⇒ Object
417
418
419
|
# File 'lib/gapic/presenters/service_presenter.rb', line 417
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.
565
566
567
568
569
570
571
|
# File 'lib/gapic/presenters/service_presenter.rb', line 565
def usable_service_presenter
if generate_grpc_clients?
self
elsif generate_rest_clients?
rest
end
end
|
#version ⇒ Object
122
123
124
|
# File 'lib/gapic/presenters/service_presenter.rb', line 122
def version
ActiveSupport::Inflector.camelize @service.address[-2]
end
|