Class: Gapic::Model::Method::HttpAnnotation

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(proto_http) ⇒ 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

#bindingsArray<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_paramsArray<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_patternsArray<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