1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

cleanup leftover files (now in fog-aws)

This commit is contained in:
geemus 2015-01-12 09:57:42 -06:00
parent d4ef0983b4
commit 3b0a132ac7
3 changed files with 0 additions and 204 deletions

View file

@ -1,61 +0,0 @@
module Fog
module Parsers
module Storage
module AWS
class GetBucketNotification < Fog::Parsers::Base
def reset
@func = {}
@queue = {}
@topic = {}
@response = {
'Topics' => [],
'Queues' => [],
'CloudFunctions' => []
}
end
def start_element(name, attrs = [])
super
case name
when 'TopicConfiguration'
@configuration = 'topic'
when 'QueueConfiguration'
@configuration = 'queue'
when 'CloudFunctionConfiguration'
@configuration = 'func'
end
end
def end_element(name)
case @configuration
when 'topic'
case name
when 'Id', 'Event', 'Topic'
@topic[name] = value
when 'TopicConfiguration'
@response['Topics'] << @topic
@topic = {}
end
when 'queue'
case name
when 'Id', 'Queue', 'Event'
@queue[name] = value
when 'QueueConfiguration'
@response['Queues'] << @queue
@queue = {}
end
when 'func'
case name
when 'Id', 'CloudFunction', 'InvocationRule', 'Event'
@func[name] = value
when 'CloudFunctionConfiguration'
@response['CloudFunctions'] << @func
@func = {}
end
end
end
end
end
end
end
end

View file

@ -1,60 +0,0 @@
module Fog
module Storage
class AWS
class Real
require 'fog/aws/parsers/storage/get_bucket_notification'
# Get bucket notification configuration
#
# @param bucket_name [String] name of bucket to get notification configuration for
#
# @return [Excon::Response] response:
# * body [Hash]:
# * Topics [Array] SNS topic configurations for the notification
# * ID [String] Unique identifier for the configuration
# * Topic [String] Amazon SNS topic ARN to which Amazon S3 will publish a message when it detects events of specified type
# * Event [String] Bucket event for which to send notifications
# * Queues [Array] SQS queue configurations for the notification
# * ID [String] Unique identifier for the configuration
# * Queue [String] Amazon SQS queue ARN to which Amazon S3 will publish a message when it detects events of specified type
# * Event [String] Bucket event for which to send notifications
# * CloudFunctions [Array] AWS Lambda notification configurations
# * ID [String] Unique identifier for the configuration
# * CloudFunction [String] Lambda cloud function ARN that Amazon S3 can invoke when it detects events of the specified type
# * InvocationRole [String] IAM role ARN that Amazon S3 can assume to invoke the specified cloud function on your behalf
# * Event [String] Bucket event for which to send notifications
#
# @see http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketGETnotification.html
def get_bucket_notification(bucket_name)
unless bucket_name
raise ArgumentError.new('bucket_name is required')
end
request({
:expects => 200,
:headers => {},
:bucket_name => bucket_name,
:idempotent => true,
:method => 'GET',
:parser => Fog::Parsers::Storage::AWS::GetBucketNotification.new,
:query => {'notification' => nil}
})
end
end
class Mock
def get_bucket_notification(bucket_name)
response = Excon::Response.new
if self.data[:buckets][bucket_name] && self.data[:bucket_notifications][bucket_name]
response.status = 200
response.body = self.data[:bucket_notifications][bucket_name]
else
response.status = 404
raise(Excon::Errors.status_error({:expects => 200}, response))
end
response
end
end
end
end
end

View file

@ -1,83 +0,0 @@
module Fog
module Storage
class AWS
class Real
# Change notification configuration for an S3 bucket
#
# @param bucket_name [String] name of bucket to set notification configuration for
# * notications [Hash]:
# * Topics [Array] SNS topic configurations for the notification
# * ID [String] Unique identifier for the configuration
# * Topic [String] Amazon SNS topic ARN to which Amazon S3 will publish a message when it detects events of specified type
# * Event [String] Bucket event for which to send notifications
# * Queues [Array] SQS queue configurations for the notification
# * ID [String] Unique identifier for the configuration
# * Queue [String] Amazon SQS queue ARN to which Amazon S3 will publish a message when it detects events of specified type
# * Event [String] Bucket event for which to send notifications
# * CloudFunctions [Array] AWS Lambda notification configurations
# * ID [String] Unique identifier for the configuration
# * CloudFunction [String] Lambda cloud function ARN that Amazon S3 can invoke when it detects events of the specified type
# * InvocationRole [String] IAM role ARN that Amazon S3 can assume to invoke the specified cloud function on your behalf
# * Event [String] Bucket event for which to send notifications
#
# @see http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketPUTnotification.html
#
def put_bucket_notification(bucket_name, notification)
builder = Nokogiri::XML::Builder.new do
NotificationConfiguration do
notification.fetch('Topics', []).each do |topic|
TopicConfiguration do
Id topic['Id']
Topic topic['Topic']
Event topic['Event']
end
end
notification.fetch('Queues', []).each do |queue|
QueueConfiguration do
Id queue['Id']
Queue queue['Queue']
Event topic['Event']
end
end
notification.fetch('CloudFunctions', []).each do |func|
CloudFunctionConfiguration do
Id func['Id']
CloudFunction func['CloudFunction']
InvocationRole func['InvocationRole']
Event func['Event']
end
end
end
end
body = builder.to_xml
body.gsub!(/<([^<>]+)\/>/, '<\1></\1>')
request({
:body => body,
:expects => 200,
:headers => {'Content-MD5' => Base64.encode64(Digest::MD5.digest(body)).chomp!,
'Content-Type' => 'application/xml'},
:bucket_name => bucket_name,
:method => 'PUT',
:query => {'notification' => nil}
})
end
end
class Mock
def put_bucket_notification(bucket_name, notification)
response = Excon::Response.new
if self.data[:buckets][bucket_name]
self.data[:bucket_notifications][bucket_name] = notification
response.status = 204
else
response.status = 404
raise(Excon::Errors.status_error({:expects => 204}, response))
end
response
end
end
end
end
end