morpheus-cli 3.3.2.6.2 → 3.3.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/lib/morpheus/api/api_client.rb +4 -0
  3. data/lib/morpheus/api/cloud_datastores_interface.rb +47 -0
  4. data/lib/morpheus/api/virtual_images_interface.rb +2 -2
  5. data/lib/morpheus/cli.rb +1 -0
  6. data/lib/morpheus/cli/app_templates.rb +5 -15
  7. data/lib/morpheus/cli/cli_command.rb +5 -1
  8. data/lib/morpheus/cli/cloud_datastores_command.rb +399 -0
  9. data/lib/morpheus/cli/containers_command.rb +2 -8
  10. data/lib/morpheus/cli/hosts.rb +10 -21
  11. data/lib/morpheus/cli/instance_types.rb +4 -10
  12. data/lib/morpheus/cli/instances.rb +14 -34
  13. data/lib/morpheus/cli/library_container_scripts_command.rb +5 -12
  14. data/lib/morpheus/cli/library_container_templates_command.rb +4 -10
  15. data/lib/morpheus/cli/library_container_types_command.rb +4 -10
  16. data/lib/morpheus/cli/library_instance_types_command.rb +4 -10
  17. data/lib/morpheus/cli/library_layouts_command.rb +4 -10
  18. data/lib/morpheus/cli/library_option_types_command.rb +2 -5
  19. data/lib/morpheus/cli/library_upgrades_command.rb +4 -10
  20. data/lib/morpheus/cli/load_balancers.rb +4 -16
  21. data/lib/morpheus/cli/monitoring_apps_command.rb +5 -14
  22. data/lib/morpheus/cli/monitoring_checks_command.rb +13 -33
  23. data/lib/morpheus/cli/monitoring_contacts_command.rb +10 -11
  24. data/lib/morpheus/cli/monitoring_groups_command.rb +19 -38
  25. data/lib/morpheus/cli/monitoring_incidents_command.rb +37 -66
  26. data/lib/morpheus/cli/network_domains_command.rb +7 -16
  27. data/lib/morpheus/cli/network_groups_command.rb +6 -16
  28. data/lib/morpheus/cli/network_pool_servers_command.rb +6 -16
  29. data/lib/morpheus/cli/network_pools_command.rb +6 -16
  30. data/lib/morpheus/cli/network_proxies_command.rb +6 -16
  31. data/lib/morpheus/cli/network_services_command.rb +4 -11
  32. data/lib/morpheus/cli/networks_command.rb +6 -16
  33. data/lib/morpheus/cli/packages_command.rb +148 -13
  34. data/lib/morpheus/cli/policies_command.rb +6 -16
  35. data/lib/morpheus/cli/power_scheduling_command.rb +6 -24
  36. data/lib/morpheus/cli/recent_activity_command.rb +19 -19
  37. data/lib/morpheus/cli/remote.rb +7 -8
  38. data/lib/morpheus/cli/storage_providers_command.rb +6 -16
  39. data/lib/morpheus/cli/tasks.rb +4 -12
  40. data/lib/morpheus/cli/user_groups_command.rb +7 -25
  41. data/lib/morpheus/cli/user_sources_command.rb +9 -21
  42. data/lib/morpheus/cli/users.rb +6 -17
  43. data/lib/morpheus/cli/version.rb +1 -1
  44. data/lib/morpheus/cli/workflows.rb +4 -12
  45. metadata +4 -2
@@ -44,19 +44,13 @@ class Morpheus::Cli::LoadBalancers
44
44
  end
45
45
  json_response = @load_balancers_interface.get(params)
46
46
  if options[:json]
47
- if options[:include_fields]
48
- json_response = {"loadBalancers" => filter_data(json_response["loadBalancers"], options[:include_fields]) }
49
- end
50
- puts as_json(json_response, options)
47
+ puts as_json(json_response, options, "loadBalancers")
51
48
  return 0
52
49
  elsif options[:csv]
53
50
  puts records_as_csv(json_response["loadBalancers"], options)
54
51
  return 0
