morpheus-cli 5.2.4 → 5.2.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3798eb711a94541135bbefd28bbf1b33db18460ab70d7caf4d6f1cde90dafed3
4
- data.tar.gz: b24f15db530f004a00899a86d8c609ee5dc44e71ee7b69cc821e33f91070b4f1
3
+ metadata.gz: 37c9d87f1bfe67cebd9a25486613f11f221f5600a3fc888f58f073c97c12a656
4
+ data.tar.gz: d1cbd8a33bea8749c042c3a3557760566102a24c8ddb54f7c4e5c0f833445504
5
5
  SHA512:
6
- metadata.gz: 165402498f461633ca18f4fd273e27cc5dcf7fddfd219722912563ea1c318a4412b9f6c6f5a014382e14bac1bfa060ffb4a794b72182739e57c1299ce685e7d2
7
- data.tar.gz: 2305c2c67c28e206c9507abda3a95b2e62dadb0a6e73e44fd4b79a4feaa40f40fe713e47619f0383a30dfca22828ff439446063e5e7417746b658b08ced63804
6
+ metadata.gz: 2d47d04efd457d117b30d3909707924f3215e5d7196692a9b4f6e2d83f553d6b0a78b8a07b03e2350f8ff0750c64c9265a4c58c496eab71901c89ac9cfc0cc58
7
+ data.tar.gz: fd8d5788f2288369735015854a5a6d469887d5624c8fe5fb212f077f54e15033397164f85c932883029f20f813296366fbe374855a7fd53461a58a022c384629
data/README.md CHANGED
@@ -1,12 +1,12 @@
1
+ <img src="https://morpheusdata.com/wp-content/uploads/2020/04/morpheus-logo-v2.svg" width="200px">
2
+
1
3
  # Morpheus CLI
2
4
 
3
5
  - Website: https://www.morpheusdata.com/
