morpheus-cli 2.10.0 → 2.10.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/bin/morpheus +27 -32
  3. data/lib/morpheus/api/accounts_interface.rb +36 -47
  4. data/lib/morpheus/api/api_client.rb +141 -110
  5. data/lib/morpheus/api/app_templates_interface.rb +56 -72
  6. data/lib/morpheus/api/apps_interface.rb +111 -132
  7. data/lib/morpheus/api/auth_interface.rb +30 -0
  8. data/lib/morpheus/api/clouds_interface.rb +71 -76
  9. data/lib/morpheus/api/custom_instance_types_interface.rb +21 -46
  10. data/lib/morpheus/api/dashboard_interface.rb +10 -17
  11. data/lib/morpheus/api/deploy_interface.rb +60 -72
  12. data/lib/morpheus/api/deployments_interface.rb +53 -71
  13. data/lib/morpheus/api/groups_interface.rb +55 -45
  14. data/lib/morpheus/api/instance_types_interface.rb +19 -23
  15. data/lib/morpheus/api/instances_interface.rb +179 -177
  16. data/lib/morpheus/api/key_pairs_interface.rb +11 -17
  17. data/lib/morpheus/api/license_interface.rb +18 -23
  18. data/lib/morpheus/api/load_balancers_interface.rb +54 -69
  19. data/lib/morpheus/api/logs_interface.rb +25 -29
  20. data/lib/morpheus/api/options_interface.rb +13 -17
  21. data/lib/morpheus/api/provision_types_interface.rb +19 -22
  22. data/lib/morpheus/api/roles_interface.rb +75 -94
  23. data/lib/morpheus/api/security_group_rules_interface.rb +28 -37
  24. data/lib/morpheus/api/security_groups_interface.rb +39 -51
  25. data/lib/morpheus/api/servers_interface.rb +113 -115
  26. data/lib/morpheus/api/setup_interface.rb +31 -0
  27. data/lib/morpheus/api/task_sets_interface.rb +36 -38
  28. data/lib/morpheus/api/tasks_interface.rb +56 -69
  29. data/lib/morpheus/api/users_interface.rb +67 -76
  30. data/lib/morpheus/api/virtual_images_interface.rb +61 -61
  31. data/lib/morpheus/api/whoami_interface.rb +12 -15
  32. data/lib/morpheus/cli.rb +71 -60
  33. data/lib/morpheus/cli/accounts.rb +254 -315
  34. data/lib/morpheus/cli/alias_command.rb +219 -0
  35. data/lib/morpheus/cli/app_templates.rb +264 -272
  36. data/lib/morpheus/cli/apps.rb +608 -671
  37. data/lib/morpheus/cli/cli_command.rb +259 -21
  38. data/lib/morpheus/cli/cli_registry.rb +99 -14
  39. data/lib/morpheus/cli/clouds.rb +599 -372
  40. data/lib/morpheus/cli/config_file.rb +126 -0
  41. data/lib/morpheus/cli/credentials.rb +141 -117
  42. data/lib/morpheus/cli/dashboard_command.rb +48 -56
  43. data/lib/morpheus/cli/deployments.rb +254 -268
  44. data/lib/morpheus/cli/deploys.rb +150 -142
  45. data/lib/morpheus/cli/error_handler.rb +38 -0
  46. data/lib/morpheus/cli/groups.rb +551 -179
  47. data/lib/morpheus/cli/hosts.rb +862 -617
  48. data/lib/morpheus/cli/instance_types.rb +103 -95
  49. data/lib/morpheus/cli/instances.rb +1335 -1009
  50. data/lib/morpheus/cli/key_pairs.rb +82 -90
  51. data/lib/morpheus/cli/library.rb +498 -499
  52. data/lib/morpheus/cli/license.rb +83 -101
  53. data/lib/morpheus/cli/load_balancers.rb +314 -300
  54. data/lib/morpheus/cli/login.rb +66 -44
  55. data/lib/morpheus/cli/logout.rb +47 -46
  56. data/lib/morpheus/cli/mixins/accounts_helper.rb +69 -31
  57. data/lib/morpheus/cli/mixins/infrastructure_helper.rb +106 -0
  58. data/lib/morpheus/cli/mixins/print_helper.rb +181 -17
  59. data/lib/morpheus/cli/mixins/provisioning_helper.rb +535 -458
  60. data/lib/morpheus/cli/mixins/whoami_helper.rb +2 -2
  61. data/lib/morpheus/cli/option_parser.rb +35 -0
  62. data/lib/morpheus/cli/option_types.rb +232 -192
  63. data/lib/morpheus/cli/recent_activity_command.rb +61 -65
  64. data/lib/morpheus/cli/remote.rb +446 -199
  65. data/lib/morpheus/cli/roles.rb +884 -906
  66. data/lib/morpheus/cli/security_group_rules.rb +213 -203
  67. data/lib/morpheus/cli/security_groups.rb +237 -192
  68. data/lib/morpheus/cli/shell.rb +338 -231
  69. data/lib/morpheus/cli/tasks.rb +326 -308
  70. data/lib/morpheus/cli/users.rb +457 -462
  71. data/lib/morpheus/cli/version.rb +1 -1
  72. data/lib/morpheus/cli/version_command.rb +16 -18
  73. data/lib/morpheus/cli/virtual_images.rb +526 -345
  74. data/lib/morpheus/cli/whoami.rb +125 -111
  75. data/lib/morpheus/cli/workflows.rb +338 -185
  76. data/lib/morpheus/formatters.rb +8 -1
  77. data/lib/morpheus/logging.rb +1 -1
  78. data/lib/morpheus/rest_client.rb +17 -8
  79. metadata +9 -3
  80. data/lib/morpheus/api/custom_instance_types.rb +0 -55