55
52
  elsif options[:yaml]
56
- if options[:include_fields]
57
- json_response = {"loadBalancers" => filter_data(json_response["loadBalancers"], options[:include_fields]) }
58
- end
59
- puts as_yaml(json_response, options)
53
+ puts as_yaml(json_response, options, "loadBalancers")
60
54
  return 0
61
55
  else
62
56
  lbs = json_response['loadBalancers']
@@ -112,19 +106,13 @@ class Morpheus::Cli::LoadBalancers
112
106
  #puts "LB TYPE: #{lb_type}"
113
107
  if options[:json]
114
108
  puts JSON.pretty_generate({loadBalancer: lb})
115
- if options[:include_fields]
116
- json_response = {"loadBalancer" => filter_data(json_response["loadBalancer"], options[:include_fields]) }
117
- end
118
- puts as_json(json_response, options)
109
+ puts as_json(json_response, options, "loadBalancer")
119
110
  return 0
120
111
  elsif options[:csv]
121
112
  puts records_as_csv(json_response["loadBalancer"], options)
122
113
  return 0
123
114
  elsif options[:yaml]
124
- if options[:include_fields]
125
- json_response = {"loadBalancer" => filter_data(json_response["loadBalancer"], options[:include_fields]) }
126
- end
127
- puts as_yaml(json_response, options)
115
+ puts as_yaml(json_response, options, "loadBalancer")
128
116
  return 0
129
117
  else
130
118
  print_h1 "Load Balancer Details"
@@ -42,17 +42,14 @@ class Morpheus::Cli::MonitoringAppsCommand
42
42
  end
43
43
 
44
44
  json_response = @monitoring_interface.apps.list(params)
45
- if options[:include_fields]
46
- json_response = {"monitorApps" => filter_data(json_response["monitorApps"], options[:include_fields]) }
47
- end
48
45
  if options[:json]
49
- puts as_json(json_response, options)
46
+ puts as_json(json_response, options, "monitorApps")
50
47
  return 0
51
48
  elsif options[:csv]
52
49
  puts records_as_csv(json_response['monitorApps'], options)
53
50
  return 0
54
51
  elsif options[:yaml]
55
- puts as_yaml(json_response, options)
52
+ puts as_yaml(json_response, options, "monitorApps")
56
53
  return 0
57
54
  end
58
55
  monitor_apps = json_response['monitorApps']
@@ -117,14 +114,11 @@ class Morpheus::Cli::MonitoringAppsCommand
117
114
  end
118
115
  json_response = @monitoring_interface.apps.get(monitor_app['id'])
119
116
  monitor_app = json_response['monitorApp']
120
- if options[:include_fields]
121
- json_response = {"monitorApp" => filter_data(json_response["monitorApp"], options[:include_fields]) }
122
- end
123
117
  if options[:json]
124
- puts as_json(json_response, options)
118
+ puts as_json(json_response, options, "monitorApp")
125
119
  return 0
126
120
  elsif options[:yaml]
127
- puts as_yaml(json_response, options)
121
+ puts as_yaml(json_response, options, "monitorApp")
128
122
  return 0
129
123
  elsif options[:csv]
130
124
  puts records_as_csv([json_response['monitorApp']], options)
@@ -245,10 +239,7 @@ class Morpheus::Cli::MonitoringAppsCommand
245
239
 
246
240
  json_response = @monitoring_interface.apps.history(monitor_app['id'], params)
247
241
  if options[:json]
248
- if options[:include_fields]
249
- json_response = {"history" => filter_data(json_response["history"], options[:include_fields]) }
250
- end
251
- puts as_json(json_response, options)
242
+ puts as_json(json_response, options, "history")
252
243
  return 0
253
244
  end
254
245
  if options[:csv]
@@ -44,14 +44,11 @@ class Morpheus::Cli::MonitoringChecksCommand
44
44
  return
45
45
  end
46
46
  json_response = @monitoring_interface.checks.list(params)
47
- if options[:include_fields]
48
- json_response = {"checks" => filter_data(json_response["checks"], options[:include_fields]) }
49
- end
50
47
  if options[:json]