4
6
  - Guide: [Morpheus CLI Wiki](https://github.com/gomorpheus/morpheus-cli/wiki)
5
- - Docs: [Morpheus Documentation](https://docs.morpheusdata.com)
7
+ - Docs: [Morpheus CLI Documentation](https://clidocs.morpheusdata.com)
6
8
  - Support: [Morpheus Support](https://support.morpheusdata.com)
7
9
 
8
- <img src="https://www.morpheusdata.com/wp-content/uploads/2018/06/cropped-morpheus_highres.png" width="600px">
9
-
10
10
  This library is a Ruby gem that provides a command line interface for interacting with the Morpheus Data appliance. The features provided include provisioning clusters, hosts, and containers, deploying and monitoring applications, automating tasks, and much more.
11
11
 
12
12
  ## Installation
@@ -10,7 +10,7 @@ class Morpheus::Cli::BackupJobsCommand
10
10
 
11
11
  set_command_name :'backup-jobs'
12
12
 
13
- register_subcommands :list, :get, :add, :update, :remove, :run
13
+ register_subcommands :list, :get #, :add, :update, :remove, :run
14
14
 
15
15
  def connect(opts)
16
16
  @api_client = establish_remote_appliance_connection(opts)
@@ -10,7 +10,7 @@ class Morpheus::Cli::BackupsCommand
10
10
 
11
11
  set_command_name :'backups'
12
12
 
13
- register_subcommands :list, :get, :add, :update, :remove, :run, :restore
13
+ register_subcommands :list, :get #, :add, :update, :remove, :run, :restore
14
14
 
15
15
  def connect(opts)
16
16
  @api_client = establish_remote_appliance_connection(opts)
@@ -82,8 +82,7 @@ EOT
82
82
  end
83
83
  end
84
84
 
85
- def _get(id, options)
86
- params = {}
85
+ def _get(id, params, options)
87
86
  @backups_interface.setopts(options)
88
87
  if options[:dry_run]
89
88
  print_dry_run @backups_interface.dry.get(id, params)
@@ -466,11 +466,16 @@ module Morpheus
466
466
 
467
467
  when :list
468
468
  opts.on( '-m', '--max MAX', "Max Results" ) do |val|
469
- max = val.to_i
470
- if max <= 0
471
- raise ::OptionParser::InvalidArgument.new("must be a positive integer")
469
+ # api supports max=-1 for all at the moment..
470
+ if val.to_s == "all" || val.to_s == "-1"
471
+ options[:max] = "-1"
472
+ else
473
+ max = val.to_i
474
+ if max <= 0
475
+ raise ::OptionParser::InvalidArgument.new("must be a positive integer")
476
+ end
477
+ options[:max] = max
472
478
  end
473
- options[:max] = max
474
479
  end
475
480
 
476
481
  opts.on( '-o', '--offset OFFSET', "Offset Results" ) do |val|
@@ -486,12 +491,17 @@ module Morpheus
486
491
  end
487
492
 
488
493
  opts.on( '-S', '--sort ORDER', "Sort Order. DIRECTION may be included as \"ORDER [asc|desc]\"." ) do |v|
489
- v_parts = v.to_s.split(" ")
490
- if v_parts.size > 1
491
- options[:sort] = v_parts[0]
492
- options[:direction] = (v_parts[1].strip == "desc") ? "desc" : "asc"
493
- else
494
+ if v.to_s.include?(",")
495
+ # sorting on multiple properties, just pass it as is, newer api supports multiple fields
494
496
  options[:sort] = v
497
+ else
498
+ v_parts = v.to_s.split(" ")
499
+ if v_parts.size > 1
500
+ options[:sort] = v_parts[0]
501
+ options[:direction] = (v_parts[1].strip == "desc") ? "desc" : "asc"
502
+ else
503
+ options[:sort] = v
504
+ end
495
505
  end
496
506
  end
497
507
 
@@ -33,7 +33,6 @@ class Morpheus::Cli::InvoicesCommand
33
33
  options[:show_estimates] = true
34
34
  # options[:show_costs] = true
35
35
  options[:show_prices] = true
36
- # options[:show_raw_data] = true
37
36
  end
38
37
  opts.on('--dates', "Display Ref Start, Ref End, etc.") do |val|
39
38
  options[:show_dates] = true
@@ -117,9 +116,6 @@ class Morpheus::Cli::InvoicesCommand
117
116
  options[:tags][k] << (v || '')
118
117
  end
119
118
  end
120
- opts.on('--raw-data', '--raw-data', "Display Raw Data, the cost data from the cloud provider's API.") do |val|
121
- options[:show_raw_data] = true
122
- end
123
119
  opts.on('--totals', "View total costs and prices for all the invoices found.") do |val|
124
120
  params['includeTotals'] = true
125
121
  options[:show_invoice_totals] = true
@@ -173,7 +169,6 @@ class Morpheus::Cli::InvoicesCommand
173
169
  return 1, "projects not found for #{options[:projects]}" if project_ids.nil?
174
170
  params['projectId'] = project_ids
175
171
  end
176
- params['rawData'] = true if options[:show_raw_data]
177
172
  params['refId'] = ref_ids unless ref_ids.empty?
178
173
  if options[:tags] && !options[:tags].empty?
179
174
  options[:tags].each do |k,v|
@@ -271,7 +266,7 @@ class Morpheus::Cli::InvoicesCommand
271
266
  columns += [
272
267
  {"ESTIMATE" => lambda {|it| format_boolean(it['estimate']) } },
273
268
  {"ACTIVE" => lambda {|it| format_boolean(it['active']) } },
274
- {"ITEMS" => lambda {|it| it['lineItems'].size rescue '' } },
269
+ {"ITEMS" => lambda {|it| (it['lineItemCount'] ? it['lineItemCount'] : it['lineItems'].size) rescue '' } },
275
270
  {"TAGS" => lambda {|it| (it['metadata'] || it['tags']) ? (it['metadata'] || it['tags']).collect {|m| "#{m['name']}: #{m['value']}" }.join(', ') : '' } },
276
271
  ]
277
272
  if show_projects
@@ -291,9 +286,6 @@ class Morpheus::Cli::InvoicesCommand
291
286
  {"CREATED" => lambda {|it| format_local_dt(it['dateCreated']) } },
292
287
  {"UPDATED" => lambda {|it| format_local_dt(it['lastUpdated']) } },
293
288
  ]
294
- if options[:show_raw_data]
295
- columns += [{"RAW DATA" => lambda {|it| truncate_string(it['rawData'].to_s, 10) } }]
296
- end
297
289
  unless options[:totals_only]
298
290
  print as_pretty_table(invoices, columns, options)
299
291
  print_results_pagination(json_response, {:label => "invoice", :n_label => "invoices"})
@@ -361,7 +353,6 @@ class Morpheus::Cli::InvoicesCommand
361
353
  options[:show_estimates] = true
362
354
  # options[:show_costs] = true
363
355
  options[:show_prices] = true
364
- # options[:show_raw_data] = true
365
356
  options[:max_line_items] = 10000
366
357
  end
367
358
  opts.on('--prices', '--prices', "Display prices: Total, Compute, Storage, Network, Extra" ) do
@@ -370,13 +361,6 @@ class Morpheus::Cli::InvoicesCommand
370
361
  opts.on('--estimates', '--estimates', "Display all estimated costs, from usage info: Compute, Storage, Network, Extra" ) do
371
362
  options[:show_estimates] = true
372
363
  end
373
- opts.on('--raw-data', '--raw-data', "Display Raw Data, the cost data from the cloud provider's API.") do |val|
374
- options[:show_raw_data] = true
375
- end
376
- opts.on('--pretty-raw-data', '--raw-data', "Display Raw Data that is a bit more pretty") do |val|
377
- options[:show_raw_data] = true
378
- options[:pretty_json] = true
379
- end
380
364
  opts.on('--no-line-items', '--no-line-items', "Do not display line items.") do |val|
381
365
  options[:hide_line_items] = true
382
366
  end
@@ -401,9 +385,6 @@ EOT
401
385
 
402
386
  def _get(id, options)
403
387
  params = {}
404
- if options[:show_raw_data]
405
- params['rawData'] = true
406
- end
407
388
  begin
408
389
  @invoices_interface.setopts(options)
409
390
  if options[:dry_run]
@@ -412,6 +393,9 @@ EOT
412
393
  end
413
394
  json_response = @invoices_interface.get(id, params)
414
395
  invoice = json_response['invoice']
396
+ if options[:hide_line_items]
397
+ json_response['invoice'].delete('lineItems') rescue nil
398
+ end
415
399
  render_result = render_with_format(json_response, options, 'invoice')
416
400
  return 0 if render_result
417
401
 
@@ -437,7 +421,7 @@ EOT
437
421
  "End" => lambda {|it| format_date(it['endDate']) },
438
422
  "Ref Start" => lambda {|it| format_dt(it['refStart']) },
439
423
  "Ref End" => lambda {|it| format_dt(it['refEnd']) },
440
- "Items" => lambda {|it| it['lineItems'].size rescue '' },
424
+ "Items" => lambda {|it| (it['lineItemCount'] ? it['lineItemCount'] : it['lineItems'].size) rescue '' },
441
425
  "Tags" => lambda {|it| (it['metadata'] || it['tags']) ? (it['metadata'] || it['tags']).collect {|m| "#{m['name']}: #{m['value']}" }.join(', ') : '' },
442
426
  "Project ID" => lambda {|it| it['project'] ? it['project']['id'] : '' },
443
427
  "Project Name" => lambda {|it| it['project'] ? it['project']['name'] : '' },
@@ -523,9 +507,6 @@ EOT
523
507
  {"CREATED" => lambda {|it| format_local_dt(it['dateCreated']) } },
524
508
  {"UPDATED" => lambda {|it| format_local_dt(it['lastUpdated']) } }
525
509
  ]
526
- if options[:show_raw_data]
527
- line_items_columns += [{"RAW DATA" => lambda {|it| truncate_string(it['rawData'].to_s, 10) } }]
528
- end
529
510
  print_h2 "Line Items"
530
511
  #max_line_items = options[:max_line_items] ? options[:max_line_items].to_i : 5
531
512
  paged_line_items = line_items #.first(max_line_items)
@@ -578,10 +559,7 @@ EOT
578
559
  end
579
560
  print as_pretty_table(cost_rows, cost_columns, options)
580
561
 
581
- if options[:show_raw_data]
582
- print_h2 "Raw Data"
583
- puts as_json(invoice['rawData'], {pretty_json:false}.merge(options))
584
- end
562
+
585
563
 
586
564
  print reset,"\n"
587
565
  return 0
@@ -740,7 +718,6 @@ EOT
740
718
  options[:show_actual_costs] = true
741
719
  options[:show_costs] = true
742
720
  options[:show_prices] = true
743
- # options[:show_raw_data] = true
744
721
  end
745
722
  # opts.on('--actuals', '--actuals', "Display all actual costs: Compute, Storage, Network, Extra" ) do
746
723
  # options[:show_actual_costs] = true
@@ -829,9 +806,6 @@ EOT
829
806
  options[:tags][k] << (v || '')
830
807
  end
831
808
  end
832
- opts.on('--raw-data', '--raw-data', "Display Raw Data, the cost data from the cloud provider's API.") do |val|
833
- options[:show_raw_data] = true
834
- end
835
809
  opts.on('--totals', "View total costs and prices for all the invoices found.") do |val|
836
810
  params['includeTotals'] = true
837
811
  options[:show_invoice_totals] = true
@@ -886,7 +860,6 @@ EOT
886
860
  return 1, "projects not found for #{options[:projects]}" if project_ids.nil?
887
861
  params['projectId'] = project_ids
888
862
  end
889
- params['rawData'] = true if options[:show_raw_data]
890
863
  params['refId'] = ref_ids unless ref_ids.empty?
891
864
  if options[:tags] && !options[:tags].empty?
892
865
  options[:tags].each do |k,v|
@@ -944,9 +917,6 @@ EOT
944
917
  "UPDATED" => lambda {|it| format_local_dt(it['lastUpdated']) }
945
918
  ]
946
919
 
947
- if options[:show_raw_data]
948
- columns += [{"RAW DATA" => lambda {|it| truncate_string(it['rawData'].to_s, 10) } }]
949
- end
950
920
  # if options[:show_invoice_totals]
951
921
  # line_item_totals = json_response['lineItemTotals']
952
922
  # if line_item_totals
@@ -995,13 +965,6 @@ EOT
995
965
  options = {}
996
966
  optparse = Morpheus::Cli::OptionParser.new do |opts|
997
967
  opts.banner = subcommand_usage("[id]")
998
- opts.on('--raw-data', '--raw-data', "Display Raw Data, the cost data from the cloud provider's API.") do |val|
999
- options[:show_raw_data] = true
1000
- end
1001
- opts.on('--pretty-raw-data', '--raw-data', "Display Raw Data that is a bit more pretty") do |val|
1002
- options[:show_raw_data] = true
1003
- options[:pretty_json] = true
1004
- end
1005
968
  opts.on('--sigdig DIGITS', "Significant digits when rounding cost values for display as currency. Default is 2. eg. $3.50") do |val|
1006
969
  options[:sigdig] = val.to_i
1007
970
  end
@@ -1023,9 +986,6 @@ EOT
1023
986
 
1024
987
  def _get_line_item(id, options)
1025
988
  params = {}
1026
- if options[:show_raw_data]
1027
- params['rawData'] = true
1028
- end
1029
989
  @invoice_line_items_interface.setopts(options)
1030
990
  if options[:dry_run]
1031
991
  print_dry_run @invoice_line_items_interface.dry.get(id, params)
@@ -1063,11 +1023,6 @@ EOT
1063
1023
  }
