Class: CivoCLI::Snapshot
- Inherits:
-
Thor
- Object
- Thor
- CivoCLI::Snapshot
- Defined in:
- lib/snapshot.rb
Instance Method Summary collapse
Instance Method Details
#create(name, instance_id) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/snapshot.rb', line 17 def create(name, instance_id) CivoCLI::Config.set_api_auth params = {name: name, instance_id: instance_id} params[:cron_timing] = ["cron"] unless ["cron"].nil? snapshot = Civo::Snapshot.create(params) puts "Created snapshot #{name.colorize(:green)} with ID #{snapshot.id.colorize(:green)} #{"with cron timing #{["cron"].colorize(:green)}" unless ["cron"].nil?}" rescue Flexirest::HTTPException => e puts e.result.reason.colorize(:red) exit 1 end |
#list ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/snapshot.rb', line 4 def list CivoCLI::Config.set_api_auth rows = [] Civo::Snapshot.all.items.each do |snapshot| rows << [snapshot.id, snapshot.name, snapshot.state, snapshot.size_gb, (snapshot.cron_timing || "One-off")] end puts Terminal::Table.new headings: ['ID', 'Name', 'State', "Size (GB)", "Cron"], rows: rows end |
#remove(id) ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/snapshot.rb', line 30 def remove(id) CivoCLI::Config.set_api_auth snapshot = Civo::Snapshot.all.items.detect {|key| key.id == id} Civo::Snapshot.remove(id: id) puts "Removed snapshot #{snapshot.name.colorize(:green)} with ID #{snapshot.id.colorize(:green)}" rescue Flexirest::HTTPException => e puts e.result.reason.colorize(:red) exit 1 end |