@@ -1,5 +1,4 @@
1
- require 'json'
2
- require 'rest-client'
1
+ require 'morpheus/api/api_client'
3
2
 
4
3
  class Morpheus::KeyPairsInterface < Morpheus::APIClient
5
4
  def initialize(access_token, refresh_token,expires_at = nil, base_url=nil)
@@ -14,9 +13,8 @@ class Morpheus::KeyPairsInterface < Morpheus::APIClient
14
13
  url = "#{@base_url}/api/key-pairs/#{id}"
15
14
  headers = { params: {}, authorization: "Bearer #{@access_token}" }
16
15
  headers[:params]['accountId'] = account_id if account_id
17
- response = Morpheus::RestClient.execute(method: :get, url: url,
18
- timeout: 10, headers: headers)
19
- JSON.parse(response.to_s)
16
+ opts = {method: :get, url: url, headers: headers}
17
+ execute(opts)
20
18
  end
21
19
 
22
20
  def list(account_id, options={})
@@ -24,9 +22,8 @@ class Morpheus::KeyPairsInterface < Morpheus::APIClient
24
22
  headers = { params: {}, authorization: "Bearer #{@access_token}" }
25
23
  headers[:params].merge!(options)
26
24
  headers[:params]['accountId'] = account_id if account_id
27
- response = Morpheus::RestClient.execute(method: :get, url: url,
28
- timeout: 10, headers: headers)
29
- JSON.parse(response.to_s)
25
+ opts = {method: :get, url: url, headers: headers}
26
+ execute(opts)
30
27
  end
31
28
 
32
29
  def create(account_id, options)
