morpheus-cli 4.1.4 → 4.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/morpheus.rb +5 -0
- data/lib/morpheus/api.rb +2 -2
- data/lib/morpheus/api/api_client.rb +47 -12
- data/lib/morpheus/api/appliance_settings_interface.rb +30 -0
- data/lib/morpheus/api/auth_interface.rb +14 -10
- data/lib/morpheus/api/clouds_interface.rb +7 -0
- data/lib/morpheus/api/clusters_interface.rb +17 -5
- data/lib/morpheus/api/custom_instance_types_interface.rb +2 -3
- data/lib/morpheus/api/deployments_interface.rb +7 -0
- data/lib/morpheus/api/execute_schedules_interface.rb +2 -3
- data/lib/morpheus/api/groups_interface.rb +7 -0
- data/lib/morpheus/api/license_interface.rb +9 -2
- data/lib/morpheus/api/load_balancers_interface.rb +7 -0
- data/lib/morpheus/api/logs_interface.rb +11 -2
- data/lib/morpheus/api/monitoring_alerts_interface.rb +45 -0
- data/lib/morpheus/api/monitoring_checks_interface.rb +2 -2
- data/lib/morpheus/api/monitoring_interface.rb +13 -8
- data/lib/morpheus/api/power_schedules_interface.rb +2 -3
- data/lib/morpheus/api/servers_interface.rb +5 -2
- data/lib/morpheus/api/setup_interface.rb +25 -7
- data/lib/morpheus/api/task_sets_interface.rb +7 -1
- data/lib/morpheus/api/tasks_interface.rb +7 -0
- data/lib/morpheus/api/virtual_images_interface.rb +2 -3
- data/lib/morpheus/api/whitelabel_settings_interface.rb +60 -0
- data/lib/morpheus/cli.rb +18 -14
- data/lib/morpheus/cli/access_token_command.rb +18 -2
- data/lib/morpheus/cli/appliance_settings_command.rb +303 -0
- data/lib/morpheus/cli/apps.rb +4 -3
- data/lib/morpheus/cli/archives_command.rb +0 -21
- data/lib/morpheus/cli/blueprints_command.rb +2 -2
- data/lib/morpheus/cli/cli_command.rb +32 -8
- data/lib/morpheus/cli/clouds.rb +6 -11
- data/lib/morpheus/cli/clusters.rb +346 -117
- data/lib/morpheus/cli/command_error.rb +4 -0
- data/lib/morpheus/cli/commands/standard/man_command.rb +1 -1
- data/lib/morpheus/cli/containers_command.rb +2 -1
- data/lib/morpheus/cli/credentials.rb +49 -4
- data/lib/morpheus/cli/deployments.rb +2 -2
- data/lib/morpheus/cli/dot_file.rb +2 -2
- data/lib/morpheus/cli/error_handler.rb +6 -3
- data/lib/morpheus/cli/execute_schedules_command.rb +1 -1
- data/lib/morpheus/cli/groups.rb +4 -4
- data/lib/morpheus/cli/hosts.rb +3 -2
- data/lib/morpheus/cli/image_builder_command.rb +0 -21
- data/lib/morpheus/cli/instances.rb +17 -4
- data/lib/morpheus/cli/library_container_types_command.rb +1 -1
- data/lib/morpheus/cli/library_layouts_command.rb +1 -1
- data/lib/morpheus/cli/library_upgrades_command.rb +1 -1
- data/lib/morpheus/cli/license.rb +185 -72
- data/lib/morpheus/cli/load_balancers.rb +4 -4
- data/lib/morpheus/cli/login.rb +4 -0
- data/lib/morpheus/cli/logs_command.rb +132 -0
- data/lib/morpheus/cli/mixins/infrastructure_helper.rb +2 -2
- data/lib/morpheus/cli/mixins/logs_helper.rb +65 -0
- data/lib/morpheus/cli/mixins/monitoring_helper.rb +410 -28
- data/lib/morpheus/cli/mixins/print_helper.rb +14 -4
- data/lib/morpheus/cli/monitoring_alerts_command.rb +800 -0
- data/lib/morpheus/cli/monitoring_apps_command.rb +85 -28
- data/lib/morpheus/cli/monitoring_checks_command.rb +60 -27
- data/lib/morpheus/cli/monitoring_contacts_command.rb +54 -79
- data/lib/morpheus/cli/monitoring_groups_command.rb +62 -23
- data/lib/morpheus/cli/monitoring_incidents_command.rb +91 -70
- data/lib/morpheus/cli/network_pools_command.rb +39 -23
- data/lib/morpheus/cli/power_schedules_command.rb +1 -1
- data/lib/morpheus/cli/remote.rb +834 -275
- data/lib/morpheus/cli/roles.rb +100 -38
- data/lib/morpheus/cli/tasks.rb +1 -1
- data/lib/morpheus/cli/user_settings_command.rb +20 -12
- data/lib/morpheus/cli/version.rb +1 -1
- data/lib/morpheus/cli/virtual_images.rb +1 -1
- data/lib/morpheus/cli/whitelabel_settings_command.rb +546 -0
- data/lib/morpheus/cli/whoami.rb +1 -1
- data/lib/morpheus/cli/workflows.rb +2 -2
- data/lib/morpheus/terminal.rb +22 -8
- metadata +11 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8cf9fe88c6a717fcd35c655ca1bf208842bd6669c793a698cbee17d6a1c6263a
|
4
|
+
data.tar.gz: fc1ecf887d8b6bd1ef7b3de650d1a2a9d88bd13a7fc4b6a781858623da57dcd3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2af125ef03ebc7cfcdd528f069c33a4af72e037039b3256c954bb2e8f75511989b25be9b06a5508a49d28ebfe2686ecec6057ba19066c4daf466135570d3a9bd
|
7
|
+
data.tar.gz: ccf40b9d7d5e1a0bc7f12d5cb9249da035c5d043028fbf5ceb58dfdf95f2fad5b53eda43a0e9521060f92d77fd2e6369cbbe53616b92bf78ad762c241014aac8
|
data/lib/morpheus.rb
ADDED
data/lib/morpheus/api.rb
CHANGED
@@ -3,19 +3,30 @@ require 'uri'
|
|
3
3
|
require 'rest-client'
|
4
4
|
|
5
5
|
class Morpheus::APIClient
|
6
|
+
|
7
|
+
CLIENT_ID = 'morph-cli' unless defined?(CLIENT_ID)
|
8
|
+
|
9
|
+
attr_accessor :client_id
|
6
10
|
# Initialize a new APIClient
|
7
11
|
# client = APIClient.new(url:"https://morpheus.yourcompany.com", verify_ssl:false)
|
8
12
|
# This old method signature is being deprecated:
|
9
13
|
# client = APIClient.new(access_token, refresh_token, expires_in, base_url, verify_ssl, options={})
|
10
14
|
#
|
15
|
+
# def initialize(attrs={}, options={})
|
11
16
|
def initialize(access_token, refresh_token=nil,expires_in = nil, base_url=nil, verify_ssl=true, options={})
|
17
|
+
self.client_id = CLIENT_ID
|
18
|
+
attrs = {}
|
12
19
|
if access_token.is_a?(Hash)
|
13
|
-
|
14
|
-
access_token =
|
15
|
-
refresh_token =
|
16
|
-
base_url =
|
17
|
-
expires_in =
|
18
|
-
verify_ssl =
|
20
|
+
attrs = access_token.clone()
|
21
|
+
access_token = attrs[:access_token]
|
22
|
+
refresh_token = attrs[:refresh_token]
|
23
|
+
base_url = attrs[:url] || attrs[:base_url]
|
24
|
+
expires_in = attrs[:expires_in]
|
25
|
+
verify_ssl = attrs.key?(:verify_ssl) ? attrs[:verify_ssl] : true
|
26
|
+
self.client_id = attrs[:client_id] ? attrs[:client_id] : CLIENT_ID
|
27
|
+
if attrs[:client_id]
|
28
|
+
self.client_id = attrs[:client_id]
|
29
|
+
end
|
19
30
|
options = refresh_token.is_a?(Hash) ? refresh_token.clone() : {}
|
20
31
|
end
|
21
32
|
@access_token = access_token
|
@@ -38,7 +49,7 @@ class Morpheus::APIClient
|
|
38
49
|
end
|
39
50
|
|
40
51
|
def to_s
|
41
|
-
"<##{self.class}:#{self.object_id.to_s(8)} @url=#{@base_url} @verify_ssl=#{@verify_ssl} @access_token=#{@access_token ? '************' : nil} @refresh_token=#{@access_token ? '************' : nil} @expires_at=#{@expires_at} @options=#{@options}>"
|
52
|
+
"<##{self.class}:#{self.object_id.to_s(8)} @url=#{@base_url} @verify_ssl=#{@verify_ssl} @access_token=#{@access_token ? '************' : nil} @refresh_token=#{@access_token ? '************' : nil} @expires_at=#{@expires_at} @client_id=#{@client_id} @options=#{@options}>"
|
42
53
|
end
|
43
54
|
|
44
55
|
def inspect
|
@@ -219,9 +230,20 @@ class Morpheus::APIClient
|
|
219
230
|
!!@access_token
|
220
231
|
end
|
221
232
|
|
222
|
-
def
|
233
|
+
def client_id
|
234
|
+
@client_id
|
235
|
+
end
|
236
|
+
|
237
|
+
def client_id=(val)
|
238
|
+
@client_id = val
|
239
|
+
end
|
240
|
+
|
241
|
+
def login(username, password, use_client_id=nil)
|
242
|
+
if use_client_id
|
243
|
+
self.client_id = use_client_id
|
244
|
+
end
|
223
245
|
@access_token, @refresh_token, @expires_at = nil, nil, nil
|
224
|
-
response = auth.login(username, password)
|
246
|
+
response = auth.login(username, password, self.client_id)
|
225
247
|
@access_token = response['access_token']
|
226
248
|
@refresh_token = response['refresh_token']
|
227
249
|
if response['expires_in'] != nil
|
@@ -235,7 +257,7 @@ class Morpheus::APIClient
|
|
235
257
|
if @refresh_token.nil?
|
236
258
|
raise "#{self.class} does not currently have a refresh_token"
|
237
259
|
end
|
238
|
-
response = auth.use_refresh_token(@refresh_token)
|
260
|
+
response = auth.use_refresh_token(@refresh_token, self.client_id)
|
239
261
|
@access_token = response['access_token']
|
240
262
|
@refresh_token = response['refresh_token']
|
241
263
|
if response['expires_in'] != nil
|
@@ -253,8 +275,12 @@ class Morpheus::APIClient
|
|
253
275
|
return self
|
254
276
|
end
|
255
277
|
|
278
|
+
def common_iface_opts
|
279
|
+
{url: @base_url, access_token: @access_token, refresh_token: @refresh_token, expires_at: @expires_at}
|
280
|
+
end
|
281
|
+
|
256
282
|
def auth
|
257
|
-
Morpheus::AuthInterface.new(@base_url, @
|
283
|
+
Morpheus::AuthInterface.new({url: @base_url, client_id: @client_id}).setopts(@options)
|
258
284
|
end
|
259
285
|
|
260
286
|
def whoami
|
@@ -301,6 +327,10 @@ class Morpheus::APIClient
|
|
301
327
|
Morpheus::InstancesInterface.new(@access_token, @refresh_token, @expires_at, @base_url).setopts(@options)
|
302
328
|
end
|
303
329
|
|
330
|
+
def appliance_settings
|
331
|
+
Morpheus::ApplianceSettingsInterface.new(@access_token, @refresh_token, @expires_at, @base_url).setopts(@options)
|
332
|
+
end
|
333
|
+
|
304
334
|
def containers
|
305
335
|
Morpheus::ContainersInterface.new(@access_token, @refresh_token, @expires_at, @base_url).setopts(@options)
|
306
336
|
end
|
@@ -421,8 +451,9 @@ class Morpheus::APIClient
|
|
421
451
|
Morpheus::ExecuteSchedulesInterface.new(@access_token, @refresh_token, @expires_at, @base_url).setopts(@options)
|
422
452
|
end
|
423
453
|
|
454
|
+
|
424
455
|
def setup
|
425
|
-
Morpheus::SetupInterface.new(
|
456
|
+
Morpheus::SetupInterface.new(common_iface_opts).setopts(@options).setopts(@options)
|
426
457
|
end
|
427
458
|
|
428
459
|
def monitoring
|
@@ -576,6 +607,10 @@ class Morpheus::APIClient
|
|
576
607
|
Morpheus::EnvironmentsInterface.new(@access_token, @refresh_token, @expires_at, @base_url).setopts(@options)
|
577
608
|
end
|
578
609
|
|
610
|
+
def whitelabel_settings
|
611
|
+
Morpheus::WhitelabelSettingsInterface.new(@access_token, @refresh_token, @expires_at, @base_url).setopts(@options)
|
612
|
+
end
|
613
|
+
|
579
614
|
def wiki
|
580
615
|
Morpheus::WikiInterface.new(@access_token, @refresh_token, @expires_at, @base_url).setopts(@options)
|
581
616
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'morpheus/api/api_client'
|
2
|
+
|
3
|
+
class Morpheus::ApplianceSettingsInterface < Morpheus::APIClient
|
4
|
+
def initialize(access_token, refresh_token,expires_at = nil, base_url=nil, api='appliance-settings')
|
5
|
+
@access_token = access_token
|
6
|
+
@refresh_token = refresh_token
|
7
|
+
@base_url = base_url
|
8
|
+
@api_url = "#{base_url}/api/#{api}"
|
9
|
+
@expires_at = expires_at
|
10
|
+
end
|
11
|
+
|
12
|
+
def get()
|
13
|
+
url = @api_url
|
14
|
+
headers = { params: {}, authorization: "Bearer #{@access_token}" }
|
15
|
+
execute(method: :get, url: url, headers: headers)
|
16
|
+
end
|
17
|
+
|
18
|
+
def update(payload)
|
19
|
+
url = @api_url
|
20
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
21
|
+
execute(method: :put, url: url, headers: headers, payload: payload.to_json)
|
22
|
+
end
|
23
|
+
|
24
|
+
def cloud_types(params={})
|
25
|
+
url = "#{@api_url}/zone-types"
|
26
|
+
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
27
|
+
opts = {method: :get, url: url, headers: headers}
|
28
|
+
execute(opts)
|
29
|
+
end
|
30
|
+
end
|
@@ -2,17 +2,18 @@ require 'morpheus/api/api_client'
|
|
2
2
|
|
3
3
|
class Morpheus::AuthInterface < Morpheus::APIClient
|
4
4
|
|
5
|
-
#
|
5
|
+
# def initialize(base_url, access_token=nil)
|
6
|
+
# @base_url = base_url
|
7
|
+
# @access_token = access_token
|
8
|
+
# end
|
6
9
|
|
7
|
-
def
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
def login(username, password)
|
10
|
+
def login(username, password, use_client_id=nil)
|
11
|
+
if use_client_id
|
12
|
+
self.client_id = use_client_id
|
13
|
+
end
|
13
14
|
@access_token, @refresh_token, @expires_at = nil, nil, nil
|
14
15
|
url = "#{@base_url}/oauth/token"
|
15
|
-
params = {grant_type: 'password', scope:'write', client_id:
|
16
|
+
params = {grant_type: 'password', scope:'write', client_id: self.client_id, username: username}
|
16
17
|
payload = {password: password}
|
17
18
|
opts = {method: :post, url: url, headers:{ params: params}, payload: payload, timeout: 5}
|
18
19
|
response = execute(opts)
|
@@ -26,10 +27,13 @@ class Morpheus::AuthInterface < Morpheus::APIClient
|
|
26
27
|
end
|
27
28
|
|
28
29
|
# this regenerates the access_token and refresh_token
|
29
|
-
def use_refresh_token(refresh_token)
|
30
|
+
def use_refresh_token(refresh_token, use_client_id=nil)
|
31
|
+
if use_client_id
|
32
|
+
self.client_id = use_client_id
|
33
|
+
end
|
30
34
|
@access_token = nil
|
31
35
|
url = "#{@base_url}/oauth/token"
|
32
|
-
params = {grant_type: 'refresh_token', scope:'write', client_id:
|
36
|
+
params = {grant_type: 'refresh_token', scope:'write', client_id: self.client_id}
|
33
37
|
payload = {refresh_token: refresh_token}
|
34
38
|
opts = {method: :post, url: url, headers:{ params: params}, payload: payload}
|
35
39
|
response = execute(opts)
|
@@ -45,6 +45,13 @@ class Morpheus::CloudsInterface < Morpheus::APIClient
|
|
45
45
|
execute(opts)
|
46
46
|
end
|
47
47
|
|
48
|
+
def list(params={})
|
49
|
+
url = "#{@base_url}/api/zones"
|
50
|
+
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
51
|
+
opts = {method: :get, url: url, headers: headers}
|
52
|
+
execute(opts)
|
53
|
+
end
|
54
|
+
|
48
55
|
def create(payload)
|
49
56
|
url = "#{@base_url}/api/zones"
|
50
57
|
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
@@ -226,11 +226,23 @@ class Morpheus::ClustersInterface < Morpheus::APIClient
|
|
226
226
|
execute(method: :delete, url: url, headers: headers)
|
227
227
|
end
|
228
228
|
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
229
|
+
def list_datastores(id, params={})
|
230
|
+
url = "#{@api_url}/#{id}/datastores"
|
231
|
+
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
232
|
+
execute(method: :get, url: url, headers: headers)
|
233
|
+
end
|
234
|
+
|
235
|
+
def get_datastore(id, datastore_id, params={})
|
236
|
+
url = "#{@api_url}/#{id}/datastores/#{datastore_id}"
|
237
|
+
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
238
|
+
execute(method: :get, url: url, headers: headers)
|
239
|
+
end
|
240
|
+
|
241
|
+
def update_datastore(id, datastore_id, payload)
|
242
|
+
url = "#{@api_url}/#{id}/datastores/#{datastore_id}"
|
243
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
244
|
+
execute(method: :put, url: url, headers: headers, payload: payload.to_json)
|
245
|
+
end
|
234
246
|
|
235
247
|
def wiki(id, params)
|
236
248
|
url = "#{@base_url}/api/clusters/#{id}/wiki"
|
@@ -8,10 +8,9 @@ class Morpheus::CustomInstanceTypesInterface < Morpheus::APIClient
|
|
8
8
|
@expires_at = expires_at
|
9
9
|
end
|
10
10
|
|
11
|
-
def list(
|
11
|
+
def list(params={})
|
12
12
|
url = "#{@base_url}/api/custom-instance-types"
|
13
|
-
headers = { params:
|
14
|
-
headers[:params].merge!(options)
|
13
|
+
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
15
14
|
execute(method: :get, url: url, headers: headers)
|
16
15
|
end
|
17
16
|
|
@@ -8,6 +8,13 @@ class Morpheus::DeploymentsInterface < Morpheus::APIClient
|
|
8
8
|
@expires_at = expires_at
|
9
9
|
end
|
10
10
|
|
11
|
+
def list(params={})
|
12
|
+
url = "#{@base_url}/api/deployments"
|
13
|
+
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
14
|
+
opts = {method: :get, url: url, headers: headers}
|
15
|
+
execute(opts)
|
16
|
+
end
|
17
|
+
|
11
18
|
def get(options=nil)
|
12
19
|
url = "#{@base_url}/api/deployments"
|
13
20
|
headers = { params: {}, authorization: "Bearer #{@access_token}" }
|
@@ -16,10 +16,9 @@ class Morpheus::ExecuteSchedulesInterface < Morpheus::APIClient
|
|
16
16
|
execute(opts)
|
17
17
|
end
|
18
18
|
|
19
|
-
def list(
|
19
|
+
def list(params={})
|
20
20
|
url = "#{@base_url}/api/execute-schedules"
|
21
|
-
headers = { params:
|
22
|
-
headers[:params].merge!(options)
|
21
|
+
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
23
22
|
opts = {method: :get, url: url, timeout: 10, headers: headers}
|
24
23
|
execute(opts)
|
25
24
|
end
|
@@ -9,6 +9,13 @@ class Morpheus::GroupsInterface < Morpheus::APIClient
|
|
9
9
|
end
|
10
10
|
|
11
11
|
|
12
|
+
def list(params={})
|
13
|
+
url = "#{@base_url}/api/groups"
|
14
|
+
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
15
|
+
opts = {method: :get, url: url, headers: headers}
|
16
|
+
execute(opts)
|
17
|
+
end
|
18
|
+
|
12
19
|
def get(options=nil)
|
13
20
|
url = "#{@base_url}/api/groups"
|
14
21
|
headers = { params: {}, authorization: "Bearer #{@access_token}" }
|
@@ -14,18 +14,25 @@ class Morpheus::LicenseInterface < Morpheus::APIClient
|
|
14
14
|
execute(method: :get, url: url, headers: headers)
|
15
15
|
end
|
16
16
|
|
17
|
-
def
|
17
|
+
def install(key)
|
18
18
|
url = "#{@base_url}/api/license"
|
19
19
|
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
20
20
|
payload = {license: key}
|
21
21
|
execute(method: :post, url: url, headers: headers, payload: payload.to_json)
|
22
22
|
end
|
23
23
|
|
24
|
-
def
|
24
|
+
def test(key)
|
25
|
+
# use /test instead, since 4.1.1
|
25
26
|
url = "#{@base_url}/api/license/decode"
|
26
27
|
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
27
28
|
payload = {license: key}
|
28
29
|
execute(method: :post, url: url, headers: headers, payload: payload.to_json)
|
29
30
|
end
|
30
31
|
|
32
|
+
def uninstall(params={})
|
33
|
+
url = "#{@base_url}/api/license"
|
34
|
+
headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
35
|
+
execute(method: :delete, url: url, headers: headers)
|
36
|
+
end
|
37
|
+
|
31
38
|
end
|
@@ -21,6 +21,13 @@ class Morpheus::LoadBalancersInterface < Morpheus::APIClient
|
|
21
21
|
execute(method: :get, url: url, headers: headers)
|
22
22
|
end
|
23
23
|
|
24
|
+
def list(params={})
|
25
|
+
url = "#{@base_url}/api/load-balancers"
|
26
|
+
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
27
|
+
opts = {method: :get, url: url, headers: headers}
|
28
|
+
execute(opts)
|
29
|
+
end
|
30
|
+
|
24
31
|
def get(options=nil)
|
25
32
|
url = "#{@base_url}/api/load-balancers"
|
26
33
|
headers = { params: {}, authorization: "Bearer #{@access_token}" }
|
@@ -8,15 +8,24 @@ class Morpheus::LogsInterface < Morpheus::APIClient
|
|
8
8
|
@expires_at = expires_at
|
9
9
|
end
|
10
10
|
|
11
|
+
def list(params={})
|
12
|
+
url = "#{@base_url}/api/logs"
|
13
|
+
# old versions expected containers[]
|
14
|
+
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
15
|
+
execute({method: :get, url: url, headers: headers})
|
16
|
+
end
|
17
|
+
|
11
18
|
def container_logs(containers=[], params={})
|
12
19
|
url = "#{@base_url}/api/logs"
|
13
|
-
|
20
|
+
# old versions expected containers[]
|
21
|
+
headers = { params: {'containers' => containers, 'containers[]' => containers}.merge(params), authorization: "Bearer #{@access_token}" }
|
14
22
|
execute({method: :get, url: url, headers: headers})
|
15
23
|
end
|
16
24
|
|
17
25
|
def server_logs(servers=[], params={})
|
18
26
|
url = "#{@base_url}/api/logs"
|
19
|
-
|
27
|
+
# old versions expected containers[]
|
28
|
+
headers = { params: {'servers' => servers, 'servers[]' => servers}.merge(params), authorization: "Bearer #{@access_token}" }
|
20
29
|
execute({method: :get, url: url, headers: headers})
|
21
30
|
end
|
22
31
|
|
@@ -0,0 +1,45 @@
|
|
1
|
+
class Morpheus::MonitoringAlertsInterface < Morpheus::APIClient
|
2
|
+
def initialize(access_token, refresh_token,expires_at = nil, base_url=nil)
|
3
|
+
@access_token = access_token
|
4
|
+
@refresh_token = refresh_token
|
5
|
+
@base_url = base_url
|
6
|
+
@expires_at = expires_at
|
7
|
+
end
|
8
|
+
|
9
|
+
def get(id, params={})
|
10
|
+
raise "#{self.class}.get() passed a blank id!" if id.to_s == ''
|
11
|
+
url = "#{@base_url}/api/monitoring/alerts/#{id}"
|
12
|
+
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
13
|
+
opts = {method: :get, url: url, headers: headers}
|
14
|
+
execute(opts)
|
15
|
+
end
|
16
|
+
|
17
|
+
def list(params={})
|
18
|
+
url = "#{@base_url}/api/monitoring/alerts"
|
19
|
+
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
20
|
+
opts = {method: :get, url: url, headers: headers}
|
21
|
+
execute(opts)
|
22
|
+
end
|
23
|
+
|
24
|
+
def create(payload)
|
25
|
+
url = "#{@base_url}/api/monitoring/alerts"
|
26
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
27
|
+
opts = {method: :post, url: url, headers: headers, payload: payload.to_json}
|
28
|
+
execute(opts)
|
29
|
+
end
|
30
|
+
|
31
|
+
def update(id, payload)
|
32
|
+
url = "#{@base_url}/api/monitoring/alerts/#{id}"
|
33
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
34
|
+
opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
|
35
|
+
execute(opts)
|
36
|
+
end
|
37
|
+
|
38
|
+
def destroy(id)
|
39
|
+
url = "#{@base_url}/api/monitoring/alerts/#{id}"
|
40
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
41
|
+
opts = {method: :delete, url: url, headers: headers}
|
42
|
+
execute(opts)
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
@@ -16,9 +16,9 @@ class Morpheus::MonitoringChecksInterface < Morpheus::APIClient
|
|
16
16
|
execute(opts)
|
17
17
|
end
|
18
18
|
|
19
|
-
def list(
|
19
|
+
def list(params={})
|
20
20
|
url = "#{@base_url}/api/monitoring/checks"
|
21
|
-
headers = { params:
|
21
|
+
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
22
22
|
opts = {method: :get, url: url, headers: headers}
|
23
23
|
execute(opts)
|
24
24
|
end
|