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/sqs/delete_message.rb

61 lines
1.7 KiB
Ruby
Raw Normal View History

module Fog
module AWS
class SQS
class Real
2011-07-19 16:10:26 -04:00
require 'fog/aws/parsers/sqs/basic'
2011-07-19 16:10:26 -04:00
# Delete a message from a queue
#
# ==== Parameters
# * queue_url<~String> - Url of queue to delete message from
# * receipt_handle<~String> - Token from previous recieve message
#
# ==== See Also
# http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/APIReference/Query_QueryDeleteMessage.html
#
def delete_message(queue_url, receipt_handle)
request({
'Action' => 'DeleteMessage',
'ReceiptHandle' => receipt_handle,
2011-07-19 16:10:26 -04:00
:parser => Fog::Parsers::AWS::SQS::Basic.new,
:path => path_from_queue_url(queue_url),
})
end
end
2011-09-18 16:00:58 -04:00
class Mock
2011-09-18 16:00:58 -04:00
def delete_message(queue_url, receipt_handle)
Excon::Response.new.tap do |response|
if (queue = data[:queues][queue_url])
message_id, _ = queue[:receipt_handles].find { |msg_id, receipts|
receipts.keys.include?(receipt_handle)
}
if message_id
queue[:receipt_handles].delete(message_id)
queue[:messages].delete(message_id)
queue['Attributes']['LastModifiedTimestamp'] = Time.now
end
response.body = {
'ResponseMetadata' => {
'RequestId' => Fog::AWS::Mock.request_id
}
}
response.status = 200
else
response.status = 404
raise(Excon::Errors.status_error({:expects => 200}, response))
end
end
end
end
end
end
end