Class: Morpheus::ServersInterface
Instance Method Summary
collapse
-
#assign_account(serverId, payload = {}) ⇒ Object
-
#create(options) ⇒ Object
-
#destroy(id, params = {}) ⇒ Object
-
#get(options = nil) ⇒ Object
-
#initialize(access_token, refresh_token, expires_at = nil, base_url = nil) ⇒ ServersInterface
constructor
A new instance of ServersInterface.
-
#install_agent(serverId, payload = {}) ⇒ Object
-
#reinitialize(serverId, payload = {}) ⇒ Object
-
#reprovision(serverId, payload = {}) ⇒ Object
-
#resize(id, payload) ⇒ Object
-
#service_plans(params) ⇒ Object
-
#start(serverId, payload = {}) ⇒ Object
-
#stop(serverId, payload = {}) ⇒ Object
-
#upgrade(serverId, payload = {}) ⇒ Object
-
#volumes(id) ⇒ Object
-
#workflow(id, task_set_id, payload) ⇒ Object
Methods inherited from APIClient
#accounts, #app_templates, #apps, #auth, #clouds, #custom_instance_types, #dashboard, #deploy, #deployments, #dry, #dry_run, #execute, #groups, #instance_types, #instances, #key_pairs, #license, #load_balancers, #logs, #options, #provision_types, #roles, #security_group_rules, #security_groups, #servers, #setup, #task_sets, #tasks, #users, #virtual_images, #whoami
Constructor Details
#initialize(access_token, refresh_token, expires_at = nil, base_url = nil) ⇒ ServersInterface
Returns a new instance of ServersInterface.
4
5
6
7
8
9
|
# File 'lib/morpheus/api/servers_interface.rb', line 4
def initialize(access_token, refresh_token,expires_at = nil, base_url=nil)
@access_token = access_token
@refresh_token = refresh_token
@base_url = base_url
@expires_at = expires_at
end
|
Instance Method Details
#assign_account(serverId, payload = {}) ⇒ Object
75
76
77
78
79
80
|
# File 'lib/morpheus/api/servers_interface.rb', line 75
def assign_account(serverId,payload = {})
url = "#{@base_url}/api/servers/#{serverId}/assign-account"
= { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
opts = {method: :put, url: url, headers: , payload: payload.to_json}
execute(opts)
end
|
#create(options) ⇒ Object
25
26
27
28
29
30
31
|
# File 'lib/morpheus/api/servers_interface.rb', line 25
def create(options)
url = "#{@base_url}/api/servers"
= { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
payload = options
opts = {method: :post, url: url, headers: , payload: payload.to_json}
execute(opts)
end
|
#destroy(id, params = {}) ⇒ Object
89
90
91
92
93
94
|
# File 'lib/morpheus/api/servers_interface.rb', line 89
def destroy(id, params={})
url = "#{@base_url}/api/servers/#{id}"
= { :params => params,:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
opts = {method: :delete, url: url, headers: }
execute(opts)
end
|
#get(options = nil) ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/morpheus/api/servers_interface.rb', line 11
def get(options=nil)
url = "#{@base_url}/api/servers"
= { params: {}, authorization: "Bearer #{@access_token}" }
if options.is_a?(Hash)
[:params].merge!(options)
elsif options.is_a?(Numeric)
url = "#{@base_url}/api/servers/#{options}"
elsif options.is_a?(String)
[:params]['name'] = options
end
opts = {method: :get, url: url, headers: }
execute(opts)
end
|
#install_agent(serverId, payload = {}) ⇒ Object
47
48
49
50
51
52
|
# File 'lib/morpheus/api/servers_interface.rb', line 47
def install_agent(serverId,payload = {})
url = "#{@base_url}/api/servers/#{serverId}/install-agent"
= { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
opts = {method: :put, url: url, headers: , payload: payload.to_json}
execute(opts)
end
|
#reinitialize(serverId, payload = {}) ⇒ Object
68
69
70
71
72
73
|
# File 'lib/morpheus/api/servers_interface.rb', line 68
def reinitialize(serverId,payload = {})
url = "#{@base_url}/api/servers/#{serverId}/reinitialize"
= { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
opts = {method: :put, url: url, headers: , payload: payload.to_json}
execute(opts)
end
|
#reprovision(serverId, payload = {}) ⇒ Object
61
62
63
64
65
66
|
# File 'lib/morpheus/api/servers_interface.rb', line 61
def reprovision(serverId,payload = {})
url = "#{@base_url}/api/servers/#{serverId}/reprovision"
= { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
opts = {method: :put, url: url, headers: , payload: payload.to_json}
execute(opts)
end
|
#resize(id, payload) ⇒ Object
110
111
112
113
114
115
|
# File 'lib/morpheus/api/servers_interface.rb', line 110
def resize(id,payload)
url = "#{@base_url}/api/servers/#{id}/resize"
= { :params => {},:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
opts = {method: :put, url: url, headers: , payload: payload.to_json}
execute(opts)
end
|
#service_plans(params) ⇒ Object
96
97
98
99
100
101
|
# File 'lib/morpheus/api/servers_interface.rb', line 96
def service_plans(params)
url = "#{@base_url}/api/servers/service-plans"
= { params: params, authorization: "Bearer #{@access_token}" }
opts = {method: :get, url: url, headers: }
execute(opts)
end
|
#start(serverId, payload = {}) ⇒ Object
40
41
42
43
44
45
|
# File 'lib/morpheus/api/servers_interface.rb', line 40
def start(serverId,payload = {})
url = "#{@base_url}/api/servers/#{serverId}/start"
= { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
opts = {method: :put, url: url, headers: , payload: payload.to_json}
execute(opts)
end
|
#stop(serverId, payload = {}) ⇒ Object
33
34
35
36
37
38
|
# File 'lib/morpheus/api/servers_interface.rb', line 33
def stop(serverId,payload = {})
url = "#{@base_url}/api/servers/#{serverId}/stop"
= { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
opts = {method: :put, url: url, headers: , payload: payload.to_json}
execute(opts)
end
|
#upgrade(serverId, payload = {}) ⇒ Object
54
55
56
57
58
59
|
# File 'lib/morpheus/api/servers_interface.rb', line 54
def upgrade(serverId,payload = {})
url = "#{@base_url}/api/servers/#{serverId}/upgrade"
= { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
opts = {method: :put, url: url, headers: , payload: payload.to_json}
execute(opts)
end
|
#volumes(id) ⇒ Object
103
104
105
106
107
108
|
# File 'lib/morpheus/api/servers_interface.rb', line 103
def volumes(id)
url = "#{@base_url}/api/servers/#{id}/volumes"
= { :params => {},:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
opts = {method: :get, url: url, headers: }
execute(opts)
end
|
#workflow(id, task_set_id, payload) ⇒ Object
82
83
84
85
86
87
|
# File 'lib/morpheus/api/servers_interface.rb', line 82
def workflow(id,task_set_id,payload)
url = "#{@base_url}/api/servers/#{id}/workflow"
= { :params => {:taskSetId => task_set_id},:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
opts = {method: :put, url: url, headers: , payload: payload.to_json}
execute(opts)
end
|