1064
1024
  print_description_list(description_cols, line_item, options)
1065
1025
 
1066
- if options[:show_raw_data]
1067
- print_h2 "Raw Data"
1068
- puts as_json(line_item['rawData'], {pretty_json:false}.merge(options))
1069
- end
1070
-
1071
1026
  print reset,"\n"
1072
1027
  end
1073
1028
  return 0, nil
@@ -6,6 +6,7 @@ class Morpheus::Cli::UserSourcesCommand
6
6
  include Morpheus::Cli::AccountsHelper
7
7
 
8
8
  set_command_name :'user-sources'
9
+ set_command_description "View and manage user identity sources"
9
10
 
10
11
  register_subcommands :list, :get, :add, :update, :remove
11
12
  register_subcommands :activate, :deactivate
@@ -43,49 +44,32 @@ class Morpheus::Cli::UserSourcesCommand
43
44
  account_id = val
44
45
  end
45
46
  opts.add_hidden_option('-a, --account') if opts.is_a?(Morpheus::Cli::OptionParser)
46
- # opts.on('--technology VALUE', String, "Filter by technology") do |val|
47
- # params['provisionType'] = val
48
- # end
49
- build_common_options(opts, options, [:list, :query, :json, :yaml, :csv, :fields, :dry_run, :remote])
50
- opts.footer = "List user sources."
47
+ build_standard_list_options(opts, options)
48
+ opts.footer = "List identity sources."
51
49
  end
