Class: Gapic::Presenters::MethodRestPresenter
- Inherits:
-
Object
- Object
- Gapic::Presenters::MethodRestPresenter
- Defined in:
- lib/gapic/presenters/method_rest_presenter.rb
Overview
A presenter for rpc methods (REST submethods)
Instance Attribute Summary collapse
- #compute_pagination ⇒ Gapic::Presenters::Method::RestPaginationInfo readonly
-
#http_bindings ⇒ Object
readonly
Returns the value of attribute http_bindings.
-
#type ⇒ String
readonly
String representation of this presenter type.
Instance Method Summary collapse
-
#can_generate_rest? ⇒ Boolean
Whether this method can be generated in REST clients Only methods with http bindings can be generated, and additionally only unary methods are currently supported.
-
#doc_response_type ⇒ String
Full class name of the return type of the method (including LRO and Paged cases).
-
#grpc_full_name ⇒ String
Fully qualified proto name of the method (namespace.PascalCase).
-
#initialize(main_method, api) ⇒ MethodRestPresenter
constructor
A new instance of MethodRestPresenter.
-
#is_deprecated? ⇒ Boolean
Whether the method is marked as deprecated.
- #lro? ⇒ Boolean
-
#name ⇒ String
Method name.
-
#nonstandard_lro? ⇒ Boolean
Whether this method uses nonstandard LROs.
-
#nonstandard_lro_client ⇒ Gapic::Presenters::Service::LroClientPresenter?
The presenter for the nonstandard LRO client of the kind this method uses.
-
#paged? ⇒ Boolean
Whether the REGAPIC method should be rendered as paged.
-
#paged_response_repeated_field_name ⇒ String
The name of the repeated field in paginated responses.
-
#request_type ⇒ String
Full class name of the request type.
-
#return_type ⇒ String
Full class name of the raw return type of the RPC.
-
#server_streaming? ⇒ Boolean
Whether this method is a server-streaming method.
-
#transcoding_helper_name ⇒ String
Name for the GRPC transcoding helper method.
Constructor Details
#initialize(main_method, api) ⇒ MethodRestPresenter
Returns a new instance of MethodRestPresenter.
37 38 39 40 41 42 43 44 45 |
# File 'lib/gapic/presenters/method_rest_presenter.rb', line 37 def initialize main_method, api @main_method = main_method @http_bindings = main_method.http_bindings @compute_pagination = if @main_method.service.special_compute_behavior? Gapic::Presenters::Method::RestPaginationInfo.new main_method.method, api end @type = "method" end |
Instance Attribute Details
#compute_pagination ⇒ Gapic::Presenters::Method::RestPaginationInfo (readonly)
26 27 28 |
# File 'lib/gapic/presenters/method_rest_presenter.rb', line 26 def compute_pagination @compute_pagination end |
#http_bindings ⇒ Object (readonly)
Returns the value of attribute http_bindings.
28 29 30 |
# File 'lib/gapic/presenters/method_rest_presenter.rb', line 28 def http_bindings @http_bindings end |
#type ⇒ String (readonly)
Returns String representation of this presenter type.
31 32 33 |
# File 'lib/gapic/presenters/method_rest_presenter.rb', line 31 def type @type end |
Instance Method Details
#can_generate_rest? ⇒ Boolean
Whether this method can be generated in REST clients Only methods with http bindings can be generated, and additionally only unary methods are currently supported.
155 156 157 158 159 |
# File 'lib/gapic/presenters/method_rest_presenter.rb', line 155 def can_generate_rest? [:normal, :server].include?(@main_method.kind) && http_bindings.first&.verb? && http_bindings.first&.path? end |
#doc_response_type ⇒ String
Full class name of the return type of the method (including LRO and Paged cases)
95 96 97 98 99 100 101 102 103 |
# File 'lib/gapic/presenters/method_rest_presenter.rb', line 95 def doc_response_type return "::Gapic::Operation" if lro? if paged? elem_type = compute_pagination&.paged_element_doc_type || @main_method.paged_response_type return "::Gapic::Rest::PagedEnumerable<#{elem_type}>" end return "::Gapic::GenericLRO::Operation" if nonstandard_lro? return_type end |
#grpc_full_name ⇒ String
Fully qualified proto name of the method (namespace.PascalCase)
67 68 69 |
# File 'lib/gapic/presenters/method_rest_presenter.rb', line 67 def grpc_full_name @main_method.grpc.full_name end |
#is_deprecated? ⇒ Boolean
Returns Whether the method is marked as deprecated.
173 174 175 |
# File 'lib/gapic/presenters/method_rest_presenter.rb', line 173 def is_deprecated? @main_method.is_deprecated? end |
#lro? ⇒ Boolean
125 126 127 |
# File 'lib/gapic/presenters/method_rest_presenter.rb', line 125 def lro? @main_method.lro? end |
#name ⇒ String
Method name
61 62 63 |
# File 'lib/gapic/presenters/method_rest_presenter.rb', line 61 def name @main_method.name end |
#nonstandard_lro? ⇒ Boolean
Whether this method uses nonstandard LROs
134 135 136 |
# File 'lib/gapic/presenters/method_rest_presenter.rb', line 134 def nonstandard_lro? @main_method.nonstandard_lro? end |
#nonstandard_lro_client ⇒ Gapic::Presenters::Service::LroClientPresenter?
The presenter for the nonstandard LRO client of the kind this method uses
143 144 145 146 |
# File 'lib/gapic/presenters/method_rest_presenter.rb', line 143 def nonstandard_lro_client return unless nonstandard_lro? @main_method.service.rest.nonstandard_lros.find { |model| model.service == @main_method.lro.service_full_name } end |
#paged? ⇒ Boolean
Whether the REGAPIC method should be rendered as paged
121 122 123 |
# File 'lib/gapic/presenters/method_rest_presenter.rb', line 121 def paged? compute_pagination ? compute_pagination.paged? : @main_method.paged? end |
#paged_response_repeated_field_name ⇒ String
Returns The name of the repeated field in paginated responses.
108 109 110 111 112 113 114 |
# File 'lib/gapic/presenters/method_rest_presenter.rb', line 108 def paged_response_repeated_field_name if compute_pagination compute_pagination.response_repeated_field_name else @main_method.paged_response_repeated_field_name end end |
#request_type ⇒ String
Full class name of the request type
76 77 78 |
# File 'lib/gapic/presenters/method_rest_presenter.rb', line 76 def request_type @main_method.request_type end |
#return_type ⇒ String
Full class name of the raw return type of the RPC
85 86 87 |
# File 'lib/gapic/presenters/method_rest_presenter.rb', line 85 def return_type @main_method.return_type end |
#server_streaming? ⇒ Boolean
Whether this method is a server-streaming method
166 167 168 |
# File 'lib/gapic/presenters/method_rest_presenter.rb', line 166 def server_streaming? @main_method.server_streaming? end |
#transcoding_helper_name ⇒ String
Name for the GRPC transcoding helper method
52 53 54 |
# File 'lib/gapic/presenters/method_rest_presenter.rb', line 52 def transcoding_helper_name "transcode_#{name}_request" end |