51
- puts as_json(json_response, options)
48
+ puts as_json(json_response, options, "checks")
52
49
  return 0
53
50
  elsif options[:yaml]
54
- puts as_yaml(json_response, options)
51
+ puts as_yaml(json_response, options, "checks")
55
52
  return 0
56
53
  elsif options[:csv]
57
54
  puts records_as_csv(json_response['checks'], options)
@@ -118,14 +115,11 @@ class Morpheus::Cli::MonitoringChecksCommand
118
115
  end
119
116
  json_response = @monitoring_interface.checks.get(check['id'])
120
117
  check = json_response['check']
121
- if options[:include_fields]
122
- json_response = {'check' => filter_data(check, options[:include_fields]) }
123
- end
124
118
  if options[:json]
125
- puts as_json(json_response, options)
119
+ puts as_json(json_response, options, 'check')
126
120
  return 0
127
121
  elsif options[:yaml]
128
- puts as_yaml(json_response, options)
122
+ puts as_yaml(json_response, options, 'check')
129
123
  return 0
130
124
  elsif options[:csv]
131
125
  puts records_as_csv([json_response['check']], options)
@@ -248,7 +242,7 @@ class Morpheus::Cli::MonitoringChecksCommand
248
242
  opts.on('--severity LIST', Array, "Filter by severity. critical, warning, info") do |list|
249
243
  params['severity'] = list
250
244
  end
251
- build_common_options(opts, options, [:list, :last_updated, :json, :csv, :fields, :json, :dry_run, :remote])
245
+ build_common_options(opts, options, [:list, :last_updated, :json, :yaml, :csv, :fields, :json, :dry_run, :remote])
252
246
  end
253
247
  optparse.parse!(args)
254
248
  if args.count < 1
@@ -272,10 +266,10 @@ class Morpheus::Cli::MonitoringChecksCommand
272
266
 
273
267
  json_response = @monitoring_interface.checks.history(check['id'], params)
274
268
  if options[:json]
275
- if options[:include_fields]
276
- json_response = {"history" => filter_data(json_response["history"], options[:include_fields]) }
277
- end
278
- puts as_json(json_response, options)
269
+ puts as_json(json_response, options, "history")
270
+ return 0
271
+ elsif options[:yaml]
272
+ puts as_yaml(json_response, options, "history")
279
273
  return 0
280
274
  end
281
275
  if options[:csv]
@@ -601,28 +595,14 @@ class Morpheus::Cli::MonitoringChecksCommand
601
595
  end
602
596
 
603
597
  json_response = @monitoring_interface.checks.list_check_types(params)
604
- if options[:include_fields]
605
- json_response = {"checkTypes" => filter_data(json_response["checkTypes"], options[:include_fields]) }
606
- end
607
598
  if options[:json]
608
- puts as_json(json_response, options)
609
- return 0
610
- elsif options[:csv]
611
- puts records_as_csv(json_response['monitorApps'], options)
599
+ puts as_json(json_response, options, "checkTypes")
612
600
  return 0
613
601
  elsif options[:yaml]
614
- puts as_yaml(json_response, options)
615
- return 0
616
- end
617
- if options[:json]
618
- if options[:include_fields]
619
- json_response = {"checkTypes" => filter_data(json_response["checkTypes"], options[:include_fields]) }
620
- end
621
- puts as_json(json_response, options)
602
+ puts as_yaml(json_response, options, "checkTypes")
622
603
  return 0
623
- end
624
- if options[:csv]
625
- puts records_as_csv(json_response['checkTypes'], options)
604
+ elsif options[:csv]
605
+ puts records_as_csv(json_response["checkTypes"], options)
626
606
  return 0
627
607
  end
628
608
  check_types = json_response['checkTypes']
@@ -34,7 +34,7 @@ class Morpheus::Cli::MonitoringContactsCommand
34
34
  params = {}
35
35
  optparse = OptionParser.new do|opts|
36
36
  opts.banner = subcommand_usage()
