Class: VcoWorkflows::Cli::Query
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- VcoWorkflows::Cli::Query
- Includes:
- Thor::Actions
- Defined in:
- lib/vcoworkflows/cli/query.rb
Overview
Query
Class Method Summary collapse
-
.source_root ⇒ Object
Thor.
Instance Method Summary collapse
-
#query ⇒ Object
Process the subcommand rubocop:disable CyclomaticComplexity, PerceivedComplexity.
Class Method Details
.source_root ⇒ Object
Thor
30 31 32 |
# File 'lib/vcoworkflows/cli/query.rb', line 30 def self.source_root File.dirname(__FILE__) end |
Instance Method Details
#query ⇒ Object
Process the subcommand rubocop:disable CyclomaticComplexity, PerceivedComplexity
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/vcoworkflows/cli/query.rb', line 36 def query config = VcoWorkflows::Config.new(url: [:server], username: [:username], password: [:password], verify_ssl: [:verify_ssl]) if [:dry_run] puts "\nQuerying against vCO REST endpoint:\n #{[:server]}" puts "Will search for workflow: '#{workflow}'" puts "Will query workflow by GUID (#{[:id]})" if [:id] return end # Get the workflow puts "\nRetrieving workflow '#{workflow}' ..." wf = VcoWorkflows::Workflow.new(workflow, id: [:id], config: config) puts '' if [:execution_id] puts "Fetching data for execution #{[:execution_id]}..." execution = wf.token([:execution_id]) if [:state] puts "Execution started at #{Time.at(execution.start_date / 1000)}" puts "Execution #{execution.state} at #{Time.at(execution.end_date / 1000)}" else puts '' if [:show_json] puts execution.to_json else puts execution end end if [:logs] puts '' wflog = wf.log([:execution_id]) if [:show_json] puts wflog.to_json else puts wflog end end else puts wf unless [:executions] end # Last thing we're checking for, so if it's not wanted, just return return unless [:executions] puts "\nWorkflow: #{wf.name}" puts "ID: #{wf.id}" puts "Description: #{wf.description}" puts "Version: #{wf.version}" puts "\nExecutions: " executions = {} wf.executions.each_value { |attrs| executions[attrs['startDate']] = attrs } keys = executions.keys.sort keys = keys.slice(keys.size - [:last], keys.size) if [:last] > 0 keys.each do || dataline = .to_s dataline << " [#{executions[]['id']}]" dataline << " #{executions[]['state']}" puts dataline end end |