Class: Morpheus::InstancesInterface
Constant Summary
Constants inherited
from APIClient
APIClient::CLIENT_ID
Instance Attribute Summary
Attributes inherited from APIClient
#client_id
Instance Method Summary
collapse
-
#action(id, action_code, payload = {}) ⇒ Object
-
#apply_security_groups(id, payload) ⇒ Object
-
#available_actions(id) ⇒ Object
-
#backup(id, server = true) ⇒ Object
-
#backups(id, params) ⇒ Object
-
#cancel_removal(id, params = {}) ⇒ Object
-
#clone(id, payload) ⇒ Object
-
#containers(instance_id, params = {}) ⇒ Object
-
#create(payload) ⇒ Object
-
#create_env(id, payload = {}) ⇒ Object
-
#del_env(id, name) ⇒ Object
-
#destroy(id, params = {}) ⇒ Object
-
#eject(id, params = {}) ⇒ Object
-
#firewall_disable(id) ⇒ Object
-
#firewall_enable(id) ⇒ Object
-
#get(params = {}) ⇒ Object
-
#get_envs(id, params = {}) ⇒ Object
-
#history(id, params = {}) ⇒ Object
-
#history_details(id, process_id, params = {}) ⇒ Object
-
#history_event_details(id, process_event_id, params = {}) ⇒ Object
-
#import_snapshot(id, params = {}, payload = {}) ⇒ Object
-
#initialize(access_token, refresh_token, expires_at = nil, base_url = nil) ⇒ InstancesInterface
constructor
A new instance of InstancesInterface.
-
#list(params = {}) ⇒ Object
-
#remove_load_balancer(id, payload = {}) ⇒ Object
-
#resize(id, payload) ⇒ Object
-
#restart(id, params = {}) ⇒ Object
-
#security_groups(id) ⇒ Object
-
#service_plans(params = {}) ⇒ Object
-
#start(id, params = {}) ⇒ Object
-
#stop(id, params = {}) ⇒ Object
-
#suspend(id, params = {}) ⇒ Object
-
#threshold(id, params = {}) ⇒ Object
-
#update(id, payload) ⇒ Object
-
#update_load_balancer(id, payload) ⇒ Object
-
#update_threshold(id, payload) ⇒ Object
-
#update_wiki(id, payload) ⇒ Object
-
#volumes(id) ⇒ Object
-
#wiki(id, params) ⇒ Object
-
#workflow(id, task_set_id, payload) ⇒ Object
Methods inherited from APIClient
#account_groups, #accounts, #activity, #appliance_settings, #approvals, #apps, #archive_buckets, #archive_files, #auth, #authorization_required?, #backup_settings, #blueprints, #budgets, #cloud_datastores, #cloud_folders, #cloud_policies, #cloud_resource_pools, #clouds, #clusters, #common_interface_options, #custom_instance_types, #cypher, #dashboard, #datastores, #default_content_type, #default_timeout, #deploy, #deployments, #dry, #dry_run, #environments, #execute, #execute_schedules, #execution_request, #file_copy_request, #group_policies, #groups, #guidance, #health, #image_builder, #inspect, #instance_types, #instances, #integrations, #invoice_line_items, #invoices, #jobs, #key_pairs, #library_cluster_layouts, #library_container_scripts, #library_container_templates, #library_container_types, #library_container_upgrades, #library_instance_types, #library_layouts, #library_spec_template_types, #library_spec_templates, #license, #load_balancers, #log_settings, #logged_in?, #login, #logout, #logs, #monitoring, #network_domain_records, #network_domains, #network_groups, #network_pool_ips, #network_pool_servers, #network_pools, #network_proxies, #network_routers, #network_security_servers, #network_services, #network_types, #networks, #old_cypher, #option_type_lists, #option_types, #options, #packages, #ping, #policies, #power_schedules, #price_sets, #prices, #processes, #projects, #provision_types, #provisioning_license_types, #provisioning_licenses, #provisioning_settings, #refresh_token, #reports, #roles, #security_group_rules, #server_types, #servers, #set_ssl_verification_enabled, #setopts, #setup, #ssl_verification_enabled?, #storage_providers, #subnet_types, #subnets, #task_sets, #tasks, #to_s, #url, #user_groups, #user_settings, #user_sources, #users, #virtual_images, #whitelabel_settings, #whoami, #withopts
Constructor Details
#initialize(access_token, refresh_token, expires_at = nil, base_url = nil) ⇒ InstancesInterface
Returns a new instance of InstancesInterface.
4
5
6
7
8
9
|
# File 'lib/morpheus/api/instances_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
#action(id, action_code, payload = {}) ⇒ Object
137
138
139
140
141
142
143
144
145
146
147
148
149
|
# File 'lib/morpheus/api/instances_interface.rb', line 137
def action(id, action_code, payload={})
url, params = "", {}
if id.is_a?(Array)
url = "#{@base_url}/api/instances/action"
params = {ids: id, code: action_code}
else
url = "#{@base_url}/api/instances/#{id}/action"
params = {code: action_code}
end
= { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
opts = {method: :put, url: url, headers: , payload: payload.to_json}
execute(opts)
end
|
#apply_security_groups(id, payload) ⇒ Object
214
215
216
217
218
219
|
# File 'lib/morpheus/api/instances_interface.rb', line 214
def apply_security_groups(id, payload)
url = "#{@base_url}/api/instances/#{id}/security-groups"
= { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
opts = {method: :post, url: url, headers: , payload: payload.to_json}
execute(opts)
end
|
#available_actions(id) ⇒ Object
123
124
125
126
127
128
129
130
131
132
133
134
135
|
# File 'lib/morpheus/api/instances_interface.rb', line 123
def available_actions(id)
url, params = "", {}
if id.is_a?(Array)
url = "#{@base_url}/api/instances/actions"
params = {ids: id}
else
url = "#{@base_url}/api/instances/#{id}/actions"
params = {}
end
= { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
opts = {method: :get, url: url, headers: }
execute(opts)
end
|
#backup(id, server = true) ⇒ Object
172
173
174
175
176
177
|
# File 'lib/morpheus/api/instances_interface.rb', line 172
def backup(id,server=true)
url = "#{@base_url}/api/instances/#{id}/backup"
= {:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
opts = {method: :put, url: url, headers: }
execute(opts)
end
|
#backups(id, params) ⇒ Object
179
180
181
182
183
184
|
# File 'lib/morpheus/api/instances_interface.rb', line 179
def backups(id, params)
url = "#{@base_url}/api/instances/#{id}/backups"
= { params: params, authorization: "Bearer #{@access_token}" }
opts = {method: :get, url: url, headers: }
execute(opts)
end
|
#cancel_removal(id, params = {}) ⇒ Object
71
72
73
74
75
76
|
# File 'lib/morpheus/api/instances_interface.rb', line 71
def cancel_removal(id, params = {})
url = "#{@base_url}/api/instances/#{id}/cancel-removal"
= {:params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
opts = {method: :put, url: url, headers: }
execute(opts)
end
|
#clone(id, payload) ⇒ Object
186
187
188
189
190
191
|
# File 'lib/morpheus/api/instances_interface.rb', line 186
def clone(id, payload)
url = "#{@base_url}/api/instances/#{id}/clone"
= {:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
opts = {method: :put, url: url, headers: , payload: payload.to_json}
execute(opts)
end
|
#containers(instance_id, params = {}) ⇒ Object
235
236
237
238
239
240
|
# File 'lib/morpheus/api/instances_interface.rb', line 235
def containers(instance_id, params={})
url = "#{@base_url}/api/instances/#{instance_id}/containers"
= { params: params, authorization: "Bearer #{@access_token}" }
opts = {method: :get, url: url, headers: }
execute(opts)
end
|
#create(payload) ⇒ Object
50
51
52
53
54
55
|
# File 'lib/morpheus/api/instances_interface.rb', line 50
def create(payload)
url = "#{@base_url}/api/instances"
= { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
opts = {method: :post, url: url, headers: , payload: payload.to_json}
execute(opts)
end
|
#create_env(id, payload = {}) ⇒ Object
36
37
38
39
40
41
|
# File 'lib/morpheus/api/instances_interface.rb', line 36
def create_env(id, payload={})
url = "#{@base_url}/api/instances/#{id}/envs"
= { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
opts = {method: :post, url: url, headers: , payload: payload.to_json}
execute(opts)
end
|
#del_env(id, name) ⇒ Object
43
44
45
46
47
48
|
# File 'lib/morpheus/api/instances_interface.rb', line 43
def del_env(id, name)
url = "#{@base_url}/api/instances/#{id}/envs/#{name}"
= { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
opts = {method: :delete, url: url, headers: }
execute(opts)
end
|
#destroy(id, params = {}) ⇒ Object
64
65
66
67
68
69
|
# File 'lib/morpheus/api/instances_interface.rb', line 64
def destroy(id, params = {})
url = "#{@base_url}/api/instances/#{id}"
= {:params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
opts = {method: :delete, url: url, headers: }
execute(opts)
end
|
#eject(id, params = {}) ⇒ Object
111
112
113
114
115
116
117
118
119
120
121
|
# File 'lib/morpheus/api/instances_interface.rb', line 111
def eject(id, params={})
url = "#{@base_url}/api/instances/eject"
if id.is_a?(Array)
params['ids'] = id
else
url = "#{@base_url}/api/instances/#{id}/eject"
end
= { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
opts = {method: :put, url: url, headers: }
execute(opts)
end
|
#firewall_disable(id) ⇒ Object
193
194
195
196
197
198
|
# File 'lib/morpheus/api/instances_interface.rb', line 193
def firewall_disable(id)
url = "#{@base_url}/api/instances/#{id}/security-groups/disable"
= { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
opts = {method: :put, url: url, headers: }
execute(opts)
end
|
#firewall_enable(id) ⇒ Object
200
201
202
203
204
205
|
# File 'lib/morpheus/api/instances_interface.rb', line 200
def firewall_enable(id)
url = "#{@base_url}/api/instances/#{id}/security-groups/enable"
= { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
opts = {method: :put, url: url, headers: }
execute(opts)
end
|
#get(params = {}) ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/morpheus/api/instances_interface.rb', line 11
def get(params={})
url = "#{@base_url}/api/instances"
= { params: {}, authorization: "Bearer #{@access_token}" }
if params.is_a?(Hash)
[:params].merge!(params)
elsif params.is_a?(Numeric)
url = "#{@base_url}/api/instances/#{params}"
elsif params.is_a?(String)
[:params]['name'] = params
end
opts = {method: :get, url: url, headers: }
execute(opts)
end
|
#get_envs(id, params = {}) ⇒ Object
29
30
31
32
33
34
|
# File 'lib/morpheus/api/instances_interface.rb', line 29
def get_envs(id, params={})
url = "#{@base_url}/api/instances/#{id}/envs"
= { params: params, authorization: "Bearer #{@access_token}" }
opts = {method: :get, url: url, headers: }
execute(opts)
end
|
#history(id, params = {}) ⇒ Object
270
271
272
273
274
275
|
# File 'lib/morpheus/api/instances_interface.rb', line 270
def history(id, params={})
url = "#{@base_url}/api/instances/#{id}/history"
= { params: params, authorization: "Bearer #{@access_token}" }
opts = {method: :get, url: url, headers: }
execute(opts)
end
|
#history_details(id, process_id, params = {}) ⇒ Object
277
278
279
280
281
282
|
# File 'lib/morpheus/api/instances_interface.rb', line 277
def history_details(id, process_id, params={})
url = "#{@base_url}/api/instances/#{id}/history/#{process_id}"
= { params: params, authorization: "Bearer #{@access_token}" }
opts = {method: :get, url: url, headers: }
execute(opts)
end
|
#history_event_details(id, process_event_id, params = {}) ⇒ Object
284
285
286
287
288
289
|
# File 'lib/morpheus/api/instances_interface.rb', line 284
def history_event_details(id, process_event_id, params={})
url = "#{@base_url}/api/instances/#{id}/history/events/#{process_event_id}"
= { params: params, authorization: "Bearer #{@access_token}" }
opts = {method: :get, url: url, headers: }
execute(opts)
end
|
#import_snapshot(id, params = {}, payload = {}) ⇒ Object
221
222
223
224
225
226
|
# File 'lib/morpheus/api/instances_interface.rb', line 221
def import_snapshot(id, params={}, payload={})
url = "#{@base_url}/api/instances/#{id}/import-snapshot"
= {:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
opts = {method: :put, url: url, headers: , payload: payload.to_json}
execute(opts)
end
|
#list(params = {}) ⇒ Object
25
26
27
|
# File 'lib/morpheus/api/instances_interface.rb', line 25
def list(params={})
get(params)
end
|
#remove_load_balancer(id, payload = {}) ⇒ Object
263
264
265
266
267
268
|
# File 'lib/morpheus/api/instances_interface.rb', line 263
def remove_load_balancer(id, payload={})
url = "#{@base_url}/api/instances/#{id}/load-balancer"
= {authorization: "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
opts = {method: :delete, url: url, headers: , payload: payload.to_json}
execute(opts)
end
|
#resize(id, payload) ⇒ Object
158
159
160
161
162
163
|
# File 'lib/morpheus/api/instances_interface.rb', line 158
def resize(id,payload)
url = "#{@base_url}/api/instances/#{id}/resize"
= { :params => {},:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
opts = {method: :put, url: url, headers: ,payload: payload.to_json}
execute(opts)
end
|
#restart(id, params = {}) ⇒ Object
92
93
94
95
96
97
|
# File 'lib/morpheus/api/instances_interface.rb', line 92
def restart(id, params={})
url = "#{@base_url}/api/instances/#{id}/restart"
= { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
opts = {method: :put, url: url, headers: }
execute(opts)
end
|
#security_groups(id) ⇒ Object
207
208
209
210
211
212
|
# File 'lib/morpheus/api/instances_interface.rb', line 207
def security_groups(id)
url = "#{@base_url}/api/instances/#{id}/security-groups"
= { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
opts = {method: :get, url: url, headers: }
execute(opts)
end
|
#service_plans(params = {}) ⇒ Object
228
229
230
231
232
233
|
# File 'lib/morpheus/api/instances_interface.rb', line 228
def service_plans(params={})
url = "#{@base_url}/api/instances/service-plans"
= { params: params, authorization: "Bearer #{@access_token}" }
opts = {method: :get, url: url, headers: }
execute(opts)
end
|
#start(id, params = {}) ⇒ Object
85
86
87
88
89
90
|
# File 'lib/morpheus/api/instances_interface.rb', line 85
def start(id, params={})
url = "#{@base_url}/api/instances/#{id}/start"
= { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
opts = {method: :put, url: url, headers: }
execute(opts)
end
|
#stop(id, params = {}) ⇒ Object
78
79
80
81
82
83
|
# File 'lib/morpheus/api/instances_interface.rb', line 78
def stop(id, params={})
url = "#{@base_url}/api/instances/#{id}/stop"
= { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
opts = {method: :put, url: url, headers: }
execute(opts)
end
|
#suspend(id, params = {}) ⇒ Object
99
100
101
102
103
104
105
106
107
108
109
|
# File 'lib/morpheus/api/instances_interface.rb', line 99
def suspend(id, params={})
url = "#{@base_url}/api/instances/suspend"
if id.is_a?(Array)
params['ids'] = id
else
url = "#{@base_url}/api/instances/#{id}/suspend"
end
= { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
opts = {method: :put, url: url, headers: }
execute(opts)
end
|
#threshold(id, params = {}) ⇒ Object
242
243
244
245
246
247
|
# File 'lib/morpheus/api/instances_interface.rb', line 242
def threshold(id, params={})
url = "#{@base_url}/api/instances/#{id}/threshold"
= { params: params, authorization: "Bearer #{@access_token}" }
opts = {method: :get, url: url, headers: }
execute(opts)
end
|
#update(id, payload) ⇒ Object
57
58
59
60
61
62
|
# File 'lib/morpheus/api/instances_interface.rb', line 57
def update(id, payload)
url = "#{@base_url}/api/instances/#{id}"
= { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
opts = {method: :put, url: url, headers: , payload: payload.to_json}
execute(opts)
end
|
#update_load_balancer(id, payload) ⇒ Object
256
257
258
259
260
261
|
# File 'lib/morpheus/api/instances_interface.rb', line 256
def update_load_balancer(id, payload)
url = "#{@base_url}/api/instances/#{id}/load-balancer"
= {authorization: "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
opts = {method: :put, url: url, headers: , payload: payload.to_json}
execute(opts)
end
|
#update_threshold(id, payload) ⇒ Object
249
250
251
252
253
254
|
# File 'lib/morpheus/api/instances_interface.rb', line 249
def update_threshold(id, payload)
url = "#{@base_url}/api/instances/#{id}/threshold"
= {authorization: "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
opts = {method: :put, url: url, headers: , payload: payload.to_json}
execute(opts)
end
|
#update_wiki(id, payload) ⇒ Object
298
299
300
301
302
303
|
# File 'lib/morpheus/api/instances_interface.rb', line 298
def update_wiki(id, payload)
url = "#{@base_url}/api/instances/#{id}/wiki"
= {authorization: "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
opts = {method: :put, url: url, headers: , payload: payload.to_json}
execute(opts)
end
|
#volumes(id) ⇒ Object
151
152
153
154
155
156
|
# File 'lib/morpheus/api/instances_interface.rb', line 151
def volumes(id)
url = "#{@base_url}/api/instances/#{id}/volumes"
= { :params => {},:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
opts = {method: :get, url: url, headers: }
execute(opts)
end
|
#wiki(id, params) ⇒ Object
291
292
293
294
295
296
|
# File 'lib/morpheus/api/instances_interface.rb', line 291
def wiki(id, params)
url = "#{@base_url}/api/instances/#{id}/wiki"
= { params: params, authorization: "Bearer #{@access_token}" }
opts = {method: :get, url: url, headers: }
execute(opts)
end
|
#workflow(id, task_set_id, payload) ⇒ Object
165
166
167
168
169
170
|
# File 'lib/morpheus/api/instances_interface.rb', line 165
def workflow(id,task_set_id,payload)
url = "#{@base_url}/api/instances/#{id}/workflow"
= { :params => {:workflowId => task_set_id},:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
opts = {method: :put, url: url, headers: ,payload: payload.to_json}
execute(opts)
end
|