Class: DotBlockAPI::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/dotblock_api/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(username, password) ⇒ Client

Returns a new instance of Client.



7
8
9
10
# File 'lib/dotblock_api/client.rb', line 7

def initialize(username, password)
  @username = username
  @password = password
end

Instance Method Details

#boot_server(id) ⇒ Object



37
38
39
# File 'lib/dotblock_api/client.rb', line 37

def boot_server(id)
  send_request("/v1/servers/#{id}.json", 'PUT', { "action" => "boot" })
end

#client_infoObject



16
17
18
# File 'lib/dotblock_api/client.rb', line 16

def client_info
  send_request("/v1/account.json")
end

#pingObject



12
13
14
# File 'lib/dotblock_api/client.rb', line 12

def ping
  send_request("/v1/ping")
end

#reboot_server(id) ⇒ Object



33
34
35
# File 'lib/dotblock_api/client.rb', line 33

def reboot_server(id)
  send_request("/v1/servers/#{id}.json", 'PUT', { "action" => "reboot" })
end

#resume_server(id) ⇒ Object



45
46
47
# File 'lib/dotblock_api/client.rb', line 45

def resume_server(id)
  send_request("/v1/servers/#{id}.json", 'PUT', { "action" => "resume" })
end

#server_info(id) ⇒ Object



29
30
31
# File 'lib/dotblock_api/client.rb', line 29

def server_info(id)
  send_request("/v1/servers/#{id}.json")
end

#server_listObject



25
26
27
# File 'lib/dotblock_api/client.rb', line 25

def server_list
  send_request("/v1/servers.json")
end

#shutdown_server(id) ⇒ Object



49
50
51
# File 'lib/dotblock_api/client.rb', line 49

def shutdown_server(id)
  send_request("/v1/servers/#{id}.json", 'PUT', { "action" => "shutdown" })
end

#suspend_server(id) ⇒ Object



41
42
43
# File 'lib/dotblock_api/client.rb', line 41

def suspend_server(id)
  send_request("/v1/servers/#{id}.json", 'PUT', { "action" => "suspend" })
end

#update_client_info(params = {}) ⇒ Object



20
21
22
23
# File 'lib/dotblock_api/client.rb', line 20

def update_client_info(params = {})
  info = Hash[params.map { |key, val| ["info[#{key}]", val] }]
  send_request("/v1/account.json", 'PUT', info)
end