52
50
  optparse.parse!(args)
53
51
  connect(options)
54
- # instance is required right now.
55
- # account_id = args[0] if !account_id
52
+ # verify_args!(args:args, optparse:optparse, count:0)
56
53
  if args.count > 0
57
- print_error Morpheus::Terminal.angry_prompt
58
- puts_error "wrong number of arguments, expected 1 and got (#{args.count}) #{args.inspect}\n#{optparse}"
59
- return 1
54
+ options[:phrase] = args.join(" ")
60
55
  end
61
- begin
62
- # construct payload
63
- if account_id
64
- account = find_account_by_name_or_id(account_id)
65
- return 1 if account.nil?
66
- account_id = account['id']
67
- end
68
-
69
- params.merge!(parse_list_options(options))
70
- @user_sources_interface.setopts(options)
71
- if options[:dry_run]
72
- print_dry_run @user_sources_interface.dry.list(account_id, params)
73
- return
74
- end
75
-
76
- json_response = @user_sources_interface.list(account_id, params)
77
- if options[:json]
78
- puts as_json(json_response, options, "userSources")
79
- return 0
80
- elsif options[:csv]
81
- puts records_as_csv(json_response['userSources'], options)
82
- return 0
83
- elsif options[:yaml]
84
- puts as_yaml(json_response, options, "userSources")
85
- return 0
56
+ if account_id
57
+ account = find_account_by_name_or_id(account_id)
58
+ if account.nil?
59
+ return 1, "Tenant not found for '#{account_id}'"
86
60
  end
87
- user_sources = json_response['userSources']
88
- title = "Morpheus User Sources"
61
+ account_id = account['id']
62
+ end
63
+ params.merge!(parse_list_options(options))
64
+ @user_sources_interface.setopts(options)
65
+ if options[:dry_run]
66
+ print_dry_run @user_sources_interface.dry.list(account_id, params)
67
+ return 0, nil
68
+ end
69
+ json_response = @user_sources_interface.list(account_id, params)
70
+ render_response(json_response, options, "userSources") do
71
+ user_sources = json_response["userSources"]
72
+ title = "Morpheus Identity Sources"
89
73
  subtitles = []
90
74
  if account
91
75
  subtitles << "Tenant: #{account['name']}".strip
@@ -93,82 +77,77 @@ class Morpheus::Cli::UserSourcesCommand
93
77
  subtitles += parse_list_subtitles(options)
94
78
  print_h1 title, subtitles
95
79
  if user_sources.empty?
96
- if account
97
- print cyan,"No user sources found for account #{account['name']}.",reset,"\n"
98
- else
99
- print cyan,"No user sources found.",reset,"\n"
100
- end
80
+ print cyan,"No identity sources found.",reset,"\n"
101
81
  else
102
82
  print_user_sources_table(user_sources, options)
103
- print_results_pagination(json_response, {:label => "user source", :n_label => "user sources"})
83
+ print_results_pagination(json_response)
104
84
  end
105
85
  print reset,"\n"
106
- rescue RestClient::Exception => e
107
- print_rest_exception(e, options)
108
- return 1
109
86
  end
87
+ return 0, nil
88
+
110
89
  end
111
90
 
112
91
  def get(args)
113
- options = {}
114
92
  params = {}
