Class: Emasser::Milestones

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

Overview

Remove one or more Milestones from a system for a POA

Endpoint:

/api/systems/{systemId}/poam/{poamId}/milestones - Remove milestones in a system for one or many poa&m items

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)


344
345
346
# File 'lib/emasser/get.rb', line 344

def self.exit_on_failure?
  true
end

Instance Method Details

#addObject



394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
# File 'lib/emasser/post.rb', line 394

def add
  body = EmassClient::MilestonesGet.new
  body.description = options[:description]
  body.scheduled_completion_date = options[:scheduledCompletionDate]
  body_array = Array.new(1, body)

  begin
    result = EmassClient::MilestonesApi
             .new.add_milestone_by_system_id_and_poam_id(options[:systemId], options[:poamId], body_array)
    puts to_output_hash(result).green
  rescue EmassClient::ApiError => e
    puts 'Exception when calling MilestonesApi->add_milestone_by_system_id_and_poam_id'.red
    puts to_output_hash(e)
  end
end

#byMilestoneIdObject



385
386
387
388
389
390
391
392
393
# File 'lib/emasser/get.rb', line 385

def byMilestoneId
  result = EmassClient::MilestonesApi.new.get_system_milestones_by_poam_id_and_milestone_id(
    options[:systemId], options[:poamId], options[:milestoneId]
  )
  puts to_output_hash(result).green
rescue EmassClient::ApiError => e
  puts 'Exception when calling MilestonesApi->get_system_milestones_by_poam_id_and_milestone_id'.red
  puts to_output_hash(e)
end

#byPoamIdObject



360
361
362
363
364
365
366
367
368
369
370
371
372
373
# File 'lib/emasser/get.rb', line 360

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

  begin
    # Get milestones in one or many poa&m items in a system
    result = EmassClient::MilestonesApi.new.get_system_milestones_by_poam_id(options[:systemId],
                                                                             options[:poamId], optional_options)
    puts to_output_hash(result).green
  rescue EmassClient::ApiError => e
    puts 'Exception when calling MilestonesApi->get_system_milestones_by_poam_id'.red
    puts to_output_hash(e)
  end
end

#removeObject



90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/emasser/delete.rb', line 90

def remove
  body = EmassClient::MilestonesRequestDeleteBodyInner.new
  body.milestone_id = options[:milestoneId]
  body_array = Array.new(1, body)

  result = EmassClient::MilestonesApi.new.delete_milestone(options[:systemId], options[:poamId], body_array)
  # The server returns an empty object upon successfully deleting a milestone.
  puts to_output_hash(result).green
rescue EmassClient::ApiError => e
  puts 'Exception when calling MilestonesApi->delete_milestone'.red
  puts to_output_hash(e)
end

#updateObject



524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
# File 'lib/emasser/put.rb', line 524

def update
  body = EmassClient::MilestonesGet.new
  body.milestone_id = options[:milestoneId]
  body.description = options[:description]
  body.scheduled_completion_date = options[:scheduledCompletionDate]
  body_array = Array.new(1, body)

  begin
    # Get milestones in one or many poa&m items in a system
    result = EmassClient::MilestonesApi
             .new
             .update_milestone_by_system_id_and_poam_id(options[:systemId], options[:poamId], body_array)
    puts to_output_hash(result).green
  rescue EmassClient::ApiError => e
    puts 'Exception when calling MilestonesApi->update_milestone_by_system_id_and_poam_id'.red
    puts to_output_hash(e)
  end
end