Class: ElasticDot::Command::Keys

Inherits:
Base
  • Object
show all
Defined in:
lib/elasticdot/command/keys.rb

Class Method Summary collapse

Class Method Details

.addObject



2
3
4
# File 'lib/elasticdot/command/keys.rb', line 2

def self.add
  associate_or_generate_ssh_key
end

.clearObject



21
22
23
24
25
# File 'lib/elasticdot/command/keys.rb', line 21

def self.clear
  api.get('/stats')['profile']['keys'].each do |k|
    api.delete "/account/keys/#{k['id']}"
  end
end

.listObject



27
28
29
30
31
32
# File 'lib/elasticdot/command/keys.rb', line 27

def self.list
  puts "=== #{api.email} Keys"
  keys = api.get('/stats')['profile']['keys'].each do |k|
    puts k['content']
  end
end

.remove(keys, opts) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/elasticdot/command/keys.rb', line 6

def self.remove(keys, opts)
  rkeys = api.get('/stats')['profile']['keys']

  keys.each do |k|
    rk = rkeys.select {|rk| rk['content'] =~ /#{k}/ }.first

    unless rk
      puts "Key not found, skipping #{k}..."
      next
    end

    api.delete "/account/keys/#{rk['id']}"
  end
end