morpheus-cli 3.6.8 → 3.6.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/lib/morpheus/api/account_groups_interface.rb +2 -2
  3. data/lib/morpheus/api/accounts_interface.rb +4 -7
  4. data/lib/morpheus/api/api_client.rb +207 -70
  5. data/lib/morpheus/api/app_templates_interface.rb +7 -28
  6. data/lib/morpheus/api/apps_interface.rb +14 -21
  7. data/lib/morpheus/api/archive_buckets_interface.rb +2 -2
  8. data/lib/morpheus/api/archive_files_interface.rb +6 -6
  9. data/lib/morpheus/api/auth_interface.rb +14 -1
  10. data/lib/morpheus/api/blueprints_interface.rb +9 -16
  11. data/lib/morpheus/api/cloud_datastores_interface.rb +1 -1
  12. data/lib/morpheus/api/cloud_policies_interface.rb +1 -1
  13. data/lib/morpheus/api/clouds_interface.rb +18 -21
  14. data/lib/morpheus/api/cypher_interface.rb +19 -28
  15. data/lib/morpheus/api/file_copy_request_interface.rb +1 -1
  16. data/lib/morpheus/api/group_policies_interface.rb +1 -1
  17. data/lib/morpheus/api/groups_interface.rb +4 -4
  18. data/lib/morpheus/api/image_builder_boot_scripts_interface.rb +1 -1
  19. data/lib/morpheus/api/image_builder_image_builds_interface.rb +2 -2
  20. data/lib/morpheus/api/image_builder_preseed_scripts_interface.rb +1 -1
  21. data/lib/morpheus/api/instances_interface.rb +17 -23
  22. data/lib/morpheus/api/logs_interface.rb +7 -10
  23. data/lib/morpheus/api/network_domains_interface.rb +1 -1
  24. data/lib/morpheus/api/network_groups_interface.rb +1 -1
  25. data/lib/morpheus/api/network_pool_servers_interface.rb +1 -1
  26. data/lib/morpheus/api/network_pools_interface.rb +1 -1
  27. data/lib/morpheus/api/network_proxies_interface.rb +1 -1
  28. data/lib/morpheus/api/network_services_interface.rb +1 -1
  29. data/lib/morpheus/api/networks_interface.rb +1 -1
  30. data/lib/morpheus/api/old_cypher_interface.rb +55 -0
  31. data/lib/morpheus/api/packages_interface.rb +1 -1
  32. data/lib/morpheus/api/policies_interface.rb +1 -1
  33. data/lib/morpheus/api/setup_interface.rb +1 -1
  34. data/lib/morpheus/api/storage_providers_interface.rb +1 -1
  35. data/lib/morpheus/api/whoami_interface.rb +1 -1
  36. data/lib/morpheus/benchmarking.rb +277 -0
  37. data/lib/morpheus/cli.rb +6 -22
  38. data/lib/morpheus/cli/access_token_command.rb +172 -0
  39. data/lib/morpheus/cli/accounts.rb +5 -0
  40. data/lib/morpheus/cli/apps.rb +93 -37
  41. data/lib/morpheus/cli/archives_command.rb +0 -2
  42. data/lib/morpheus/cli/auth_command.rb +112 -0
  43. data/lib/morpheus/cli/blueprints_command.rb +50 -13
  44. data/lib/morpheus/cli/change_password_command.rb +148 -0
  45. data/lib/morpheus/cli/cli_command.rb +173 -49
  46. data/lib/morpheus/cli/clouds.rb +15 -5
  47. data/lib/morpheus/cli/command_error.rb +7 -1
  48. data/lib/morpheus/cli/{alias_command.rb → commands/standard/alias_command.rb} +79 -51
  49. data/lib/morpheus/cli/commands/standard/benchmark_command.rb +399 -0
  50. data/lib/morpheus/cli/commands/standard/coloring_command.rb +60 -0
  51. data/lib/morpheus/cli/{curl_command.rb → commands/standard/curl_command.rb} +0 -7
  52. data/lib/morpheus/cli/commands/standard/debug_command.rb +61 -0
  53. data/lib/morpheus/cli/{echo_command.rb → commands/standard/echo_command.rb} +1 -1
  54. data/lib/morpheus/cli/{edit_profile_command.rb → commands/standard/edit_profile_command.rb} +0 -0
  55. data/lib/morpheus/cli/{edit_rc_command.rb → commands/standard/edit_rc_command.rb} +0 -0
  56. data/lib/morpheus/cli/commands/standard/get_prompt_command.rb +39 -0
  57. data/lib/morpheus/cli/commands/standard/history_command.rb +76 -0
  58. data/lib/morpheus/cli/{log_level_command.rb → commands/standard/log_level_command.rb} +1 -1
  59. data/lib/morpheus/cli/{man_command.rb → commands/standard/man_command.rb} +2 -2
  60. data/lib/morpheus/cli/commands/standard/rm_command.rb +14 -0
  61. data/lib/morpheus/cli/commands/standard/set_prompt_command.rb +54 -0
  62. data/lib/morpheus/cli/{sleep_command.rb → commands/standard/sleep_command.rb} +0 -0
  63. data/lib/morpheus/cli/{source_command.rb → commands/standard/source_command.rb} +0 -0
  64. data/lib/morpheus/cli/{ssl_verification_command.rb → commands/standard/ssl_verification_command.rb} +1 -1
  65. data/lib/morpheus/cli/commands/standard/tee_command.rb +14 -0
  66. data/lib/morpheus/cli/{version_command.rb → commands/standard/version_command.rb} +0 -0
  67. data/lib/morpheus/cli/credentials.rb +276 -87
  68. data/lib/morpheus/cli/cypher_command.rb +333 -214
  69. data/lib/morpheus/cli/error_handler.rb +12 -2
  70. data/lib/morpheus/cli/groups.rb +44 -20
  71. data/lib/morpheus/cli/hosts.rb +39 -16
  72. data/lib/morpheus/cli/instances.rb +114 -62
  73. data/lib/morpheus/cli/login.rb +74 -21
  74. data/lib/morpheus/cli/logout.rb +3 -4
  75. data/lib/morpheus/cli/mixins/accounts_helper.rb +50 -18
  76. data/lib/morpheus/cli/mixins/print_helper.rb +207 -42
  77. data/lib/morpheus/cli/old_cypher_command.rb +414 -0
  78. data/lib/morpheus/cli/option_parser.rb +6 -1
  79. data/lib/morpheus/cli/processes_command.rb +3 -0
  80. data/lib/morpheus/cli/remote.rb +11 -17
  81. data/lib/morpheus/cli/roles.rb +17 -17
  82. data/lib/morpheus/cli/security_groups.rb +47 -17
  83. data/lib/morpheus/cli/shell.rb +139 -79
  84. data/lib/morpheus/cli/tenants_command.rb +353 -0
  85. data/lib/morpheus/cli/users.rb +26 -18
  86. data/lib/morpheus/cli/version.rb +1 -1
  87. data/lib/morpheus/cli/whoami.rb +14 -10
  88. data/lib/morpheus/formatters.rb +4 -4
  89. data/lib/morpheus/logging.rb +16 -8
  90. data/lib/morpheus/terminal.rb +63 -34
  91. metadata +28 -15
  92. data/lib/morpheus/cli/coloring_command.rb +0 -45
  93. data/lib/morpheus/cli/set_prompt_command.rb +0 -51
