Class: Ey::Core::Client::Keypair

Inherits:
Model
  • Object
show all
Extended by:
Associations
Defined in:
lib/ey-core/models/keypair.rb

Instance Method Summary collapse

Methods included from Associations

assoc_accessor, assoc_coverage, assoc_reader, assoc_writer, associations, collection_reader

Methods inherited from Model

#destroy, range_parser, #save, #to_s, #update!, #url

Instance Method Details

#deploy(environment) ⇒ Object



13
14
15
# File 'lib/ey-core/models/keypair.rb', line 13

def deploy(environment)
  connection.keypair_deployments.create(keypair: self, environment: environment)
end

#destroy!Object



17
18
19
# File 'lib/ey-core/models/keypair.rb', line 17

def destroy!
  connection.requests.new(self.connection.destroy_keypair("id" => self.id).body["request"])
end

#save!Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/ey-core/models/keypair.rb', line 21

def save!
  requires :name, :public_key

  params = {
    "url"     => self.collection.url,
    "user"    => self.user_id,
    "keypair" => {
      "name"       => self.name,
      "public_key" => self.public_key,
    },
  }

  if new_record?
    merge_attributes(self.connection.create_keypair(params).body["keypair"])
  else raise NotImplementedError # update
  end
end