Class: AWS::SNS::Subscription

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Methods included from HasDeliveryPolicy

#delivery_policy, #delivery_policy=, #effective_delivery_policy

Instance Attribute Details

#arnString (readonly)



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

def arn
  @arn
end

#endpointString (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

#protocolString (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_jsonnil, 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_jsonnil, 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

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.



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_idString



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

def owner_id
  @owner_id ||= get_attributes['Owner']
end

#topicTopic



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

def topic
  Topic.new(topic_arn, :config => config)  
end

#topic_arnString



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

def topic_arn
  @topic_arn ||= get_attributes['TopicArn']
end

#unsubscribenil

Deletes this subscription.



69
70
71
72
# File 'lib/aws/sns/subscription.rb', line 69

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