@@ -15,35 +15,24 @@ class Morpheus::AppTemplatesInterface < Morpheus::APIClient
15
15
  execute(method: :get, url: url, headers: headers)
16
16
  end
17
17
 
18
- def list(options={})
18
+ def list(params={})
19
19
  url = "#{@base_url}/api/app-templates"
20
- headers = { params: {}, authorization: "Bearer #{@access_token}" }
21
- headers[:params].merge!(options)
20
+ headers = { params: params, authorization: "Bearer #{@access_token}" }
22
21
  execute(method: :get, url: url, headers: headers)
23
22
  end
24
23
 
25
- def create(options)
24
+ def create(payload)
26
25
  url = "#{@base_url}/api/app-templates"
27
26
  headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
28
- payload = options
29
27
  execute(method: :post, url: url, headers: headers, payload: payload.to_json)
30
28
  end
31
29
 
32
- def update(id, options)
30
+ def update(id, payload)
33
31
  url = "#{@base_url}/api/app-templates/#{id}"
34
32
  headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
35
- payload = options
36
33
  execute(method: :put, url: url, headers: headers, payload: payload.to_json)
37
34
  end
38
35
 
39
- def save_image(id, options)
40
- url = "#{@base_url}/api/app-templates/#{id}"
41
- headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
42
- payload = options
43
- execute(method: :put, url: url, headers: headers, payload: payload.to_json)
44
- end
45
-
46
-
47
36
  # multipart image upload
