Class: Kongfigure::Resources::Route

Inherits:
Base
  • Object
show all
Defined in:
lib/kongfigure/resources/route.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#id, #kongfigure_ignore_fields, #plugins, #unchanged, #updated

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#==, build_all, #has_to_be_deleted?, #initialize, #mark_as_unchanged, #mark_as_updated, #plugin_allowed?

Constructor Details

This class inherits a constructor from Kongfigure::Resources::Base

Instance Attribute Details

#destinationsObject

Returns the value of attribute destinations.



3
4
5
# File 'lib/kongfigure/resources/route.rb', line 3

def destinations
  @destinations
end

#headersObject

Returns the value of attribute headers.



3
4
5
# File 'lib/kongfigure/resources/route.rb', line 3

def headers
  @headers
end

#hostsObject

Returns the value of attribute hosts.



3
4
5
# File 'lib/kongfigure/resources/route.rb', line 3

def hosts
  @hosts
end

#methodsObject

Returns the value of attribute methods.



3
4
5
# File 'lib/kongfigure/resources/route.rb', line 3

def methods
  @methods
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/kongfigure/resources/route.rb', line 3

def name
  @name
end

#pathsObject

Returns the value of attribute paths.



3
4
5
# File 'lib/kongfigure/resources/route.rb', line 3

def paths
  @paths
end

#preserve_hostObject

Returns the value of attribute preserve_host.



3
4
5
# File 'lib/kongfigure/resources/route.rb', line 3

def preserve_host
  @preserve_host
end

#protocolsObject

Returns the value of attribute protocols.



3
4
5
# File 'lib/kongfigure/resources/route.rb', line 3

def protocols
  @protocols
end

#regex_priorityObject

Returns the value of attribute regex_priority.



3
4
5
# File 'lib/kongfigure/resources/route.rb', line 3

def regex_priority
  @regex_priority
end

#serviceObject

Returns the value of attribute service.



3
4
5
# File 'lib/kongfigure/resources/route.rb', line 3

def service
  @service
end

#snisObject

Returns the value of attribute snis.



3
4
5
# File 'lib/kongfigure/resources/route.rb', line 3

def snis
  @snis
end

#sourcesObject

Returns the value of attribute sources.



3
4
5
# File 'lib/kongfigure/resources/route.rb', line 3

def sources
  @sources
end

#strip_pathObject

Returns the value of attribute strip_path.



3
4
5
# File 'lib/kongfigure/resources/route.rb', line 3

def strip_path
  @strip_path
end

Class Method Details

.build(hash) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/kongfigure/resources/route.rb', line 6

def self.build(hash)
  raise "Route ID is missing for #{hash.inspect}" if hash["id"].nil?
  route                = new(hash["id"], hash["kongfigure_ignore_fields"])
  route.name           = hash["name"]
  route.protocols      = hash["protocols"]
  route.methods        = hash["methods"]
  route.paths          = hash["paths"]
  route.regex_priority = hash["regex_priority"]
  route.strip_path     = hash["strip_path"]
  route.preserve_host  = hash["snis"]
  route.sources        = hash["destinations"]
  route.service        = hash["service"]
  route.hosts          = hash["hosts"]
  route.headers        = hash["headers"]
  route.plugins        = Kongfigure::Resources::Plugin.build_all(hash["plugins"] || [])
  route
end

Instance Method Details

#api_attributesObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/kongfigure/resources/route.rb', line 40

def api_attributes
  {
    "id"             => id,
    "name"           => name,
    "protocols"      => protocols,
    "methods"        => methods,
    "paths"          => paths,
    "hosts"          => hosts,
    "headers"        => headers,
    "regex_priority" => regex_priority,
    "strip_path"     => strip_path,
    "preserve_host"  => preserve_host,
    "sources"        => sources,
    "service"        => service
  }.compact
end

#api_nameObject



28
29
30
# File 'lib/kongfigure/resources/route.rb', line 28

def api_name
  "routes"
end

#display_nameObject



32
33
34
35
36
37
38
# File 'lib/kongfigure/resources/route.rb', line 32

def display_name
  if name.nil?
    "default route"
  else
    "route (name: #{name})"
  end
end

#identifierObject



24
25
26
# File 'lib/kongfigure/resources/route.rb', line 24

def identifier
  id
end