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,45 +1,36 @@
1
- require 'json'
2
- require 'morpheus/rest_client'
1
+ require 'morpheus/api/api_client'
3
2
 
4
3
  class Morpheus::SecurityGroupRulesInterface < 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
11
 
13
- def get(security_group_id, options=nil)
14
- url = "#{@base_url}/api/security-groups/#{security_group_id}/rules"
15
- headers = { params: {}, authorization: "Bearer #{@access_token}" }
12
+ def get(security_group_id, options=nil)
13
+ url = "#{@base_url}/api/security-groups/#{security_group_id}/rules"
14
+ headers = { params: {}, authorization: "Bearer #{@access_token}" }
16
15
 
17
- if options.is_a?(Hash)
18
- headers[:params].merge!(options)
19
- elsif options.is_a?(Numeric)
20
- url = "#{@base_url}/api/security-groups/#{security_group_id}/rules/#{options}"
21
- end
22
- response = Morpheus::RestClient.execute(method: :get, url: url,
23
- timeout: 30, headers: headers)
24
- JSON.parse(response.to_s)
25
- end
16
+ if options.is_a?(Hash)
17
+ headers[:params].merge!(options)
18
+ elsif options.is_a?(Numeric)
19
+ url = "#{@base_url}/api/security-groups/#{security_group_id}/rules/#{options}"
20
+ end
21
+ execute(method: :get, url: url, headers: headers)
22
+ end
26
23
 
27
- def create(security_group_id, options)
28
- url = "#{@base_url}/api/security-groups/#{security_group_id}/rules"
29
- headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
30
-
31
- payload = options
32
- response = Morpheus::RestClient.execute(method: :post, url: url,
33
- timeout: 30, headers: headers, payload: payload.to_json)
34
- JSON.parse(response.to_s)
35
- end
24
+ def create(security_group_id, options)
25
+ url = "#{@base_url}/api/security-groups/#{security_group_id}/rules"
26
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
27
+ payload = options
28
+ execute(method: :post, url: url, headers: headers, payload: payload.to_json)
29
+ end
36
30
 
37
- def delete(security_group_id, id)
38
- url = "#{@base_url}/api/security-groups/#{security_group_id}/rules/#{id}"
39
- print "url #{url}"
40
- headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
41
- response = Morpheus::RestClient.execute(method: :delete, url: url,
42
- timeout: 30, headers: headers)
43
- JSON.parse(response.to_s)
44
- end
31
+ def delete(security_group_id, id)
32
+ url = "#{@base_url}/api/security-groups/#{security_group_id}/rules/#{id}"
33
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
34
+ execute(method: :delete, url: url, headers: headers)
35
+ end
45
36
  end
@@ -1,59 +1,47 @@
1
- require 'json'
2
- require 'rest-client'
1
+ require 'morpheus/api/api_client'
3
2
 
4
3
  class Morpheus::SecurityGroupsInterface < 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 list(options=nil)
13
- url = "#{@base_url}/api/security-groups"
14
- headers = { params: {}, authorization: "Bearer #{@access_token}" }
15
- if options.is_a?(Hash)
16
- headers[:params].merge!(options)
17
- end
18
- response = Morpheus::RestClient.execute(method: :get, url: url,
19
- timeout: 30, headers: headers, verify_ssl: false)
20
- JSON.parse(response.to_s)
21
- end
11
+ def list(options=nil)
12
+ url = "#{@base_url}/api/security-groups"
13
+ headers = { params: {}, authorization: "Bearer #{@access_token}" }
14
+ if options.is_a?(Hash)
15
+ headers[:params].merge!(options)
16
+ end
17
+ execute(method: :get, url: url, headers: headers)
18
+ end
22
19
 
23
- def get(options)
24
- url = "#{@base_url}/api/security-groups/#{options[:id]}"
25
- headers = { params: {}, authorization: "Bearer #{@access_token}" }
26
- if options.is_a?(Hash)
27
- headers[:params].merge!(options)
28
- end
29
- response = Morpheus::RestClient.execute(method: :get, url: url,
30
- timeout: 30, headers: headers, verify_ssl: false)
31
- JSON.parse(response.to_s)
32
- end
20
+ def get(options)
21
+ url = "#{@base_url}/api/security-groups/#{options[:id]}"
22
+ headers = { params: {}, authorization: "Bearer #{@access_token}" }
23
+ if options.is_a?(Hash)
24
+ headers[:params].merge!(options)
25
+ end
26
+ execute(method: :get, url: url, headers: headers)
27
+ end
33
28
 