48
37
  def save_image(id, image_file, params={})
49
38
  url = "#{@base_url}/api/app-templates/#{id}/image"
@@ -54,10 +43,9 @@ class Morpheus::AppTemplatesInterface < Morpheus::APIClient
54
43
  execute(method: :post, url: url, headers: headers, payload: payload)
55
44
  end
56
45
 
57
- def duplicate(id, options)
46
+ def duplicate(id, payload)
58
47
  url = "#{@base_url}/api/app-templates/#{id}/duplicate"
59
48
  headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
60
- payload = options
61
49
  execute(method: :post, url: url, headers: headers, payload: payload.to_json)
62
50
  end
63
51
 
@@ -67,19 +55,10 @@ class Morpheus::AppTemplatesInterface < Morpheus::APIClient
67
55
  execute(method: :delete, url: url, headers: headers)
68
56
  end
69
57
 
70
- def list_tiers(options={})
58
+ def list_tiers(params={})
71
59
  url = "#{@base_url}/api/app-templates/tiers"
72
- headers = { params: {}, authorization: "Bearer #{@access_token}" }
73
- headers[:params].merge!(options)
60
+ headers = { params: params, authorization: "Bearer #{@access_token}" }
74
61
  execute(method: :get, url: url, headers: headers)
75
62
  end
76
63
 
77
- # unused, prefer /options/instanceTypes
78
- # def list_types(options={})
79
- # url = "#{@base_url}/api/app-templates/types"
80
- # headers = { params: {}, authorization: "Bearer #{@access_token}" }
81
- # headers[:params].merge!(options)
82
- # execute(method: :get, url: url, headers: headers)
83
- # end
84
-
85
64
  end
@@ -9,66 +9,60 @@ class Morpheus::AppsInterface < Morpheus::APIClient
9
9
  end
10
10
 
11
11
 
12
- def get(options=nil)
12
+ def get(params={})
13
13
  url = "#{@base_url}/api/apps"
14
14
  headers = { params: {}, authorization: "Bearer #{@access_token}" }
15
- if options.is_a?(Hash)
16
- headers[:params].merge!(options)
17
- elsif options.is_a?(Numeric)
18
- url = "#{@base_url}/api/apps/#{options}"
19
- elsif options.is_a?(String)
20
- headers[:params]['name'] = options
15
+ if params.is_a?(Hash)
16
+ headers[:params].merge!(params)
17
+ elsif params.is_a?(Numeric)
18
+ url = "#{@base_url}/api/apps/#{params}"
19
+ elsif params.is_a?(String)
20
+ headers[:params]['name'] = params
21
21
  end
22
22
  opts = {method: :get, url: url, headers: headers}
23
23
  execute(opts)
24
24
  end
