morpheus-cli 3.3.1.4 → 3.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/morpheus/api/api_client.rb +28 -0
- data/lib/morpheus/api/instance_types_interface.rb +12 -10
- data/lib/morpheus/api/instances_interface.rb +4 -0
- data/lib/morpheus/api/library_container_scripts_interface.rb +49 -0
- data/lib/morpheus/api/library_container_templates_interface.rb +49 -0
- data/lib/morpheus/api/library_container_types_interface.rb +65 -0
- data/lib/morpheus/api/library_container_upgrades_interface.rb +66 -0
- data/lib/morpheus/api/library_instance_types_interface.rb +59 -0
- data/lib/morpheus/api/library_layouts_interface.rb +65 -0
- data/lib/morpheus/api/servers_interface.rb +4 -0
- data/lib/morpheus/api/user_sources_interface.rb +120 -0
- data/lib/morpheus/api/virtual_images_interface.rb +7 -0
- data/lib/morpheus/cli.rb +12 -1
- data/lib/morpheus/cli/accounts.rb +35 -9
- data/lib/morpheus/cli/cli_command.rb +82 -2
- data/lib/morpheus/cli/curl_command.rb +1 -1
- data/lib/morpheus/cli/echo_command.rb +1 -1
- data/lib/morpheus/cli/hosts.rb +40 -14
- data/lib/morpheus/cli/instance_types.rb +106 -64
- data/lib/morpheus/cli/instances.rb +39 -15
- data/lib/morpheus/cli/library.rb +1 -1184
- data/lib/morpheus/cli/library_container_scripts_command.rb +437 -0
- data/lib/morpheus/cli/library_container_templates_command.rb +397 -0
- data/lib/morpheus/cli/library_container_types_command.rb +653 -0
- data/lib/morpheus/cli/library_instance_types_command.rb +491 -0
- data/lib/morpheus/cli/library_layouts_command.rb +650 -0
- data/lib/morpheus/cli/library_option_lists_command.rb +476 -0
- data/lib/morpheus/cli/library_option_types_command.rb +549 -0
- data/lib/morpheus/cli/library_upgrades_command.rb +604 -0
- data/lib/morpheus/cli/mixins/library_helper.rb +123 -0
- data/lib/morpheus/cli/mixins/print_helper.rb +21 -22
- data/lib/morpheus/cli/mixins/provisioning_helper.rb +56 -11
- data/lib/morpheus/cli/network_services_command.rb +1 -1
- data/lib/morpheus/cli/option_types.rb +12 -2
- data/lib/morpheus/cli/power_scheduling_command.rb +1 -1
- data/lib/morpheus/cli/shell.rb +120 -22
- data/lib/morpheus/cli/sleep_command.rb +45 -0
- data/lib/morpheus/cli/user_sources_command.rb +963 -0
- data/lib/morpheus/cli/users.rb +33 -2
- data/lib/morpheus/cli/version.rb +1 -1
- data/lib/morpheus/cli/version_command.rb +1 -1
- data/lib/morpheus/cli/virtual_images.rb +93 -39
- data/lib/morpheus/formatters.rb +37 -27
- data/lib/morpheus/terminal.rb +1 -1
- metadata +20 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da10aefff03990b69fce2466166982e4018e2e8e
|
4
|
+
data.tar.gz: 2777267312f2d3a994c3c1715fde9cd0b24d9efe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e3873db99a5e116b9420fde355e1f194a65abef24df3be5b9d4eb3efde4502217ea1bbeef54240a1bbd7d2523c3b4bb9418bae8ef1a78d1373ca5de4a3bf5b4
|
7
|
+
data.tar.gz: 64e4fb938211bdf9c305e1f74dfc21669ea57b40d30dea8c4479efc1158cf0b170816f437458fddde7d1d2bd1355ccc8fafbb9020d0d9c87c9944b7d19060f04
|
@@ -145,6 +145,10 @@ class Morpheus::APIClient
|
|
145
145
|
Morpheus::UserGroupsInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
|
146
146
|
end
|
147
147
|
|
148
|
+
def user_sources
|
149
|
+
Morpheus::UserSourcesInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
|
150
|
+
end
|
151
|
+
|
148
152
|
def logs
|
149
153
|
Morpheus::LogsInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
|
150
154
|
end
|
@@ -255,4 +259,28 @@ class Morpheus::APIClient
|
|
255
259
|
Morpheus::StorageProvidersInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
|
256
260
|
end
|
257
261
|
|
262
|
+
def library_instance_types
|
263
|
+
Morpheus::LibraryInstanceTypesInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
|
264
|
+
end
|
265
|
+
|
266
|
+
def library_layouts
|
267
|
+
Morpheus::LibraryLayoutsInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
|
268
|
+
end
|
269
|
+
|
270
|
+
def library_container_upgrades
|
271
|
+
Morpheus::LibraryContainerUpgradesInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
|
272
|
+
end
|
273
|
+
|
274
|
+
def library_container_types
|
275
|
+
Morpheus::LibraryContainerTypesInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
|
276
|
+
end
|
277
|
+
|
278
|
+
def library_container_scripts
|
279
|
+
Morpheus::LibraryContainerScriptsInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
|
280
|
+
end
|
281
|
+
|
282
|
+
def library_container_templates
|
283
|
+
Morpheus::LibraryContainerTemplatesInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
|
284
|
+
end
|
285
|
+
|
258
286
|
end
|
@@ -9,17 +9,19 @@ class Morpheus::InstanceTypesInterface < Morpheus::APIClient
|
|
9
9
|
end
|
10
10
|
|
11
11
|
|
12
|
-
def get(
|
12
|
+
def get(id, params={})
|
13
|
+
raise "#{self.class}.get() passed a blank id!" if id.to_s == ''
|
14
|
+
url = "#{@base_url}/api/instance-types/#{id}"
|
15
|
+
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
16
|
+
opts = {method: :get, url: url, headers: headers}
|
17
|
+
execute(opts)
|
18
|
+
end
|
19
|
+
|
20
|
+
def list(params={})
|
13
21
|
url = "#{@base_url}/api/instance-types"
|
14
|
-
headers = { params:
|
15
|
-
|
16
|
-
|
17
|
-
elsif options.is_a?(Numeric)
|
18
|
-
url = "#{@base_url}/api/instance-types/#{options}"
|
19
|
-
elsif options.is_a?(String)
|
20
|
-
headers[:params]['name'] = options
|
21
|
-
end
|
22
|
-
execute(method: :get, url: url, headers: headers)
|
22
|
+
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
23
|
+
opts = {method: :get, url: url, headers: headers}
|
24
|
+
execute(opts)
|
23
25
|
end
|
24
26
|
|
25
27
|
end
|
@@ -23,6 +23,10 @@ class Morpheus::InstancesInterface < Morpheus::APIClient
|
|
23
23
|
execute(opts)
|
24
24
|
end
|
25
25
|
|
26
|
+
def list(options={})
|
27
|
+
get(options)
|
28
|
+
end
|
29
|
+
|
26
30
|
def get_envs(id, options=nil)
|
27
31
|
url = "#{@base_url}/api/instances/#{id}/envs"
|
28
32
|
headers = { params: {}, authorization: "Bearer #{@access_token}" }
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'morpheus/api/api_client'
|
2
|
+
|
3
|
+
class Morpheus::LibraryContainerScriptsInterface < Morpheus::APIClient
|
4
|
+
def initialize(access_token, refresh_token,expires_at = nil, base_url=nil)
|
5
|
+
@access_token = access_token
|
6
|
+
@refresh_token = refresh_token
|
7
|
+
@base_url = base_url
|
8
|
+
@expires_at = expires_at
|
9
|
+
end
|
10
|
+
|
11
|
+
def get(id, params={})
|
12
|
+
raise "#{self.class}.get() passed a blank id!" if id.to_s == ''
|
13
|
+
url = "#{@base_url}/api/library/container-scripts/#{id}"
|
14
|
+
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
15
|
+
opts = {method: :get, url: url, headers: headers}
|
16
|
+
execute(opts)
|
17
|
+
end
|
18
|
+
|
19
|
+
def list(params={})
|
20
|
+
url = "#{@base_url}/api/library/container-scripts"
|
21
|
+
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
22
|
+
opts = {method: :get, url: url, headers: headers}
|
23
|
+
execute(opts)
|
24
|
+
end
|
25
|
+
|
26
|
+
def create(options)
|
27
|
+
url = "#{@base_url}/api/library/container-scripts"
|
28
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
29
|
+
payload = options
|
30
|
+
opts = {method: :post, url: url, headers: headers, payload: payload.to_json}
|
31
|
+
execute(opts)
|
32
|
+
end
|
33
|
+
|
34
|
+
def update(id, options)
|
35
|
+
url = "#{@base_url}/api/library/container-scripts/#{id}"
|
36
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
37
|
+
payload = options
|
38
|
+
opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
|
39
|
+
execute(opts)
|
40
|
+
end
|
41
|
+
|
42
|
+
def destroy(id, payload={})
|
43
|
+
url = "#{@base_url}/api/library/container-scripts/#{id}"
|
44
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
45
|
+
opts = {method: :delete, url: url, headers: headers, payload: payload.to_json}
|
46
|
+
execute(opts)
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'morpheus/api/api_client'
|
2
|
+
|
3
|
+
class Morpheus::LibraryContainerTemplatesInterface < Morpheus::APIClient
|
4
|
+
def initialize(access_token, refresh_token,expires_at = nil, base_url=nil)
|
5
|
+
@access_token = access_token
|
6
|
+
@refresh_token = refresh_token
|
7
|
+
@base_url = base_url
|
8
|
+
@expires_at = expires_at
|
9
|
+
end
|
10
|
+
|
11
|
+
def get(id, params={})
|
12
|
+
raise "#{self.class}.get() passed a blank id!" if id.to_s == ''
|
13
|
+
url = "#{@base_url}/api/library/container-templates/#{id}"
|
14
|
+
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
15
|
+
opts = {method: :get, url: url, headers: headers}
|
16
|
+
execute(opts)
|
17
|
+
end
|
18
|
+
|
19
|
+
def list(params={})
|
20
|
+
url = "#{@base_url}/api/library/container-templates"
|
21
|
+
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
22
|
+
opts = {method: :get, url: url, headers: headers}
|
23
|
+
execute(opts)
|
24
|
+
end
|
25
|
+
|
26
|
+
def create(options)
|
27
|
+
url = "#{@base_url}/api/library/container-templates"
|
28
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
29
|
+
payload = options
|
30
|
+
opts = {method: :post, url: url, headers: headers, payload: payload.to_json}
|
31
|
+
execute(opts)
|
32
|
+
end
|
33
|
+
|
34
|
+
def update(id, options)
|
35
|
+
url = "#{@base_url}/api/library/container-templates/#{id}"
|
36
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
37
|
+
payload = options
|
38
|
+
opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
|
39
|
+
execute(opts)
|
40
|
+
end
|
41
|
+
|
42
|
+
def destroy(id, payload={})
|
43
|
+
url = "#{@base_url}/api/library/container-templates/#{id}"
|
44
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
45
|
+
opts = {method: :delete, url: url, headers: headers, payload: payload.to_json}
|
46
|
+
execute(opts)
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'morpheus/api/api_client'
|
2
|
+
|
3
|
+
class Morpheus::LibraryContainerTypesInterface < Morpheus::APIClient
|
4
|
+
def initialize(access_token, refresh_token,expires_at = nil, base_url=nil)
|
5
|
+
@access_token = access_token
|
6
|
+
@refresh_token = refresh_token
|
7
|
+
@base_url = base_url
|
8
|
+
@expires_at = expires_at
|
9
|
+
end
|
10
|
+
|
11
|
+
def get(layout_id, id, params={})
|
12
|
+
raise "#{self.class}.get() passed a blank id!" if id.to_s == ''
|
13
|
+
url = build_url(layout_id, id)
|
14
|
+
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
15
|
+
opts = {method: :get, url: url, headers: headers}
|
16
|
+
execute(opts)
|
17
|
+
end
|
18
|
+
|
19
|
+
def list(layout_id, params={})
|
20
|
+
url = build_url(layout_id)
|
21
|
+
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
22
|
+
opts = {method: :get, url: url, headers: headers}
|
23
|
+
execute(opts)
|
24
|
+
end
|
25
|
+
|
26
|
+
def create(layout_id, options)
|
27
|
+
url = build_url(layout_id)
|
28
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
29
|
+
payload = options
|
30
|
+
opts = {method: :post, url: url, headers: headers, payload: payload.to_json}
|
31
|
+
execute(opts)
|
32
|
+
end
|
33
|
+
|
34
|
+
def update(layout_id, id, options)
|
35
|
+
url = build_url(layout_id, id)
|
36
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
37
|
+
payload = options
|
38
|
+
opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
|
39
|
+
execute(opts)
|
40
|
+
end
|
41
|
+
|
42
|
+
def destroy(layout_id, id, payload={})
|
43
|
+
url = build_url(layout_id, id)
|
44
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
45
|
+
opts = {method: :delete, url: url, headers: headers, payload: payload.to_json}
|
46
|
+
execute(opts)
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def build_url(layout_id=nil, id=nil)
|
52
|
+
url = "#{@base_url}/api"
|
53
|
+
if layout_id
|
54
|
+
url += "/library/#{layout_id}/container-types"
|
55
|
+
else
|
56
|
+
url += "/library/container-types"
|
57
|
+
end
|
58
|
+
if id
|
59
|
+
url += "/#{id}"
|
60
|
+
end
|
61
|
+
url
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'morpheus/api/api_client'
|
2
|
+
|
3
|
+
class Morpheus::LibraryContainerUpgradesInterface < Morpheus::APIClient
|
4
|
+
def initialize(access_token, refresh_token,expires_at = nil, base_url=nil)
|
5
|
+
@access_token = access_token
|
6
|
+
@refresh_token = refresh_token
|
7
|
+
@base_url = base_url
|
8
|
+
@expires_at = expires_at
|
9
|
+
end
|
10
|
+
|
11
|
+
def get(instance_type_id, id, params={})
|
12
|
+
#raise "#{self.class}.get() passed a blank instance_type_id!" if instance_type_id.to_s == ''
|
13
|
+
raise "#{self.class}.get() passed a blank id!" if id.to_s == ''
|
14
|
+
url = build_url(instance_type_id, id)
|
15
|
+
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
16
|
+
opts = {method: :get, url: url, headers: headers}
|
17
|
+
execute(opts)
|
18
|
+
end
|
19
|
+
|
20
|
+
def list(instance_type_id, params={})
|
21
|
+
url = build_url(instance_type_id)
|
22
|
+
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
23
|
+
opts = {method: :get, url: url, headers: headers}
|
24
|
+
execute(opts)
|
25
|
+
end
|
26
|
+
|
27
|
+
def create(instance_type_id, options)
|
28
|
+
url = build_url(instance_type_id)
|
29
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
30
|
+
payload = options
|
31
|
+
opts = {method: :post, url: url, headers: headers, payload: payload.to_json}
|
32
|
+
execute(opts)
|
33
|
+
end
|
34
|
+
|
35
|
+
def update(instance_type_id, id, options)
|
36
|
+
url = build_url(instance_type_id, id)
|
37
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
38
|
+
payload = options
|
39
|
+
opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
|
40
|
+
execute(opts)
|
41
|
+
end
|
42
|
+
|
43
|
+
def destroy(instance_type_id, id, payload={})
|
44
|
+
url = build_url(instance_type_id, id)
|
45
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
46
|
+
opts = {method: :delete, url: url, headers: headers, payload: payload.to_json}
|
47
|
+
execute(opts)
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def build_url(instance_type_id=nil, id=nil)
|
53
|
+
url = "#{@base_url}/api"
|
54
|
+
if instance_type_id
|
55
|
+
url += "/library/#{instance_type_id}/upgrades"
|
56
|
+
else
|
57
|
+
url += "/library/upgrades" # this api route does not exist yet
|
58
|
+
end
|
59
|
+
if id
|
60
|
+
url += "/#{id}"
|
61
|
+
end
|
62
|
+
url
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'morpheus/api/api_client'
|
2
|
+
|
3
|
+
class Morpheus::LibraryInstanceTypesInterface < Morpheus::APIClient
|
4
|
+
def initialize(access_token, refresh_token,expires_at = nil, base_url=nil)
|
5
|
+
@access_token = access_token
|
6
|
+
@refresh_token = refresh_token
|
7
|
+
@base_url = base_url
|
8
|
+
@expires_at = expires_at
|
9
|
+
end
|
10
|
+
|
11
|
+
def get(id, params={})
|
12
|
+
raise "#{self.class}.get() passed a blank id!" if id.to_s == ''
|
13
|
+
url = "#{@base_url}/api/library/#{id}"
|
14
|
+
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
15
|
+
opts = {method: :get, url: url, headers: headers}
|
16
|
+
execute(opts)
|
17
|
+
end
|
18
|
+
|
19
|
+
def list(params={})
|
20
|
+
url = "#{@base_url}/api/library"
|
21
|
+
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
22
|
+
opts = {method: :get, url: url, headers: headers}
|
23
|
+
execute(opts)
|
24
|
+
end
|
25
|
+
|
26
|
+
def create(options)
|
27
|
+
url = "#{@base_url}/api/library"
|
28
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
29
|
+
payload = options
|
30
|
+
opts = {method: :post, url: url, headers: headers, payload: payload.to_json}
|
31
|
+
execute(opts)
|
32
|
+
end
|
33
|
+
|
34
|
+
def update(id, options)
|
35
|
+
url = "#{@base_url}/api/library/#{id}"
|
36
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
37
|
+
payload = options
|
38
|
+
opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
|
39
|
+
execute(opts)
|
40
|
+
end
|
41
|
+
|
42
|
+
def destroy(id, payload={})
|
43
|
+
url = "#{@base_url}/api/library/#{id}"
|
44
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
45
|
+
opts = {method: :delete, url: url, headers: headers, payload: payload.to_json}
|
46
|
+
execute(opts)
|
47
|
+
end
|
48
|
+
|
49
|
+
# NOT json, multipart file upload
|
50
|
+
def update_logo(id, logo_file)
|
51
|
+
url = "#{@base_url}/api/library/#{id}/update-logo"
|
52
|
+
headers = { :params => {}, :authorization => "Bearer #{@access_token}"}
|
53
|
+
payload = {}
|
54
|
+
payload[:logo] = logo_file
|
55
|
+
payload[:multipart] = true
|
56
|
+
execute(method: :post, url: url, headers: headers, payload: payload)
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'morpheus/api/api_client'
|
2
|
+
|
3
|
+
class Morpheus::LibraryLayoutsInterface < Morpheus::APIClient
|
4
|
+
def initialize(access_token, refresh_token,expires_at = nil, base_url=nil)
|
5
|
+
@access_token = access_token
|
6
|
+
@refresh_token = refresh_token
|
7
|
+
@base_url = base_url
|
8
|
+
@expires_at = expires_at
|
9
|
+
end
|
10
|
+
|
11
|
+
def get(instance_type_id, id, params={})
|
12
|
+
raise "#{self.class}.get() passed a blank id!" if id.to_s == ''
|
13
|
+
url = build_url(instance_type_id, id)
|
14
|
+
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
15
|
+
opts = {method: :get, url: url, headers: headers}
|
16
|
+
execute(opts)
|
17
|
+
end
|
18
|
+
|
19
|
+
def list(instance_type_id, params={})
|
20
|
+
url = build_url(instance_type_id)
|
21
|
+
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
22
|
+
opts = {method: :get, url: url, headers: headers}
|
23
|
+
execute(opts)
|
24
|
+
end
|
25
|
+
|
26
|
+
def create(instance_type_id, options)
|
27
|
+
url = build_url(instance_type_id)
|
28
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
29
|
+
payload = options
|
30
|
+
opts = {method: :post, url: url, headers: headers, payload: payload.to_json}
|
31
|
+
execute(opts)
|
32
|
+
end
|
33
|
+
|
34
|
+
def update(instance_type_id, id, options)
|
35
|
+
url = build_url(instance_type_id, id)
|
36
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
37
|
+
payload = options
|
38
|
+
opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
|
39
|
+
execute(opts)
|
40
|
+
end
|
41
|
+
|
42
|
+
def destroy(instance_type_id, id, payload={})
|
43
|
+
url = build_url(instance_type_id, id)
|
44
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
45
|
+
opts = {method: :delete, url: url, headers: headers, payload: payload.to_json}
|
46
|
+
execute(opts)
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def build_url(instance_type_id=nil, id=nil)
|
52
|
+
url = "#{@base_url}/api"
|
53
|
+
if instance_type_id
|
54
|
+
url += "/library/#{instance_type_id}/layouts"
|
55
|
+
else
|
56
|
+
url += "/library/layouts"
|
57
|
+
end
|
58
|
+
if id
|
59
|
+
url += "/#{id}"
|
60
|
+
end
|
61
|
+
url
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
end
|