Class: Morpheus::InstancesInterface

Inherits:
APIClient
  • Object
show all
Defined in:
lib/morpheus/api/instances_interface.rb

Constant Summary

Constants inherited from APIClient

APIClient::CLIENT_ID

Instance Attribute Summary

Attributes inherited from APIClient

#client_id

Instance Method Summary collapse

Methods inherited from APIClient

#account_groups, #accounts, #activity, #appliance_settings, #approvals, #apps, #archive_buckets, #archive_files, #auth, #authorization_required?, #backup_jobs, #backup_settings, #billing, #blueprints, #budgets, #catalog, #catalog_item_types, #certificate_types, #certificates, #cloud_datastores, #cloud_folders, #cloud_policies, #cloud_resource_pools, #clouds, #clusters, #common_interface_options, #cypher, #dashboard, #datastores, #default_content_type, #default_timeout, #deploy, #deployments, #doc, #dry, #dry_run, #environments, #execute, #execute_schedules, #execution_request, #file_copy_request, #forgot, #group_policies, #groups, #guidance, #health, #image_builder, #initialize, #inspect, #instance_types, #instances, #integration_types, #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, #reports, #roles, #search, #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, #usage, #use_refresh_token, #user_groups, #user_settings, #user_sources, #users, #vdi, #vdi_allocations, #vdi_apps, #vdi_gateways, #vdi_pools, #virtual_images, #whitelabel_settings, #whoami, #withopts

Constructor Details

This class inherits a constructor from Morpheus::APIClient

Instance Method Details

#action(id, action_code, payload = {}) ⇒ Object



126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/morpheus/api/instances_interface.rb', line 126

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
  headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
  execute(opts)
end

#apply_security_groups(id, payload) ⇒ Object



224
225
226
227
228
229
# File 'lib/morpheus/api/instances_interface.rb', line 224

def apply_security_groups(id, payload)
  url = "#{@base_url}/api/instances/#{id}/security-groups"
  headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  opts = {method: :post, url: url, headers: headers, payload: payload.to_json}
  execute(opts)
end

#available_actions(id) ⇒ Object



112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/morpheus/api/instances_interface.rb', line 112

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
  headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  opts = {method: :get, url: url, headers: headers}
  execute(opts)
end

#backup(id, payload = {}) ⇒ Object



161
162
163
164
165
166
# File 'lib/morpheus/api/instances_interface.rb', line 161