34
- def create(options)
35
- url = "#{@base_url}/api/security-groups"
36
- headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
37
-
38
- payload = options
39
- response = Morpheus::RestClient.execute(method: :post, url: url,
40
- timeout: 30, headers: headers, verify_ssl: false, payload: payload.to_json)
41
- JSON.parse(response.to_s)
42
- end
29
+ def create(options)
30
+ url = "#{@base_url}/api/security-groups"
31
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
32
+ payload = options
33
+ execute(method: :post, url: url, headers: headers, payload: payload.to_json)
34
+ end
43
35
 
44
- def update(id)
45
- url = "#{@base_url}/api/security-groups/#{id}"
46
- headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
47
- response = Morpheus::RestClient.execute(method: :put, url: url,
48
- timeout: 30, headers: headers, verify_ssl: false)
49
- JSON.parse(response.to_s)
50
- end
36
+ def update(id)
37
+ url = "#{@base_url}/api/security-groups/#{id}"
38
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
39
+ execute(method: :put, url: url, headers: headers)
40
+ end
51
41
 
52
- def delete(id)
53
- url = "#{@base_url}/api/security-groups/#{id}"
54
- headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
55
- response = Morpheus::RestClient.execute(method: :delete, url: url,
56
- timeout: 30, headers: headers, verify_ssl: false)
57
- JSON.parse(response.to_s)
58
- end
42
+ def delete(id)
43
+ url = "#{@base_url}/api/security-groups/#{id}"
44
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
45
+ execute(method: :delete, url: url, headers: headers)
46
+ end
59
47
  end
@@ -1,119 +1,117 @@
1
- require 'json'
2
- require 'rest-client'
1
+ require 'morpheus/api/api_client'
3
2
 
4
3
  class Morpheus::ServersInterface < 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 get(options=nil)
