Sha256: 4bf12f222fb2c91cf15b871daf5e3717a6c60de00e59773297d10fbd30aceae2
Contents?: true
Size: 1.22 KB
Versions: 9
Compression:
Stored size: 1.22 KB
Contents
require 'engineyard-cloud-client/models/api_struct' require 'engineyard-cloud-client/errors' module EY class CloudClient class Keypair < ApiStruct.new(:id, :name, :public_key) def self.all(api) self.from_array(api, api.get("/keypairs")["keypairs"]) end # 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. 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 def destroy api.delete("/keypairs/#{id}") end end end end
Version data entries
9 entries across 9 versions & 1 rubygems