93
+ options = {}
115
94
  optparse = Morpheus::Cli::OptionParser.new do |opts|
116
95
  opts.banner = subcommand_usage("[name]")
117
- build_common_options(opts, options, [:json, :yaml, :csv, :fields, :dry_run, :remote])
118
- opts.footer = "Get details about an user source." + "\n" +
119
- "[name] is required. This is the name or id of an user source."
96
+ # opts.on( '-c', '--config', "Display raw config only. Default is YAML. Combine with -j for JSON instead." ) do
97
+ # options[:show_config] = true
98
+ # end
99
+ # opts.on('--no-config', "Do not display Config YAML." ) do
100
+ # options[:no_config] = true
101
+ # end
102
+ build_standard_get_options(opts, options)
103
+ opts.footer = <<-EOT
104
+ Get details about an identity source.
105
+ [name] is required. This is the name or id of an identity source.
106
+ EOT
120
107
  end
121
108
  optparse.parse!(args)
109
+ verify_args!(args:args, optparse:optparse, min:1)
122
110
  connect(options)
123
- if args.count != 1
124
- print_error Morpheus::Terminal.angry_prompt
125
- puts_error "wrong number of arguments, expected 1 and got (#{args.count}) #{args.inspect}\n#{optparse}"
126
- return 1
111
+ id_list = parse_id_list(args)
112
+ return run_command_for_each_arg(id_list) do |arg|
113
+ _get(arg, params, options)
127
114
  end
115
+ end
116
+
117
+ def _get(user_source_id, params, options)
128
118
  account_id = nil
129
119
  account = nil
130
- user_source_id = args[0]
131
120
  # account_id = args[0]
132
121
  # account = find_account_by_name_or_id(account_id)
133
122
  # exit 1 if account.nil?
134
123
  # account_id = account['id']
135
124
  # user_source_id = args[1]
136
- begin
137
- @user_sources_interface.setopts(options)
138
- if options[:dry_run]
139
- if user_source_id.to_s =~ /\A\d{1,}\Z/
140
- print_dry_run @user_sources_interface.dry.get(account_id, user_source_id.to_i)
141
- else
142
- print_dry_run @user_sources_interface.dry.list(account_id, {name:user_source_id})
143
- end
144
- return
145
- end
146
- user_source = find_user_source_by_name_or_id(account_id, user_source_id)
147
- if user_source.nil?
148
- return 1
149
- end
150
- # fetch by id to get config too
151
- json_response = nil
125
+
126
+ @user_sources_interface.setopts(options)
127
+ if options[:dry_run]
152
128
  if user_source_id.to_s =~ /\A\d{1,}\Z/
153
- json_response = {'userSource' => user_source}
129
+ print_dry_run @user_sources_interface.dry.get(account_id, user_source_id.to_i)
154
130
  else
155
- json_response = @user_sources_interface.get(account_id, user_source['id'])
156
- user_source = json_response['userSource']
131
+ print_dry_run @user_sources_interface.dry.list(account_id, {name:user_source_id})
157
132
  end
133
+ return
134
+ end
135
+ user_source = find_user_source_by_name_or_id(account_id, user_source_id)
136
+ if user_source.nil?
137
+ return 1
138
+ end
139
+ # fetch by id to get config too
140
+ json_response = nil
141
+ if user_source_id.to_s =~ /\A\d{1,}\Z/
142
+ json_response = {'userSource' => user_source}
143
+ else
144
+ json_response = @user_sources_interface.get(account_id, user_source['id'])
145
+ user_source = json_response['userSource']
146
+ end
158
147
 
159
- #user_source = json_response['userSource']
160
- if options[:json]
161
- puts as_json(json_response, options, "userSource")
162
- return 0
163
- elsif options[:yaml]
164
- puts as_yaml(json_response, options, "userSource")
165
- return 0
166
- elsif options[:csv]
167
- puts records_as_csv([json_response['userSource']], options)
168
- return 0
169
- end
170
-
171
- print_h1 "User Source Details"
148
+ #user_source = json_response['userSource']
149
+ render_response(json_response, options, "userSource") do
150
+ print_h1 "Identity Source Details"
172
151
  print cyan
173
152
  description_cols = {
174
153
  "ID" => lambda {|it| it['id'] },
@@ -187,7 +166,7 @@ class Morpheus::Cli::UserSourcesCommand
187
166
 
188
167
  # show config settings...
189
168
  user_source_config = user_source['config']
190
- print_h2 "User Source Config (#{user_source['type']})"
169
+ print_h2 "Configuration"
191
170
  if user_source_config
192
171
  columns = user_source_config.keys #.sort
193
172
  print_description_list(columns, user_source_config)
@@ -208,15 +187,27 @@ class Morpheus::Cli::UserSourcesCommand
208
187
  {"SOURCE ROLE FQN" => lambda {|it| it['sourceRoleFqn'] } },
209
188
  ]
210
189
  print as_pretty_table(role_mappings, role_mapping_columns)
