Class: Historics
- Inherits:
-
Thor
- Object
- Thor
- Historics
- Defined in:
- lib/dscli/historics.rb
Instance Method Summary collapse
Instance Method Details
#delete(id) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/dscli/historics.rb', line 50 def delete(id) api = Dscli::API.new begin 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 end |
#get(id) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/dscli/historics.rb', line 18 def get(id) begin 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 end |
#list(page = 1) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/dscli/historics.rb', line 4 def list(page = 1) api = Dscli::API.new results = api.historics_list(page) puts "\nTotal Historic 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 |
#stop(id) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/dscli/historics.rb', line 31 def stop(id) api = Dscli::API.new begin response = api.historics_stop(id) if response[:http][:status] == 204 puts "Historic query '#{id}' stopped successfully" else # TODO: How do we handle a different code? response end rescue ApiResourceNotFoundError => e puts "Specified historic query '#{id}' not found. It may have been deleted." end end |