Class: Aws::SNS::Topic
- Inherits:
-
Object
- Object
- Aws::SNS::Topic
- Extended by:
- Deprecations
- Defined in:
- lib/aws-sdk-sns/topic.rb
Defined Under Namespace
Classes: Collection
Read-Only Attributes collapse
- #arn ⇒ String
-
#attributes ⇒ Hash<String,String>
A map of the topic’s attributes.
Actions collapse
- #add_permission(options = {}) ⇒ EmptyStructure
- #confirm_subscription(options = {}) ⇒ Subscription
- #delete(options = {}) ⇒ EmptyStructure
- #publish(options = {}) ⇒ Types::PublishResponse
- #remove_permission(options = {}) ⇒ EmptyStructure
- #set_attributes(options = {}) ⇒ EmptyStructure
- #subscribe(options = {}) ⇒ Subscription
Associations collapse
- #identifiers ⇒ Object deprecated private Deprecated.
- #subscriptions(options = {}) ⇒ Subscription::Collection
Instance Method Summary collapse
- #client ⇒ Client
-
#data ⇒ Types::GetTopicAttributesResponse
Returns the data for this Topic.
-
#data_loaded? ⇒ Boolean
Returns ‘true` if this resource is loaded.
-
#initialize(*args) ⇒ Topic
constructor
A new instance of Topic.
- #load ⇒ self (also: #reload)
Constructor Details
#initialize(arn, options = {}) ⇒ Topic #initialize(options = {}) ⇒ Topic
Returns a new instance of Topic.
19 20 21 22 23 24 |
# File 'lib/aws-sdk-sns/topic.rb', line 19 def initialize(*args) = Hash === args.last ? args.pop.dup : {} @arn = extract_arn(args, ) @data = .delete(:data) @client = .delete(:client) || Client.new() end |
Instance Method Details
#add_permission(options = {}) ⇒ EmptyStructure
121 122 123 124 125 |
# File 'lib/aws-sdk-sns/topic.rb', line 121 def ( = {}) = .merge(topic_arn: @arn) resp = @client.() resp.data end |
#arn ⇒ String
29 30 31 |
# File 'lib/aws-sdk-sns/topic.rb', line 29 def arn @arn end |
#attributes ⇒ Hash<String,String>
A map of the topic’s attributes. Attributes in this map include the following:
-
‘TopicArn` – the topic’s ARN
-
‘Owner` – the AWS account ID of the topic’s owner
-
‘Policy` – the JSON serialization of the topic’s access control policy
-
‘DisplayName` – the human-readable name used in the “From” field for notifications to email and email-json endpoints
-
‘SubscriptionsPending` – the number of subscriptions pending confirmation on this topic
-
‘SubscriptionsConfirmed` – the number of confirmed subscriptions on this topic
-
‘SubscriptionsDeleted` – the number of deleted subscriptions on this topic
-
‘DeliveryPolicy` – the JSON serialization of the topic’s delivery policy
-
‘EffectiveDeliveryPolicy` – the JSON serialization of the effective delivery policy that takes into account system defaults
61 62 63 |
# File 'lib/aws-sdk-sns/topic.rb', line 61 def attributes data[:attributes] end |
#confirm_subscription(options = {}) ⇒ Subscription
143 144 145 146 147 148 149 150 |
# File 'lib/aws-sdk-sns/topic.rb', line 143 def confirm_subscription( = {}) = .merge(topic_arn: @arn) resp = @client.confirm_subscription() Subscription.new( arn: resp.data.subscription_arn, client: @client ) end |
#data ⇒ Types::GetTopicAttributesResponse
Returns the data for this Aws::SNS::Topic. Calls Client#get_topic_attributes if #data_loaded? is ‘false`.
88 89 90 91 |
# File 'lib/aws-sdk-sns/topic.rb', line 88 def data load unless @data @data end |
#data_loaded? ⇒ Boolean
96 97 98 |
# File 'lib/aws-sdk-sns/topic.rb', line 96 def data_loaded? !!@data end |
#delete(options = {}) ⇒ EmptyStructure
157 158 159 160 161 |
# File 'lib/aws-sdk-sns/topic.rb', line 157 def delete( = {}) = .merge(topic_arn: @arn) resp = @client.delete_topic() resp.data end |
#identifiers ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
431 432 433 |
# File 'lib/aws-sdk-sns/topic.rb', line 431 def identifiers { arn: @arn } end |
#load ⇒ self Also known as: reload
Loads, or reloads #data for the current Aws::SNS::Topic. Returns ‘self` making it possible to chain methods.
topic.reload.data
78 79 80 81 82 |
# File 'lib/aws-sdk-sns/topic.rb', line 78 def load resp = @client.get_topic_attributes(topic_arn: @arn) @data = resp.data self end |
#publish(options = {}) ⇒ Types::PublishResponse
278 279 280 281 282 |
# File 'lib/aws-sdk-sns/topic.rb', line 278 def publish( = {}) = .merge(topic_arn: @arn) resp = @client.publish() resp.data end |
#remove_permission(options = {}) ⇒ EmptyStructure
293 294 295 296 297 |
# File 'lib/aws-sdk-sns/topic.rb', line 293 def ( = {}) = .merge(topic_arn: @arn) resp = @client.() resp.data end |
#set_attributes(options = {}) ⇒ EmptyStructure
314 315 316 317 318 |
# File 'lib/aws-sdk-sns/topic.rb', line 314 def set_attributes( = {}) = .merge(topic_arn: @arn) resp = @client.set_topic_attributes() resp.data end |
#subscribe(options = {}) ⇒ Subscription
395 396 397 398 399 400 401 402 |
# File 'lib/aws-sdk-sns/topic.rb', line 395 def subscribe( = {}) = .merge(topic_arn: @arn) resp = @client.subscribe() Subscription.new( arn: resp.data.subscription_arn, client: @client ) end |
#subscriptions(options = {}) ⇒ Subscription::Collection
411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 |
# File 'lib/aws-sdk-sns/topic.rb', line 411 def subscriptions( = {}) batches = Enumerator.new do |y| = .merge(topic_arn: @arn) resp = @client.list_subscriptions_by_topic() resp.each_page do |page| batch = [] page.data.subscriptions.each do |s| batch << Subscription.new( arn: s.subscription_arn, client: @client ) end y.yield(batch) end end Subscription::Collection.new(batches) end |