File: get_bucket_notification.rb

package info (click to toggle)
ruby-fog-aws 3.18.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,140 kB
  • sloc: ruby: 73,328; javascript: 14; makefile: 9; sh: 4
file content (60 lines) | stat: -rw-r--r-- 2,707 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
module Fog
  module AWS
    class Storage
      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::AWS::Storage::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