class Morpheus::ClustersInterface

Public Instance Methods

add_server(id, payload) click to toggle source
# 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={}) click to toggle source
# 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={}) click to toggle source
# 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_path() click to toggle source
# File lib/morpheus/api/clusters_interface.rb, line 5
def base_path
  "/api/clusters"
end
cluster_types(params={}) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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
delete(id, params={})
Alias for: destroy
delete_namespace(id, namespace_id, params={})
Alias for: destroy_namespace
delete_volume(id, volume_id=nil, params={}, payload={})
Alias for: destroy_volume
destroy(id, params={}) click to toggle source
# 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
Also aliased as: delete
destroy_container(id, container_id, params={}) click to toggle source
# 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={}) click to toggle source
# 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={}) click to toggle source
# 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={}) click to toggle source
# 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={}) click to toggle source
# 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
Also aliased as: delete_namespace
destroy_service(id, service_id=nil, params={}, payload={}) click to toggle source

this supports multiple ids

# 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={}) click to toggle source

this supports multiple ids

# 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
Also aliased as: delete_volume
destroy_worker(id, worker_id, params={}) click to toggle source
# 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={}) click to toggle source
# 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={}) click to toggle source
# 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={}) click to toggle source
# 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={}) click to toggle source
# 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={}) click to toggle source
# 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={}) click to toggle source
# 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={}) click to toggle source
# 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={}) click to toggle source
# 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={}) click to toggle source
# 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={}) click to toggle source
# 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={}) click to toggle source
# 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={}) click to toggle source
# 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={}) click to toggle source
# 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={}) click to toggle source
# 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={}) click to toggle source
# 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={}) click to toggle source
# 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={}) click to toggle source
# 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={}) click to toggle source
# 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={}) click to toggle source
# 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={}) click to toggle source
# 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) click to toggle source
# 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={}) click to toggle source
# 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={}) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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={}) click to toggle source
# 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) click to toggle source
# 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