Class: Infoblox::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/infoblox/connection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Connection

Returns a new instance of Connection.



46
47
48
49
50
51
52
53
# File 'lib/infoblox/connection.rb', line 46

def initialize(opts={})
  self.username = opts[:username]
  self.password = opts[:password]
  self.host     = opts[:host]
  self.logger   = opts[:logger]
  self.ssl_opts = opts[:ssl_opts] || {}
  self.timeout  = opts[:timeout] || 60
end

Instance Attribute Details

#adapterObject

Returns the value of attribute adapter.



6
7
8
# File 'lib/infoblox/connection.rb', line 6

def adapter
  @adapter
end

#adapter_blockObject

Returns the value of attribute adapter_block.



6
7
8
# File 'lib/infoblox/connection.rb', line 6

def adapter_block
  @adapter_block
end

#connectionObject

Returns the value of attribute connection.



6
7
8
# File 'lib/infoblox/connection.rb', line 6

def connection
  @connection
end

#hostObject

Returns the value of attribute host.



6
7
8
# File 'lib/infoblox/connection.rb', line 6

def host
  @host
end

#loggerObject

Returns the value of attribute logger.



6
7
8
# File 'lib/infoblox/connection.rb', line 6

def logger
  @logger
end

#passwordObject

Returns the value of attribute password.



6
7
8
# File 'lib/infoblox/connection.rb', line 6

def password
  @password
end

#ssl_optsObject

Returns the value of attribute ssl_opts.



6
7
8
# File 'lib/infoblox/connection.rb', line 6

def ssl_opts
  @ssl_opts
end

#timeoutObject

Returns the value of attribute timeout.



6
7
8
# File 'lib/infoblox/connection.rb', line 6

def timeout
  @timeout
end

#usernameObject

Returns the value of attribute username.



6
7
8
# File 'lib/infoblox/connection.rb', line 6

def username
  @username
end

Instance Method Details

#delete(href) ⇒ Object



40
41
42
43
44
# File 'lib/infoblox/connection.rb', line 40

def delete(href)
  wrap do
    connection.delete(href)
  end
end

#get(href, params = {}) ⇒ Object



16
17
18
19
20
# File 'lib/infoblox/connection.rb', line 16

def get(href, params={})
  wrap do
    connection.get(href, params)
  end
end

#inspectObject

Don’t display the username/password in logging, etc.



85
86
87
# File 'lib/infoblox/connection.rb', line 85

def inspect
  "#<#{self.class}:#{object_id} @host=\"#{@host}\">"
end

#post(href, body) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/infoblox/connection.rb', line 22

def post(href, body)
  wrap do
    connection.post do |req|
      req.url href
      req.body = body.to_json
    end
  end
end

#put(href, body) ⇒ Object



31
32
33
34
35
36
37
38
# File 'lib/infoblox/connection.rb', line 31

def put(href, body)
  wrap do
    connection.put do |req|
      req.url href
      req.body = body.to_json
    end
  end
end