190
+ else
191
+ print cyan,"No role mappings found for this identity source.","\n",reset
192
+ end
193
+
194
+ provider_settings = user_source['providerSettings']
195
+ if provider_settings && !provider_settings.empty?
196
+ print_h2 "Provider Settings"
197
+ print_description_list({
198
+ "Entity ID" => lambda {|it| it['entityId'] },
199
+ "ACS URL" => lambda {|it| it['acsUrl'] }
200
+ }, provider_settings)
201
+ print_h2 "SP Metadata"
202
+ print cyan
203
+ print provider_settings['spMetadata']
211
204
  print "\n",reset
212
205
  else
213
- print cyan,"No role mappings found for this user source.","\n",reset
206
+ # print cyan,"No provider settings found.","\n",reset
214
207
  end
215
- return 0
216
- rescue RestClient::Exception => e
217
- print_rest_exception(e, options)
218
- return 1
208
+ print "\n",reset
219
209
  end
210
+ return 0, nil
220
211
  end
221
212
 
222
213
  def add(args)
@@ -229,17 +220,17 @@ class Morpheus::Cli::UserSourcesCommand
229
220
  default_role_id = nil
230
221
  optparse = Morpheus::Cli::OptionParser.new do|opts|
231
222
  opts.banner = subcommand_usage("[account] [name]")
232
- opts.on( '--tenant TENANT', String, "Tenant Name or ID the user source will belong to, default is your own." ) do |val|
223
+ opts.on( '--tenant TENANT', String, "Tenant Name or ID the identity source will belong to, default is your own." ) do |val|
233
224
  account_id = val
234
225
  end
235
- opts.on( '-a', '--account ACCOUNT', "Tenant Name or ID the user source will belong to, default is your own." ) do |val|
226
+ opts.on( '-a', '--account ACCOUNT', "Tenant Name or ID the identity source will belong to, default is your own." ) do |val|
236
227
  account_id = val
237
228
  end
238
229
  opts.add_hidden_option('-a, --account') if opts.is_a?(Morpheus::Cli::OptionParser)
239
- opts.on('--type CODE', String, "User Source Type") do |val|
230
+ opts.on('--type CODE', String, "Identity Source Type") do |val|
240
231
  type_code = val
241
232
  end
242
- opts.on('--name VALUE', String, "Name for this user source") do |val|
233
+ opts.on('--name VALUE', String, "Name for this identity source") do |val|
243
234
  params['name'] = val
244
235
  end
245
236
  opts.on('--description VALUE', String, "Description") do |val|
@@ -276,7 +267,7 @@ class Morpheus::Cli::UserSourcesCommand
276
267
  end
277
268
  #build_option_type_options(opts, options, add_user_source_option_types())
278
269
  build_standard_add_options(opts, options)
279
- opts.footer = "Create a new user source." + "\n" +
270
+ opts.footer = "Create a new identity source." + "\n" +
280
271
  "[account] is required. This is the name or id of an account."
281
272
  end
282
273
  optparse.parse!(args)
@@ -313,10 +304,10 @@ class Morpheus::Cli::UserSourcesCommand
313
304
  else
314
305
  payload.deep_merge!({'userSource' => parse_passed_options(options)})
315
306
 
316
- # User Source Type
307
+ # Identity Source Type
317
308
  user_source_types = @user_sources_interface.list_types({userSelectable: true})['userSourceTypes']
318
309
  if user_source_types.empty?
319
- print_red_alert "No available User Source Types found"
310
+ print_red_alert "No available Identity Source Types found"
320
311
  return 1
321
312
  end
322
313
  user_source_type = nil
@@ -328,7 +319,7 @@ class Morpheus::Cli::UserSourcesCommand
328
319
  user_source_type = user_source_types.find { |it| it['type'] == type_code }
329
320
 
330
321
  if user_source_type.nil?
331
- print_red_alert "User Source Type not found for '#{type_code}'"
322
+ print_red_alert "Identity Source Type not found for '#{type_code}'"
332
323
  return 1
333
324
  end
334
325
 
@@ -393,7 +384,7 @@ class Morpheus::Cli::UserSourcesCommand
393
384
  return 0
394
385
  end
395
386
  user_source = json_response['userSource']
396
- print_green_success "Added User Source #{user_source['name']}"
387
+ print_green_success "Added Identity Source #{user_source['name']}"
397
388
  get([user_source['id']] + (options[:remote] ? ["-r",options[:remote]] : []))
398
389
  return 0
399
390
  end
@@ -406,7 +397,7 @@ class Morpheus::Cli::UserSourcesCommand
406
397
  role_mapping_names = nil
407
398
  optparse = Morpheus::Cli::OptionParser.new do|opts|
408
399
  opts.banner = subcommand_usage("[name] [options]")
409
- opts.on('--name VALUE', String, "Name for this user source") do |val|
400
+ opts.on('--name VALUE', String, "Name for this identity source") do |val|
410
401
  params['name'] = val
411
402
  end
412
403
  opts.on('--description VALUE', String, "Description") do |val|
@@ -438,8 +429,8 @@ class Morpheus::Cli::UserSourcesCommand
438
429
  end
439
430
  end
440
431
  build_standard_update_options(opts, options)
441
- opts.footer = "Update a user source." + "\n" +
442
- "[name] is required. This is the name or id of a user source."
432
+ opts.footer = "Update an identity source." + "\n" +
433
+ "[name] is required. This is the name or id of an identity source."
443
434
  end
