Class: Morpheus::InstancesInterface
Instance Method Summary
collapse
-
#apply_security_groups(id, options) ⇒ Object
-
#backup(id, server = true) ⇒ Object
-
#create(options) ⇒ Object
-
#create_env(id, options) ⇒ Object
-
#del_env(id, name) ⇒ Object
-
#destroy(id, params = {}) ⇒ Object
-
#firewall_disable(id) ⇒ Object
-
#firewall_enable(id) ⇒ Object
-
#get(options = nil) ⇒ Object
-
#get_envs(id, options = nil) ⇒ Object
-
#initialize(access_token, refresh_token, expires_at = nil, base_url = nil) ⇒ InstancesInterface
constructor
A new instance of InstancesInterface.
-
#resize(id, payload) ⇒ Object
-
#restart(id, server = true) ⇒ Object
-
#security_groups(id) ⇒ Object
-
#service_plans(params) ⇒ Object
-
#start(id, server = true) ⇒ Object
-
#stop(id, server = true) ⇒ Object
-
#update(id, options) ⇒ Object
-
#volumes(id) ⇒ Object
-
#workflow(id, task_set_id, payload) ⇒ Object
Methods inherited from APIClient
#accounts, #app_templates, #apps, #clouds, #custom_instance_types, #dashboard, #deploy, #deployments, #groups, #instance_types, #instances, #key_pairs, #license, #load_balancers, #logs, #options, #provision_types, #roles, #security_group_rules, #servers, #task_sets, #tasks, #users, #virtual_images, #whoami
Constructor Details
#initialize(access_token, refresh_token, expires_at = nil, base_url = nil) ⇒ InstancesInterface
Returns a new instance of InstancesInterface.
5
6
7
8
9
10
|
# File 'lib/morpheus/api/instances_interface.rb', line 5
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
#apply_security_groups(id, options) ⇒ Object
164
165
166
167
168
169
170
171
|
# File 'lib/morpheus/api/instances_interface.rb', line 164
def apply_security_groups(id, options)
url = "#{@base_url}/api/instances/#{id}/security-groups"
= { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
payload = options
response = Morpheus::RestClient.execute(method: :post, url: url,
timeout: 30, headers: ,verify_ssl: false, payload: payload.to_json)
JSON.parse(response.to_s)
end
|
#backup(id, server = true) ⇒ Object
132
133
134
135
136
137
138
|
# File 'lib/morpheus/api/instances_interface.rb', line 132
def backup(id,server=true)
url = "#{@base_url}/api/instances/#{id}/backup"
= {:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
response = Morpheus::RestClient.execute(method: :put, url: url,
timeout: 30, headers: ,verify_ssl: false)
JSON.parse(response.to_s)
end
|
#create(options) ⇒ Object
56
57
58
59
60
61
62
63
64
|
# File 'lib/morpheus/api/instances_interface.rb', line 56
def create(options)
url = "#{@base_url}/api/instances"
= { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
payload = options
response = Morpheus::RestClient.execute(method: :post, url: url,
timeout: 30, headers: ,verify_ssl: false, payload: payload.to_json)
JSON.parse(response.to_s)
end
|
#create_env(id, options) ⇒ Object
36
37
38
39
40
41
42
43
44
|
# File 'lib/morpheus/api/instances_interface.rb', line 36
def create_env(id, options)
url = "#{@base_url}/api/instances/#{id}/envs"
= { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
payload = {envs: options}
response = Morpheus::RestClient.execute(method: :post, url: url,
timeout: 30, headers: ,verify_ssl: false, payload: payload.to_json)
JSON.parse(response.to_s)
end
|
#del_env(id, name) ⇒ Object
46
47
48
49
50
51
52
53
|
# File 'lib/morpheus/api/instances_interface.rb', line 46
def del_env(id, name)
url = "#{@base_url}/api/instances/#{id}/envs/#{name}"
= { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
response = Morpheus::RestClient.execute(method: :delete, url: url,
timeout: 30, headers: ,verify_ssl: false)
JSON.parse(response.to_s)
end
|
#destroy(id, params = {}) ⇒ Object
76
77
78
79
80
81
82
|
# File 'lib/morpheus/api/instances_interface.rb', line 76
def destroy(id, params = {})
url = "#{@base_url}/api/instances/#{id}"
= {:params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
response = Morpheus::RestClient.execute(method: :delete, url: url,
timeout: 30, headers: ,verify_ssl: false)
JSON.parse(response.to_s)
end
|
#firewall_disable(id) ⇒ Object
140
141
142
143
144
145
146
|
# File 'lib/morpheus/api/instances_interface.rb', line 140
def firewall_disable(id)
url = "#{@base_url}/api/instances/#{id}/security-groups/disable"
= { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
response = Morpheus::RestClient.execute(method: :put, url: url,
timeout: 30, headers: ,verify_ssl: false)
JSON.parse(response.to_s)
end
|
#firewall_enable(id) ⇒ Object
148
149
150
151
152
153
154
|
# File 'lib/morpheus/api/instances_interface.rb', line 148
def firewall_enable(id)
url = "#{@base_url}/api/instances/#{id}/security-groups/enable"
= { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
response = Morpheus::RestClient.execute(method: :put, url: url,
timeout: 30, headers: ,verify_ssl: false)
JSON.parse(response.to_s)
end
|
#get(options = nil) ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/morpheus/api/instances_interface.rb', line 12
def get(options=nil)
url = "#{@base_url}/api/instances"
= { params: {}, authorization: "Bearer #{@access_token}" }
if options.is_a?(Hash)
[:params].merge!(options)
elsif options.is_a?(Numeric)
url = "#{@base_url}/api/instances/#{options}"
elsif options.is_a?(String)
[:params]['name'] = options
end
response = Morpheus::RestClient.execute(method: :get, url: url,
timeout: 30, headers: ,verify_ssl: false)
JSON.parse(response.to_s)
end
|
#get_envs(id, options = nil) ⇒ Object
28
29
30
31
32
33
34
|
# File 'lib/morpheus/api/instances_interface.rb', line 28
def get_envs(id, options=nil)
url = "#{@base_url}/api/instances/#{id}/envs"
= { params: {}, authorization: "Bearer #{@access_token}" }
response = Morpheus::RestClient.execute(method: :get, url: url,
timeout: 30, headers: ,verify_ssl: false)
JSON.parse(response.to_s)
end
|
#resize(id, payload) ⇒ Object
116
117
118
119
120
121
122
|
# File 'lib/morpheus/api/instances_interface.rb', line 116
def resize(id,payload)
url = "#{@base_url}/api/instances/#{id}/resize"
= { :params => {},:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
response = Morpheus::RestClient.execute(method: :put, url: url,
timeout: 30, headers: ,verify_ssl: false,payload: payload.to_json)
JSON.parse(response.to_s)
end
|
#restart(id, server = true) ⇒ Object
100
101
102
103
104
105
106
|
# File 'lib/morpheus/api/instances_interface.rb', line 100
def restart(id,server=true)
url = "#{@base_url}/api/instances/#{id}/restart"
= { :params => {:server => server},:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
response = Morpheus::RestClient.execute(method: :put, url: url,
timeout: 30, headers: ,verify_ssl: false)
JSON.parse(response.to_s)
end
|
#security_groups(id) ⇒ Object
156
157
158
159
160
161
162
|
# File 'lib/morpheus/api/instances_interface.rb', line 156
def security_groups(id)
url = "#{@base_url}/api/instances/#{id}/security-groups"
= { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
response = Morpheus::RestClient.execute(method: :get, url: url,
timeout: 30, headers: ,verify_ssl: false)
JSON.parse(response.to_s)
end
|
#service_plans(params) ⇒ Object
173
174
175
176
177
178
179
|
# File 'lib/morpheus/api/instances_interface.rb', line 173
def service_plans(params)
url = "#{@base_url}/api/instances/service-plans"
= { params: params, authorization: "Bearer #{@access_token}" }
response = Morpheus::RestClient.execute(method: :get, url: url,
timeout: 30, headers: , verify_ssl: false)
JSON.parse(response.to_s)
end
|
#start(id, server = true) ⇒ Object
92
93
94
95
96
97
98
|
# File 'lib/morpheus/api/instances_interface.rb', line 92
def start(id,server=true)
url = "#{@base_url}/api/instances/#{id}/start"
= { :params => {:server => server}, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
response = Morpheus::RestClient.execute(method: :put, url: url,
timeout: 30, headers: ,verify_ssl: false)
JSON.parse(response.to_s)
end
|
#stop(id, server = true) ⇒ Object
84
85
86
87
88
89
90
|
# File 'lib/morpheus/api/instances_interface.rb', line 84
def stop(id,server=true)
url = "#{@base_url}/api/instances/#{id}/stop"
= { :params => {:server => server}, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
response = Morpheus::RestClient.execute(method: :put, url: url,
timeout: 30, headers: ,verify_ssl: false)
JSON.parse(response.to_s)
end
|
#update(id, options) ⇒ Object
66
67
68
69
70
71
72
73
74
|
# File 'lib/morpheus/api/instances_interface.rb', line 66
def update(id, options)
url = "#{@base_url}/api/instances/#{id}"
= { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
payload = options
response = Morpheus::RestClient.execute(method: :put, url: url,
timeout: 30, headers: ,verify_ssl: false, payload: payload.to_json)
JSON.parse(response.to_s)
end
|
#volumes(id) ⇒ Object
108
109
110
111
112
113
114
|
# File 'lib/morpheus/api/instances_interface.rb', line 108
def volumes(id)
url = "#{@base_url}/api/instances/#{id}/volumes"
= { :params => {},:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
response = Morpheus::RestClient.execute(method: :get, url: url,
timeout: 30, headers: ,verify_ssl: false)
JSON.parse(response.to_s)
end
|
#workflow(id, task_set_id, payload) ⇒ Object
124
125
126
127
128
129
130
|
# File 'lib/morpheus/api/instances_interface.rb', line 124
def workflow(id,task_set_id,payload)
url = "#{@base_url}/api/instances/#{id}/workflow"
= { :params => {:taskSetId => task_set_id},:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
response = Morpheus::RestClient.execute(method: :put, url: url,
timeout: 30, headers: ,verify_ssl: false,payload: payload.to_json)
JSON.parse(response.to_s)
end
|