class AWS::SNS::Subscription

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

Attributes

arn[R]

@return [String] The ARN of the subscription.

endpoint[R]

@return [String] The endpoint. This can be an HTTP or HTTPS URL, an e-mail address, or a queue ARN.

protocol[R]

@return [String] The protocol. Possible values:

* +:http+
* +:https+
* +:email+
* +:email_json+
* +:sqs+

Public Class Methods

new(arn, opts = {}) click to toggle source

@private

# 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

Public Instance Methods

==(other) click to toggle source

@return [Boolean] Returns true if the subscriptions have the same

resource ARN.
# File lib/aws/sns/subscription.rb, line 122
def ==(other)
  other.kind_of?(Subscription) and other.arn == arn
end
Also aliased as: eql?
confirmation_authenticated?() click to toggle source

@return [Boolean] Returns true if the subscription confirmation

request was authenticated.
# 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() click to toggle source

You can get the parsed JSON hash from {delivery_policy}. @return [nil,String] Returns the delivery policy JSON string.

# File lib/aws/sns/subscription.rb, line 90
def delivery_policy_json
  get_attributes['DeliveryPolicy']
end
effective_delivery_policy_json() click to toggle source

You can get the parsed JSON hash from {effective_delivery_policy}. @return [nil,String] Returns the effective delivery policy JSON string.

# File lib/aws/sns/subscription.rb, line 96
def effective_delivery_policy_json
  get_attributes['EffectiveDeliveryPolicy']
end
eql?(other) click to toggle source
Alias for: ==
exists?() click to toggle source

@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.

@return [Boolean] Returns true if the subscription exists.

# File lib/aws/sns/subscription.rb, line 106
def exists?
  begin
    get_attributes
    true
  rescue Errors::NotFound, Errors::InvalidParameter
    false
  end
end
inspect() click to toggle source

@private

# File lib/aws/sns/subscription.rb, line 116
def inspect
  "<#{self.class} arn:#{arn}>"
end
owner_id() click to toggle source

@return [String] The AWS account ID of the subscription owner.

# File lib/aws/sns/subscription.rb, line 53
def owner_id
  @owner_id ||= get_attributes['Owner']
end
topic() click to toggle source

@return [Topic]

# File lib/aws/sns/subscription.rb, line 63
def topic
  Topic.new(topic_arn, :config => config)  
end
topic_arn() click to toggle source

@return [String]

# File lib/aws/sns/subscription.rb, line 58
def topic_arn
  @topic_arn ||= get_attributes['TopicArn']
end
unsubscribe() click to toggle source

Deletes this subscription. @return [nil]

# File lib/aws/sns/subscription.rb, line 69
def unsubscribe
  client.unsubscribe(:subscription_arn => arn)
  nil
end

Protected Instance Methods

get_attributes() click to toggle source
# File lib/aws/sns/subscription.rb, line 137
def get_attributes
  client.get_subscription_attributes(:subscription_arn => arn).attributes
end
update_delivery_policy(policy_json) click to toggle source
# File lib/aws/sns/subscription.rb, line 128
def update_delivery_policy policy_json
  client_opts = {}
  client_opts[:subscription_arn] = arn
  client_opts[:attribute_name] = 'DeliveryPolicy'
  client_opts[:attribute_value] = policy_json
  client.set_subscription_attributes(client_opts)
end