37
- build_common_options(opts, options, [:list, :json, :csv, :fields, :json, :dry_run])
37
+ build_common_options(opts, options, [:list, :json, :csv, :yaml, :fields, :json, :dry_run])
38
38
  end
39
39
  optparse.parse!(args)
40
40
  connect(options)
@@ -51,13 +51,12 @@ class Morpheus::Cli::MonitoringContactsCommand
51
51
 
52
52
  json_response = @monitoring_interface.contacts.list(params)
53
53
  if options[:json]
54
- if options[:include_fields]
55
- json_response = {"contacts" => filter_data(json_response["contacts"], options[:include_fields]) }
56
- end
57
- puts as_json(json_response, options)
54
+ puts as_json(json_response, options, "contacts")
58
55
  return 0
59
- end
60
- if options[:csv]
56
+ elsif options[:yaml]
57
+ puts as_json(json_response, options, "contacts")
58
+ return 0
59
+ elsif options[:csv]
61
60
  puts records_as_csv(json_response['contacts'], options)
62
61
  return 0
63
62
  end
@@ -117,10 +116,10 @@ class Morpheus::Cli::MonitoringContactsCommand
117
116
  contact = json_response['contact']
118
117
 
119
118
  if options[:json]
120
- if options[:include_fields]
121
- json_response = {"contact" => filter_data(json_response["contact"], options[:include_fields]) }
122
- end
123
- puts as_json(json_response, options)
119
+ puts as_json(json_response, options, "contact")
120
+ return 0
121
+ elsif options[:yaml]
122
+ puts as_yaml(json_response, options, "contact")
124
123
  return 0
125
124
  elsif options[:csv]
126
125
  puts records_as_csv([json_response['contact']], options)
@@ -31,9 +31,8 @@ class Morpheus::Cli::MonitoringGroupsCommand
31
31
  optparse.parse!(args)
32
32
  connect(options)
33
33
  begin
34
- [:phrase, :offset, :max, :sort, :direction, :lastUpdated].each do |k|
35
- params[k] = options[k] unless options[k].nil?
36
- end
34
+ # construct payload
35
+ params.merge!(parse_list_options(options))
37
36
 
38
37
  if options[:dry_run]
39
38
  print_dry_run @monitoring_interface.groups.dry.list(params)
@@ -41,31 +40,21 @@ class Morpheus::Cli::MonitoringGroupsCommand
41
40
  end
42
41
 
43
42
  json_response = @monitoring_interface.groups.list(params)
44
- if options[:include_fields]
45
- json_response = {"checkGroups" => filter_data(json_response["checkGroups"], options[:include_fields]) }
46
- end
43
+
47
44
  if options[:json]
48
- puts as_json(json_response, options)
45
+ puts as_json(json_response, options, "checkGroups")
49
46
  return 0
50
47
  elsif options[:csv]
51
48
  puts records_as_csv(json_response['checkGroups'], options)
52
49
  return 0
53
50
  elsif options[:yaml]
54
- puts as_yaml(json_response, options)
51
+ puts as_yaml(json_response, options, "checkGroups")
55
52
  return 0
56
53
  end
57
54
  check_groups = json_response['checkGroups']
58
55
  title = "Morpheus Monitoring Check Groups"
59
56
  subtitles = []
60
- # if group
61
- # subtitles << "Group: #{group['name']}".strip
62
- # end
63
- # if cloud
64
- # subtitles << "Cloud: #{cloud['name']}".strip
65
- # end
66
- if params[:phrase]
67
- subtitles << "Search: #{params[:phrase]}".strip
68
- end
57
+ subtitles += parse_list_subtitles(options)
69
58
  print_h1 title, subtitles
70
59
  if check_groups.empty?
71
60
  print cyan,"No check groups found.",reset,"\n"
@@ -116,14 +105,11 @@ class Morpheus::Cli::MonitoringGroupsCommand
116
105
  end
117
106
  json_response = @monitoring_interface.groups.get(check_group['id'])
118
107
  check_group = json_response['checkGroup']