def backup(id, payload={})
  url = "#{@base_url}/api/instances/#{id}/backup"
  headers = {:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
  execute(opts)
end

#backups(id, params) ⇒ Object



168
169
170
171
172
173
# File 'lib/morpheus/api/instances_interface.rb', line 168

def backups(id, params)
  url = "#{@base_url}/api/instances/#{id}/backups"
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  opts = {method: :get, url: url, headers: headers}
  execute(opts)
end

#base_pathObject



5
6
7
# File 'lib/morpheus/api/instances_interface.rb', line 5

def base_path
  "/api/instances"
end

#cancel_removal(id, params = {}) ⇒ Object



60
61
62
63
64
65
# File 'lib/morpheus/api/instances_interface.rb', line 60

def cancel_removal(id, params = {})
  url = "#{@base_url}/api/instances/#{id}/cancel-removal"
  headers = {:params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  opts = {method: :put, url: url, headers: headers}
  execute(opts)
end

#clone(id, payload) ⇒ Object



175
176
177
178
179
180
# File 'lib/morpheus/api/instances_interface.rb', line 175

def clone(id, payload)
  url = "#{@base_url}/api/instances/#{id}/clone"
  headers = {:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
  execute(opts)
end

#clone_image(id, payload) ⇒ Object



182
183
184
185
186
187
# File 'lib/morpheus/api/instances_interface.rb', line 182

def clone_image(id, payload)
  url = "#{@base_url}/api/instances/#{id}/clone-image"
  headers = {:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
  execute(opts)
end

#containers(instance_id, params = {}) ⇒ Object



259
260
261
262
263
264
# File 'lib/morpheus/api/instances_interface.rb', line 259

def containers(instance_id, params={})
  url = "#{@base_url}/api/instances/#{instance_id}/containers"
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  opts = {method: :get, url: url, headers: headers}
  execute(opts)
end

#create(payload) ⇒ Object



39
40
41
42
43
44
# File 'lib/morpheus/api/instances_interface.rb', line 39

def create(payload)
  url = "#{@base_url}/api/instances"
  headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  opts = {method: :post, url: url, headers: headers, payload: payload.to_json}
  execute(opts)
end

#create_env(id, payload = {}) ⇒ Object



25
26
27
28
29
30
# File 'lib/morpheus/api/instances_interface.rb', line 25

def create_env(id, payload={})
  url = "#{@base_url}/api/instances/#{id}/envs"
  headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  opts = {method: :post, url: url, headers: headers, payload: payload.to_json}
  execute(opts)
end

#del_env(id, name) ⇒ Object



32
33
34
35
36
37
# File 'lib/morpheus/api/instances_interface.rb', line 32

def del_env(id, name)
  url = "#{@base_url}/api/instances/#{id}/envs/#{name}"
  headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  opts = {method: :delete, url: url, headers: headers}
  execute(opts)
end

#deploys(id, params) ⇒ Object



329
330
331
332
# File 'lib/morpheus/api/instances_interface.rb', line 329

def deploys(id, params)
  # todo: make this plural??
  execute(method: :get, url: "/api/instances/#{id}/deploy", params: params)
end

#destroy(id, params = {}) ⇒ Object



53
54
55
56
57
58
# File 'lib/morpheus/api/instances_interface.rb', line 53

def destroy(id, params = {})
  url = "#{@base_url}/api/instances/#{id}"
  headers = {:params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  opts = {method: :delete, url: url, headers: headers}
  execute(opts)
end

#eject(id, params = {}) ⇒ Object



100
101
102
103
104
105
106
107
108
109
110
# File 'lib/morpheus/api/instances_interface.rb', line 100

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
  headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  opts = {method: :put, url: url, headers: headers}
  execute(opts)
end

#firewall_disable(id) ⇒ Object



203
204
205
206
207
208
# File 'lib/morpheus/api/instances_interface.rb', line 203

def firewall_disable(id)
  url = "#{@base_url}/api/instances/#{id}/security-groups/disable"
  headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  opts = {method: :put, url: url, headers: headers}
  execute(opts)
end

#firewall_enable(id) ⇒ Object



210
211
212
213
214
215
# File 'lib/morpheus/api/instances_interface.rb', line 210

def firewall_enable(id)
  url = "#{@base_url}/api/instances/#{id}/security-groups/enable"
  headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  opts = {method: :put, url: url, headers: headers}
  execute(opts)
end

#get(id, params = {}, headers = {}) ⇒ Object



13
14
15
16
# File 'lib/morpheus/api/instances_interface.rb', line 13

def get(id, params={}, headers={})
  validate_id!(id)
  execute(method: :get, url: "#{base_path}/#{id}", params: params, headers: headers)
end

#get_envs(id, params = {}) ⇒ Object



18
19
20
21
22
23
# File 'lib/morpheus/api/instances_interface.rb', line 18

def get_envs(id, params={})
  url = "#{@base_url}/api/instances/#{id}/envs"
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  opts = {method: :get, url: url, headers: headers}
  execute(opts)
end

#history(id, params = {}) ⇒ Object



294
295
296
297
298
299
# File 'lib/morpheus/api/instances_interface.rb', line 294

def history(id, params={})
  url = "#{@base_url}/api/instances/#{id}/history"
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  opts = {method: :get, url: url, headers: headers}
  execute(opts)
end

#history_details(id, process_id, params = {}) ⇒ Object



301
302
303
304
305
306
# File 'lib/morpheus/api/instances_interface.rb', line 301

def history_details(id, process_id, params={})
  url = "#{@base_url}/api/instances/#{id}/history/#{process_id}"
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  opts = {method: :get, url: url, headers: headers}
  execute(opts)
end

#history_event_details(id, process_event_id, params = {}) ⇒ Object



308
309
310
311
312
313
# File 'lib/morpheus/api/instances_interface.rb', line 308

def history_event_details(id, process_event_id, params={})
  url = "#{@base_url}/api/instances/#{id}/history/events/#{process_event_id}"
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  opts = {method: :get, url: url, headers: headers}
  execute(opts)
end

#import_snapshot(id, params = {}, payload = {}) ⇒ Object



245
246
247
248
249
250
# File 'lib/morpheus/api/instances_interface.rb', line 245

def import_snapshot(id, params={}, payload={})
  url = "#{@base_url}/api/instances/#{id}/import-snapshot"
  headers = {:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
  execute(opts)
end

#list(params = {}, headers = {}) ⇒ Object



9
10
11
# File 'lib/morpheus/api/instances_interface.rb', line 9

def list(params={}, headers={})
  execute(method: :get, url: "#{base_path}", params: params, headers: headers)
end

#lock(id, payload) ⇒ Object



189
190
191
192
193
194
# File 'lib/morpheus/api/instances_interface.rb', line 189

def lock(id, payload)
  url = "#{@base_url}/api/instances/#{id}/lock"
  headers = {:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
  execute(opts)
end

#remove_load_balancer(id, payload = {}) ⇒ Object



287
288
289
290
291
292
# File 'lib/morpheus/api/instances_interface.rb', line 287

def remove_load_balancer(id, payload={})
  url = "#{@base_url}/api/instances/#{id}/load-balancer"
  headers = {authorization: "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  opts = {method: :delete, url: url, headers: headers, payload: payload.to_json}
  execute(opts)
end

#resize(id, payload) ⇒ Object



147
148
149
150
151
152
# File 'lib/morpheus/api/instances_interface.rb', line 147

def resize(id,payload)
  url = "#{@base_url}/api/instances/#{id}/resize"
  headers = { :params => {},:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  opts = {method: :put, url: url, headers: headers,payload: payload.to_json}
  execute(opts)
end

#restart(id, params = {}) ⇒ Object



81
82
83
84
85
86
# File 'lib/morpheus/api/instances_interface.rb', line 81

def restart(id, params={})
  url = "#{@base_url}/api/instances/#{id}/restart"
  headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  opts = {method: :put, url: url, headers: headers}
  execute(opts)
end

#security_groups(id) ⇒ Object



217
218
219
220
221
222
# File 'lib/morpheus/api/instances_interface.rb', line 217

def security_groups(id)
  url = "#{@base_url}/api/instances/#{id}/security-groups"
  headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  opts = {method: :get, url: url, headers: headers}
  execute(opts)
end

#service_plans(params = {}) ⇒ Object



252
253
254
255
256
257
# File 'lib/morpheus/api/instances_interface.rb', line 252

def service_plans(params={})
  url = "#{@base_url}/api/instances/service-plans"
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  opts = {method: :get, url: url, headers: headers}
  execute(opts)
end

#snapshot(id, payload = {}) ⇒ Object



231
232
233
234
235
236
# File 'lib/morpheus/api/instances_interface.rb', line 231

def snapshot(id, payload={})
  url = "#{@base_url}/api/instances/#{id}/snapshot"
  headers = {:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
  execute(opts)
end

#snapshots(instance_id, params = {}) ⇒ Object



238
239
240
241
242
243
# File 'lib/morpheus/api/instances_interface.rb', line 238

def snapshots(instance_id, params={})
  url = "#{@base_url}/api/instances/#{instance_id}/snapshots"
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  opts = {method: :get, url: url, headers: headers}
  execute(opts)
end

#start(id, params = {}) ⇒ Object



74
75
76
77
78
79
# File 'lib/morpheus/api/instances_interface.rb', line 74

def start(id, params={})
  url = "#{@base_url}/api/instances/#{id}/start"
  headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  opts = {method: :put, url: url, headers: headers}
  execute(opts)
end

#stop(id, params = {}) ⇒ Object



67
68
69
70
71
72
# File 'lib/morpheus/api/instances_interface.rb', line 67

def stop(id, params={})
  url = "#{@base_url}/api/instances/#{id}/stop"
  headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  opts = {method: :put, url: url, headers: headers}
  execute(opts)
end

#suspend(id, params = {}) ⇒ Object



88
89
90
91
92
93
94
95
96
97
98
# File 'lib/morpheus/api/instances_interface.rb', line 88

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
  headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  opts = {method: :put, url: url, headers: headers}
  execute(opts)
end

#threshold(id, params = {}) ⇒ Object



266
267
268
269
270
271
# File 'lib/morpheus/api/instances_interface.rb', line 266

def threshold(id, params={})
  url = "#{@base_url}/api/instances/#{id}/threshold"
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  opts = {method: :get, url: url, headers: headers}
  execute(opts)
end

#unlock(id, payload) ⇒ Object



196
197
198
199
200
201
# File 'lib/morpheus/api/instances_interface.rb', line 196

def unlock(id, payload)
  url = "#{@base_url}/api/instances/#{id}/unlock"
  headers = {:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
  execute(opts)
end

#update(id, payload) ⇒ Object



46
47
48
49
50
51
# File 'lib/morpheus/api/instances_interface.rb', line 46

def update(id, payload)
  url = "#{@base_url}/api/instances/#{id}"
  headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
  execute(opts)
end

#update_load_balancer(id, payload) ⇒ Object



280
281
282
283
284
285
# File 'lib/morpheus/api/instances_interface.rb', line 280

def update_load_balancer(id, payload)
  url = "#{@base_url}/api/instances/#{id}/load-balancer"
  headers = {authorization: "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
  execute(opts)
end

#update_threshold(id, payload) ⇒ Object



273
274
275
276
277
278
# File 'lib/morpheus/api/instances_interface.rb', line 273

def update_threshold(id, payload)
  url = "#{@base_url}/api/instances/#{id}/threshold"
  headers = {authorization: "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
  execute(opts)
end

#update_wiki(id, payload) ⇒ Object



322
323
324
325
326
327
# File 'lib/morpheus/api/instances_interface.rb', line 322

def update_wiki(id, payload)
  url = "#{@base_url}/api/instances/#{id}/wiki"
  headers = {authorization: "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
  execute(opts)
end

#volumes(id) ⇒ Object



140
141
142
143
144
145
# File 'lib/morpheus/api/instances_interface.rb', line 140

def volumes(id)
  url = "#{@base_url}/api/instances/#{id}/volumes"
  headers = { :params => {},:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  opts = {method: :get, url: url, headers: headers}
  execute(opts)
end

#wiki(id, params) ⇒ Object



315
316
317
318
319
320
# File 'lib/morpheus/api/instances_interface.rb', line 315

def wiki(id, params)
  url = "#{@base_url}/api/instances/#{id}/wiki"
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  opts = {method: :get, url: url, headers: headers}
  execute(opts)
end

#workflow(id, task_set_id, payload) ⇒ Object



154
155
156
157
158
159
# File 'lib/morpheus/api/instances_interface.rb', line 154

def workflow(id,task_set_id,payload)
  url = "#{@base_url}/api/instances/#{id}/workflow"
  headers = { :params => {:workflowId => task_set_id},:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  opts = {method: :put, url: url, headers: headers,payload: payload.to_json}
  execute(opts)
end