Class: Morpheus::ClustersInterface

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

Constant Summary

Constants inherited from APIClient

APIClient::CLIENT_ID

Instance Method Summary collapse

Methods inherited from APIClient

#account_groups, #account_users, #accounts, #activity, #appliance_settings, #approvals, #apps, #archive_buckets, #archive_files, #audit, #auth, #authorization_required?, #backup_jobs, #backup_restores, #backup_results, #backup_service_types, #backup_services, #backup_settings, #backup_types, #backups, #billing, #blueprints, #budgets, #catalog, #catalog_item_types, #certificate_types, #certificates, #client_id, #client_id=, #clients, #cloud_datastores, #cloud_folders, #cloud_policies, #cloud_resource_pools, #clouds, #clusters, #common_interface_options, #containers, #credential_types, #credentials, #cypher, #dashboard, #datastores, #default_content_type, #default_timeout, #deploy, #deployments, #dry, #dry_run, #email_templates, #environments, #execute, #execute_schedules, #execution_request, #file_copy_request, #forgot, #group_policies, #groups, #guidance, #guidance_settings, #health, #hub, #image_builder, #initialize, #inspect, #instance_types, #instances, #integration_types, #integrations, #interface, #invoice_line_items, #invoices, #jobs, #key_pairs, #library_cluster_layouts, #library_cluster_packages, #library_container_scripts, #library_container_templates, #library_container_types, #library_container_upgrades, #library_instance_types, #library_layouts, #library_operating_systems, #library_spec_template_types, #library_spec_templates, #license, #load_balancer_monitors, #load_balancer_pool_nodes, #load_balancer_pools, #load_balancer_pools_secondary, #load_balancer_profiles, #load_balancer_types, #load_balancer_virtual_servers, #load_balancers, #log_settings, #logged_in?, #login, #logout, #logs, #monitoring, #monitoring_settings, #network_dhcp_relays, #network_dhcp_servers, #network_domain_records, #network_domains, #network_edge_clusters, #network_floating_ips, #network_groups, #network_pool_ips, #network_pool_server_types, #network_pool_servers, #network_pools, #network_proxies, #network_resource_types, #network_routers, #network_security_server_types, #network_security_servers, #network_server_groups, #network_server_services, #network_server_types, #network_servers, #network_services, #network_static_routes, #network_types, #networks, #old_cypher, #option_type_forms, #option_type_lists, #option_types, #options, #packages, #ping, #plugins, #policies, #power_schedules, #price_sets, #prices, #processes, #projects, #provision_types, #provisioning_license_types, #provisioning_licenses, #provisioning_settings, #reports, #resource_pool_groups, #rest, #roles, #scale_thresholds, #search, #security_group_rules, #security_groups, #security_package_types, #security_packages, #security_scans, #server_types, #servers, #service_plans, #set_ssl_verification_enabled, #setopts, #setup, #snapshots, #ssl_verification_enabled?, #storage_providers, #storage_server_types, #storage_servers, #storage_volume_types, #storage_volumes, #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

#add_server(id, payload) ⇒ Object



139
140
141
142
143
# File 'lib/morpheus/api/clusters_interface.rb', line 139

def add_server(id, payload)
  url = "#{base_path}/#{id}/servers"
  headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  execute(method: :post, url: url, headers: headers, payload: payload.to_json)
end

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



300
301
302
303
304
# File 'lib/morpheus/api/clusters_interface.rb', line 300

def api_config(id, params={})
  url = "#{base_path}/#{id}/api-config"
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  execute(method: :get, url: url, headers: headers)
end

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



328
329
330
331
332
333
# File 'lib/morpheus/api/clusters_interface.rb', line 328

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

#base_pathObject



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

def base_path
  "/api/clusters"
end

#cluster_types(params = {}) ⇒ Object



49
50
51
52
53
54
# File 'lib/morpheus/api/clusters_interface.rb', line 49

def cluster_types(params={})
  url = "#{@base_url}/api/cluster-types"
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  opts = {method: :get, url: url, headers: headers}
  execute(opts)
end

#create(payload) ⇒ Object



29
30
31
32
33
# File 'lib/morpheus/api/clusters_interface.rb', line 29

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

#create_datastore(id, payload) ⇒ Object



