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.
22 23 24 25 26 27 28 |
# File 'lib/aws-sdk-sns/topic.rb', line 22 def initialize(*args) = Hash === args.last ? args.pop.dup : {} @arn = extract_arn(args, ) @data = .delete(:data) @client = .delete(:client) || Client.new() @waiter_block_warned = false end |
Instance Method Details
#add_permission(options = {}) ⇒ EmptyStructure
140 141 142 143 144 |
# File 'lib/aws-sdk-sns/topic.rb', line 140 def ( = {}) = .merge(topic_arn: @arn) resp = @client.() resp.data end |
#arn ⇒ String
33 34 35 |
# File 'lib/aws-sdk-sns/topic.rb', line 33 def arn @arn end |
#attributes ⇒ Hash<String,String>
A map of the topic’s attributes. Attributes in this map include the following:
-
‘DeliveryPolicy` – The JSON serialization of the topic’s delivery policy.
-
‘DisplayName` – The human-readable name used in the `From` field for notifications to `email` and `email-json` endpoints.
-
‘Owner` – The AWS account ID of the topic’s owner.
-
‘Policy` – The JSON serialization of the topic’s access control policy.
-
‘SubscriptionsConfirmed` – The number of confirmed subscriptions for the topic.
-
‘SubscriptionsDeleted` – The number of deleted subscriptions for the topic.
-
‘SubscriptionsPending` – The number of subscriptions pending confirmation for the topic.
-
‘TopicArn` – The topic’s ARN.
-
‘EffectiveDeliveryPolicy` – The JSON serialization of the effective delivery policy, taking system defaults into account.
The following attribute applies only to [server-side-encryption]:
-
‘KmsMasterKeyId` - The ID of an AWS-managed customer master key (CMK) for Amazon SNS or a custom CMK. For more information, see [Key Terms]. For more examples, see [KeyId] in the *AWS Key Management Service API Reference*.
^
[1]: docs.aws.amazon.com/sns/latest/dg/sns-server-side-encryption.html [2]: docs.aws.amazon.com/sns/latest/dg/sns-server-side-encryption.html#sse-key-terms [3]: docs.aws.amazon.com/kms/latest/APIReference/API_DescribeKey.html#API_DescribeKey_RequestParameters
80 81 82 |
# File 'lib/aws-sdk-sns/topic.rb', line 80 def attributes data[:attributes] end |
#confirm_subscription(options = {}) ⇒ Subscription
162 163 164 165 166 167 168 169 |
# File 'lib/aws-sdk-sns/topic.rb', line 162 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`.
107 108 109 110 |
# File 'lib/aws-sdk-sns/topic.rb', line 107 def data load unless @data @data end |
#data_loaded? ⇒ Boolean
115 116 117 |
# File 'lib/aws-sdk-sns/topic.rb', line 115 def data_loaded? !!@data end |
#delete(options = {}) ⇒ EmptyStructure
176 177 178 179 180 |
# File 'lib/aws-sdk-sns/topic.rb', line 176 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.
531 532 533 |
# File 'lib/aws-sdk-sns/topic.rb', line 531 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
97 98 99 100 101 |
# File 'lib/aws-sdk-sns/topic.rb', line 97 def load resp = @client.get_topic_attributes(topic_arn: @arn) @data = resp.data self end |
#publish(options = {}) ⇒ Types::PublishResponse
317 318 319 320 321 |
# File 'lib/aws-sdk-sns/topic.rb', line 317 def publish( = {}) = .merge(topic_arn: @arn) resp = @client.publish() resp.data end |
#remove_permission(options = {}) ⇒ EmptyStructure
332 333 334 335 336 |
# File 'lib/aws-sdk-sns/topic.rb', line 332 def ( = {}) = .merge(topic_arn: @arn) resp = @client.() resp.data end |
#set_attributes(options = {}) ⇒ EmptyStructure
391 392 393 394 395 |
# File 'lib/aws-sdk-sns/topic.rb', line 391 def set_attributes( = {}) = .merge(topic_arn: @arn) resp = @client.set_topic_attributes() resp.data end |
#subscribe(options = {}) ⇒ Subscription
495 496 497 498 499 500 501 502 |
# File 'lib/aws-sdk-sns/topic.rb', line 495 def subscribe( = {}) = .merge(topic_arn: @arn) resp = @client.subscribe() Subscription.new( arn: resp.data.subscription_arn, client: @client ) end |
#subscriptions(options = {}) ⇒ Subscription::Collection
511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 |
# File 'lib/aws-sdk-sns/topic.rb', line 511 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 |