class Fog::Compute::CloudAtCost::Real
Public Class Methods
new(options = {})
click to toggle source
# File lib/fog/cloudatcost/compute.rb, line 45 def initialize(options = {}) @api_key = options[:api_key] @email = options[:email] persistent = false @connection = Fog::Core::Connection.new 'https://panel.cloudatcost.com', persistent, options end
Public Instance Methods
console(id)
click to toggle source
# File lib/fog/cloudatcost/requests/console.rb, line 7 def console(id) body = { sid: id.to_s } request( expects: [200], method: 'POST', path: 'api/v1/console.php', body: body ) end
create_server(cpu, ram, storage, template_id)
click to toggle source
# File lib/fog/cloudatcost/requests/create_server.rb, line 7 def create_server(cpu, ram, storage, template_id) body = { cpu: cpu.to_s, ram: ram.to_s, storage: storage.to_s, os: template_id.to_s } request( expects: [200], method: 'POST', path: 'api/v1/cloudpro/build.php', body: body ) end
delete_server(id)
click to toggle source
# File lib/fog/cloudatcost/requests/delete_server.rb, line 7 def delete_server(id) body = { sid: id.to_s } request( expects: [200], method: 'POST', path: 'api/v1/cloudpro/delete.php', body: body ) end
list_servers()
click to toggle source
# File lib/fog/cloudatcost/requests/list_servers.rb, line 7 def list_servers request( expects: [200], method: 'GET', path: '/api/v1/listservers.php' ) end
list_tasks()
click to toggle source
# File lib/fog/cloudatcost/requests/list_tasks.rb, line 7 def list_tasks request( expects: [200], method: 'GET', path: '/api/v1/listtasks.php' ) end
list_templates()
click to toggle source
# File lib/fog/cloudatcost/requests/list_templates.rb, line 7 def list_templates request( expects: [200], method: 'GET', path: '/api/v1/listtemplates.php' ) end
power_off(id)
click to toggle source
# File lib/fog/cloudatcost/requests/power_off.rb, line 7 def power_off(id) body = { sid: id.to_s, action: 'poweroff' } request( expects: [200], method: 'POST', path: 'api/v1/powerop.php', body: body ) end
power_on(id)
click to toggle source
# File lib/fog/cloudatcost/requests/power_on.rb, line 7 def power_on(id) body = { sid: id.to_s, action: 'poweron' } request( expects: [200], method: 'POST', path: 'api/v1/powerop.php', body: body ) end
rename_server(id, name)
click to toggle source
# File lib/fog/cloudatcost/requests/rename_server.rb, line 7 def rename_server(id, name) body = { sid: id.to_s, name: name.to_s } request( expects: [200], method: 'POST', path: 'api/v1/renameserver.php', body: body ) end
request(params)
click to toggle source
# File lib/fog/cloudatcost/compute.rb, line 52 def request(params) params[:headers] ||= { 'Content-Type' => 'application/x-www-form-urlencoded' } params[:query] ||= {} required_params = { key: @api_key.to_s, login: @email.to_s } begin if params[:method] == 'POST' params_body = required_params.merge(params[:body]) params[:body] = params_body.reduce('') { |acc, (x, y)| "#{acc}&#{x}=#{y}" } else params[:query] = required_params.merge(params[:query]) end response = @connection.request(params) rescue Excon::Errors::HTTPStatusError => error raise case error when Excon::Errors::NotFound Fog::Compute::Bluebox::NotFound.slurp(error) else error end end response.body = Fog::JSON.decode(response.body) unless response.body.empty? response end
reset(id)
click to toggle source
# File lib/fog/cloudatcost/requests/reset.rb, line 7 def reset(id) body = { sid: id.to_s, action: 'reset' } request( expects: [200], method: 'POST', path: 'api/v1/powerop.php', body: body ) end
reverse_dns(id, host_name)
click to toggle source
# File lib/fog/cloudatcost/requests/reverse_dns.rb, line 7 def reverse_dns(id, host_name) body = { sid: id.to_s, hostname: host_name.to_s } request( expects: [200], method: 'POST', path: 'api/v1/rdns.php', body: body ) end
run_mode(id, action)
click to toggle source
# File lib/fog/cloudatcost/requests/run_mode.rb, line 7 def run_mode(id, action) body = { sid: id.to_s, mode: action.to_s } request( expects: [200], method: 'POST', path: 'api/v1/runmode.php', body: body ) end