morpheus-cli 5.3.1.1 → 5.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Dockerfile +1 -1
- data/lib/morpheus/api/option_type_lists_interface.rb +19 -7
- data/lib/morpheus/cli/library_cluster_layouts_command.rb +2 -3
- data/lib/morpheus/cli/library_container_scripts_command.rb +3 -4
- data/lib/morpheus/cli/library_container_templates_command.rb +4 -0
- data/lib/morpheus/cli/library_container_types_command.rb +2 -3
- data/lib/morpheus/cli/library_instance_types_command.rb +2 -3
- data/lib/morpheus/cli/library_layouts_command.rb +4 -0
- data/lib/morpheus/cli/library_option_lists_command.rb +68 -16
- data/lib/morpheus/cli/library_option_types_command.rb +4 -0
- data/lib/morpheus/cli/library_spec_templates_command.rb +3 -4
- data/lib/morpheus/cli/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e776b0e0602c4de27079e0796d270009b0d3a592d571a41721ac936c7537b94e
|
4
|
+
data.tar.gz: 10f231de3b75dc6a16d5433af35a1cbde2931d1871bf2106040ee49a0812091c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 893fd73648238a2a360273fef6a44654b0011075401743f6be61ba5f32c487f8bc5c5936f440cbcbb6be99ce05888ef99e453545e7f435e834a54ade3062851a
|
7
|
+
data.tar.gz: c558b3e31997546f382b44339183431e6d855be77b82e6c85be623c32dcf3333ae0a34c725b19fb317e308d8ec3ca2963de9f51ceba5b3bd658c7ad013ae9d67
|
data/Dockerfile
CHANGED
@@ -2,38 +2,50 @@ require 'morpheus/api/api_client'
|
|
2
2
|
|
3
3
|
class Morpheus::OptionTypeListsInterface < Morpheus::APIClient
|
4
4
|
|
5
|
-
def
|
5
|
+
def base_path
|
6
|
+
"/api/library/option-type-lists"
|
7
|
+
end
|
8
|
+
|
9
|
+
def get(id, params={})
|
6
10
|
raise "#{self.class}.get() passed a blank id!" if id.to_s == ''
|
7
|
-
url = "#{
|
8
|
-
headers = { params:
|
11
|
+
url = "#{base_path}/#{id}"
|
12
|
+
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
9
13
|
opts = {method: :get, url: url, headers: headers}
|
10
14
|
execute(opts)
|
11
15
|
end
|
12
16
|
|
13
17
|
def list(params={})
|
14
|
-
url = "#{
|
18
|
+
url = "#{base_path}"
|
15
19
|
headers = { params: {}, authorization: "Bearer #{@access_token}" }
|
16
20
|
headers[:params].merge!(params)
|
17
21
|
opts = {method: :get, url: url, headers: headers}
|
18
22
|
execute(opts)
|
19
23
|
end
|
20
24
|
|
25
|
+
def list_items(id, params={})
|
26
|
+
raise "#{self.class}.get() passed a blank id!" if id.to_s == ''
|
27
|
+
url = "#{base_path}/#{id}/items"
|
28
|
+
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
29
|
+
opts = {method: :get, url: url, headers: headers}
|
30
|
+
execute(opts)
|
31
|
+
end
|
32
|
+
|
21
33
|
def create(payload)
|
22
|
-
url = "#{
|
34
|
+
url = "#{base_path}"
|
23
35
|
headers = { :params => {}, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
24
36
|
opts = {method: :post, url: url, headers: headers, payload: payload.to_json}
|
25
37
|
execute(opts)
|
26
38
|
end
|
27
39
|
|
28
40
|
def update(id, payload)
|
29
|
-
url = "#{
|
41
|
+
url = "#{base_path}/#{id}"
|
30
42
|
headers = { :params => {}, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
31
43
|
opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
|
32
44
|
execute(opts)
|
33
45
|
end
|
34
46
|
|
35
47
|
def destroy(id)
|
36
|
-
url = "#{
|
48
|
+
url = "#{base_path}/#{id}"
|
37
49
|
headers = { :params => {}, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
38
50
|
opts = {method: :delete, url: url, headers: headers}
|
39
51
|
execute(opts)
|
@@ -41,10 +41,9 @@ class Morpheus::Cli::LibraryClusterLayoutsCommand
|
|
41
41
|
opts.footer = "List cluster layouts."
|
42
42
|
end
|
43
43
|
optparse.parse!(args)
|
44
|
+
# verify_args!(args:args, optparse:optparse, count:0)
|
44
45
|
if args.count > 0
|
45
|
-
|
46
|
-
puts_error "wrong number of arguments, expected 0 and got (#{args.count}) #{args.inspect}\n#{optparse}"
|
47
|
-
return 1
|
46
|
+
options[:phrase] = args.join(" ")
|
48
47
|
end
|
49
48
|
connect(options)
|
50
49
|
begin
|
@@ -25,12 +25,11 @@ class Morpheus::Cli::LibraryContainerScriptsCommand
|
|
25
25
|
opts.footer = "List container scripts."
|
26
26
|
end
|
27
27
|
optparse.parse!(args)
|
28
|
-
|
28
|
+
# verify_args!(args:args, optparse:optparse, count:0)
|
29
29
|
if args.count > 0
|
30
|
-
|
31
|
-
puts_error "wrong number of arguments, expected 0 and got (#{args.count}) #{args.join(', ')}\n#{optparse}"
|
32
|
-
return 1
|
30
|
+
options[:phrase] = args.join(" ")
|
33
31
|
end
|
32
|
+
connect(options)
|
34
33
|
begin
|
35
34
|
# construct payload
|
36
35
|
params.merge!(parse_list_options(options))
|
@@ -26,6 +26,10 @@ class Morpheus::Cli::LibraryContainerTemplatesCommand
|
|
26
26
|
build_common_options(opts, options, [:list, :json, :yaml, :csv, :fields, :dry_run, :remote])
|
27
27
|
end
|
28
28
|
optparse.parse!(args)
|
29
|
+
# verify_args!(args:args, optparse:optparse, count:0)
|
30
|
+
if args.count > 0
|
31
|
+
options[:phrase] = args.join(" ")
|
32
|
+
end
|
29
33
|
connect(options)
|
30
34
|
begin
|
31
35
|
[:phrase, :offset, :max, :sort, :direction, :lastUpdated].each do |k|
|
@@ -49,10 +49,9 @@ class Morpheus::Cli::LibraryContainerTypesCommand
|
|
49
49
|
opts.footer = "List node types."
|
50
50
|
end
|
51
51
|
optparse.parse!(args)
|
52
|
+
# verify_args!(args:args, optparse:optparse, count:0)
|
52
53
|
if args.count > 0
|
53
|
-
|
54
|
-
puts_error "wrong number of arguments, expected 0 and got (#{args.count}) #{args.inspect}\n#{optparse}"
|
55
|
-
return 1
|
54
|
+
options[:phrase] = args.join(" ")
|
56
55
|
end
|
57
56
|
connect(options)
|
58
57
|
begin
|
@@ -47,10 +47,9 @@ class Morpheus::Cli::LibraryInstanceTypesCommand
|
|
47
47
|
opts.footer = "List instance types."
|
48
48
|
end
|
49
49
|
optparse.parse!(args)
|
50
|
+
# verify_args!(args:args, optparse:optparse, count:0)
|
50
51
|
if args.count > 0
|
51
|
-
|
52
|
-
puts_error "wrong number of arguments, expected 0 and got (#{args.count}) #{args.inspect}\n#{optparse}"
|
53
|
-
return 1
|
52
|
+
options[:phrase] = args.join(" ")
|
54
53
|
end
|
55
54
|
connect(options)
|
56
55
|
begin
|
@@ -59,6 +59,10 @@ class Morpheus::Cli::LibraryLayoutsCommand
|
|
59
59
|
opts.footer = "List layouts."
|
60
60
|
end
|
61
61
|
optparse.parse!(args)
|
62
|
+
# verify_args!(args:args, optparse:optparse, count:0)
|
63
|
+
if args.count > 0
|
64
|
+
options[:phrase] = args.join(" ")
|
65
|
+
end
|
62
66
|
connect(options)
|
63
67
|
begin
|
64
68
|
# construct payload
|
@@ -9,7 +9,7 @@ class Morpheus::Cli::LibraryOptionListsCommand
|
|
9
9
|
include Morpheus::Cli::LibraryHelper
|
10
10
|
|
11
11
|
set_command_name :'library-option-lists'
|
12
|
-
register_subcommands :list, :get, :add, :update, :remove
|
12
|
+
register_subcommands :list, :get, :list_items, :add, :update, :remove
|
13
13
|
|
14
14
|
def initialize()
|
15
15
|
# @appliance_name, @appliance_url = Morpheus::Cli::Remote.active_appliance
|
@@ -35,6 +35,10 @@ class Morpheus::Cli::LibraryOptionListsCommand
|
|
35
35
|
opts.footer = "List option lists."
|
36
36
|
end
|
37
37
|
optparse.parse!(args)
|
38
|
+
# verify_args!(args:args, optparse:optparse, count:0)
|
39
|
+
if args.count > 0
|
40
|
+
options[:phrase] = args.join(" ")
|
41
|
+
end
|
38
42
|
connect(options)
|
39
43
|
begin
|
40
44
|
params = {}
|
@@ -61,16 +65,14 @@ class Morpheus::Cli::LibraryOptionListsCommand
|
|
61
65
|
id: option_type_list['id'],
|
62
66
|
name: option_type_list['name'],
|
63
67
|
description: option_type_list['description'],
|
64
|
-
type: option_type_list['type']
|
65
|
-
size: option_type_list['listItems'] ? option_type_list['listItems'].size : ''
|
68
|
+
type: ((option_type_list['type'] == 'api') ? "#{option_type_list['type']} (#{option_type_list['apiType']})" : option_type_list['type'])
|
66
69
|
}
|
67
70
|
end
|
68
71
|
columns = [
|
69
72
|
:id,
|
70
73
|
:name,
|
71
74
|
:description,
|
72
|
-
:type
|
73
|
-
:size
|
75
|
+
:type
|
74
76
|
]
|
75
77
|
print cyan
|
76
78
|
print as_pretty_table(rows, columns, options)
|
@@ -90,8 +92,8 @@ class Morpheus::Cli::LibraryOptionListsCommand
|
|
90
92
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
91
93
|
opts.banner = subcommand_usage("[name]")
|
92
94
|
build_standard_get_options(opts, options)
|
93
|
-
opts.on(nil,'--
|
94
|
-
options[:
|
95
|
+
opts.on(nil,'--items', "Load and display option list items") do |val|
|
96
|
+
options[:list_items] = true
|
95
97
|
end
|
96
98
|
opts.footer = "Get details about an option list.\n" +
|
97
99
|
"[name] is required. This is the name or id of an option list. Supports 1-N [name] arguments."
|
@@ -108,20 +110,31 @@ class Morpheus::Cli::LibraryOptionListsCommand
|
|
108
110
|
end
|
109
111
|
|
110
112
|
def _get(id, options)
|
111
|
-
|
113
|
+
params = {}
|
114
|
+
params.merge!(parse_query_options(options))
|
112
115
|
begin
|
113
116
|
@option_type_lists_interface.setopts(options)
|
114
117
|
if options[:dry_run]
|
115
118
|
if id.to_s =~ /\A\d{1,}\Z/
|
116
|
-
print_dry_run @option_type_lists_interface.dry.get(id.to_i)
|
119
|
+
print_dry_run @option_type_lists_interface.dry.get(id.to_i, params)
|
117
120
|
else
|
118
|
-
print_dry_run @option_type_lists_interface.dry.list({name: id})
|
121
|
+
print_dry_run @option_type_lists_interface.dry.list(params.merge({name: id}))
|
119
122
|
end
|
120
123
|
return
|
121
124
|
end
|
122
125
|
option_type_list = find_option_type_list_by_name_or_id(id)
|
123
126
|
return 1 if option_type_list.nil?
|
124
|
-
|
127
|
+
list_items = nil
|
128
|
+
if options[:list_items]
|
129
|
+
list_items = option_type_list['listItems']
|
130
|
+
if list_items.nil?
|
131
|
+
begin
|
132
|
+
list_items = @option_type_lists_interface.list_items(option_type_list['id'])['listItems']
|
133
|
+
rescue => e
|
134
|
+
puts_error "Failed to load option list items: #{e.message}"
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
125
138
|
json_response = {'optionTypeList' => option_type_list}
|
126
139
|
render_result = render_with_format(json_response, options, 'optionTypeList')
|
127
140
|
return 0 if render_result
|
@@ -142,12 +155,14 @@ class Morpheus::Cli::LibraryOptionListsCommand
|
|
142
155
|
"ID" => 'id',
|
143
156
|
"Name" => 'name',
|
144
157
|
"Description" => 'description',
|
145
|
-
"Type" => lambda {|it| it['type']
|
158
|
+
"Type" => lambda {|it| it['type'] },
|
159
|
+
"API Type" => lambda {|it| it['apiType'] },
|
146
160
|
"Source URL" => 'sourceUrl',
|
147
161
|
"Real Time" => lambda {|it| format_boolean it['realTime'] },
|
148
162
|
"Ignore SSL Errors" => lambda {|it| format_boolean it['ignoreSSLErrors'] },
|
149
163
|
"Source Method" => lambda {|it| it['sourceMethod'].to_s.upcase }
|
150
164
|
}
|
165
|
+
option_list_columns.delete("API Type") if option_type_list['type'] != 'api'
|
151
166
|
source_headers = []
|
152
167
|
if option_type_list['config'] && option_type_list['config']['sourceHeaders']
|
153
168
|
source_headers = option_type_list['config']['sourceHeaders'].collect do |header|
|
@@ -174,12 +189,13 @@ class Morpheus::Cli::LibraryOptionListsCommand
|
|
174
189
|
print reset,"#{option_type_list['requestScript']}","\n",reset
|
175
190
|
end
|
176
191
|
end
|
177
|
-
if options[:
|
178
|
-
|
192
|
+
if options[:list_items]
|
193
|
+
print_h2 "List Items"
|
179
194
|
if list_items && list_items.size > 0
|
180
|
-
print_h2 "List Items"
|
181
195
|
print as_pretty_table(list_items, [:name, :value], options)
|
182
196
|
print_results_pagination({size: list_items.size, total: list_items.size})
|
197
|
+
else
|
198
|
+
print cyan,"No list items found.",reset,"\n"
|
183
199
|
end
|
184
200
|
end
|
185
201
|
print reset,"\n"
|
@@ -189,6 +205,42 @@ class Morpheus::Cli::LibraryOptionListsCommand
|
|
189
205
|
end
|
190
206
|
end
|
191
207
|
|
208
|
+
def list_items(args)
|
209
|
+
params = {}
|
210
|
+
options = {}
|
211
|
+
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
212
|
+
opts.banner = subcommand_usage("[name]")
|
213
|
+
build_standard_get_options(opts, options)
|
214
|
+
opts.footer = "List items for an option list.\n" +
|
215
|
+
"[name] is required. This is the name or id of an option list."
|
216
|
+
end
|
217
|
+
optparse.parse!(args)
|
218
|
+
verify_args!(args:args, optparse:optparse, count:1)
|
219
|
+
connect(options)
|
220
|
+
option_type_list = find_option_type_list_by_name_or_id(args[0])
|
221
|
+
return 1 if option_type_list.nil?
|
222
|
+
|
223
|
+
params.merge!(parse_list_options(options))
|
224
|
+
@option_type_lists_interface.setopts(options)
|
225
|
+
if options[:dry_run]
|
226
|
+
print_dry_run @option_type_lists_interface.dry.list_items(option_type_list['id'], params)
|
227
|
+
return
|
228
|
+
end
|
229
|
+
json_response = @option_type_lists_interface.list_items(option_type_list['id'], params)
|
230
|
+
list_items = json_response['listItems']
|
231
|
+
render_response(json_response, options, "listItems") do
|
232
|
+
print_h2 "List Items"
|
233
|
+
if list_items && list_items.size > 0
|
234
|
+
print as_pretty_table(list_items, [:name, :value], options)
|
235
|
+
print_results_pagination({size: list_items.size, total: list_items.size})
|
236
|
+
else
|
237
|
+
print cyan,"No list items found.",reset,"\n"
|
238
|
+
end
|
239
|
+
print reset,"\n"
|
240
|
+
end
|
241
|
+
return 0, nil
|
242
|
+
end
|
243
|
+
|
192
244
|
def add(args)
|
193
245
|
options = {}
|
194
246
|
my_option_types = nil
|
@@ -373,7 +425,7 @@ class Morpheus::Cli::LibraryOptionListsCommand
|
|
373
425
|
{'dependsOnCode' => 'optionTypeList.type:rest', 'fieldName' => 'realTime', 'fieldLabel' => 'Real Time', 'type' => 'checkbox', 'defaultValue' => false, 'displayOrder' => 7},
|
374
426
|
{'dependsOnCode' => 'optionTypeList.type:rest', 'fieldName' => 'sourceMethod', 'fieldLabel' => 'Source Method', 'type' => 'select', 'selectOptions' => [{'name' => 'GET', 'value' => 'GET'}, {'name' => 'POST', 'value' => 'POST'}], 'defaultValue' => 'GET', 'required' => true, 'displayOrder' => 8},
|
375
427
|
# sourceHeaders component (is done afterwards manually)
|
376
|
-
{'dependsOnCode' => 'optionTypeList.type:api', 'fieldName' => 'apiType', 'fieldLabel' => 'Option List', 'type' => 'select', 'optionSource' => 'apiOptionLists', 'required' => true, 'description' => 'The code of the api list to use, eg. clouds, servers,
|
428
|
+
{'dependsOnCode' => 'optionTypeList.type:api', 'fieldName' => 'apiType', 'fieldLabel' => 'Option List', 'type' => 'select', 'optionSource' => 'apiOptionLists', 'required' => true, 'description' => 'The code of the api option list to use, eg. clouds, environments, groups, instances, instance-wiki, networks, servicePlans, resourcePools, securityGroups, servers, server-wiki', 'displayOrder' => 9},
|
377
429
|
{'dependsOnCode' => 'optionTypeList.type:ldap', 'fieldName' => 'sourceUsername', 'fieldLabel' => 'Source Username', 'type' => 'text', 'description' => "An LDAP Username for use when type is 'ldap'.", 'displayOrder' => 10},
|
378
430
|
{'dependsOnCode' => 'optionTypeList.type:ldap', 'fieldName' => 'sourcePassword', 'fieldLabel' => 'Source Username', 'type' => 'text', 'description' => "An LDAP Password for use when type is 'ldap'.", 'displayOrder' => 11},
|
379
431
|
{'dependsOnCode' => 'optionTypeList.type:ldap', 'fieldName' => 'ldapQuery', 'fieldLabel' => 'LDAP Query', 'type' => 'text', 'description' => "LDAP Queries are standard LDAP formatted queries where different objects can be searched. Dependent parameters can be loaded into the query using the <%=phrase%> syntax.", 'displayOrder' => 12},
|
@@ -35,6 +35,10 @@ class Morpheus::Cli::LibraryOptionTypesCommand
|
|
35
35
|
opts.footer = "List option types."
|
36
36
|
end
|
37
37
|
optparse.parse!(args)
|
38
|
+
# verify_args!(args:args, optparse:optparse, count:0)
|
39
|
+
if args.count > 0
|
40
|
+
options[:phrase] = args.join(" ")
|
41
|
+
end
|
38
42
|
connect(options)
|
39
43
|
begin
|
40
44
|
params = {}
|
@@ -26,12 +26,11 @@ class Morpheus::Cli::LibrarySpecTemplatesCommand
|
|
26
26
|
opts.footer = "List spec templates."
|
27
27
|
end
|
28
28
|
optparse.parse!(args)
|
29
|
-
|
29
|
+
# verify_args!(args:args, optparse:optparse, count:0)
|
30
30
|
if args.count > 0
|
31
|
-
|
32
|
-
puts_error "wrong number of arguments, expected 0 and got (#{args.count}) #{args.inspect}\n#{optparse}"
|
33
|
-
return 1
|
31
|
+
options[:phrase] = args.join(" ")
|
34
32
|
end
|
33
|
+
connect(options)
|
35
34
|
begin
|
36
35
|
# construct payload
|
37
36
|
params.merge!(parse_list_options(options))
|
data/lib/morpheus/cli/version.rb
CHANGED
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.3.
|
4
|
+
version: 5.3.2
|
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-
|
14
|
+
date: 2021-07-12 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: bundler
|