13
- url = "#{@base_url}/api/servers"
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/servers/#{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
-
29
- def create(options)
30
- url = "#{@base_url}/api/servers"
31
- headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
32
-
33
- payload = options
34
- response = Morpheus::RestClient.execute(method: :post, url: url,
35
- timeout: 30, headers: headers, verify_ssl:false, payload: payload.to_json)
36
- JSON.parse(response.to_s)
37
- end
38
-
39
- def stop(serverId,payload = {})
40
- url = "#{@base_url}/api/servers/#{serverId}/stop"
41
- headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
42
- response = Morpheus::RestClient.execute(method: :put, url: url,
43
- timeout: 30, headers: headers, verify_ssl:false, payload: payload.to_json)
44
- JSON.parse(response.to_s)
45
- end
46
-
47
- def start(serverId,payload = {})
48
- url = "#{@base_url}/api/servers/#{serverId}/start"
49
- headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
50
- response = Morpheus::RestClient.execute(method: :put, url: url,
51
- timeout: 30, headers: headers, verify_ssl:false, payload: payload.to_json)
52
- JSON.parse(response.to_s)
53
- end
54
-
55
- def install_agent(serverId,payload = {})
56
- url = "#{@base_url}/api/servers/#{serverId}/install-agent"
57
- headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
58
- response = Morpheus::RestClient.execute(method: :put, url: url,
59
- timeout: 30, headers: headers, verify_ssl:false, payload: payload.to_json)
60
- JSON.parse(response.to_s)
61
- end
62
-
63
- def upgrade(serverId,payload = {})
64
- url = "#{@base_url}/api/servers/#{serverId}/upgrade"
65
- headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
66
- response = Morpheus::RestClient.execute(method: :put, url: url,
67
- timeout: 30, headers: headers, verify_ssl:false, payload: payload.to_json)
68
- JSON.parse(response.to_s)
69
- end
70
-
71
- def reprovision(serverId,payload = {})
72
- url = "#{@base_url}/api/servers/#{serverId}/reprovision"
73
- headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
74
- response = Morpheus::RestClient.execute(method: :put, url: url,
75
- timeout: 30, headers: headers, verify_ssl:false, payload: payload.to_json)
76
- JSON.parse(response.to_s)
77
- end
78
-
79
- def reinitialize(serverId,payload = {})
80
- url = "#{@base_url}/api/servers/#{serverId}/reinitialize"
81
- headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
82
- response = Morpheus::RestClient.execute(method: :put, url: url,
83
- timeout: 30, headers: headers, verify_ssl:false, payload: payload.to_json)
84
- JSON.parse(response.to_s)
85
- end
86
-
87
- def assign_account(serverId,payload = {})
88
- url = "#{@base_url}/api/servers/#{serverId}/assign-account"
89
- headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
90
- response = Morpheus::RestClient.execute(method: :put, url: url,
91
- timeout: 30, headers: headers, verify_ssl:false, payload: payload.to_json)
92
- JSON.parse(response.to_s)
93
- end
94
-
95
- def workflow(id,task_set_id,payload)
96
- url = "#{@base_url}/api/servers/#{id}/workflow"
97
- headers = { :params => {:taskSetId => task_set_id},:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
98
- response = Morpheus::RestClient.execute(method: :put, url: url,
99
- timeout: 30, headers: headers,verify_ssl: false,payload: payload.to_json)
100
- JSON.parse(response.to_s)
101
- end
102
-
103
- def destroy(id, params={})
104
- url = "#{@base_url}/api/servers/#{id}"
105
- headers = { :params => params,:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
106
- response = Morpheus::RestClient.execute(method: :delete, url: url,
107
- timeout: 30, headers: headers, verify_ssl:false)
108
- JSON.parse(response.to_s)
109
- end
110
-
111
- def service_plans(params)
112
- url = "#{@base_url}/api/servers/service-plans"
113
- headers = { params: params, authorization: "Bearer #{@access_token}" }
114
- response = Morpheus::RestClient.execute(method: :get, url: url,
115
- timeout: 30, headers: headers, verify_ssl: false)
116
- JSON.parse(response.to_s)
117
- 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 get(options=nil)
12
+ url = "#{@base_url}/api/servers"
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/servers/#{options}"
18
+ elsif options.is_a?(String)
19
+ headers[:params]['name'] = options
20
+ end
21
+ opts = {method: :get, url: url, headers: headers}
22
+ execute(opts)
23
+ end
24
+
25
+ def create(options)
26
+ url = "#{@base_url}/api/servers"
27
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
28
+ payload = options
29
+ opts = {method: :post, url: url, headers: headers, payload: payload.to_json}
30
+ execute(opts)
31
+ end
32
+
33
+ def stop(serverId,payload = {})
34
+ url = "#{@base_url}/api/servers/#{serverId}/stop"
35
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
36
+ opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
37
+ execute(opts)
38
+ end
39
+
40
+ def start(serverId,payload = {})
41
+ url = "#{@base_url}/api/servers/#{serverId}/start"
42
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
43
+ opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
44
+ execute(opts)
45
+ end
46
+
47
+ def install_agent(serverId,payload = {})
48
+ url = "#{@base_url}/api/servers/#{serverId}/install-agent"
49
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
50
+ opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
51
+ execute(opts)
52
+ end
53
+
54
+ def upgrade(serverId,payload = {})
55
+ url = "#{@base_url}/api/servers/#{serverId}/upgrade"
56
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
57
+ opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
58
+ execute(opts)
59
+ end
60
+
61
+ def reprovision(serverId,payload = {})
62
+ url = "#{@base_url}/api/servers/#{serverId}/reprovision"
63
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
64
+ opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
65
+ execute(opts)
66
+ end
67
+
68
+ def reinitialize(serverId,payload = {})
69
+ url = "#{@base_url}/api/servers/#{serverId}/reinitialize"
70
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
71
+ opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
72
+ execute(opts)
73
+ end
74
+
75
+ def assign_account(serverId,payload = {})
76
+ url = "#{@base_url}/api/servers/#{serverId}/assign-account"
77
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
78
+ opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
79
+ execute(opts)
80
+ end
81
+
82
+ def workflow(id,task_set_id,payload)
83
+ url = "#{@base_url}/api/servers/#{id}/workflow"
84
+ headers = { :params => {:taskSetId => task_set_id},:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
85
+ opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
86
+ execute(opts)
87
+ end
88
+
89
+ def destroy(id, params={})
90
+ url = "#{@base_url}/api/servers/#{id}"
91
+ headers = { :params => params,:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
92
+ opts = {method: :delete, url: url, headers: headers}
93
+ execute(opts)
94
+ end
95
+
96
+ def service_plans(params)
97
+ url = "#{@base_url}/api/servers/service-plans"
98
+ headers = { params: params, authorization: "Bearer #{@access_token}" }
99
+ opts = {method: :get, url: url, headers: headers}
100
+ execute(opts)
101
+ end
102
+
103
+ def volumes(id)
104
+ url = "#{@base_url}/api/servers/#{id}/volumes"
105
+ headers = { :params => {},:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
106
+ opts = {method: :get, url: url, headers: headers}
107
+ execute(opts)
108
+ end
109
+
110
+ def resize(id,payload)
111
+ url = "#{@base_url}/api/servers/#{id}/resize"
112
+ headers = { :params => {},:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
113
+ opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
114
+ execute(opts)
115
+ end
118
116
 
119
117
  end
@@ -0,0 +1,31 @@
1
+ require 'morpheus/api/api_client'
2
+ # There is no authentication required for this API.
3
+ class Morpheus::SetupInterface < 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 initialize(base_url)
12
+ @base_url = base_url
13
+ end
14
+
15
+ def get(options={})
16
+ url = "#{@base_url}/api/setup"
17
+ # headers = {:params => {}, authorization: "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
18
+ headers = {:params => {}, 'Content-Type' => 'application/json' }
19
+ headers[:params].merge!(options)
20
+ execute(method: :get, url: url, headers: headers)
21
+ end
22
+
23
+ def init(options={})
24
+ url = "#{@base_url}/api/setup/init"
25
+ # headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
26
+ headers = { 'Content-Type' => 'application/json' }
27
+ payload = options
28
+ execute(method: :post, url: url, timeout: 30, headers: headers, payload: payload.to_json)
29
+ end
30
+
31
+ end
@@ -1,46 +1,44 @@
1
- require 'json'
2
- require 'rest-client'
1
+ require 'morpheus/api/api_client'
3
2
 
4
3
  class Morpheus::TaskSetsInterface < 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/task-sets"
14
- headers = { params: {}, authorization: "Bearer #{@access_token}" }
11
+ def get(options=nil)
12
+ url = "#{@base_url}/api/task-sets"
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/task-sets/#{options}"
18
+ elsif options.is_a?(String)
19
+ headers[:params]['name'] = options
20
+ end
21
+ execute(method: :get, url: url, headers: headers)
22
+ end
15
23
 
16
- if options.is_a?(Hash)
17
- headers[:params].merge!(options)
18
- elsif options.is_a?(Numeric)
19
- url = "#{@base_url}/api/tasks/#{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
24
 
25
+ def create(options)
26
+ url = "#{@base_url}/api/task-sets"
27
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
28
+ payload = options
29
+ execute(method: :post, url: url, headers: headers, payload: payload.to_json)
30
+ end
28
31
 
29
- def create(options)
30
- url = "#{@base_url}/api/task-sets"
31
- headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
32
-
33
- payload = options
34
- response = Morpheus::RestClient.execute(method: :post, url: url,
35
- timeout: 30, headers: headers, verify_ssl:false, payload: payload.to_json)
36
- JSON.parse(response.to_s)
37
- end
32
+ def update(id, options)
33
+ url = "#{@base_url}/api/task-sets/#{id}"
34
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
35
+ payload = options
36
+ execute(method: :put, url: url, headers: headers, payload: payload.to_json)
37
+ end
38
38
 
39
- def destroy(id)
40
- url = "#{@base_url}/api/task-sets/#{id}"
41
- headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
42
- response = Morpheus::RestClient.execute(method: :delete, url: url,
43
- timeout: 30, headers: headers, verify_ssl:false)
44
- JSON.parse(response.to_s)
45
- end
39
+ def destroy(id)
40
+ url = "#{@base_url}/api/task-sets/#{id}"
41
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
42
+ execute(method: :delete, url: url, headers: headers)
43
+ end
46
44
  end