Class: Pulp::Connection::Handler
- Inherits:
-
Object
- Object
- Pulp::Connection::Handler
- Includes:
- Pulp::Common::Debug
- Defined in:
- lib/pulp/connection/handler.rb
Class Attribute Summary collapse
-
.hostname ⇒ Object
Returns the value of attribute hostname.
-
.password ⇒ Object
Returns the value of attribute password.
-
.username ⇒ Object
Returns the value of attribute username.
Class Method Summary collapse
- .instance_for(identifier, h = nil, u = nil, p = nil, https = true) ⇒ Object
- .reset_all ⇒ Object
- .reset_instance(identifier) ⇒ Object
Instance Method Summary collapse
- #api_path ⇒ Object
- #connection ⇒ Object
-
#initialize(identifier, hostname, username = nil, password = nil, https = true) ⇒ Handler
constructor
A new instance of Handler.
- #parsed ⇒ Object
- #url ⇒ Object
Methods included from Pulp::Common::Debug
Constructor Details
#initialize(identifier, hostname, username = nil, password = nil, https = true) ⇒ Handler
Returns a new instance of Handler.
33 34 35 36 37 38 39 |
# 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 |
Class Attribute Details
.hostname ⇒ Object
Returns the value of attribute hostname.
8 9 10 |
# File 'lib/pulp/connection/handler.rb', line 8 def hostname @hostname end |
.password ⇒ Object
Returns the value of attribute password.
8 9 10 |
# File 'lib/pulp/connection/handler.rb', line 8 def password @password end |
.username ⇒ Object
Returns the value of attribute username.
8 9 10 |
# File 'lib/pulp/connection/handler.rb', line 8 def username @username end |
Class Method Details
.instance_for(identifier, h = nil, u = nil, p = nil, https = true) ⇒ Object
10 11 12 13 14 15 16 17 |
# 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 |
.reset_all ⇒ Object
23 24 25 |
# File 'lib/pulp/connection/handler.rb', line 23 def reset_all @instances = {} end |
.reset_instance(identifier) ⇒ Object
19 20 21 |
# File 'lib/pulp/connection/handler.rb', line 19 def reset_instance(identifier) instances.delete(identifier) end |
Instance Method Details
#api_path ⇒ Object
49 50 51 |
# File 'lib/pulp/connection/handler.rb', line 49 def api_path "/pulp/api" end |
#connection ⇒ Object
45 46 47 |
# File 'lib/pulp/connection/handler.rb', line 45 def connection @connection ||= RestClient::Resource.new(url, :user => @username, :password => @password, :headers => { :accept => :json }) end |
#parsed ⇒ Object
41 42 43 |
# File 'lib/pulp/connection/handler.rb', line 41 def parsed JSON.parse((yield self.connection).body) end |
#url ⇒ Object
53 54 55 |
# File 'lib/pulp/connection/handler.rb', line 53 def url @url ||= "#{@https ? 'https' : 'http'}://#{@hostname}#{api_path}/#{@identifier.to_s.pluralize}" end |