@@ -34,9 +31,8 @@ class Morpheus::KeyPairsInterface < Morpheus::APIClient
34
31
  headers = { :params => {}, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
35
32
  headers[:params]['accountId'] = account_id if account_id
36
33
  payload = options
37
- response = Morpheus::RestClient.execute(method: :post, url: url,
38
- timeout: 10, headers: headers, payload: payload.to_json)
39
- JSON.parse(response.to_s)
34
+ opts = {method: :post, url: url, headers: headers, payload: payload.to_json}
35
+ execute(opts)
40
36
  end
41
37
 
42
38
  def update(account_id, id, options)
@@ -44,17 +40,15 @@ class Morpheus::KeyPairsInterface < Morpheus::APIClient
44
40
  headers = { :params => {}, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
45
41
  headers[:params]['accountId'] = account_id if account_id
46
42
  payload = options
47
- response = Morpheus::RestClient.execute(method: :put, url: url,
48
- timeout: 10, headers: headers, payload: payload.to_json)
49
- JSON.parse(response.to_s)
43
+ opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
44
+ execute(opts)
50
45
  end
51
46
 
52
47
  def destroy(account_id, id)
53
48
  url = "#{@base_url}/api/key-pairs/#{id}"
54
49
  headers = { :params => {}, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
55
50
  headers[:params]['accountId'] = account_id if account_id
56
- response = Morpheus::RestClient.execute(method: :delete, url: url,
57
- timeout: 10, headers: headers)
58
- JSON.parse(response.to_s)
51
+ opts = {method: :delete, url: url, headers: headers}
52
+ execute(opts)
59
53
  end
60
54
  end
@@ -1,29 +1,24 @@
1
- require 'json'
2
- require 'rest-client'
1
+ require 'morpheus/api/api_client'
3
2
 
4
3
  class Morpheus::LicenseInterface < Morpheus::APIClient
5
- def initialize(access_token, refresh_token,expires_at = nil, base_url=nil)
6
- @access_token = access_token
7
- @refresh_token = refresh_token
8
- @base_url = base_url
9
- @expires_at = expires_at
10
- end
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
11
10
 
12
- def get()
13
- url = "#{@base_url}/api/license"
14
- headers = { params: {}, authorization: "Bearer #{@access_token}" }
15
- response = Morpheus::RestClient.execute(method: :get, url: url,
16
- timeout: 30, headers: headers, verify_ssl: false)
17
- JSON.parse(response.to_s)
18
- end
11
+ def get()
12
+ url = "#{@base_url}/api/license"
13
+ headers = { params: {}, authorization: "Bearer #{@access_token}" }
14
+ execute(method: :get, url: url, headers: headers)
15
+ end
19
16
 
20
- def apply(key)
21
- url = "#{@base_url}/api/license"
22
- headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
23
- payload = {license: key}
24
- response = Morpheus::RestClient.execute(method: :post, url: url,
25
- timeout: 30, headers: headers, payload: payload.to_json, verify_ssl: false)
26
- JSON.parse(response.to_s)
27
- end
17
+ def apply(key)
18
+ url = "#{@base_url}/api/license"
19
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
20
+ payload = {license: key}
21
+ execute(method: :post, url: url, headers: headers, payload: payload.to_json)
22
+ end
28
23
 
29
24
  end
@@ -1,72 +1,57 @@
1
- require 'json'
2
- require 'rest-client'
1
+ require 'morpheus/api/api_client'
3
2
 
4
3
  class Morpheus::LoadBalancersInterface < Morpheus::APIClient
5
- def initialize(access_token, refresh_token,expires_at = nil, base_url=nil)
6
- @access_token = access_token
7
- @refresh_token = refresh_token
8
- @base_url = base_url
9
- @expires_at = expires_at
10
- end
11
-
12
- def load_balancer_types(options={})
13
- url = "#{@base_url}/api/load-balancer-types"
14
- headers = { params: {}, authorization: "Bearer #{@access_token}" }
15
-
16
- if options.is_a?(Hash)
17
- headers[:params].merge!(options)
18
- elsif options.is_a?(Numeric)
19
- url = "#{@base_url}/api/load-balancer-types/#{options}"
20
- elsif options.is_a?(String)
21
- headers[:params]['name'] = options
22
- end
23
- response = Morpheus::RestClient.execute(method: :get, url: url,
24
- timeout: 30, headers: headers, verify_ssl:false)
25
- JSON.parse(response.to_s)
26
- end
27
-
28
- def get(options=nil)
29
- url = "#{@base_url}/api/load-balancers"
30
- headers = { params: {}, authorization: "Bearer #{@access_token}" }
31
-
32
- if options.is_a?(Hash)
33
- headers[:params].merge!(options)
34
- elsif options.is_a?(Numeric)
35
- url = "#{@base_url}/api/load-balancers/#{options}"
36
- elsif options.is_a?(String)
37
- headers[:params]['name'] = options
38
- end
39
- response = Morpheus::RestClient.execute(method: :get, url: url,
40
- timeout: 30, headers: headers, verify_ssl:false)
41
- JSON.parse(response.to_s)
42
- end
43
-
44
- def update(id, options)
45
- url = "#{@base_url}/api/load-balancers/#{id}"
46
- headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
47
-
48
- payload = options
49
- response = Morpheus::RestClient.execute(method: :put, url: url,
50
- timeout: 10, headers: headers, payload: payload.to_json)
51
- JSON.parse(response.to_s)
52
- end
53
-
54
-
55
- def create(options)
56
- url = "#{@base_url}/api/load-balancers"
57
- headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
58
-
59
- payload = options
60
- response = Morpheus::RestClient.execute(method: :post, url: url,
61
- timeout: 30, headers: headers, verify_ssl:false, payload: payload.to_json)
62
- JSON.parse(response.to_s)
63
- end
64
-
65
- def destroy(id)
66
- url = "#{@base_url}/api/load-balancers/#{id}"
67
- headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
68
- response = Morpheus::RestClient.execute(method: :delete, url: url,
69
- timeout: 30, headers: headers, verify_ssl:false)
70
- JSON.parse(response.to_s)
71
- end
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 load_balancer_types(options={})
12
+ url = "#{@base_url}/api/load-balancer-types"
13
+ headers = { params: {}, authorization: "Bearer #{@access_token}" }
14
+ if options.is_a?(Hash)
15
+ headers[:params].merge!(options)
16
+ elsif options.is_a?(Numeric)
17
+ url = "#{@base_url}/api/load-balancer-types/#{options}"
18
+ elsif options.is_a?(String)
19
+ headers[:params]['name'] = options
20
+ end
21
+ execute(method: :get, url: url, headers: headers)
22
+ end
23
+
24
+ def get(options=nil)
25
+ url = "#{@base_url}/api/load-balancers"
26
+ headers = { params: {}, authorization: "Bearer #{@access_token}" }
27
+ if options.is_a?(Hash)
28
+ headers[:params].merge!(options)
29
+ elsif options.is_a?(Numeric)
30
+ url = "#{@base_url}/api/load-balancers/#{options}"
31
+ elsif options.is_a?(String)
32
+ headers[:params]['name'] = options
33
+ end
34
+ execute(method: :get, url: url, headers: headers)
35
+ end
36
+
37
+ def update(id, options)
38
+ url = "#{@base_url}/api/load-balancers/#{id}"
39
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
40
+ payload = options
41
+ execute(method: :put, url: url, headers: headers, payload: payload.to_json)
42
+ end
43
+
44
+
45
+ def create(options)
46
+ url = "#{@base_url}/api/load-balancers"
47
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
48
+ payload = options
49
+ execute(method: :post, url: url, headers: headers, payload: payload.to_json)
50
+ end
51
+
52
+ def destroy(id)
53
+ url = "#{@base_url}/api/load-balancers/#{id}"
54
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
55
+ execute(method: :delete, url: url, headers: headers)
56
+ end
72
57
  end
@@ -1,37 +1,33 @@
1
- require 'json'
2
- require 'rest-client'
1
+ require 'morpheus/api/api_client'
3
2
 
4
3
  class Morpheus::LogsInterface < Morpheus::APIClient
5
- def initialize(access_token, refresh_token,expires_at = nil, base_url=nil)
6
- @access_token = access_token
7
- @refresh_token = refresh_token
8
- @base_url = base_url
9
- @expires_at = expires_at
10
- end
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
11
10
 
12
- def container_logs(containers=[], options={})
13
- url = "#{@base_url}/api/logs"
14
- headers = { params: {'containers' => containers}.merge(options), authorization: "Bearer #{@access_token}" }
15
- response = Morpheus::RestClient.execute(method: :get, url: url,
16
- timeout: 30, headers: headers, verify_ssl: false)
17
- JSON.parse(response.to_s)
18
- end
11
+ def container_logs(containers=[], options={})
12
+ url = "#{@base_url}/api/logs"
13
+ headers = { params: {'containers' => containers}.merge(options), authorization: "Bearer #{@access_token}" }
14
+ opts = {method: :get, url: url, headers: headers}
15
+ execute(opts)
16
+ end
19
17
 
20
- def server_logs(servers=[], options={})
21
- url = "#{@base_url}/api/logs"
22
- headers = { params: {'servers' => servers}.merge(options), authorization: "Bearer #{@access_token}" }
23
- response = Morpheus::RestClient.execute(method: :get, url: url,
24
- timeout: 30, headers: headers, verify_ssl: false)
25
- JSON.parse(response.to_s)
26
- end
18
+ def server_logs(servers=[], options={})
19
+ url = "#{@base_url}/api/logs"
20
+ headers = { params: {'servers' => servers}.merge(options), authorization: "Bearer #{@access_token}" }
21
+ opts = {method: :get, url: url, headers: headers}
22
+ execute(opts)
23
+ end
27
24
 
28
- def stats()
29
- url = "#{@base_url}/api/logs/log-stats"
30
- headers = { params: {}, authorization: "Bearer #{@access_token}" }
31
- response = Morpheus::RestClient.execute(method: :get, url: url,
32
- timeout: 30, headers: headers, verify_ssl: false)
33
- JSON.parse(response.to_s)
34
- end
25
+ def stats()
26
+ url = "#{@base_url}/api/logs/log-stats"
27
+ headers = { params: {}, authorization: "Bearer #{@access_token}" }
28
+ opts = {method: :get, url: url, headers: headers}
29
+ execute(opts)
30
+ end
35
31
 
36
32
 
37
33
  end
@@ -1,20 +1,16 @@
1
- require 'json'
2
- require 'rest-client'
1
+ require 'morpheus/api/api_client'
3
2
 
4
3
  class Morpheus::OptionsInterface < Morpheus::APIClient
5
- def initialize(access_token, refresh_token,expires_at = nil, base_url=nil)
6
- @access_token = access_token
7
- @refresh_token = refresh_token
8
- @base_url = base_url
9
- @expires_at = expires_at
10
- end
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
11
10
 
12
- def options_for_source(source,params = {})
13
- url = "#{@base_url}/api/options/#{source}"
14
- headers = { params: params, authorization: "Bearer #{@access_token}" }
15
-
16
- response = Morpheus::RestClient.execute(method: :get, url: url,
17
- timeout: 30, headers: headers,verify_ssl: false)
18
- JSON.parse(response.to_s)
19
- end
20
- end
11
+ def options_for_source(source,params = {})
12
+ url = "#{@base_url}/api/options/#{source}"
13
+ headers = { params: params, authorization: "Bearer #{@access_token}" }
14
+ execute(method: :get, url: url, headers: headers)
15
+ end
16
+ end
@@ -1,27 +1,24 @@
1
- require 'json'
2
- require 'morpheus/rest_client'
1
+ require 'morpheus/api/api_client'
3
2
 
4
3
  class Morpheus::ProvisionTypesInterface < Morpheus::APIClient
5
- def initialize(access_token, refresh_token,expires_at = nil, base_url=nil)
6
- @access_token = access_token
7
- @refresh_token = refresh_token
8
- @base_url = base_url
9
- @expires_at = expires_at
10
- end
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
11
10
 
12
- def get(options=nil)
13
- url = "#{@base_url}/api/provision-types"
14
- headers = { params: {}, authorization: "Bearer #{@access_token}" }
11
+ def get(options=nil)
12
+ url = "#{@base_url}/api/provision-types"
13
+ headers = { params: {}, authorization: "Bearer #{@access_token}" }
15
14
 
16
- if options.is_a?(Hash)
17
- headers[:params].merge!(options)
18
- elsif options.is_a?(Numeric)
19
- url = "#{@base_url}/api/provision-types/#{options}"
20
- elsif options.is_a?(String)
21
- headers[:params]['name'] = options
22
- end
23
- response = Morpheus::RestClient.execute(method: :get, url: url,
24
- timeout: 30, headers: headers, verify_ssl:false)
25
- JSON.parse(response.to_s)
26
- end
15
+ if options.is_a?(Hash)
16
+ headers[:params].merge!(options)
17
+ elsif options.is_a?(Numeric)
18
+ url = "#{@base_url}/api/provision-types/#{options}"
19
+ elsif options.is_a?(String)
20
+ headers[:params]['name'] = options
21
+ end
22
+ execute(method: :get, url: url, headers: headers)
23
+ end
27
24
  end
@@ -1,109 +1,90 @@
1
- require 'json'
2
- require 'rest-client'
1
+ require 'morpheus/api/api_client'
3
2
 
4
3
  class Morpheus::RolesInterface < Morpheus::APIClient
5
-
6
- def initialize(access_token, refresh_token, expires_at = nil, base_url=nil)
7
- @access_token = access_token
8
- @refresh_token = refresh_token
9
- @base_url = base_url
10
- @expires_at = expires_at
11
- end
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
12
10
 
13
- def get(account_id, id)
14
- raise "#{self.class}.get() passed a blank id!" if id.to_s == ''
15
- url = build_url(account_id, id)
16
- headers = { params: {}, authorization: "Bearer #{@access_token}" }
17
- response = Morpheus::RestClient.execute(method: :get, url: url,
18
- timeout: 10, headers: headers)
19
- JSON.parse(response.to_s)
20
- end
11
+ def get(account_id, id)
12
+ raise "#{self.class}.get() passed a blank id!" if id.to_s == ''
13
+ url = build_url(account_id, id)
14
+ headers = { params: {}, authorization: "Bearer #{@access_token}" }
15
+ execute(method: :get, url: url, headers: headers)
16
+ execute(method: :get, url: url, headers: headers)
17
+ end
21
18
 
22
- def list(account_id, options={})
23
- url = build_url(account_id)
24
- headers = { params: {}, authorization: "Bearer #{@access_token}" }
25
- headers[:params].merge!(options)
26
- response = Morpheus::RestClient.execute(method: :get, url: url,
27
- timeout: 10, headers: headers)
28
- JSON.parse(response.to_s)
29
- end
19
+ def list(account_id, options={})
20
+ url = build_url(account_id)
21
+ headers = { params: {}, authorization: "Bearer #{@access_token}" }
22
+ headers[:params].merge!(options)
23
+ execute(method: :get, url: url, headers: headers)
24
+ end
30
25
 
31
- def create(account_id, options)
32
- url = build_url(account_id)
33
- headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
34
- payload = options
35
- response = Morpheus::RestClient.execute(method: :post, url: url,
36
- timeout: 10, headers: headers, payload: payload.to_json)
37
- JSON.parse(response.to_s)
38
- end
26
+ def create(account_id, options)
27
+ url = build_url(account_id)
28
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
29
+ payload = options
30
+ execute(method: :post, url: url, headers: headers, payload: payload.to_json)
31
+ end
39
32
 
40
- def update(account_id, id, options)
41
- url = build_url(account_id, id)
42
- headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
43
- payload = options
44
- response = Morpheus::RestClient.execute(method: :put, url: url,
45
- timeout: 10, headers: headers, payload: payload.to_json)
46
- JSON.parse(response.to_s)
47
- end
33
+ def update(account_id, id, options)
34
+ url = build_url(account_id, id)
35
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
36
+ payload = options
37
+ execute(method: :put, url: url, headers: headers, payload: payload.to_json)
38
+ end
48
39
 
49
- def destroy(account_id, id)
50
- url = build_url(account_id, id)
51
- headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
52
- response = Morpheus::RestClient.execute(method: :delete, url: url,
53
- timeout: 10, headers: headers)
54
- JSON.parse(response.to_s)
55
- end
40
+ def destroy(account_id, id)
41
+ url = build_url(account_id, id)
42
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
43
+ execute(method: :delete, url: url, headers: headers)
44
+ end
56
45
 
57
- def update_permission(account_id, id, options)
58
- url = build_url(account_id, id) + "/update-permission"
59
- headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
60
- payload = options
61
- response = Morpheus::RestClient.execute(method: :put, url: url,
62
- timeout: 10, headers: headers, payload: payload.to_json)
63
- JSON.parse(response.to_s)
64
- end
46
+ def update_permission(account_id, id, options)
47
+ url = build_url(account_id, id) + "/update-permission"
48
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
49
+ payload = options
50
+ execute(method: :put, url: url, headers: headers, payload: payload.to_json)
51
+ end
65
52
 
66
- def update_instance_type(account_id, id, options)
67
- url = build_url(account_id, id) + "/update-instance-type"
68
- headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
69
- payload = options
70
- response = Morpheus::RestClient.execute(method: :put, url: url,
71
- timeout: 10, headers: headers, payload: payload.to_json)
72
- JSON.parse(response.to_s)
73
- end
53
+ def update_instance_type(account_id, id, options)
54
+ url = build_url(account_id, id) + "/update-instance-type"
55
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
56
+ payload = options
57
+ execute(method: :put, url: url, headers: headers, payload: payload.to_json)
58
+ end
74
59
 
75
- def update_group(account_id, id, options)
76
- url = build_url(account_id, id) + "/update-group"
77
- headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
78
- payload = options
79
- response = Morpheus::RestClient.execute(method: :put, url: url,
80
- timeout: 10, headers: headers, payload: payload.to_json)
81
- JSON.parse(response.to_s)
82
- end
60
+ def update_group(account_id, id, options)
61
+ url = build_url(account_id, id) + "/update-group"
62
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
63
+ payload = options
64
+ execute(method: :put, url: url, headers: headers, payload: payload.to_json)
65
+ end
83
66
 
84
- def update_cloud(account_id, id, options)
85
- url = build_url(account_id, id) + "/update-cloud"
86
- headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
87
- payload = options
88
- response = Morpheus::RestClient.execute(method: :put, url: url,
89
- timeout: 10, headers: headers, payload: payload.to_json)
90
- JSON.parse(response.to_s)
91
- end
67
+ def update_cloud(account_id, id, options)
68
+ url = build_url(account_id, id) + "/update-cloud"
69
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
70
+ payload = options
71
+ execute(method: :put, url: url, headers: headers, payload: payload.to_json)
72
+ end
92
73
 
93
- private
74
+ private
94
75
 
95
- def build_url(account_id=nil, role_id=nil)
96
- url = "#{@base_url}/api"
97
- if account_id
98
- #url += "/accounts/#{account_id}/roles"
99
- url += "/roles"
100
- else
101
- url += "/roles"
102
- end
103
- if role_id
104
- url += "/#{role_id}"
105
- end
106
- url
107
- end
76
+ def build_url(account_id=nil, role_id=nil)
77
+ url = "#{@base_url}/api"
78
+ if account_id
79
+ #url += "/accounts/#{account_id}/roles"
80
+ url += "/roles"
81
+ else
82
+ url += "/roles"
83
+ end
84
+ if role_id
85
+ url += "/#{role_id}"
86
+ end
87
+ url
88
+ end
108
89
 
109
90
  end