268
269
270
271
272
# File 'lib/morpheus/api/clusters_interface.rb', line 268

def create_datastore(id, payload)
  url = "#{base_path}/#{id}/data-stores"
  headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  execute(method: :post, url: url, headers: headers, payload: payload.to_json)
end

#create_namespace(id, payload) ⇒ Object



180
181
182
183
184
# File 'lib/morpheus/api/clusters_interface.rb', line 180

def create_namespace(id, payload)
  url = "#{base_path}/#{id}/namespaces"
  headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  execute(method: :post, url: url, headers: headers, payload: payload.to_json)
end

#destroy(id, params = {}) ⇒ Object Also known as: delete



41
42
43
44
45
# File 'lib/morpheus/api/clusters_interface.rb', line 41

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

#destroy_container(id, container_id, params = {}) ⇒ Object



212
213
214
215
216
217
218
219
220
221
222
223
# File 'lib/morpheus/api/clusters_interface.rb', line 212

def destroy_container(id, container_id, params={})
  if container_id.is_a?(Array)
    url = "#{base_path}/#{id}/containers"
    params['containerId'] = container_id
  elsif container_id.is_a?(Numeric) || container_id.is_a?(String)
    url = "#{base_path}/#{id}/containers/#{container_id}"
  else
    raise "passed a bad container_id: #{container_id || '(none)'}" # lazy
  end
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  execute(method: :delete, url: url, headers: headers)
end

#destroy_container_group(id, container_group_id, resource_type, params = {}) ⇒ Object



243
244
245
246
247
248
249
250
251
252
253
254
# File 'lib/morpheus/api/clusters_interface.rb', line 243

def destroy_container_group(id, container_group_id, resource_type, params={})
  if container_group_id.is_a?(Array)
    url = "#{base_path}/#{id}/#{resource_type}s"
    params['containerGroupId'] = container_group_id
  elsif container_group_id.is_a?(Numeric) || container_group_id.is_a?(String)
    url = "#{base_path}/#{id}/#{resource_type}s/#{container_group_id}"
  else
    raise "passed a bad container_group_id: #{container_group_id || '(none)'}" # lazy
  end
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  execute(method: :delete, url: url, headers: headers)
end

#destroy_datastore(id, datastore_id, params = {}) ⇒ Object



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

def destroy_datastore(id, datastore_id, params={})
  url = "#{base_path}/#{id}/datastores/#{datastore_id}"
  headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  execute(method: :delete, url: url, headers: headers)
end

#destroy_job(id, job_id = nil, params = {}, payload = {}) ⇒ Object



68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/morpheus/api/clusters_interface.rb', line 68

def destroy_job(id, job_id=nil, params={}, payload={})
  url = nil
  if job_id.is_a?(Array)
    url = "#{base_path}/#{id}/jobs"
    params['jobId'] = job_id
  elsif job_id.is_a?(Numeric) || job_id.is_a?(String)
    url = "#{base_path}/#{id}/jobs/#{job_id}"
  else
    raise "passed a bad volume_id: #{job_id || '(none)'}" # lazy
  end
  headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  execute(method: :delete, url: url, headers: headers, payload: payload.to_json)
end

#destroy_namespace(id, namespace_id, params = {}) ⇒ Object Also known as: delete_namespace



192
193
194
195
196
# File 'lib/morpheus/api/clusters_interface.rb', line 192

def destroy_namespace(id, namespace_id, params={})
  url = "#{base_path}/#{id}/namespaces/#{namespace_id}"
  headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  execute(method: :delete, url: url, headers: headers)
end

#destroy_service(id, service_id = nil, params = {}, payload = {}) ⇒ Object

this supports multiple ids



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

def destroy_service(id, service_id=nil, params={}, payload={})
  url = nil
  if service_id.is_a?(Array)
    url = "#{base_path}/#{id}/services"
    params['serviceId'] = service_id
  elsif service_id.is_a?(Numeric) || service_id.is_a?(String)
    url = "#{base_path}/#{id}/services/#{service_id}"
  else
    raise "passed a bad volume_id: #{service_id || '(none)'}" # lazy
  end
  headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  execute(method: :delete, url: url, headers: headers, payload: payload.to_json)
