Class: A2::Subcommand::Reporting::ExportNodeReports
Instance Attribute Summary
Attributes inherited from Filtered
Instance Method Summary collapse
- #execute(filename = nil, output_type = 'csv') ⇒ Object
-
#initialize ⇒ ExportNodeReports
constructor
A new instance of ExportNodeReports.
Methods inherited from Paginated
#generate_paginated_query_string, #with_paginated_filter_json, #with_paginated_filter_query
Methods inherited from Filtered
#generate_json_filters, #generate_query_filters, #parse_filters, #set_custom_opts!, #set_filter_optparse_options!, #with_filter_query
Constructor Details
#initialize ⇒ ExportNodeReports
Returns a new instance of ExportNodeReports.
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/a2/subcommands/reporting.rb', line 5 def initialize super('export-node-reports', takes_commands: false, filter_key: 'type') @opt[:type] = 'csv' .on('-n', '--name NAME', 'Name of the profile (as defined in inspec.yml).') do |name| @opt[:name] = name end .on('-O', '--owner OWNER', 'Automate user associated with the profile.') do |owner| @opt[:owner] = owner end .on('-o', '--output OUTPUT_TYPE', 'Desired report data format (either "csv" or "json"). Default value is "csv".') do |output_type| @opt[:type] = output_type end end |
Instance Method Details
#execute(filename = nil, output_type = 'csv') ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/a2/subcommands/reporting.rb', line 19 def execute(filename = nil, output_type = 'csv') # Workaround for bug: https://github.com/chef/automate/issues/4926 @opt[:order] = @opt[:order].downcase.eql?('asc') ? 0 : 1 with_paginated_filter_json do |json| filename ||= "report-#{Time.now.strftime('%Y%m%d%H%M%S')}.#{@opt[:type]}" response = A2::Client.new(command_parser.data).export_node_reports(json, filename) end end |