Class: Simnos::ClientWrapper
- Inherits:
-
Object
- Object
- Simnos::ClientWrapper
- Extended by:
- Forwardable
- Includes:
- Filterable
- Defined in:
- lib/simnos/client_wrapper.rb
Instance Method Summary collapse
-
#initialize(options) ⇒ ClientWrapper
constructor
A new instance of ClientWrapper.
- #region ⇒ Object
- #subscriptions_by_topic(topic_arn:) ⇒ Object
- #topic_attrs(topic_arn:) ⇒ Object
- #topics ⇒ Object
Methods included from Filterable
Constructor Details
#initialize(options) ⇒ ClientWrapper
Returns a new instance of ClientWrapper.
12 13 14 15 16 17 18 19 |
# File 'lib/simnos/client_wrapper.rb', line 12 def initialize() = if [:region] @client = Aws::SNS::Client.new(region: [:region]) else @client = Aws::SNS::Client.new end end |
Instance Method Details
#region ⇒ Object
54 55 56 |
# File 'lib/simnos/client_wrapper.rb', line 54 def region @client.config.region end |
#subscriptions_by_topic(topic_arn:) ⇒ Object
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/simnos/client_wrapper.rb', line 43 def subscriptions_by_topic(topic_arn: ) results = [] next_token = nil begin resp = @client.list_subscriptions_by_topic(topic_arn: topic_arn, next_token: next_token) results.concat(resp.subscriptions) next_token = resp.next_token end while next_token results end |
#topic_attrs(topic_arn:) ⇒ Object
21 22 23 |
# File 'lib/simnos/client_wrapper.rb', line 21 def topic_attrs(topic_arn: ) @client.get_topic_attributes(topic_arn: topic_arn) end |
#topics ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/simnos/client_wrapper.rb', line 25 def topics results = {} next_token = nil begin resp = @client.list_topics(next_token: next_token) resp.topics.each do |t| name = t.topic_arn.split(':').last next unless target?(name) results[name] = { topic: t, attrs: topic_attrs(topic_arn: t.topic_arn), } end next_token = resp.next_token end while next_token results end |