Class: EY::CloudClient::Keypair

Inherits:
Object
  • Object
show all
Defined in:
lib/engineyard-cloud-client/models/keypair.rb

Class Method Summary collapse

Class Method Details

.all(api) ⇒ Object



7
8
9
# File 'lib/engineyard-cloud-client/models/keypair.rb', line 7

def self.all(api)
  self.from_array(api, api.get("/keypairs")["keypairs"])
end

.create(api, attrs = {}) ⇒ Object

Create a Keypair with your SSH public key so that you can access your Instances via SSH If successful, returns new Keypair and EY Cloud will have registered your public key If unsuccessful, raises EY::CloudClient::RequestFailed

Usage Keypair.create(api,

name:       "laptop",
public_key: "ssh-rsa OTHERKEYPAIR"

)

NOTE: Syntax above is for Ruby 1.9. In Ruby 1.8, keys must all be strings.



23
24
25
26
27
28
29
# File 'lib/engineyard-cloud-client/models/keypair.rb', line 23

def self.create(api, attrs = {})
  params = attrs.dup # no default fields
  raise EY::CloudClient::AttributeRequiredError.new("name") unless params["name"]
  raise EY::CloudClient::AttributeRequiredError.new("public_key") unless params["public_key"]
  response = api.post("/keypairs", "keypair" => params)['keypair']
  self.from_hash(api, response)
end