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::ComputePaginationInfo
readonly
Special pagination presenter for Compute.
-
#http_bindings ⇒ Array<Gapic::Presenters::Method::HttpBindingsPresenter>
readonly
Presenters for HTTP bindings, used to check whether this method should be generated in REST client.
-
#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's 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
Name of the repeated field in paginated responses For Compute the pagination is different from GRPC and cannot be looked up in GRPC method presenter.
-
#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.
42 43 44 45 46 47 48 49 50 |
# File 'lib/gapic/presenters/method_rest_presenter.rb', line 42 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::ComputePaginationInfo.new main_method.method, api end @type = "method" end |
Instance Attribute Details
#compute_pagination ⇒ Gapic::Presenters::Method::ComputePaginationInfo (readonly)
Returns Special pagination presenter for Compute.
26 27 28 |
# File 'lib/gapic/presenters/method_rest_presenter.rb', line 26 def compute_pagination @compute_pagination end |
#http_bindings ⇒ Array<Gapic::Presenters::Method::HttpBindingsPresenter> (readonly)
Presenters for HTTP bindings, used to check whether this method should be generated in REST client
33 34 35 |
# File 'lib/gapic/presenters/method_rest_presenter.rb', line 33 def http_bindings @http_bindings end |
#type ⇒ String (readonly)
Returns String representation of this presenter type.
36 37 38 |
# File 'lib/gapic/presenters/method_rest_presenter.rb', line 36 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.
166 167 168 169 170 |
# File 'lib/gapic/presenters/method_rest_presenter.rb', line 166 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)
103 104 105 106 107 108 109 110 111 |
# File 'lib/gapic/presenters/method_rest_presenter.rb', line 103 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)
75 76 77 |
# File 'lib/gapic/presenters/method_rest_presenter.rb', line 75 def grpc_full_name @main_method.grpc.full_name end |
#is_deprecated? ⇒ Boolean
Whether the method is marked as deprecated.
186 187 188 |
# File 'lib/gapic/presenters/method_rest_presenter.rb', line 186 def is_deprecated? @main_method.is_deprecated? end |
#lro? ⇒ Boolean
136 137 138 |
# File 'lib/gapic/presenters/method_rest_presenter.rb', line 136 def lro? @main_method.lro? end |
#name ⇒ String
Method's name
66 67 68 |
# File 'lib/gapic/presenters/method_rest_presenter.rb', line 66 def name @main_method.name end |
#nonstandard_lro? ⇒ Boolean
Whether this method uses nonstandard LROs
145 146 147 |
# File 'lib/gapic/presenters/method_rest_presenter.rb', line 145 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
154 155 156 157 |
# File 'lib/gapic/presenters/method_rest_presenter.rb', line 154 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
132 133 134 |
# File 'lib/gapic/presenters/method_rest_presenter.rb', line 132 def paged? compute_pagination ? compute_pagination.paged? : @main_method.paged? end |
#paged_response_repeated_field_name ⇒ String
Name of the repeated field in paginated responses For Compute the pagination is different from GRPC and cannot be looked up in GRPC method presenter
119 120 121 122 123 124 125 |
# File 'lib/gapic/presenters/method_rest_presenter.rb', line 119 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
84 85 86 |
# File 'lib/gapic/presenters/method_rest_presenter.rb', line 84 def request_type @main_method.request_type end |
#return_type ⇒ String
Full class name of the raw return type of the RPC
93 94 95 |
# File 'lib/gapic/presenters/method_rest_presenter.rb', line 93 def return_type @main_method.return_type end |
#server_streaming? ⇒ Boolean
Whether this method is a server-streaming method
177 178 179 |
# File 'lib/gapic/presenters/method_rest_presenter.rb', line 177 def server_streaming? @main_method.server_streaming? end |
#transcoding_helper_name ⇒ String
Name for the GRPC transcoding helper method
57 58 59 |
# File 'lib/gapic/presenters/method_rest_presenter.rb', line 57 def transcoding_helper_name "transcode_#{name}_request" end |