25
25
 
26
- def validate(options)
26
+ def validate(payload)
27
27
  # url = "#{@base_url}/api/apps/validate-instance"
28
28
  url = "#{@base_url}/api/apps/validate"
29
29
  headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
30
- payload = options
31
30
  opts = {method: :post, url: url, headers: headers, payload: payload.to_json}
32
31
  execute(opts)
33
32
  end
34
33
 
35
- def validate_instance(options)
34
+ def validate_instance(payload)
36
35
  # url = "#{@base_url}/api/apps/validate-instance"
37
36
  url = "#{@base_url}/api/apps/validate-instance"
38
37
  headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
39
- payload = options
40
38
  opts = {method: :post, url: url, headers: headers, payload: payload.to_json}
41
39
  execute(opts)
42
40
  end
43
41
 
44
- def create(options)
42
+ def create(payload)
45
43
  url = "#{@base_url}/api/apps"
46
44
  headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
47
- payload = options
48
45
  opts = {method: :post, url: url, headers: headers, payload: payload.to_json}
49
46
  execute(opts)
50
47
  end
51
48
 
52
- def update(app_id, options)
49
+ def update(app_id, payload)
53
50
  url = "#{@base_url}/api/apps/#{app_id}"
54
51
  headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
55
- payload = options
56
52
  opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
57
53
  execute(opts)
58
54
  end
59
55
 
60
- def add_instance(app_id, options)
56
+ def add_instance(app_id, payload)
61
57
  url = "#{@base_url}/api/apps/#{app_id}/add-instance"
62
58
  headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
63
- payload = options
64
59
  opts = {method: :post, url: url, headers: headers, payload: payload.to_json}
65
60
  execute(opts)
66
61
  end
67
62
 
68
- def remove_instance(app_id, options)
63
+ def remove_instance(app_id, payload)
69
64
  url = "#{@base_url}/api/apps/#{app_id}/remove-instance"
70
65
  headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
71
- payload = options
72
66
  opts = {method: :post, url: url, headers: headers, payload: payload.to_json}
73
67
  execute(opts)
74
68
  end
@@ -123,10 +117,9 @@ class Morpheus::AppsInterface < Morpheus::APIClient
123
117
  execute(opts)
124
118
  end
125
119
 
126
- def apply_security_groups(id, options)
120
+ def apply_security_groups(id, payload)
127
121
  url = "#{@base_url}/api/apps/#{id}/security-groups"
128
122
  headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
129
- payload = options
130
123
  opts = {method: :post, url: url, headers: headers, payload: payload.to_json}
131
124
  execute(opts)
132
125
  end
@@ -41,7 +41,7 @@ class Morpheus::ArchiveBucketsInterface < Morpheus::APIClient
41
41
  def destroy(id, params={})
42
42
  url = "#{@base_url}/api/archives/buckets/#{URI.escape(id.to_s)}"
43
43
  headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
44
- opts = {method: :delete, url: url, timeout: 30, headers: headers}
44
+ opts = {method: :delete, url: url, headers: headers}
45
45
  execute(opts)
46
46
  end
47
47
 
@@ -89,7 +89,7 @@ class Morpheus::ArchiveBucketsInterface < Morpheus::APIClient
89
89
  url = "#{@base_url}/api/archives/buckets/#{URI.escape(bucket_id.to_s)}" + ".zip"
90
90
  headers = { params: params, authorization: "Bearer #{@access_token}" }
91
91
  opts = {method: :get, url: url, headers: headers, timeout: 172800}
92
- # execute(opts, false)
92
+ # execute(opts, {parse_json:false})
93
93
  if Dir.exists?(outfile)
94
94
  raise "outfile is invalid. It is the name of an existing directory: #{outfile}"
95
95
  end
@@ -21,7 +21,7 @@ class Morpheus::ArchiveFilesInterface < Morpheus::APIClient
21
21
  url = "#{@base_url}/api/archives/download" + "/#{full_file_path}".squeeze('/')
