Class: EY::CloudClient::Keypair

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.all(api) ⇒ Object



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

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.



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

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

Instance Method Details

#destroyObject



32
33
34
# File 'lib/engineyard-cloud-client/models/keypair.rb', line 32

def destroy
  api.delete("/keypairs/#{id}")
end

#sort_attributesObject



36
37
38
# File 'lib/engineyard-cloud-client/models/keypair.rb', line 36

def sort_attributes
  sort_string(name)
end