Class: Emasser::CAC

Inherits:
SubCommandBase show all
Defined in:
lib/emasser/get.rb,
lib/emasser/post.rb

Overview

Add a Control Approval Chain (CAC)

Endpoints:

/api/systems/{systemId}/approval/cac

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from SubCommandBase

banner

Methods included from OutputConverters

#change_to_datetime, #to_output_hash

Methods included from InputConverters

#to_input_hash

Methods included from OptionsParser

#optional_options, #required_options

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


502
503
504
# File 'lib/emasser/get.rb', line 502

def self.exit_on_failure?
  true
end

Instance Method Details

#addObject



521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
# File 'lib/emasser/post.rb', line 521

def add
  body = EmassClient::CacGet.new
  body.control_acronym = options[:controlAcronym]
  body.comments = options[:comments]

  body_array = Array.new(1, body)

  begin
    # Get location of one or many controls in CAC
    result = EmassClient::CACApi.new.add_system_cac(options[:systemId], body_array)
    puts to_output_hash(result).green
  rescue EmassClient::ApiError => e
    puts 'Exception when calling ApprovalChainApi->add_system_cac'.red
    puts to_output_hash(e)
  end
end

#controlsObject



514
515
516
517
518
519
520
521
522
523
524
525
526
# File 'lib/emasser/get.rb', line 514

def controls
  optional_options_keys = optional_options(@_initializer).keys
  optional_options = to_input_hash(optional_options_keys, options)

  begin
    # Get location of one or many controls in CAC
    result = EmassClient::CACApi.new.get_system_cac(options[:systemId], optional_options)
    puts to_output_hash(result).green
  rescue EmassClient::ApiError => e
    puts 'Exception when calling CACApi->get_system_cac'.red
    puts to_output_hash(e)
  end
end