end

#destroy_volume(id, volume_id = nil, params = {}, payload = {}) ⇒ Object Also known as: delete_volume

this supports multiple ids



152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/morpheus/api/clusters_interface.rb', line 152

def destroy_volume(id, volume_id=nil, params={}, payload={})
  url = nil
  if volume_id.is_a?(Array)
    url = "#{base_path}/#{id}/volumes"
    params['volumeId'] = volume_id
  elsif volume_id.is_a?(Numeric) || volume_id.is_a?(String)
    url = "#{base_path}/#{id}/volumes/#{volume_id}"
  else
    raise "passed a bad volume_id: #{volume_id || '(none)'}" # lazy
  end
  headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  execute(method: :delete, url: url, headers: headers, payload: payload.to_json)
end

#destroy_worker(id, worker_id, params = {}) ⇒ Object



94
95
96
97
98
# File 'lib/morpheus/api/clusters_interface.rb', line 94

def destroy_worker(id, worker_id, params={})
  url = "#{base_path}/#{id}/servers/#{worker_id}"
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  execute(method: :delete, url: url, headers: headers)
end

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



112
113
114
115
116
# File 'lib/morpheus/api/clusters_interface.rb', line 112

def do_cluster_upgrade(id, params={})
  url = "#{base_path}/#{id}/upgrade-cluster"
  headers = { params: params, authorization: "Bearer #{@access_token}", 'Content-Type' => 'application/json'  }
  execute(method: :post, url: url, headers: headers)
end

#get(params = {}) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/morpheus/api/clusters_interface.rb', line 15

def get(params={})
  url = base_path
  headers = { params: {}, authorization: "Bearer #{@access_token}" }

  if params.is_a?(Hash)
    headers[:params].merge!(params)
  elsif params.is_a?(Numeric)
    url = "#{base_path}/#{params}"
  elsif params.is_a?(String)
    headers[:params]['name'] = params
  end
  execute(method: :get, url: url, headers: headers)
end

#get_container_group(cluster_id, resource_type, id, params = {}) ⇒ Object



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

def get_container_group(cluster_id, resource_type, id, params={})
  url = "#{base_path}/#{cluster_id}/#{resource_type}s/#{id}"
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  execute(method: :get, url: url, headers: headers)
end

#get_datastore(id, datastore_id, params = {}) ⇒ Object



262
263
264
265
266
# File 'lib/morpheus/api/clusters_interface.rb', line 262

def get_datastore(id, datastore_id, params={})
  url = "#{base_path}/#{id}/datastores/#{datastore_id}"
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  execute(method: :get, url: url, headers: headers)
end

#get_namespace(id, namespace_id, params = {}) ⇒ Object



174
175
176
177
178
# File 'lib/morpheus/api/clusters_interface.rb', line 174

def get_namespace(id, namespace_id, params={})
  url = "#{base_path}/#{id}/namespaces/#{namespace_id}"
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  execute(method: :get, url: url, headers: headers)
end

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



106
107
108
109
110
# File 'lib/morpheus/api/clusters_interface.rb', line 106

def get_upgrade_versions(id, params={})
  url = "#{base_path}/#{id}/upgrade-cluster"
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  execute(method: :get, url: url, headers: headers)
end

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



306
307
308
309
310
311
# File 'lib/morpheus/api/clusters_interface.rb', line 306

def history(id, params={})
  url = "#{@base_url}/api/clusters/#{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



313
314
315
316
317
318
# File 'lib/morpheus/api/clusters_interface.rb', line 313

def history_details(id, process_id, params={})
  url = "#{@base_url}/api/clusters/#{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



320
321
322
323
324
325
# File 'lib/morpheus/api/clusters_interface.rb', line 320

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

#list(params = {}) ⇒ Object



9
10
11
12
13
# File 'lib/morpheus/api/clusters_interface.rb', line 9

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

#list_container_groups(id, resource_type, params = {}) ⇒ Object



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

def list_container_groups(id, resource_type, params={})
  url = "#{base_path}/#{id}/#{resource_type}s"
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  execute(method: :get, url: url, headers: headers)
end

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



200
201
202
203
204
# File 'lib/morpheus/api/clusters_interface.rb', line 200

