Class: Nephophobia::Client
- Inherits:
-
Object
- Object
- Nephophobia::Client
- Defined in:
- lib/nephophobia/client.rb
Instance Method Summary collapse
-
#action(inflict, filter) ⇒ Object
Vanity wrapper around #raw.
-
#compute ⇒ Object
Provide a simple interface to the EC2 Compute resources.
-
#credential ⇒ Object
Provide a simple interface to the EC2 Credential resources.
-
#image ⇒ Object
Provide a simple interface to the EC2 Image resources.
-
#initialize(options) ⇒ Client
constructor
Required:
host
: A String with the host to connect. -
#project ⇒ Object
Provide a simple interface to the OpenStack Project resources.
-
#raw(method, params) ⇒ Object
Worker method which constructs the properly signed URL, and performs the Net::HTTP call.
-
#role ⇒ Object
Provide a simple interface to the OpenStack Role resources.
-
#user ⇒ Object
Provide a simple interface to the OpenStack User resources.
Constructor Details
#initialize(options) ⇒ Client
Required: host
: A String with the host to connect. access_key
: A String containing the AWS Access Key. secret_key
: A String containing the AWS Secret Key. project
: An optional String containing the “Project Name”
the Acccess Key is intended for.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/nephophobia/client.rb', line 11 def initialize @port = [:port] || 8773 @connection = Hugs::Client.new( :host => [:host], :scheme => [:scheme] || "http", :port => @port, :type => [:type] || :xml, :raise_errors => true ) @aws = AWS.new( :host => [:host], :port => @port, :access_key => [:access_key], :secret_key => [:secret_key], :project => [:project] ) end |
Instance Method Details
#action(inflict, filter) ⇒ Object
Vanity wrapper around #raw.
inflict
: A String with the EC2 API action to execute. filter
: An optional Hash containing the EC2 API filters.
53 54 55 |
# File 'lib/nephophobia/client.rb', line 53 def action inflict, filter raw "get", { "Action" => inflict }.merge(filter) end |
#compute ⇒ Object
Provide a simple interface to the EC2 Compute resources.
60 61 62 63 |
# File 'lib/nephophobia/client.rb', line 60 def compute @path = "/services/Cloud" @compute ||= Nephophobia::Resource::Compute.new self end |
#credential ⇒ Object
Provide a simple interface to the EC2 Credential resources.
68 69 70 71 |
# File 'lib/nephophobia/client.rb', line 68 def credential @path = "/services/Cloud" @credential ||= Nephophobia::Resource::Credential.new self end |
#image ⇒ Object
Provide a simple interface to the EC2 Image resources.
76 77 78 79 |
# File 'lib/nephophobia/client.rb', line 76 def image @path = "/services/Cloud" @image ||= Nephophobia::Resource::Image.new self end |
#project ⇒ Object
Provide a simple interface to the OpenStack Project resources.
84 85 86 87 |
# File 'lib/nephophobia/client.rb', line 84 def project @path = "/services/Admin" @project ||= Nephophobia::Resource::Project.new self end |
#raw(method, params) ⇒ Object
Worker method which constructs the properly signed URL, and performs the Net::HTTP call. Returns a typical Net::HTTP response with a Hash body.
method
: The HTTP method used for the request. params
: A Hash containing the
39 40 41 42 43 44 45 |
# File 'lib/nephophobia/client.rb', line 39 def raw method, params @aws.path = @path response = @connection.send method, @path, :query => @aws.signed_params(method, params) response.body = Hashify.convert response.body.root response end |
#role ⇒ Object
Provide a simple interface to the OpenStack Role resources.
100 101 102 103 |
# File 'lib/nephophobia/client.rb', line 100 def role @path = "/services/Admin" @role ||= Nephophobia::Resource::Role.new self end |
#user ⇒ Object
Provide a simple interface to the OpenStack User resources.
92 93 94 95 |
# File 'lib/nephophobia/client.rb', line 92 def user @path = "/services/Admin" @user ||= Nephophobia::Resource::User.new self end |