22
22
  headers = { params: params, authorization: "Bearer #{@access_token}" }
23
23
  opts = {method: :get, url: url, headers: headers, timeout: 172800}
24
- execute(opts, false)
24
+ execute(opts, {parse_json: false})
25
25
  end
26
26
 
27
27
  def download_file_by_path_chunked(full_file_path, outfile, params={})
@@ -29,7 +29,7 @@ class Morpheus::ArchiveFilesInterface < Morpheus::APIClient
29
29
  url = "#{@base_url}/api/archives/download" + "/#{full_file_path}".squeeze('/')
30
30
  headers = { params: params, authorization: "Bearer #{@access_token}" }
31
31
  opts = {method: :get, url: url, headers: headers, timeout: 172800}
32
- # execute(opts, false)
32
+ # execute(opts, {parse_json: false})
33
33
  if Dir.exists?(outfile)
34
34
  raise "outfile is invalid. It is the name of an existing directory: #{outfile}"
35
35
  end
@@ -59,7 +59,7 @@ class Morpheus::ArchiveFilesInterface < Morpheus::APIClient
59
59
  url = "#{@base_url}/public-archives/download" + "/#{full_file_path}".squeeze('/')
60
60
  headers = { params: params, authorization: "Bearer #{@access_token}" }
61
61
  opts = {method: :get, url: url, headers: headers, timeout: 172800}
62
- # execute(opts, false)
62
+ # execute(opts, {parse_json: false})
63
63
  if Dir.exists?(outfile)
64
64
  raise "outfile is invalid. It is the name of an existing directory: #{outfile}"
65
65
  end
@@ -90,7 +90,7 @@ class Morpheus::ArchiveFilesInterface < Morpheus::APIClient
90
90
  params['s'] = link_key
91
91
  headers = { params: params, authorization: "Bearer #{@access_token}" }
92
92
  opts = {method: :get, url: url, headers: headers, timeout: 172800}
93
- # execute(opts, false)
93
+ # execute(opts, {parse_json: false})
94
94
  if Dir.exists?(outfile)
95
95
  raise "outfile is invalid. It is the name of an existing directory: #{outfile}"
96
96
  end
@@ -144,7 +144,7 @@ class Morpheus::ArchiveFilesInterface < Morpheus::APIClient
144
144
  def destroy_file_link(file_id, link_id, params={})
145
145
  url = "#{@base_url}/api/archives/files/#{file_id}/links/#{link_id}"
146
146
  headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
147
- opts = {method: :delete, url: url, timeout: 30, headers: headers}
147
+ opts = {method: :delete, url: url, headers: headers}
148
148
  execute(opts)
149
149
  end
150
150
 
@@ -175,7 +175,7 @@ class Morpheus::ArchiveFilesInterface < Morpheus::APIClient
175
175
  def destroy(id, params={})
176
176
  url = "#{@base_url}/api/archives/files/#{id}"
177
177
  headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
178
- opts = {method: :delete, url: url, timeout: 30, headers: headers}
178
+ opts = {method: :delete, url: url, headers: headers}
179
179
  execute(opts)
180
180
  end
181
181
 
@@ -14,7 +14,20 @@ class Morpheus::AuthInterface < Morpheus::APIClient
14
14
  url = "#{@base_url}/oauth/token"
15
15
  params = {grant_type: 'password', scope:'write', client_id: 'morph-cli', username: username}
16
16
  payload = {password: password}
