File: describe_notification_configurations.rb

package info (click to toggle)
ruby-fog-aws 3.3.0-5
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 7,816 kB
  • sloc: ruby: 68,587; makefile: 6
file content (73 lines) | stat: -rw-r--r-- 3,105 bytes parent folder | download | duplicates (5)
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
61
62
63
64
65
66
67
68
69
70
71
72
73
module Fog
  module AWS
    class AutoScaling
      class Real
        require 'fog/aws/parsers/auto_scaling/describe_notification_configurations'

        # Returns a list of notification actions associated with Auto Scaling
        # groups for specified events.
        #
        # ==== Parameters
        # * options<~Hash>:
        #   * 'AutoScalingGroupNames'<~String> - The name of the Auto Scaling
        #     group.
        #   * 'MaxRecords'<~Integer> - The maximum number of records to return.
        #   * 'NextToken'<~String> - A string that is used to mark the start of
        #     the next batch of returned results for pagination.
        #
        # ==== Returns
        # * response<~Excon::Response>:
        #   * body<~Hash>:
        #     * 'ResponseMetadata'<~Hash>:
        #       * 'RequestId'<~String> - Id of request
        #     * 'DescribeNotificationConfigurationsResult'<~Hash>:
        #       * 'NotificationConfigurations'<~Array>:
        #         * notificationConfiguration<~Hash>:
        #           * 'AutoScalingGroupName'<~String> - Specifies the Auto
        #             Scaling group name.
        #           * 'NotificationType'<~String> - The types of events for an
        #             action to start.
        #         * 'TopicARN'<~String> - The Amazon Resource Name (ARN) of the
        #           Amazon Simple Notification Service (SNS) topic.
        #
        # ==== See Also
        # http://docs.amazonwebservices.com/AutoScaling/latest/APIReference/API_DescribeNotificationConfigurations.html
        #
        def describe_notification_configurations(options = {})
          if auto_scaling_group_names = options.delete('AutoScalingGroupNames')
            options.merge!(AWS.indexed_param('AutoScalingGroupNames.member.%d', [*auto_scaling_group_names]))
          end
          request({
            'Action' => 'DescribeNotificationConfigurations',
            :parser  => Fog::Parsers::AWS::AutoScaling::DescribeNotificationConfigurations.new
          }.merge!(options))
        end
      end

      class Mock
        def describe_notification_configurations(options = {})
          results = { 'NotificationConfigurations' => [] }
          (options['AutoScalingGroupNames']||self.data[:notification_configurations].keys).each do |asg_name|
            (self.data[:notification_configurations][asg_name]||{}).each do |topic_arn, notification_types|
              notification_types.each do |notification_type|
                results['NotificationConfigurations'] << {
                  'AutoScalingGroupName' => asg_name,
                  'NotificationType'     => notification_type,
                  'TopicARN'             => topic_arn,
                }
              end
            end
          end

          response = Excon::Response.new
          response.status = 200
          response.body = {
            'DescribeNotificationConfigurationsResult' => results,
            'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id }
          }
          response
        end
      end
    end
  end
end