File: create_topic.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 (48 lines) | stat: -rw-r--r-- 2,056 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
module Fog
  module AWS
    class SNS
      class Real
        require 'fog/aws/parsers/sns/create_topic'

        # Create a topic
        #
        # ==== Parameters
        # * name<~String> - Name of topic to create
        #
        # ==== See Also
        # http://docs.amazonwebservices.com/sns/latest/api/API_CreateTopic.html
        #

        def create_topic(name)
          request({
            'Action'  => 'CreateTopic',
            'Name'    => name,
            :parser   => Fog::Parsers::AWS::SNS::CreateTopic.new
          })
        end
      end

      class Mock
        def create_topic(name)
          response = Excon::Response.new

          topic_arn = Fog::AWS::Mock.arn(@module, @account_id, name, @region)

          self.data[:topics][topic_arn] = {
            "Owner"                   => @account_id,
            "SubscriptionsPending"    => 0,
            "SubscriptionsConfirmed"  => 0,
            "SubscriptionsDeleted"    => 0,
            "DisplayName"             => name,
            "TopicArn"                => topic_arn,
            "EffectiveDeliveryPolicy" => %Q|{"http":{"defaultHealthyRetryPolicy":{"minDelayTarget":20,"maxDelayTarget":20,"numRetries":3,"numMaxDelayRetries":0,"numNoDelayRetries":0,"numMinDelayRetries":0,"backoffFunction":"linear"},"disableSubscriptionOverrides":false}}|,
            "Policy"                  => %Q|{"Version":"2008-10-17","Id":"__default_policy_ID","Statement":[{"Sid":"__default_statement_ID","Effect":"Allow","Principal":{"AWS":"*"},"Action":["SNS:Publish","SNS:RemovePermission","SNS:SetTopicAttributes","SNS:DeleteTopic","SNS:ListSubscriptionsByTopic","SNS:GetTopicAttributes","SNS:Receive","SNS:AddPermission","SNS:Subscribe"],"Resource":"arn:aws:sns:us-east-1:990279267269:Smithy","Condition":{"StringEquals":{"AWS:SourceOwner":"990279267269"}}}]}|
          }
          self.data[:permissions][topic_arn] = {}
          response.body = {"TopicArn" => topic_arn, "RequestId" => Fog::AWS::Mock.request_id}
          response
        end
      end
    end
  end
end