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

#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)


332
333
334
# File 'lib/emasser/get.rb', line 332

def self.exit_on_failure?
  true
end

Instance Method Details

#addObject



321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
# File 'lib/emasser/post.rb', line 321

def add
  body = SwaggerClient::MilestonesRequestPostBody.new
  body.poam_id = options[:poamId]
  body.description = options[:description]
  body.scheduled_completion_date = options[:scheduledCompletionDate]
  body_array = Array.new(1, body)

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

#byMilestoneIdObject



373
374
375
376
377
378
379
380
381
# File 'lib/emasser/get.rb', line 373

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

#byPoamIdObject



348
349
350
351
352
353
354
355
356
357
358
359
360
361
# File 'lib/emasser/get.rb', line 348

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 = SwaggerClient::MilestonesApi.new.get_system_milestones_by_poam_id(options[:systemId],
                                                                               options[:poamId], optional_options)
    puts to_output_hash(result).green
  rescue SwaggerClient::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 = SwaggerClient::DeleteMilestone.new
  body.milestone_id = options[:milestoneId]
  body_array = Array.new(1, body)

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

#updateObject



484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
# File 'lib/emasser/put.rb', line 484

def update
  body = SwaggerClient::MilestonesRequestPutBody.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 = SwaggerClient::POAMApi
             .new
             .update_milestone_by_system_id_and_poam_id(body_array, options[:systemId], options[:poamId])
    puts to_output_hash(result).green
  rescue SwaggerClient::ApiError => e
    puts 'Exception when calling POAMApi->update_milestone_by_system_id_and_poam_id'.red
    puts to_output_hash(e)
  end
end