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/aws/requests/ec2/delete_volume.rb
2009-08-15 15:19:07 -07:00

56 lines
1.3 KiB
Ruby

unless Fog.mocking?
module Fog
module AWS
class EC2
# Delete an EBS volume
#
# ==== Parameters
# * volume_id<~String> - Id of volume to delete.
#
# ==== Returns
# * response<~Fog::AWS::Response>:
# * body<~Hash>:
# * 'requestId'<~String> - Id of request
# * 'return'<~Boolean> - success?
def delete_volume(volume_id)
request({
'Action' => 'DeleteVolume',
'VolumeId' => volume_id
}, Fog::Parsers::AWS::EC2::Basic.new)
end
end
end
end
else
module Fog
module AWS
class EC2
def delete_volume(volume_id)
response = Fog::Response.new
initial_volumes_count = @data['volumeSet'].length
volume = @data['volumeSet'].select {|volume| volume['volumeId'] == volume_id}.first
if volume
@data[:deleted_at][volume['volumeId']] = Time.now
volume['status'] = 'deleting'
response.status = 200
response.body = {
'requestId' => Fog::AWS::Mock.request_id,
'return' => true
}
else
response.status = 400
end
response
end
end
end
end
end