Class: Droplet

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/droplet_manager.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDroplet

Returns a new instance of Droplet.



21
22
23
24
25
# File 'lib/droplet_manager.rb', line 21

def initialize
  @client_id = ENV['CLIENT_ID']
  @api_key = ENV['API_KEY']
  @droplet_id = ENV['DROPLET_ID']
end

Class Method Details

.destroyObject



63
64
65
# File 'lib/droplet_manager.rb', line 63

def self.destroy
  post("/droplets/#{DROPLET_ID}/destroy/?client_id=#{CLIENT_ID}&api_key=#{API_KEY}")
end

.idObject



27
28
29
# File 'lib/droplet_manager.rb', line 27

def self.id
  get("/droplets/#{DROPLET_ID}?client_id=#{CLIENT_ID}&api_key=#{API_KEY}")
end

.power_cycleObject



39
40
41
# File 'lib/droplet_manager.rb', line 39

def self.power_cycle
  post("/droplets/#{DROPLET_ID}/power_cycle/?client_id=#{CLIENT_ID}&api_key=#{API_KEY}")
end

.poweroffObject



47
48
49
# File 'lib/droplet_manager.rb', line 47

def self.poweroff
  post("/droplets/#{DROPLET_ID}/power_off/?client_id=#{CLIENT_ID}&api_key=#{API_KEY}")
end

.poweronObject



51
52
53
# File 'lib/droplet_manager.rb', line 51

def self.poweron
  post("/droplets/#{DROPLET_ID}/power_on/?client_id=#{CLIENT_ID}&api_key=#{API_KEY}")
end

.rebootObject



35
36
37
# File 'lib/droplet_manager.rb', line 35

def self.reboot
  post("/droplets/#{DROPLET_ID}/reboot/?client_id=#{CLIENT_ID}&api_key=#{API_KEY}")
end

.shutdownObject



43
44
45
# File 'lib/droplet_manager.rb', line 43

def self.shutdown
  post("/droplets/#{DROPLET_ID}/shutdown/?client_id=#{CLIENT_ID}&api_key=#{API_KEY}")
end

.snapshotObject



55
56
57
# File 'lib/droplet_manager.rb', line 55

def self.snapshot
  post("/droplets/#{DROPLET_ID}/snapshot/?name=#{Time.now.strftime('%m_%d_%Y')}&client_id=#{CLIENT_ID}&api_key=#{API_KEY}")
end

.snapshotsObject



59
60
61
# File 'lib/droplet_manager.rb', line 59

def self.snapshots
  Droplet.id['droplet']['snapshots']
end

.statusObject



31
32
33
# File 'lib/droplet_manager.rb', line 31

def self.status
  Droplet.id['droplet']['status']
end