# File lib/infoblox/connection.rb, line 45 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] || {} end
# File lib/infoblox/connection.rb, line 39 def delete(href) wrap do connection.delete(href) end end
# File lib/infoblox/connection.rb, line 15 def get(href, params={}) wrap do connection.get(href, params) end end
The host variable is expected to be a protocol with a host name. If the host has no protocol, https:// is added before it.
# File lib/infoblox/connection.rb, line 66 def host=(new_host) unless new_host =~ /^http(s)?:\/\// new_host = "https://#{new_host}" end @host = new_host end
Don't display the username/password in logging, etc.
# File lib/infoblox/connection.rb, line 80 def inspect "#<#{self.class}:#{object_id} @host=\"#{@host}\">" end
# File lib/infoblox/connection.rb, line 21 def post(href, body) wrap do connection.post do |req| req.url href req.body = body.to_json end end end
# File lib/infoblox/connection.rb, line 30 def put(href, body) wrap do connection.put do |req| req.url href req.body = body.to_json end end end
# File lib/infoblox/connection.rb, line 86 def wrap yield.tap do |response| unless response.status < 300 raise Infoblox::Error.new("Error: #{response.status} #{response.body}") end end