Class: AWS::SNS::Subscription
- Inherits:
-
Object
- Object
- AWS::SNS::Subscription
- Includes:
- Core::Model, HasDeliveryPolicy
- 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
-
#arn ⇒ String
readonly
The ARN of the subscription.
-
#endpoint ⇒ String
readonly
URL, an e-mail address, or a queue ARN.
-
#protocol ⇒ String
readonly
The protocol.
Attributes included from Core::Model
Instance Method Summary collapse
-
#confirmation_authenticated? ⇒ Boolean
Returns true if the subscription confirmation request was authenticated.
-
#delivery_policy_json ⇒ nil, String
You can get the parsed JSON hash from HasDeliveryPolicy#delivery_policy.
-
#effective_delivery_policy_json ⇒ nil, String
You can get the parsed JSON hash from HasDeliveryPolicy#effective_delivery_policy.
-
#eql?(other) ⇒ Boolean
(also: #==)
Returns true if the subscriptions have the same resource ARN.
-
#exists? ⇒ Boolean
Returns true if the subscription exists.
-
#initialize(arn, opts = {}) ⇒ Subscription
constructor
A new instance of Subscription.
- #inspect ⇒ Object
-
#owner_id ⇒ String
The AWS account ID of the subscription owner.
- #topic ⇒ Topic
- #topic_arn ⇒ String
-
#unsubscribe ⇒ nil
Deletes this subscription.
Methods included from HasDeliveryPolicy
#delivery_policy, #delivery_policy=, #effective_delivery_policy
Methods included from Core::Model
Constructor Details
#initialize(arn, opts = {}) ⇒ Subscription
27 28 29 30 31 32 33 34 |
# File 'lib/aws/sns/subscription.rb', line 27 def initialize(arn, opts = {}) @arn = arn @topic_arn = opts[:topic_arn] @endpoint = opts[:endpoint] @protocol = opts[:protocol] @owner_id = opts[:owner_id] super end |
Instance Attribute Details
#arn ⇒ String (readonly)
37 38 39 |
# File 'lib/aws/sns/subscription.rb', line 37 def arn @arn end |
#endpoint ⇒ String (readonly)
URL, an e-mail address, or a queue ARN.
41 42 43 |
# File 'lib/aws/sns/subscription.rb', line 41 def endpoint @endpoint end |
#protocol ⇒ String (readonly)
50 51 52 |
# File 'lib/aws/sns/subscription.rb', line 50 def protocol @protocol end |
Instance Method Details
#confirmation_authenticated? ⇒ Boolean
76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/aws/sns/subscription.rb', line 76 def confirmation_authenticated? return true if @authenticated if authenticated = get_attributes['ConfirmationWasAuthenticated'] @authenticated = true else false end end |
#delivery_policy_json ⇒ nil, String
You can get the parsed JSON hash from HasDeliveryPolicy#delivery_policy.
90 91 92 |
# File 'lib/aws/sns/subscription.rb', line 90 def delivery_policy_json get_attributes['DeliveryPolicy'] end |
#effective_delivery_policy_json ⇒ nil, String
You can get the parsed JSON hash from HasDeliveryPolicy#effective_delivery_policy.
96 97 98 |
# File 'lib/aws/sns/subscription.rb', line 96 def effective_delivery_policy_json get_attributes['EffectiveDeliveryPolicy'] end |
#eql?(other) ⇒ Boolean Also known as: ==
122 123 124 |
# File 'lib/aws/sns/subscription.rb', line 122 def eql? other other.kind_of?(Subscription) and other.arn == arn end |
#exists? ⇒ Boolean
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.
106 107 108 109 110 111 112 113 |
# File 'lib/aws/sns/subscription.rb', line 106 def exists? begin get_attributes true rescue Errors::NotFound, Errors::InvalidParameter false end end |
#inspect ⇒ Object
116 117 118 |
# File 'lib/aws/sns/subscription.rb', line 116 def inspect "<#{self.class} arn:#{arn}>" end |
#owner_id ⇒ String
53 54 55 |
# File 'lib/aws/sns/subscription.rb', line 53 def owner_id @owner_id ||= get_attributes['Owner'] end |
#topic ⇒ Topic
63 64 65 |
# File 'lib/aws/sns/subscription.rb', line 63 def topic Topic.new(topic_arn, :config => config) end |
#topic_arn ⇒ String
58 59 60 |
# File 'lib/aws/sns/subscription.rb', line 58 def topic_arn @topic_arn ||= get_attributes['TopicArn'] end |
#unsubscribe ⇒ nil
Deletes this subscription.
69 70 71 72 |
# File 'lib/aws/sns/subscription.rb', line 69 def unsubscribe client.unsubscribe(:subscription_arn => arn) nil end |