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.



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

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



47
48
49
# File 'lib/aws/sns/subscription.rb', line 47

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.



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

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



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

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.



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

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.



92
93
94
# File 'lib/aws/sns/subscription.rb', line 92

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.



74
75
76
77
78
79
80
81
82
83
# File 'lib/aws/sns/subscription.rb', line 74

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)


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

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