Class: Gapic::Model::Method::HttpAnnotation
- Inherits:
-
Object
- Object
- Gapic::Model::Method::HttpAnnotation
- Defined in:
- lib/gapic/model/method/http_annotation.rb
Overview
The information used in the generation process that
can be gathered from the google.api.http
annotation.
google.api.http
is used in two distinct ways:
- REST libs use it as part of the transcoding to set up the REST call
- gRPC libs use it as a source of implicit routing headers
Defined Under Namespace
Classes: HttpBinding
Instance Attribute Summary collapse
-
#bindings ⇒ Array<HttpBinding>
readonly
The Http bindings found in the annotation this includes main binding in the annotation itself, as well as those in the
additional_bindings
.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(proto_http) ⇒ HttpAnnotation
constructor
A new instance of HttpAnnotation.
-
#routing_params ⇒ Array<String>
The implicit routing parameter names.
-
#routing_params? ⇒ Boolean
Whether any implicit routing parameters are present.
-
#routing_params_with_patterns ⇒ Array<Array<String>>
The implicit routing parameter names and their corresponding paterns, including the
*
pattern implied for the named segments without an explicitly specified pattern.
Constructor Details
#initialize(proto_http) ⇒ HttpAnnotation
Returns a new instance of HttpAnnotation.
42 43 44 |
# File 'lib/gapic/model/method/http_annotation.rb', line 42 def initialize proto_http @bindings = parse_bindings proto_http end |
Instance Attribute Details
#bindings ⇒ Array<HttpBinding> (readonly)
The Http bindings found in the annotation
this includes main binding in the annotation itself,
as well as those in the additional_bindings
.
36 37 38 |
# File 'lib/gapic/model/method/http_annotation.rb', line 36 def bindings @bindings end |
Class Method Details
.create_with_override(proto_method, service_config = nil) ⇒ Object
82 83 84 85 86 87 88 89 |
# File 'lib/gapic/model/method/http_annotation.rb', line 82 def self.create_with_override proto_method, service_config = nil proto_http = proto_method.http http_override = service_config&.http&.rules&.find { |http_rule| http_rule.selector == proto_method.full_name } http = http_override || proto_http HttpAnnotation.new http end |
Instance Method Details
#routing_params ⇒ Array<String>
The implicit routing parameter names.
58 59 60 |
# File 'lib/gapic/model/method/http_annotation.rb', line 58 def routing_params routing_params_with_patterns.map { |param, _| param } end |
#routing_params? ⇒ Boolean
Whether any implicit routing parameters are present.
50 51 52 |
# File 'lib/gapic/model/method/http_annotation.rb', line 50 def routing_params? routing_params.any? end |
#routing_params_with_patterns ⇒ Array<Array<String>>
The implicit routing parameter names and their corresponding paterns,
including the *
pattern implied for the named segments
without an explicitly specified pattern.
68 69 70 |
# File 'lib/gapic/model/method/http_annotation.rb', line 68 def routing_params_with_patterns bindings.first&.routing_params_with_patterns || [] end |