119
- if options[:include_fields]
120
- json_response = {"checkGroup" => filter_data(json_response["checkGroup"], options[:include_fields]) }
121
- end
122
108
  if options[:json]
123
- puts as_json(json_response, options)
109
+ puts as_json(json_response, options, "checkGroup")
124
110
  return 0
125
111
  elsif options[:yaml]
126
- puts as_yaml(json_response, options)
112
+ puts as_yaml(json_response, options, "checkGroup")
127
113
  return 0
128
114
  elsif options[:csv]
129
115
  puts records_as_csv([json_response['checkGroup']], options)
@@ -227,10 +213,8 @@ class Morpheus::Cli::MonitoringGroupsCommand
227
213
  check_group = find_check_group_by_name_or_id(args[0])
228
214
  return 1 if check_group.nil?
229
215
 
230
- [:phrase, :offset, :max, :sort, :direction, :lastUpdated].each do |k|
231
- params[k] = options[k] unless options[k].nil?
232
- end
233
- # JD: lastUpdated 500ing, checks don't have that property ? =o Fix it!
216
+ # construct payload
217
+ params.merge!(parse_list_options(options))
234
218
 
235
219
  if options[:dry_run]
236
220
  print_dry_run @monitoring_interface.groups.dry.history(check_group['id'], params)
@@ -239,22 +223,19 @@ class Morpheus::Cli::MonitoringGroupsCommand
239
223
 
240
224
  json_response = @monitoring_interface.groups.history(check_group['id'], params)
241
225
  if options[:json]
242
- if options[:include_fields]
243
- json_response = {"history" => filter_data(json_response["history"], options[:include_fields]) }
244
- end
245
- puts as_json(json_response, options)
226
+ puts as_json(json_response, options, "history")
246
227
  return 0
247
- end
248
- if options[:csv]
249
- puts records_as_csv(json_response['history'], options)
228
+ elsif options[:csv]
229
+ puts records_as_csv(json_response["history"], options)
230
+ return 0
231
+ elsif options[:yaml]
232
+ puts as_yaml(json_response, options, "history")
250
233
  return 0
251
234
  end
252
- history_items = json_response['history']
253
- title = "Check Group History: #{check_group['id']}: #{check_group['displayName'] || check_group['name']}"
235
+ history_items = json_response["history"]
236
+ title = "Check Group History - [#{check_group['id']}] #{check_group['displayName'] || check_group['name']}"
254
237
  subtitles = []
255
- if params[:phrase]
256
- subtitles << "Search: #{params[:phrase]}".strip
257
- end
238
+ subtitles += parse_list_subtitles(options)
258
239
  print_h1 title, subtitles
259
240
  if history_items.empty?
260
241
  print cyan,"No history found.",reset,"\n"
@@ -33,39 +33,26 @@ class Morpheus::Cli::MonitoringIncidentsCommand
33
33
  optparse.parse!(args)
34
34
  connect(options)
35
35
  begin
36
- [:phrase, :offset, :max, :sort, :direction, :lastUpdated].each do |k|
37
- params[k] = options[k] unless options[k].nil?
38
- end
36
+ params.merge!(parse_list_options(options))
39
37
  if options[:dry_run]
40
38
  print_dry_run @monitoring_interface.incidents.dry.list(params)
41
39
  return
42
40
  end
43
41
  json_response = @monitoring_interface.incidents.list(params)
44
- if options[:include_fields]
45
- json_response = {"incidents" => filter_data(json_response["incidents"], options[:include_fields]) }
46
- end
47
42
  if options[:json]
48
- puts as_json(json_response, options)
49
- return 0
50
- elsif options[:yaml]
51
- puts as_yaml(json_response, options)
43
+ puts as_json(json_response, options, "incidents")
52
44
  return 0
53
45
  elsif options[:csv]
54
46
  puts records_as_csv(json_response['incidents'], options)
55
47
  return 0
48
+ elsif options[:yaml]
49
+ puts as_yaml(json_response, options, "incidents")
50
+ return 0
56
51
  end
57
52
  incidents = json_response['incidents']