444
435
  optparse.parse!(args)
445
436
  if args.count < 1
@@ -494,7 +485,7 @@ class Morpheus::Cli::UserSourcesCommand
494
485
  return
495
486
  end
496
487
 
497
- print_green_success "Updated User Source #{params['name'] || user_source['name']}"
488
+ print_green_success "Updated Identity Source #{params['name'] || user_source['name']}"
498
489
  get([user_source['id']] + (options[:remote] ? ["-r",options[:remote]] : []))
499
490
  rescue RestClient::Exception => e
500
491
  print_rest_exception(e, options)
@@ -511,8 +502,8 @@ class Morpheus::Cli::UserSourcesCommand
511
502
  optparse = Morpheus::Cli::OptionParser.new do|opts|
512
503
  opts.banner = subcommand_usage("[name]")
513
504
  build_common_options(opts, options, [:options, :json, :dry_run, :remote])
514
- opts.footer = "Activate a user source." + "\n" +
515
- "[name] is required. This is the name or id of a user source."
505
+ opts.footer = "Activate an identity source." + "\n" +
506
+ "[name] is required. This is the name or id of an identity source."
516
507
  end
517
508
  optparse.parse!(args)
518
509
  if args.count < 1
@@ -544,7 +535,7 @@ class Morpheus::Cli::UserSourcesCommand
544
535
  return
545
536
  end
546
537
 
547
- print_green_success "Activated User Source #{user_source['name']}"
538
+ print_green_success "Activated Identity Source #{user_source['name']}"
548
539
  get([user_source['id']] + (options[:remote] ? ["-r",options[:remote]] : []))
549
540
  rescue RestClient::Exception => e
550
541
  print_rest_exception(e, options)
@@ -561,8 +552,8 @@ class Morpheus::Cli::UserSourcesCommand
561
552
  optparse = Morpheus::Cli::OptionParser.new do|opts|
562
553
  opts.banner = subcommand_usage("[name]")
563
554
  build_common_options(opts, options, [:options, :json, :dry_run, :remote])
564
- opts.footer = "Deactivate a user source." + "\n" +
565
- "[name] is required. This is the name or id of a user source."
555
+ opts.footer = "Deactivate an identity source." + "\n" +
556
+ "[name] is required. This is the name or id of an identity source."
566
557
  end
567
558
  optparse.parse!(args)
568
559
  if args.count < 1
@@ -594,7 +585,7 @@ class Morpheus::Cli::UserSourcesCommand
594
585
  return
595
586
  end
596
587
 
597
- print_green_success "Activated User Source #{user_source['name']}"
588
+ print_green_success "Activated Identity Source #{user_source['name']}"
598
589
  get([user_source['id']] + (options[:remote] ? ["-r",options[:remote]] : []))
599
590
  rescue RestClient::Exception => e
600
591
  print_rest_exception(e, options)
@@ -608,12 +599,12 @@ class Morpheus::Cli::UserSourcesCommand
608
599
  account_id = nil
609
600
  optparse = Morpheus::Cli::OptionParser.new do|opts|
610
601
  opts.banner = subcommand_usage("[name]")
611
- opts.on('--subdomain VALUE', String, "New subdomain for this user source") do |val|
602
+ opts.on('--subdomain VALUE', String, "New subdomain for this identity source") do |val|
612
603
  params['subdomain'] = (val == 'null') ? nil : val
613
604
  end
614
605
  build_common_options(opts, options, [:options, :json, :dry_run, :remote])
615
- opts.footer = "Update subdomain for a user source." + "\n" +
616
- "[name] is required. This is the name or id of a user source."
606
+ opts.footer = "Update subdomain for an identity source." + "\n" +
607
+ "[name] is required. This is the name or id of an identity source."
617
608
  end
618
609
  optparse.parse!(args)
619
610
  if args.count < 1
@@ -645,8 +636,8 @@ class Morpheus::Cli::UserSourcesCommand
645
636
  puts JSON.pretty_generate(json_response)
646
637
  return
647
638
  end
648
- # JD: uhh this updates the account too, it cannot be set per user source ...yet
649
- print_green_success "Updated User Source #{user_source['name']} subdomain to '#{payload['subdomain']}'"
639
+ # JD: uhh this updates the account too, it cannot be set per identity source ...yet
640
+ print_green_success "Updated Identity Source #{user_source['name']} subdomain to '#{payload['subdomain']}'"
650
641
  get([user_source['id']] + (options[:remote] ? ["-r",options[:remote]] : []))
651
642
  rescue RestClient::Exception => e
652
643
  print_rest_exception(e, options)
@@ -672,7 +663,7 @@ class Morpheus::Cli::UserSourcesCommand
672
663
  user_source = find_user_source_by_name_or_id(nil, args[0])
673
664
  exit 1 if user_source.nil?
674
665
 
675
- unless Morpheus::Cli::OptionTypes.confirm("Are you sure you want to delete the user source #{user_source['name']}?", options)
666
+ unless Morpheus::Cli::OptionTypes.confirm("Are you sure you want to delete the identity source #{user_source['name']}?", options)
676
667
  exit
