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

Inherits:
Object
  • Object
show all
Defined in:
lib/gapic/model/method/http_annotation.rb

Overview

A single Http binding.

Instance Method Summary collapse

Constructor Details

#initialize(binding) ⇒ HttpBinding

Returns a new instance of HttpBinding.

Parameters:

  • binding (::Google::Api::HttpRule)

    The baseline instance of the Http annotation



98
99
100
# File 'lib/gapic/model/method/http_annotation.rb', line 98

def initialize binding
  @binding = binding
end

Instance Method Details

#bodyString

The body specified for the given method in proto or an empty string if not specified

Returns:

  • (String)


178
179
180
# File 'lib/gapic/model/method/http_annotation.rb', line 178

def body
  @binding&.body || ""
end

#body?Boolean

Whether method has body specified in proto

Returns:

  • (Boolean)


169
170
171
# File 'lib/gapic/model/method/http_annotation.rb', line 169

def body?
  !body.empty?
end

#pathString

A method path or an empty string if not present

Returns:

  • (String)


130
131
132
133
# File 'lib/gapic/model/method/http_annotation.rb', line 130

def path
  return "" unless verb_path
  verb_path[1]
end

#path?Boolean

Whether a method path is present and non-empty

Returns:

  • (Boolean)


122
123
124
# File 'lib/gapic/model/method/http_annotation.rb', line 122

def path?
  !path.empty?
end

#routing_paramsArray<String>

The segment key names.

Returns:

  • (Array<String>)


161
162
163
# File 'lib/gapic/model/method/http_annotation.rb', line 161

def routing_params
  routing_params_with_patterns.map { |param, _| param }
end

#routing_params?Boolean

Whether any routing params are present

Returns:

  • (Boolean)


139
140
141
# File 'lib/gapic/model/method/http_annotation.rb', line 139

def routing_params?
  routing_params.any?
end

#routing_params_with_patternsArray<Array<String>>

The segment key names and their corresponding paterns, including the * pattern implied for the named segments without pattern explicitly specified.

Returns:

  • (Array<Array<String>>)


149
150
151
152
153
154
155
# File 'lib/gapic/model/method/http_annotation.rb', line 149

def routing_params_with_patterns
  @routing_params_with_patterns ||= begin
    Gapic::UriTemplate.parse_arguments(path).map do |name, pattern|
      [name, pattern.empty? ? "*" : pattern]
    end
  end
end

#verbSymbol?

The http verb for this method

Returns:

  • (Symbol, nil)


114
115
116
# File 'lib/gapic/model/method/http_annotation.rb', line 114

def verb
  verb_path[0] if verb_path
end

#verb?Boolean

Whether a http verb is present for this method

Returns:

  • (Boolean)


106
107
108
# File 'lib/gapic/model/method/http_annotation.rb', line 106

def verb?
  !verb.nil?
end