58
53
  title = "Morpheus Monitoring Incidents"
59
54
  subtitles = []
60
- # if group
61
- # subtitles << "Group: #{group['name']}".strip
62
- # end
63
- # if cloud
64
- # subtitles << "Cloud: #{cloud['name']}".strip
65
- # end
66
- if params[:phrase]
67
- subtitles << "Search: #{params[:phrase]}".strip
68
- end
55
+ subtitles += parse_list_subtitles(options)
69
56
  print_h1 title, subtitles
70
57
  if incidents.empty?
71
58
  print cyan,"No incidents found.",reset,"\n"
@@ -104,25 +91,23 @@ class Morpheus::Cli::MonitoringIncidentsCommand
104
91
  connect(options)
105
92
  begin
106
93
  params = {}
107
- [:phrase, :offset, :max, :sort, :direction, :lastUpdated].each do |k|
108
- params[k] = options[k] unless options[k].nil?
109
- end
94
+ params.merge!(parse_list_options(options))
110
95
  if options[:dry_run]
111
96
  print_dry_run @monitoring_interface.incidents.dry.stats(params)
112
97
  return
113
98
  end
114
99
  json_response = @monitoring_interface.incidents.stats(params)
115
100
  if options[:json]
116
- if options[:include_fields]
117
- json_response.merge!({"openIncidents" => filter_data(json_response["openIncidents"], options[:include_fields])})
118
- end
119
- puts as_json(json_response, options)
101
+ puts as_json(json_response, options, "openIncidents")
102
+ return 0
103
+ elsif options[:csv]
104
+ puts records_as_csv(json_response['openIncidents'], options)
105
+ return 0
106
+ elsif options[:yaml]
107
+ puts as_yaml(json_response, options, "openIncidents")
120
108
  return 0
121
109
  end
122
- # if options[:csv]
123
- # puts records_as_csv(json_response['openIncidents'], options)
124
- # return 0
125
- # end
110
+
126
111
  open_incidents = json_response['openIncidents']
127
112
  open_incidents_count = json_response['openIncidentCount']
128
113
  stats = json_response['incidentStats']
@@ -205,17 +190,14 @@ class Morpheus::Cli::MonitoringIncidentsCommand
205
190
  json_response = @monitoring_interface.incidents.get(incident['id'])
206
191
  incident = json_response['incident']
207
192
 
208
- if options[:include_fields]
209
- json_response = {"incident" => filter_data(json_response["incident"], options[:include_fields]) }
210
- end
211
193
  if options[:json]
212
- puts as_json(json_response, options)
213
- return 0
214
- elsif options[:yaml]
215
- puts as_yaml(json_response, options)
194
+ puts as_json(json_response, options, "incident")
216
195
  return 0
217
196
  elsif options[:csv]
218
- puts records_as_csv(json_response['incident'], options)
197
+ puts records_as_csv([json_response['incident']], options)
198
+ return 0
199
+ elsif options[:yaml]
200
+ puts as_yaml(json_response, options, "incident")
219
201
  return 0
220
202
  end
221
203
 
@@ -303,7 +285,7 @@ class Morpheus::Cli::MonitoringIncidentsCommand
303
285
  opts.on('--severity LIST', Array, "Filter by severity. critical, warning, info") do |list|
304
286
  params['severity'] = list
305
287
  end
306
- build_common_options(opts, options, [:list, :last_updated, :json, :csv, :fields, :json, :dry_run, :remote])
288
+ build_common_options(opts, options, [:list, :last_updated, :json, :csv, :yaml, :fields, :json, :dry_run, :remote])
307
289
  end
308
290
  optparse.parse!(args)
309
291
  if args.count < 1
@@ -313,12 +295,9 @@ class Morpheus::Cli::MonitoringIncidentsCommand
313
295
  connect(options)
314
296
  begin
315
297
  incident = find_incident_by_id(args[0])
316
- # return false if incident.nil?
298
+ return 1 if incident.nil?
317
299
 