17
- opts = {method: :post, url: url, headers:{ params: params}, payload: payload, timeout: 10}
17
+ opts = {method: :post, url: url, headers:{ params: params}, payload: payload, timeout: 5}
18
+ response = execute(opts)
19
+ return response if @dry_run
20
+ @access_token = response['access_token']
21
+ return response
22
+ end
23
+
24
+ # this regenerates the access_token and refresh_token
25
+ def use_refresh_token(refresh_token)
26
+ @access_token = nil
27
+ url = "#{@base_url}/oauth/token"
28
+ params = {grant_type: 'refresh_token', scope:'write', client_id: 'morph-cli'}
29
+ payload = {refresh_token: refresh_token}
30
+ opts = {method: :post, url: url, headers:{ params: params}, payload: payload}
18
31
  response = execute(opts)
19
32
  return response if @dry_run
20
33
  @access_token = response['access_token']
@@ -15,31 +15,27 @@ class Morpheus::BlueprintsInterface < Morpheus::APIClient
15
15
  execute(method: :get, url: url, headers: headers)
16
16
  end
17
17
 
18
- def list(options={})
18
+ def list(params={})
19
19
  url = "#{@base_url}/api/blueprints"
20
- headers = { params: {}, authorization: "Bearer #{@access_token}" }
21
- headers[:params].merge!(options)
20
+ headers = { params: params, authorization: "Bearer #{@access_token}" }
22
21
  execute(method: :get, url: url, headers: headers)
23
22
  end
24
23
 
25
- def create(options)
24
+ def create(payload)
26
25
  url = "#{@base_url}/api/blueprints"
27
26
  headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
28
- payload = options
29
27
  execute(method: :post, url: url, headers: headers, payload: payload.to_json)
30
28
  end
31
29
 
32
- def update(id, options)
30
+ def update(id, payload)
33
31
  url = "#{@base_url}/api/blueprints/#{id}"
34
32
  headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
35
- payload = options
36
33
  execute(method: :put, url: url, headers: headers, payload: payload.to_json)
37
34
  end
38
35
 
39
- def update_permissions(id, options)
36
+ def update_permissions(id, payload)
40
37
  url = "#{@base_url}/api/blueprints/#{id}/update-permissions"
41
38
  headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
42
- payload = options
43
39
  execute(method: :post, url: url, headers: headers, payload: payload.to_json)
44
40
  end
45
41
 
@@ -53,10 +49,9 @@ class Morpheus::BlueprintsInterface < Morpheus::APIClient
53
49
  execute(method: :post, url: url, headers: headers, payload: payload)
54
50
  end
55
51
 
56
- def duplicate(id, options)
52
+ def duplicate(id, payload)
57
53
  url = "#{@base_url}/api/blueprints/#{id}/duplicate"
58
54
  headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
59
- payload = options
60
55
  execute(method: :post, url: url, headers: headers, payload: payload.to_json)
61
56
  end
62
57
 
@@ -66,17 +61,15 @@ class Morpheus::BlueprintsInterface < Morpheus::APIClient
66
61
  execute(method: :delete, url: url, headers: headers)
67
62
  end
68
63
 
69
- def list_tiers(options={})
64
+ def list_tiers(payload={})
70
65
  url = "#{@base_url}/api/blueprints/tiers"
71
66
  headers = { params: {}, authorization: "Bearer #{@access_token}" }
72
- headers[:params].merge!(options)
73
67
  execute(method: :get, url: url, headers: headers)
74
68
  end
75
69
 
76
- def list_types(options={})
70
+ def list_types(params={})
77
71
  url = "#{@base_url}/api/blueprints/types"
78
- headers = { params: {}, authorization: "Bearer #{@access_token}" }
79
- headers[:params].merge!(options)
72
+ headers = { params: params, authorization: "Bearer #{@access_token}" }
80
73
  execute(method: :get, url: url, headers: headers)
81
74
  end
82
75
 
@@ -40,7 +40,7 @@ class Morpheus::CloudDatastoresInterface < Morpheus::APIClient
40
40
  def destroy(cloud_id, id, params={})
41
41
  url = "#{@base_url}/api/zones/#{cloud_id}/data-stores/#{id}"
42
42
  headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
