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)



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

def arn
  @arn
end

#endpointString (readonly)

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



47
48
49
# File 'lib/aws/sns/subscription.rb', line 47

def endpoint
  @endpoint
end

#owner_idString (readonly)



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

def owner_id
  @owner_id
end

#protocolString (readonly)



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

def protocol
  @protocol
end

#topicTopic (readonly)



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

def topic
  @topic
end

Instance Method Details

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



92
93
94
# File 'lib/aws/sns/subscription.rb', line 92

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.



74
75
76
77
78
79
80
81
82
83
# File 'lib/aws/sns/subscription.rb', line 74

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

#unsubscribenil

Deletes this subscription.



63
64
65
66
# File 'lib/aws/sns/subscription.rb', line 63

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