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)

Returns The ARN of the subscription.

Returns:

  • (String)

    The ARN of the subscription.



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

def arn
  @arn
end

#endpointString (readonly)

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

Returns:

  • (String)

    The endpoint. This can be an HTTP or HTTPS



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

def endpoint
  @endpoint
end

#owner_idString (readonly)

Returns The AWS account ID of the subscription owner.

Returns:

  • (String)

    The AWS account ID of the subscription owner.



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

def owner_id
  @owner_id
end

#protocolString (readonly)

Returns The protocol. Possible values:

  • :http

  • :https

  • :email

  • :email_json

  • :sqs.

Returns:

  • (String)

    The protocol. Possible values:

    • :http

    • :https

    • :email

    • :email_json

    • :sqs



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

def protocol
  @protocol
end

#topicTopic (readonly)

Returns The topic to which the endpoint is subscribed.

Returns:

  • (Topic)

    The topic to which the endpoint is subscribed.



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

def topic
  @topic
end

Instance Method Details

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

Returns true if the subscriptions have the same resource ARN.

Returns:

  • (Boolean)

    Returns true if the subscriptions have the same resource ARN.



88
89
90
# File 'lib/aws/sns/subscription.rb', line 88

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.

Returns:

  • (Boolean)

    Returns true if the subscription exists.



70
71
72
73
74
75
76
77
78
79
# File 'lib/aws/sns/subscription.rb', line 70

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

#unsubscribenil

Deletes this subscription.

Returns:

  • (nil)


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

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