1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/digitalocean/requests/compute_v2/reboot_server.rb
bryanl b1dc264a56 support DigitalOcean v2 compute API
This commit adds support for the DigitalOcean v2 API. It implements all the compute actions.
2015-09-23 14:30:00 -04:00

44 lines
1.2 KiB
Ruby

module Fog
module Compute
class DigitalOceanV2
class Real
def reboot_server(id)
body = { :type => "reboot" }
encoded_body = Fog::JSON.encode(body)
request(
:expects => [201],
:headers => {
'Content-Type' => "application/json; charset=UTF-8",
},
:method => 'POST',
:path => "v2/droplets/#{id}/actions",
:body => encoded_body,
)
end
end
class Mock
def reboot_server(id)
response = Excon::Response.new
response.status = 201
response.body = {
'action' => {
'id' => Fog::Mock.random_numbers(1).to_i,
'status' => "in-progress",
'type' => "reboot",
'started_at' => "2014-11-14T16:31:00Z",
'completed_at' => null,
'resource_id' => id,
'resource_type' => "droplet",
'region' => "nyc3",
'region_slug' => "nyc3"
}
}
response
end
end
end
end
end