Class: Simnos::DSL::Subscription
- Inherits:
-
Object
- Object
- Simnos::DSL::Subscription
- Includes:
- TemplateHelper
- Defined in:
- lib/simnos/dsl/subscription.rb
Instance Attribute Summary collapse
-
#protocol ⇒ Object
readonly
Returns the value of attribute protocol.
-
#topic ⇒ Object
readonly
Returns the value of attribute topic.
Instance Method Summary collapse
- #aws_topic(aws_topic) ⇒ Object
- #create ⇒ Object
- #endpoint ⇒ Object
-
#initialize(context, topic:, protocol:, endpoint:) ⇒ Subscription
constructor
A new instance of Subscription.
-
#masked_endpoint ⇒ Object
We have to mask endpoint because SNS returns masked endpoint from API.
Methods included from TemplateHelper
Constructor Details
#initialize(context, topic:, protocol:, endpoint:) ⇒ Subscription
Returns a new instance of Subscription.
25 26 27 28 29 30 31 |
# File 'lib/simnos/dsl/subscription.rb', line 25 def initialize(context, topic: , protocol: , endpoint: ) @context = context @options = @context. @topic = topic @protocol = protocol @endpoint = endpoint end |
Instance Attribute Details
#protocol ⇒ Object (readonly)
Returns the value of attribute protocol.
33 34 35 |
# File 'lib/simnos/dsl/subscription.rb', line 33 def protocol @protocol end |
#topic ⇒ Object (readonly)
Returns the value of attribute topic.
33 34 35 |
# File 'lib/simnos/dsl/subscription.rb', line 33 def topic @topic end |
Instance Method Details
#aws_topic(aws_topic) ⇒ Object
20 21 22 23 |
# File 'lib/simnos/dsl/subscription.rb', line 20 def aws_topic(aws_topic) @aws_topic = aws_topic self end |
#create ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/simnos/dsl/subscription.rb', line 9 def create Simnos.logger.info("Create Topic(#{@aws_topic[:topic].topic_arn.split(':').last}) Subscription. protocol: #{protocol.inspect}, endpoint: #{masked_endpoint.inspect}#{@options[:dry_run] ? ' [dry-run]' : ''}".colorize(:green)) return if @options[:dry_run] client.subscribe( topic_arn: @aws_topic[:topic].topic_arn, protocol: protocol, endpoint: endpoint, ) end |
#endpoint ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'lib/simnos/dsl/subscription.rb', line 47 def endpoint = @options[:secret_expander] if .(@endpoint) else @endpoint end end |
#masked_endpoint ⇒ Object
We have to mask endpoint because SNS returns masked endpoint from API
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/simnos/dsl/subscription.rb', line 36 def masked_endpoint if URI.extract(@endpoint, ['http', 'https']).empty? return endpoint end uri = URI.parse(endpoint) if md = uri.userinfo&.match(/(.*):(.*)/) uri.userinfo = "#{md[1]}:****" end uri.to_s end |