318
- [:phrase, :offset, :max, :sort, :direction, :lastUpdated].each do |k|
319
- params[k] = options[k] unless options[k].nil?
320
- end
321
- # JD: lastUpdated 500ing, incidents don't have that property ? =o Fix it!
300
+ params.merge!(parse_list_options(options))
322
301
 
323
302
  if options[:dry_run]
324
303
  print_dry_run @monitoring_interface.incidents.dry.history(incident['id'], params)
@@ -327,22 +306,19 @@ class Morpheus::Cli::MonitoringIncidentsCommand
327
306
 
328
307
  json_response = @monitoring_interface.incidents.history(incident['id'], params)
329
308
  if options[:json]
330
- if options[:include_fields]
331
- json_response = {"history" => filter_data(json_response["history"], options[:include_fields]) }
332
- end
333
- puts as_json(json_response, options)
309
+ puts as_json(json_response, options, "history")
334
310
  return 0
335
- end
336
- if options[:csv]
311
+ elsif options[:csv]
337
312
  puts records_as_csv(json_response['history'], options)
338
313
  return 0
314
+ elsif options[:yaml]
315
+ puts as_yaml(json_response, options, "history")
316
+ return 0
339
317
  end
340
318
  history_items = json_response['history']
341
319
  title = "Incident History: #{incident['id']}: #{incident['displayName'] || incident['name']}"
342
320
  subtitles = []
343
- if params[:phrase]
344
- subtitles << "Search: #{params[:phrase]}".strip
345
- end
321
+ subtitles += parse_list_subtitles(options)
346
322
  print_h1 title, subtitles
347
323
  if history_items.empty?
348
324
  print cyan,"No history found.",reset,"\n"
@@ -361,7 +337,7 @@ class Morpheus::Cli::MonitoringIncidentsCommand
361
337
  options = {}
362
338
  optparse = OptionParser.new do|opts|
363
339
  opts.banner = subcommand_usage("[id] [options]")
364
- build_common_options(opts, options, [:list, :json, :csv, :fields, :json, :dry_run, :remote])
340
+ build_common_options(opts, options, [:list, :json, :csv, :yaml, :fields, :json, :dry_run, :remote])
365
341
  end
366
342
  optparse.parse!(args)
367
343
  if args.count < 1
@@ -373,9 +349,7 @@ class Morpheus::Cli::MonitoringIncidentsCommand
373
349
  incident = find_incident_by_id(args[0])
374
350
  # return false if incident.nil?
375
351
  params = {}
376
- [:phrase, :offset, :max, :sort, :direction].each do |k|
377
- params[k] = options[k] unless options[k].nil?
378
- end
352
+ params.merge!(parse_list_options(options))
379
353
 
380
354
  if options[:dry_run]
381
355
  print_dry_run @monitoring_interface.incidents.dry.notifications(incident['id'], params)
@@ -384,22 +358,19 @@ class Morpheus::Cli::MonitoringIncidentsCommand
384
358
 
385
359
  json_response = @monitoring_interface.incidents.notifications(incident['id'], params)
386
360
  if options[:json]
387
- if options[:include_fields]
388
- json_response = {"notifications" => filter_data(json_response["notifications"], options[:include_fields]) }
389
- end
390
- puts as_json(json_response, options)
361
+ puts as_json(json_response, options, "notifications")
391
362
  return 0
392
- end
393
- if options[:csv]
363
+ elsif options[:csv]
394
364
  puts records_as_csv(json_response['notifications'], options)
395
365
  return 0
366
+ elsif options[:yaml]
367
+ puts as_yaml(json_response, options, "notifications")
368
+ return 0
396
369
  end
397
370
  notification_items = json_response['notifications']
398
371
  title = "Incident Notifications: #{incident['id']}: #{incident['displayName'] || incident['name']}"
399
372
  subtitles = []
400
- if params[:phrase]
401
- subtitles << "Search: #{params[:phrase]}".strip
402
- end
373
+ subtitles += parse_list_subtitles(options)
403
374
  print_h1 title, subtitles
404
375
  if notification_items.empty?
405
376
  print cyan,"No notifications found.",reset,"\n"