Class: Gapic::Presenters::MethodPresenter
Overview
A presenter for rpc methods.
Instance Attribute Summary collapse
Instance Method Summary
collapse
#ensure_absolute_namespace, #fix_namespace, #ruby_namespace, #ruby_namespace_for_address
Constructor Details
#initialize(service_presenter, api, method) ⇒ MethodPresenter
Returns a new instance of MethodPresenter.
Instance Attribute Details
39
40
41
|
# File 'lib/gapic/presenters/method_presenter.rb', line 39
def http
@http
end
|
42
43
44
|
# File 'lib/gapic/presenters/method_presenter.rb', line 42
def lro
@lro
end
|
30
31
32
|
# File 'lib/gapic/presenters/method_presenter.rb', line 30
def method
@method
end
|
33
34
35
|
# File 'lib/gapic/presenters/method_presenter.rb', line 33
def rest
@rest
end
|
36
37
38
|
# File 'lib/gapic/presenters/method_presenter.rb', line 36
def routing
@routing
end
|
Instance Method Details
#arguments ⇒ Object
123
124
125
126
|
# File 'lib/gapic/presenters/method_presenter.rb', line 123
def arguments
arguments = @method.input.fields.reject(&:output_only?)
arguments.map { |arg| FieldPresenter.new @api, @method.input, arg }
end
|
#client_streaming? ⇒ Boolean
232
233
234
|
# File 'lib/gapic/presenters/method_presenter.rb', line 232
def client_streaming?
@method.client_streaming
end
|
#doc_description ⇒ Object
99
100
101
|
# File 'lib/gapic/presenters/method_presenter.rb', line 99
def doc_description
@method.
end
|
#doc_response_type ⇒ Object
103
104
105
106
107
108
109
110
111
112
113
114
|
# File 'lib/gapic/presenters/method_presenter.rb', line 103
def doc_response_type
ret = return_type
ret = "::Gapic::Operation" if lro?
if server_streaming?
ret = "::Enumerable<#{ret}>"
elsif paged?
paged_type = paged_response_type
paged_type = "::Gapic::Operation" if paged_type == "::Google::Longrunning::Operation"
ret = "::Gapic::PagedEnumerable<#{paged_type}>"
end
ret
end
|
#drift_manifest ⇒ Hash
303
304
305
|
# File 'lib/gapic/presenters/method_presenter.rb', line 303
def drift_manifest
{ methods: [name] }
end
|
#fields ⇒ Object
128
129
130
|
# File 'lib/gapic/presenters/method_presenter.rb', line 128
def fields
@method.input.fields.map { |field| FieldPresenter.new @api, @method.input, field }
end
|
#fields_with_first_oneof ⇒ Object
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
# File 'lib/gapic/presenters/method_presenter.rb', line 132
def fields_with_first_oneof
return fields if @method.input.oneof_decl.empty?
selected_fields = []
have_oneof = []
@method.input.fields.each do |field|
unless field.oneof?
selected_fields << field
next
end
idx = field.oneof_index
selected_fields << field unless have_oneof.include? idx
have_oneof << idx
end
selected_fields.map { |field| FieldPresenter.new @api, @method.input, field }
end
|
#generate_yardoc_snippets? ⇒ Boolean
73
74
75
|
# File 'lib/gapic/presenters/method_presenter.rb', line 73
def generate_yardoc_snippets?
@api.generate_yardoc_snippets?
end
|
#grpc_method_name ⇒ Object
290
291
292
|
# File 'lib/gapic/presenters/method_presenter.rb', line 290
def grpc_method_name
@method.name
end
|
#grpc_service_config ⇒ Object
279
280
281
282
283
284
|
# File 'lib/gapic/presenters/method_presenter.rb', line 279
def grpc_service_config
if @api.grpc_service_config&.service_method_level_configs&.key?(service.grpc_full_name) &&
@api.grpc_service_config.service_method_level_configs[service.grpc_full_name]&.key?(grpc_method_name)
@api.grpc_service_config.service_method_level_configs[service.grpc_full_name][grpc_method_name]
end
end
|
#grpc_service_config_presenter ⇒ Object
286
287
288
|
# File 'lib/gapic/presenters/method_presenter.rb', line 286
def grpc_service_config_presenter
GrpcServiceConfigPresenter.new grpc_service_config
end
|
#is_deprecated? ⇒ Boolean
119
120
121
|
# File 'lib/gapic/presenters/method_presenter.rb', line 119
def is_deprecated?
@method.is_deprecated?
end
|
#kind ⇒ Object
85
86
87
88
89
90
91
92
93
94
95
96
97
|
# File 'lib/gapic/presenters/method_presenter.rb', line 85
def kind
if client_streaming?
if server_streaming?
:bidi
else
:client
end
elsif server_streaming?
:server
else
:normal
end
end
|
#lro? ⇒ Boolean
Whether this method uses standard (AIP-151) LROs
207
208
209
210
211
|
# File 'lib/gapic/presenters/method_presenter.rb', line 207
def lro?
return paged_response_type == "::Google::Longrunning::Operation" if paged?
return_type == "::Google::Longrunning::Operation"
end
|
#name ⇒ Object
77
78
79
80
81
82
83
|
# File 'lib/gapic/presenters/method_presenter.rb', line 77
def name
@name ||= begin
candidate = ActiveSupport::Inflector.underscore @method.name
candidate = "call_#{candidate}" if Gapic::RubyInfo.excluded_method_names.include? candidate
candidate
end
end
|
#nonstandard_lro? ⇒ Boolean
Whether this method uses nonstandard LROs
218
219
220
|
# File 'lib/gapic/presenters/method_presenter.rb', line 218
def nonstandard_lro?
@lro.nonstandard_lro?
end
|
The presenter for the nonstandard LRO client of the kind this method uses
227
228
229
230
|
# File 'lib/gapic/presenters/method_presenter.rb', line 227
def nonstandard_lro_client
return unless nonstandard_lro?
service.nonstandard_lros.find { |model| model.service == @lro.service_full_name }
end
|
#paged? ⇒ Boolean
240
241
242
243
244
245
246
247
248
249
250
251
252
253
|
# File 'lib/gapic/presenters/method_presenter.rb', line 240
def paged?
return false if server_streaming?
address = @method.address.join "."
return false if address == "google.cloud.talent.v4beta1.ProfileService.SearchProfiles"
return false if address == "google.cloud.talent.v4beta1.JobService.SearchJobs"
return false if address == "google.cloud.talent.v4beta1.JobService.SearchJobsForAlert"
paged_request?(@method.input) && paged_response?(@method.output)
end
|
#paged_response_type ⇒ Object
255
256
257
258
259
260
261
262
263
|
# File 'lib/gapic/presenters/method_presenter.rb', line 255
def paged_response_type
return nil unless paged_response? @method.output
repeated_field = @method.output.fields.find do |f|
f.label == Google::Protobuf::FieldDescriptorProto::Label::LABEL_REPEATED &&
f.type == Google::Protobuf::FieldDescriptorProto::Type::TYPE_MESSAGE
end
message_ruby_type repeated_field.message
end
|
#request_type ⇒ Object
152
153
154
|
# File 'lib/gapic/presenters/method_presenter.rb', line 152
def request_type
message_ruby_type @method.input
end
|
#return_type ⇒ Object
156
157
158
|
# File 'lib/gapic/presenters/method_presenter.rb', line 156
def return_type
message_ruby_type @method.output
end
|
#routing_params ⇒ Array<String>
Returns The segment key names.
268
269
270
|
# File 'lib/gapic/presenters/method_presenter.rb', line 268
def routing_params
rest.routing_params
end
|
#routing_params? ⇒ Boolean
Returns Whether any routing params are present.
275
276
277
|
# File 'lib/gapic/presenters/method_presenter.rb', line 275
def routing_params?
@routing.routing_params?
end
|
#samples ⇒ Object
speech_transcribe_sync_gcs.yaml
194
195
196
197
198
199
200
|
# File 'lib/gapic/presenters/method_presenter.rb', line 194
def samples
sample_configs = @api.incode_samples.select do |sample_config|
sample_config["service"] == @method.address[0...-1].join(".") &&
sample_config["rpc"] == @method.name
end
sample_configs.map { |sample_config| SamplePresenter.new @api, sample_config }
end
|
#server_streaming? ⇒ Boolean
236
237
238
|
# File 'lib/gapic/presenters/method_presenter.rb', line 236
def server_streaming?
@method.server_streaming
end
|
62
63
64
|
# File 'lib/gapic/presenters/method_presenter.rb', line 62
def service
@service_presenter
end
|
69
70
71
|
# File 'lib/gapic/presenters/method_presenter.rb', line 69
def snippet
SnippetPresenter.new self, @api
end
|
#yield_doc_description ⇒ Object
165
166
167
168
169
|
# File 'lib/gapic/presenters/method_presenter.rb', line 165
def yield_doc_description
return "Register a callback to be run when an operation is done." if lro?
"Access the result along with the RPC operation"
end
|
#yield_params ⇒ Object
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
|
# File 'lib/gapic/presenters/method_presenter.rb', line 171
def yield_params
if lro?
return [
OpenStruct.new(
name: "operation",
doc_types: "::Gapic::Operation"
)
]
end
[
OpenStruct.new(
name: "result",
doc_types: return_type
),
OpenStruct.new(
name: "operation",
doc_types: "::GRPC::ActiveCall::Operation"
)
]
end
|
#yields? ⇒ Boolean
160
161
162
163
|
# File 'lib/gapic/presenters/method_presenter.rb', line 160
def yields?
!server_streaming?
end
|