Class: Historics
- Inherits:
-
Thor
- Object
- Thor
- Historics
- Defined in:
- lib/dscli/historics.rb
Instance Method Summary collapse
- #delete(id) ⇒ Object
- #get(id) ⇒ Object
- #list(page = 1) ⇒ Object
- #pause(id) ⇒ Object
- #resume(id) ⇒ Object
- #stop(id) ⇒ Object
Instance Method Details
#delete(id) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/dscli/historics.rb', line 40 def delete(id) api = Dscli::API.new response = api.historics_delete(id) if response[:http][:status] == 204 puts "Historic query '#{id}' deleted successfully" else response end rescue ApiResourceNotFoundError => e puts "Specified historic query '#{id}' not found. It may have already been deleted." end |
#get(id) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/dscli/historics.rb', line 17 def get(id) api = Dscli::API.new response = api.historics_get(id) puts response[:data].to_yaml rescue ApiResourceNotFoundError => e puts "Specified historic query '#{id}' was not found. It may have already been deleted." end |
#list(page = 1) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/dscli/historics.rb', line 4 def list(page = 1) api = Dscli::API.new results = api.historics_list(page) puts "\nTotal Historics Queries: #{results.count}\n\n" puts 'ID | Name | Created | Definition Hash | Status ' puts '---------------------------------------------------------------------------------------------------------------------------' results[:data].each { |s| puts "#{s[:id]} | #{ '%-20.20s' % s[:name] } | #{Time.at(s[:created_at])} | #{ s[:definition_id] } | #{s[:status]}" } puts "\n" end |
#pause(id) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/dscli/historics.rb', line 54 def pause(id) api = Dscli::API.new response = api.historics_pause(id) if response[:http][:status] == 204 puts "Historics query '#{id}' paused successfully" else response end rescue ApiResourceNotFoundError => e puts "Specified Historics query '#{id}' not found." end |
#resume(id) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/dscli/historics.rb', line 68 def resume(id) api = Dscli::API.new response = api.historics_resume(id) if response[:http][:status] == 204 puts "Historics query '#{id}' resumed successfully" else response end rescue ApiResourceNotFoundError => e puts "Specified Historics query '#{id}' not found." end |
#stop(id) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/dscli/historics.rb', line 26 def stop(id) api = Dscli::API.new response = api.historics_stop(id) if response[:http][:status] == 204 puts "Historic query '#{id}' stopped successfully" else response end rescue ApiResourceNotFoundError => e puts "Specified historic query '#{id}' not found. It may have been deleted." end |