Class: AWS::SNS::Subscription

Inherits:
Object
  • Object
show all
Defined in:
lib/aws/sns/subscription.rb

Overview

Represents a subscription of a single endpoint to an SNS topic. To create a subscription, use the Topic#subscribe method. Depending on the endpoint type, you may also need to use Topic#confirm_subscription.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#arnString (readonly)



36
37
38
# File 'lib/aws/sns/subscription.rb', line 36

def arn
  @arn
end

#endpointString (readonly)

URL, an e-mail address, or a queue ARN.



43
44
45
# File 'lib/aws/sns/subscription.rb', line 43

def endpoint
  @endpoint
end

#owner_idString (readonly)



55
56
57
# File 'lib/aws/sns/subscription.rb', line 55

def owner_id
  @owner_id
end

#protocolString (readonly)



52
53
54
# File 'lib/aws/sns/subscription.rb', line 52

def protocol
  @protocol
end

#topicTopic (readonly)



39
40
41
# File 'lib/aws/sns/subscription.rb', line 39

def topic
  @topic
end

Instance Method Details

#==(other) ⇒ Boolean Also known as: eql?



88
89
90
# File 'lib/aws/sns/subscription.rb', line 88

def ==(other)
  other.kind_of?(Subscription) and other.arn == arn
end

#exists?Boolean

Note:

This method requests the entire list of subscriptions for the topic (if known) or the account (if the topic is not known). It can be expensive if the number of subscriptions is high.

Returns true if the subscription exists.



70
71
72
73
74
75
76
77
78
79
# File 'lib/aws/sns/subscription.rb', line 70

def exists?
  collection =
    if topic
      TopicSubscriptionCollection.new(topic,
                                      :config => config)
    else
      SubscriptionCollection.new(:config => config)
    end
  collection.include?(self)
end

#unsubscribenil

Deletes this subscription.



59
60
61
62
# File 'lib/aws/sns/subscription.rb', line 59

def unsubscribe
  client.unsubscribe(:subscription_arn => arn)
  nil
end