43
- opts = {method: :delete, url: url, timeout: 30, headers: headers}
43
+ opts = {method: :delete, url: url, headers: headers}
44
44
  execute(opts)
45
45
  end
46
46
 
@@ -40,7 +40,7 @@ class Morpheus::CloudPoliciesInterface < Morpheus::APIClient
40
40
  def destroy(cloud_id, id, params={})
41
41
  url = "#{@base_url}/api/zones/#{cloud_id}/policies/#{id}"
42
42
  headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
43
- opts = {method: :delete, url: url, timeout: 30, headers: headers}
43
+ opts = {method: :delete, url: url, headers: headers}
44
44
  execute(opts)
45
45
  end
46
46
 
@@ -11,37 +11,35 @@ class Morpheus::CloudsInterface < Morpheus::APIClient
11
11
  def cloud_types()
12
12
  url = "#{@base_url}/api/zone-types"
13
13
  headers = { params: {}, authorization: "Bearer #{@access_token}" }
14
- opts = {method: :get, url: url, timeout: 30, headers: headers}
14
+ opts = {method: :get, url: url, headers: headers}
15
15
  execute(opts)
16
16
  end
17
17
 
18
- def get(options=nil)
18
+ def get(params=nil)
19
19
  url = "#{@base_url}/api/zones"
20
20
  headers = { params: {}, authorization: "Bearer #{@access_token}" }
21
21
 
22
- if options.is_a?(Hash)
23
- headers[:params].merge!(options)
24
- elsif options.is_a?(Numeric)
25
- url = "#{@base_url}/api/zones/#{options}"
26
- elsif options.is_a?(String)
27
- headers[:params]['name'] = options
22
+ if params.is_a?(Hash)
23
+ headers[:params].merge!(params)
24
+ elsif params.is_a?(Numeric)
25
+ url = "#{@base_url}/api/zones/#{params}"
26
+ elsif params.is_a?(String)
27
+ headers[:params]['name'] = params
28
28
  end
29
- opts = {method: :get, url: url, timeout: 30, headers: headers}
29
+ opts = {method: :get, url: url, headers: headers}
30
30
  execute(opts)
31
31
  end
32
32
 
33
- def create(options)
33
+ def create(payload)
34
34
  url = "#{@base_url}/api/zones"
35
35
  headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
36
- payload = options
37
- opts = {method: :post, url: url, timeout: 30, headers: headers, payload: payload.to_json}
36
+ opts = {method: :post, url: url, headers: headers, payload: payload.to_json}
38
37
  execute(opts)
39
38
  end
40
39
 
41
- def update(id, options)
40
+ def update(id, payload)
42
41
  url = "#{@base_url}/api/zones/#{id}"
43
42
  headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
44
- payload = options
45
43
  opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
46
44
  execute(opts)
47
45
  end
@@ -49,36 +47,35 @@ class Morpheus::CloudsInterface < Morpheus::APIClient
49
47
  def destroy(id, params={})
50
48
  url = "#{@base_url}/api/zones/#{id}"
51
49
  headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
52
- opts = {method: :delete, url: url, timeout: 30, headers: headers}
50
+ opts = {method: :delete, url: url, headers: headers}
53
51
  execute(opts)
54
52
  end
55
53
 
56
54
  def firewall_disable(id)
57
55
  url = "#{@base_url}/api/zones/#{id}/security-groups/disable"
58
56
  headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
59
- opts = {method: :put, url: url, timeout: 30, headers: headers}
57
+ opts = {method: :put, url: url, headers: headers}
60
58
  execute(opts)
61
59
  end
62
60
 
63
61
  def firewall_enable(id)
64
62
  url = "#{@base_url}/api/zones/#{id}/security-groups/enable"
65
63
  headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
66
- opts = {method: :put, url: url, timeout: 30, headers: headers}
64
+ opts = {method: :put, url: url, headers: headers}
67
65
  execute(opts)
68
66
  end
69
67
 
