Class: WavefrontCli::MetricsPolicy
- Defined in:
- lib/wavefront-cli/metricspolicy.rb
Overview
CLI coverage for the metricspolicy part of the v2 ‘usage’ API.
Constant Summary
Constants included from Constants
Constants::ALL_PAGE_SIZE, Constants::DEFAULT_CONFIG, Constants::DEFAULT_OPTS, Constants::EVENT_STATE_DIR, Constants::HUMAN_TIME_FORMAT, Constants::HUMAN_TIME_FORMAT_MS, Constants::SEARCH_SPLIT
Instance Attribute Summary
Attributes inherited from Base
#klass, #klass_word, #options, #wf
Instance Method Summary collapse
- #do_describe ⇒ Object
- #do_history ⇒ Object
- #do_revert ⇒ Object
- #do_update ⇒ Object
-
#process_update(raw) ⇒ Object
It looks like the API expects arrays of ID strings for accounts, groups, and roles, but when you export one, those fields are objects with name and ID.
Methods inherited from Base
#_sdk_class, #cannot_noop!, #check_response_blocks, #check_status, #cli_output_class, #conds_to_query, #descriptive_name, #dispatch, #display, #display_api_error, #display_class, #display_no_api_response, #do_delete, #do_dump, #do_import, #do_list, #do_search, #do_set, #do_undelete, #dump_json, #dump_yaml, #extract_values, #failed_validation_message, #format_var, #handle_error, #handle_response, #hcl_fields, #import_to_create, #initialize, #item_dump_call, #load_display_class, #matching_method, #method_word_list, #mk_creds, #mk_opts, #name_of_do_method, #no_api_response, #ok_exit, #one_or_all, #options_and_exit, #parseable_output, #range_hash, #require_sdk_class, #run, #search_key, #smart_delete, #smart_delete_message, #status_error_handler, #unsupported_format_message, #validate_id, #validate_input, #validate_opts, #validate_tags, #validator_exception, #validator_method, #warning_message
Constructor Details
This class inherits a constructor from WavefrontCli::Base
Instance Method Details
#do_describe ⇒ Object
12 13 14 |
# File 'lib/wavefront-cli/metricspolicy.rb', line 12 def do_describe wf.describe([:version]) end |
#do_history ⇒ Object
16 17 18 |
# File 'lib/wavefront-cli/metricspolicy.rb', line 16 def do_history wf.history([:offset] || 0, [:limit] || 100) end |
#do_revert ⇒ Object
20 21 22 |
# File 'lib/wavefront-cli/metricspolicy.rb', line 20 def do_revert wf.revert([:'<version>']) end |
#do_update ⇒ Object
24 25 26 27 28 |
# File 'lib/wavefront-cli/metricspolicy.rb', line 24 def do_update raw = WavefrontCli::Helper::LoadFile.new([:'<file>']).load rules = process_update(raw) wf.update(policyRules: rules) end |
#process_update(raw) ⇒ Object
It looks like the API expects arrays of ID strings for accounts, groups, and roles, but when you export one, those fields are objects with name and ID.
34 35 36 37 38 39 40 |
# File 'lib/wavefront-cli/metricspolicy.rb', line 34 def process_update(raw) raw[:policyRules].tap do |rule| rule[:accounts] = rule[:accounts].map { |r| r[:id] } rule[:userGroups] = rule[:userGroups].map { |r| r[:id] } rule[:roles] = rule[:roles].map { |r| r[:id] } end end |