Class: Marathon::Connection

Inherits:
Object
  • Object
show all
Includes:
HTTParty, Error
Defined in:
lib/marathon/connection.rb

Overview

This class represents a Marathon API Connection.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Error

error_class, error_message, from_response

Constructor Details

#initialize(url, options = {}) ⇒ Connection

Create a new API connection. url: URL of the marathon API. options: Hash with options for marathon API.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/marathon/connection.rb', line 21

def initialize(url, options = {})
  @url = url
  @options = options
  if @options[:username] and @options[:password]
    @options[:basic_auth] = {
        :username => @options[:username],
        :password => @options[:password]
    }
    @options.delete(:username)
    @options.delete(:password)
  end

  # The insecure option allows ignoring bad (or self-signed) SSL
  # certificates.
  if @options[:insecure]
    @options[:verify] = false
    @options.delete(:insecure)
  end
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



16
17
18
# File 'lib/marathon/connection.rb', line 16

def options
  @options
end

#urlObject (readonly)

Returns the value of attribute url.



16
17
18
# File 'lib/marathon/connection.rb', line 16

def url
  @url
end

Instance Method Details

#to_sObject



46
47
48
# File 'lib/marathon/connection.rb', line 46

def to_s
  "Marathon::Connection { :url => #{url} :options => #{options} }"
end