Class: AWS::SNS::Subscription
- Inherits:
-
Object
- Object
- AWS::SNS::Subscription
- Includes:
- 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.
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.
-
#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
Instance Attribute Details
#arn ⇒ String (readonly)
Returns The ARN of the subscription.
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)
Returns The protocol. Possible values:
-
:http
-
:https
-
:email
-
:email_json
-
:sqs
.
50 51 52 |
# File 'lib/aws/sns/subscription.rb', line 50 def protocol @protocol end |
Instance Method Details
#confirmation_authenticated? ⇒ Boolean
Returns true if the subscription confirmation request was authenticated.
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: ==
Returns true if the subscriptions have the same resource ARN.
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 |
#owner_id ⇒ String
Returns The AWS account ID of the subscription owner.
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 |