Class: Kongfigure::Resources::Service
- Defined in:
- lib/kongfigure/resources/service.rb
Instance Attribute Summary collapse
-
#connect_timeout ⇒ Object
Returns the value of attribute connect_timeout.
-
#host ⇒ Object
Returns the value of attribute host.
-
#name ⇒ Object
Returns the value of attribute name.
-
#path ⇒ Object
Returns the value of attribute path.
-
#port ⇒ Object
Returns the value of attribute port.
-
#protocol ⇒ Object
Returns the value of attribute protocol.
-
#read_timeout ⇒ Object
Returns the value of attribute read_timeout.
-
#retries ⇒ Object
Returns the value of attribute retries.
-
#routes ⇒ Object
Returns the value of attribute routes.
-
#url ⇒ Object
Returns the value of attribute url.
-
#write_timeout ⇒ Object
Returns the value of attribute write_timeout.
Attributes inherited from Base
#id, #kongfigure_ignore_fields, #plugins, #unchanged, #updated
Class Method Summary collapse
Instance Method Summary collapse
- #api_attributes ⇒ Object
- #api_name ⇒ Object
- #has_route?(other_route) ⇒ Boolean
- #has_routes?(other_routes) ⇒ Boolean
- #identifier ⇒ Object
- #to_s ⇒ Object
Methods inherited from Base
#==, build_all, #display_name, #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
#connect_timeout ⇒ Object
Returns the value of attribute connect_timeout.
4 5 6 |
# File 'lib/kongfigure/resources/service.rb', line 4 def connect_timeout @connect_timeout end |
#host ⇒ Object
Returns the value of attribute host.
4 5 6 |
# File 'lib/kongfigure/resources/service.rb', line 4 def host @host end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/kongfigure/resources/service.rb', line 4 def name @name end |
#path ⇒ Object
Returns the value of attribute path.
4 5 6 |
# File 'lib/kongfigure/resources/service.rb', line 4 def path @path end |
#port ⇒ Object
Returns the value of attribute port.
4 5 6 |
# File 'lib/kongfigure/resources/service.rb', line 4 def port @port end |
#protocol ⇒ Object
Returns the value of attribute protocol.
4 5 6 |
# File 'lib/kongfigure/resources/service.rb', line 4 def protocol @protocol end |
#read_timeout ⇒ Object
Returns the value of attribute read_timeout.
4 5 6 |
# File 'lib/kongfigure/resources/service.rb', line 4 def read_timeout @read_timeout end |
#retries ⇒ Object
Returns the value of attribute retries.
4 5 6 |
# File 'lib/kongfigure/resources/service.rb', line 4 def retries @retries end |
#routes ⇒ Object
Returns the value of attribute routes.
4 5 6 |
# File 'lib/kongfigure/resources/service.rb', line 4 def routes @routes end |
#url ⇒ Object
Returns the value of attribute url.
4 5 6 |
# File 'lib/kongfigure/resources/service.rb', line 4 def url @url end |
#write_timeout ⇒ Object
Returns the value of attribute write_timeout.
4 5 6 |
# File 'lib/kongfigure/resources/service.rb', line 4 def write_timeout @write_timeout end |
Class Method Details
.build(hash) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/kongfigure/resources/service.rb', line 7 def self.build(hash) service = new(hash["id"], hash["kongfigure_ignore_fields"]) service.name = hash["name"] service.retries = hash["retries"] service.protocol = hash["protocol"] service.host = hash["host"] service.port = hash["port"] service.path = hash["path"] service.connect_timeout = hash["connect_timeout"] service.write_timeout = hash["write_timeout"] service.read_timeout = hash["read_timeout"] service.plugins = Kongfigure::Resources::Plugin.build_all(hash["plugins"] || []) service.routes = Kongfigure::Resources::Route.build_all(hash["routes"] || []) service.url = hash["url"] || URI::Generic.build({ scheme: hash["protocol"], host: hash["host"], port: hash["port"], path: hash["path"] }).to_s service end |
Instance Method Details
#api_attributes ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/kongfigure/resources/service.rb', line 49 def api_attributes { "name" => name, "retries" => retries, "protocol" => protocol, "host" => host, "port" => port, "path" => path, "connect_timeout" => connect_timeout, "write_timeout" => write_timeout, "read_timeout" => read_timeout, "url" => url }.compact end |
#api_name ⇒ Object
29 30 31 |
# File 'lib/kongfigure/resources/service.rb', line 29 def api_name "services" end |
#has_route?(other_route) ⇒ Boolean
37 38 39 40 41 |
# File 'lib/kongfigure/resources/service.rb', line 37 def has_route?(other_route) routes && routes.find do |route| other_route == route end end |
#has_routes?(other_routes) ⇒ Boolean
43 44 45 46 47 |
# File 'lib/kongfigure/resources/service.rb', line 43 def has_routes?(other_routes) other_routes.reject do |other_route| has_route?(other_route) end.size == 0 end |
#identifier ⇒ Object
33 34 35 |
# File 'lib/kongfigure/resources/service.rb', line 33 def identifier name end |
#to_s ⇒ Object
64 65 66 |
# File 'lib/kongfigure/resources/service.rb', line 64 def to_s name end |