def list_containers(id, params={})
  url = "#{base_path}/#{id}/containers"
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  execute(method: :get, url: url, headers: headers)
end

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



256
257
258
259
260
# File 'lib/morpheus/api/clusters_interface.rb', line 256

def list_datastores(id, params={})
  url = "#{base_path}/#{id}/datastores"
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  execute(method: :get, url: url, headers: headers)
end

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



62
63
64
65
66
# File 'lib/morpheus/api/clusters_interface.rb', line 62

def list_jobs(id, params={})
  url = "#{base_path}/#{id}/jobs"
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  execute(method: :get, url: url, headers: headers)
end

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



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

def list_masters(id, params={})
  url = "#{base_path}/#{id}/masters"
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  execute(method: :get, url: url, headers: headers)
end

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



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

def list_namespaces(id, params={})
  url = "#{base_path}/#{id}/namespaces"
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  execute(method: :get, url: url, headers: headers)
end

#list_resources(id, resources, params = {}) ⇒ Object



342
343
344
345
346
# File 'lib/morpheus/api/clusters_interface.rb', line 342

def list_resources(id, resources, params={})
  url = "#{base_path}/#{id}/#{resources}"
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  execute(method: :get, url: url, headers: headers)
end

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



118
119
120
121
122
# File 'lib/morpheus/api/clusters_interface.rb', line 118

def list_services(id, params={})
  url = "#{base_path}/#{id}/services"
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  execute(method: :get, url: url, headers: headers)
end

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



145
146
147
148
149
# File 'lib/morpheus/api/clusters_interface.rb', line 145

def list_volumes(id, params={})
  url = "#{base_path}/#{id}/volumes"
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  execute(method: :get, url: url, headers: headers)
end

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



88
89
90
91
92
# File 'lib/morpheus/api/clusters_interface.rb', line 88

def list_workers(id, params={})
  url = "#{base_path}/#{id}/workers"
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  execute(method: :get, url: url, headers: headers)
end

#refresh(id) ⇒ Object



335
336
337
338
339
340
# File 'lib/morpheus/api/clusters_interface.rb', line 335

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

#restart_container(id, container_id, params = {}) ⇒ Object



206
207
208
209
210
# File 'lib/morpheus/api/clusters_interface.rb', line 206

def restart_container(id, container_id, params={})
  url = "#{base_path}/#{id}/containers/#{container_id}/restart"
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  execute(method: :put, url: url, headers: headers)
end

#restart_container_group(id, container_group_id, resource_type, params = {}) ⇒ Object



237
238
239
240
241
# File 'lib/morpheus/api/clusters_interface.rb', line 237

def restart_container_group(id, container_group_id, resource_type, params={})
  url = "#{base_path}/#{id}/#{resource_type}s/#{container_group_id}/restart"
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  execute(method: :put, url: url, headers: headers)
end

#update(id, payload) ⇒ Object



35
36
37
38
39
# File 'lib/morpheus/api/clusters_interface.rb', line 35

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

#update_datastore(id, datastore_id, payload) ⇒ Object



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

def update_datastore(id, datastore_id, payload)
  url = "#{base_path}/#{id}/datastores/#{datastore_id}"
  headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  execute(method: :put, url: url, headers: headers, payload: payload.to_json)
end

#update_namespace(id, namespace_id, payload) ⇒ Object



186
187
188
189
190
# File 'lib/morpheus/api/clusters_interface.rb', line 186

def update_namespace(id, namespace_id, payload)
  url = "#{base_path}/#{id}/namespaces/#{namespace_id}"
  headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  execute(method: :put, url: url, headers: headers, payload: payload.to_json)
end

#update_permissions(id, payload) ⇒ Object



56
57
58
59
60
# File 'lib/morpheus/api/clusters_interface.rb', line 56

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

#update_wiki(id, payload) ⇒ Object



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

def update_wiki(id, payload)
  url = "#{@base_url}/api/clusters/#{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

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



100
101
102
103
104
# File 'lib/morpheus/api/clusters_interface.rb', line 100

def update_worker_count(id, params={})
  url = "#{base_path}/#{id}/worker-count"
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  execute(method: :put, url: url, headers: headers)
end

#wiki(id, params) ⇒ Object



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

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