Class: AWS::SNS::SubscriptionCollection

Inherits:
Object
  • Object
show all
Includes:
Core::Model, Enumerable
Defined in:
lib/aws/sns/subscription_collection.rb

Overview

Represents the collection of all subscriptions for the AWS account. For example:

# get the ARNs of all SQS queues with subscriptions to topics
# owned by this account
topic.subscriptions.
  select { |s| s.protocol == :sqs }.
  collect(&:endpoint)

Direct Known Subclasses

TopicSubscriptionCollection

Instance Attribute Summary

Attributes included from Core::Model

#config

Instance Method Summary collapse

Methods included from Core::Model

#client, #config_prefix, #initialize, #inspect

Instance Method Details

#[](arn) ⇒ Subscription

Retrieves a subscription object by ARN. This method does not make any requests to the service.

Parameters:

  • arn (String)

    The ARN of the subscription to retrieve.

Returns:



61
62
63
# File 'lib/aws/sns/subscription_collection.rb', line 61

def [] arn
  Subscription.new(arn, :config => config)
end

#each {|subscription| ... } ⇒ nil

Yield each subscription belonging to this account.

Yield Parameters:

  • subscription (Subscription)

    Each of the subscriptions in the account.

Returns:

  • (nil)


35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/aws/sns/subscription_collection.rb', line 35

def each
  next_token = nil
  begin
    opts = request_opts
    opts[:next_token] = next_token if next_token
    resp = client.send(list_request, opts)
    resp.subscriptions.each do |sub|
      subscription = Subscription.new(sub.subscription_arn,
        :endpoint => sub.endpoint,
        :protocol => sub.protocol.tr('-','_').to_sym,
        :owner_id => sub.owner,
        :topic_arn => sub.topic_arn,
        :config => config
      )
      yield(subscription)
    end
    next_token = resp.data[:next_token]
  end until next_token.nil?
  nil
end