70
68
  def security_groups(id)
71
69
  url = "#{@base_url}/api/zones/#{id}/security-groups"
72
70
  headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
73
- opts = {method: :get, url: url, timeout: 30, headers: headers}
71
+ opts = {method: :get, url: url, headers: headers}
74
72
  execute(opts)
75
73
  end
76
74
 
77
- def apply_security_groups(id, options)
75
+ def apply_security_groups(id, payload)
78
76
  url = "#{@base_url}/api/zones/#{id}/security-groups"
79
77
  headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
80
- payload = options
81
- opts = {method: :post, url: url, timeout: 30, headers: headers, payload: payload.to_json}
78
+ opts = {method: :post, url: url, headers: headers, payload: payload.to_json}
82
79
  execute(opts)
83
80
  end
84
81
  end
@@ -9,47 +9,38 @@ class Morpheus::CypherInterface < Morpheus::APIClient
9
9
  @expires_at = expires_at
10
10
  end
11
11
 
12
- def get(id, params={})
13
- raise "#{self.class}.get() passed a blank id!" if id.to_s == ''
14
- url = "#{@base_url}/api/cypher/#{id}"
12
+ def get(item_key, params={})
13
+ raise "#{self.class}.get() passed a blank item_key!" if item_key.to_s == ''
14
+ url = "#{@base_url}/api/cypher/v1/#{item_key}"
15
15
  headers = { params: params, authorization: "Bearer #{@access_token}" }
16
- opts = {method: :get, url: url, headers: headers}
17
- execute(opts)
16
+ execute({method: :get, url: url, headers: headers})
18
17
  end
19
18
 
20
- def list(params={})
21
- url = "#{@base_url}/api/cypher"
19
+ # list url is the same as get but uses $itemKey/?list=true
20
+ # method: 'LIST' would be neat though
21
+ def list(item_key=nil, params={})
22
+ url = item_key ? "#{@base_url}/api/cypher/v1/#{item_key}" : "#{@base_url}/api/cypher/v1"
23
+ params.merge!({list:'true'})
22
24
  headers = { params: params, authorization: "Bearer #{@access_token}" }
23
- opts = {method: :get, url: url, headers: headers}
24
- execute(opts)
25
+ execute({method: :get, url: url, headers: headers})
25
26
  end
26
27
 
27
- def create(payload)
28
- url = "#{@base_url}/api/cypher"
28
+ def create(item_key, payload)
29
+ url = "#{@base_url}/api/cypher/v1/#{item_key}"
29
30
  headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
30
- opts = {method: :post, url: url, headers: headers, payload: payload.to_json}
31
- execute(opts)
31
+ execute({method: :post, url: url, headers: headers, payload: payload.to_json})
32
32
  end
33
33
 
34
- def update(id, payload)
35
- url = "#{@base_url}/api/cypher/#{id}"
34
+ def update(item_key, payload)
35
+ url = "#{@base_url}/api/cypher/v1/#{item_key}"
36
36
  headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
37
- opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
38
- execute(opts)
37
+ execute({method: :put, url: url, headers: headers, payload: payload.to_json})
39
38
  end
40
39
 
41
- def destroy(id, params={})
42
- url = "#{@base_url}/api/cypher/#{id}"
40
+ def destroy(item_key, params={})
41
+ url = "#{@base_url}/api/cypher/v1/#{item_key}"
43
42
  headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
44
- opts = {method: :delete, url: url, timeout: 30, headers: headers}
45
- execute(opts)
46
- end
47
-
48
- def decrypt(id, params={})
49
- url = "#{@base_url}/api/cypher/#{id}/decrypt"
50
- headers = { params: params, authorization: "Bearer #{@access_token}" }
51
- opts = {method: :get, url: url, headers: headers}
52
- execute(opts)
43
+ execute({method: :delete, url: url, headers: headers})
53
44
  end
54
45
 
55
46
  end