677
668
  end
678
669
  @user_sources_interface.setopts(options)
@@ -687,7 +678,7 @@ class Morpheus::Cli::UserSourcesCommand
687
678
  return
688
679
  end
689
680
 
690
- print_green_success "Removed User Source #{user_source['name']}"
681
+ print_green_success "Removed Identity Source #{user_source['name']}"
691
682
  #list([])
692
683
  rescue RestClient::Exception => e
693
684
  print_rest_exception(e, options)
@@ -703,7 +694,7 @@ class Morpheus::Cli::UserSourcesCommand
703
694
  optparse = Morpheus::Cli::OptionParser.new do |opts|
704
695
  opts.banner = subcommand_usage()
705
696
  build_common_options(opts, options, [:list, :json, :yaml, :csv, :fields, :dry_run, :remote])
706
- opts.footer = "List user source types."
697
+ opts.footer = "List identity source types."
707
698
  end
708
699
  optparse.parse!(args)
709
700
  connect(options)
@@ -735,7 +726,7 @@ class Morpheus::Cli::UserSourcesCommand
735
726
  return 0
736
727
  end
737
728
  user_source_types = json_response['userSourceTypes']
738
- title = "Morpheus User Source Types"
729
+ title = "Morpheus Identity Source Types"
739
730
  subtitles = []
740
731
  subtitles += parse_list_subtitles(options)
741
732
  print_h1 title, subtitles
@@ -760,7 +751,7 @@ class Morpheus::Cli::UserSourcesCommand
760
751
  optparse = Morpheus::Cli::OptionParser.new do |opts|
761
752
  opts.banner = subcommand_usage("[type]")
762
753
  build_common_options(opts, options, [:json, :yaml, :csv, :fields, :dry_run, :remote])
763
- opts.footer = "Get details about a user source type." + "\n" +
754
+ opts.footer = "Get details about an identity source type." + "\n" +
764
755
  "[type] is required. This is the type identifier."
765
756
  end
766
757
  optparse.parse!(args)
@@ -776,13 +767,6 @@ class Morpheus::Cli::UserSourcesCommand
776
767
  begin
777
768
  user_source_type_id = args[0]
778
769
 
779
- # all_user_source_types = @user_sources_interface.dry.list_types({})['userSourceTypes']
780
- # user_source_type = all_user_source_types.find {|it| it['type'] == user_source_type_id }
781
- # if !user_source_type
782
- # print_red_alert "User Source Type not found by id '#{user_source_type_id}'"
783
- # return 1
784
- # end
785
-
786
770
  # construct payload
787
771
  @user_sources_interface.setopts(options)
788
772
  if options[:dry_run]
@@ -801,7 +785,7 @@ class Morpheus::Cli::UserSourcesCommand
801
785
  puts records_as_csv([user_source_type], options)
802
786
  return 0
803
787
  end
804
- title = "User Source Type"
788
+ title = "Identity Source Type"
805
789
  subtitles = []
806
790
  print_h1 title, subtitles
807
791
  print cyan
@@ -860,7 +844,7 @@ class Morpheus::Cli::UserSourcesCommand
860
844
  return json_response['userSource']
861
845
  rescue RestClient::Exception => e
862
846
  if e.response && e.response.code == 404
863
- print_red_alert "User Source not found by id #{id}"
847
+ print_red_alert "Identity Source not found by id #{id}"
864
848
  else
865
849
  raise e
866
850
  end
@@ -870,10 +854,10 @@ class Morpheus::Cli::UserSourcesCommand
870
854
  def find_user_source_by_name(account_id, name)
871
855
  user_sources = @user_sources_interface.list(account_id, {name: name.to_s})['userSources']
872
856
  if user_sources.empty?
873
- print_red_alert "User Source not found by name #{name}"
857
+ print_red_alert "Identity Source not found by name #{name}"
874
858
  return nil
875
859
  elsif user_sources.size > 1
876
- print_red_alert "#{user_sources.size} user sources found by name #{name}"
860
+ print_red_alert "#{user_sources.size} identity sources found by name #{name}"
877
861
  print_user_sources_table(user_sources, {color: red})
878
862
  print_red_alert "Try using ID instead"
879
863
  print reset,"\n"
@@ -979,7 +963,7 @@ class Morpheus::Cli::UserSourcesCommand
979
963
  {'fieldContext' => 'config', 'fieldName' => 'encryptionKey', 'type' => 'text', 'fieldLabel' => 'Encryption Key', 'required' => true, 'description' => ''},
980
964
  ]
981
965
  else
982
- print "unknown user source type: #{type_code}"
966
+ print "unknown identity source type: #{type_code}"
983
967
  []
984
968
  end
985
969
  end
@@ -1,6 +1,6 @@
1
1
 
2
2
  module Morpheus
3
3
  module Cli
4
- VERSION = "5.2.4"
4
+ VERSION = "5.2.4.1"
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: morpheus-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.2.4
4
+ version: 5.2.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Estes
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2021-01-12 00:00:00.000000000 Z
14
+ date: 2021-02-11 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler