class Pulp::Connection::Handler

Attributes

hostname[RW]
password[RW]
username[RW]

Public Class Methods

instance_for(identifier,h=nil,u=nil,p=nil,https=true) click to toggle source
# File lib/pulp/connection/handler.rb, line 10
def instance_for(identifier,h=nil,u=nil,p=nil,https=true)
  instances[identifier] ||= Handler.new(identifier,
                                        h||hostname||'localhost',
                                        u||username||'admin',
                                        p||password||'admin',
                                        https
  )
end
new(identifier,hostname,username=nil,password=nil,https=true) click to toggle source
# File lib/pulp/connection/handler.rb, line 33
def initialize(identifier,hostname,username=nil,password=nil,https=true)
  @identifier = identifier
  @hostname = hostname
  @username = username
  @password = password
  @https = https
end
reset_all() click to toggle source
# File lib/pulp/connection/handler.rb, line 23
def reset_all
  @instances = {}
end
reset_instance(identifier) click to toggle source
# File lib/pulp/connection/handler.rb, line 19
def reset_instance(identifier)
  instances.delete(identifier)
end

Private Class Methods

instances() click to toggle source
# File lib/pulp/connection/handler.rb, line 28
def instances
  @instances ||= {}
end

Public Instance Methods

api_path() click to toggle source
# File lib/pulp/connection/handler.rb, line 49
def api_path
  "/pulp/api" 
end
connection() click to toggle source
# File lib/pulp/connection/handler.rb, line 45
def connection
  @connection ||= RestClient::Resource.new(url, :user => @username, :password => @password, :headers => { :accept => :json })
end
parsed() { |connection).body)| ... } click to toggle source
# File lib/pulp/connection/handler.rb, line 41
def parsed
  JSON.parse((yield self.connection).body)
end
url() click to toggle source
# File lib/pulp/connection/handler.rb, line 53
def url
  @url ||= "#{@https ? 'https' : 'http'}://#{@hostname}#{api_path}/#{@identifier.to_s.pluralize}"
end