Sha256: b1997e85c97aff20c766eb9661366f831289fb75a84bbe01ca735b54cb4caa97
Contents?: true
Size: 1.51 KB
Versions: 6
Compression:
Stored size: 1.51 KB
Contents
require 'forwardable' require 'aws-sdk' require 'simnos/filterable' module Simnos class ClientWrapper extend Forwardable include Filterable def_delegators :@client, *%i/delete_topic get_topic_attributes create_topic set_topic_attributes set_subscription_attributes subscribe unsubscribe/ def initialize(options) @options = options if options[:region] @client = Aws::SNS::Client.new(region: @options[:region]) else @client = Aws::SNS::Client.new end end def topic_attrs(topic_arn: ) @client.get_topic_attributes(topic_arn: topic_arn) end 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 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 def region @client.config.region end private def topic_name(topic) topic.topic_arn.split(':').last end end end
Version data entries
6 entries across 6 versions & 1 rubygems