SNS Manager

View Licence Agreement

class sosw.components.sns.SnsManager(**kwargs)[source]

AWS Simple Notification System Manager helper. Requires the Role to have permissions to access SSM for requested resources, something like.

Must have a recipient specified either during initialization or later using set_recipient method. Messages received by send_message() are batched and will be actually send to SNS only during the call of commit() or during the destruction of the class.

The method doesn’t yet support batching messages for multiple recipients, so in case you try to change the recipient it automatically sends all the currently batched messages to the previous recipient.

commit()[source]

Combines messages from self.queue and pushes them to self.recipient. Cleans the queue after that.

send_message(message, subject=None, forse_commit=False)[source]

If the subject is not yet set (for example during __init__() of the class) - then require subject to be set. Otherwize we accept None subject and simply append messages to queue. Once the subject changes - the queue is commite automatically.

Parameters:
  • message
    • str - Message to be send in body of SNS message. Queued.
  • subject
    • str - Optional. Custom subject for message.
set_client_attr(name, value)[source]

Sets the given _name_ attribute to _value_. Commits the self.queue if there are any messages in it.