original_docstring:  Decorator that will grab messages from sns location in event body.
  
      Args:
          required_topics (iterable): Handler must be triggered by one of these Topics
  
      Returns:
          handler (func): a lambda handler function that is namespace aware
      
docstring: Decorator that will grab messages from sns location in event body.
docstring_tokens: Decorator that will grab messages from sns location in event body .
code: def subscriber(required_topics=None):
      """ Decorator that will grab messages from sns location in event body.
  
      Args:
          required_topics (iterable): Handler must be triggered by one of these Topics
  
      Returns:
          handler (func): a lambda handler function that is namespace aware
      """
      def subscriber_handler(handler):
          def handler_wrapper(event, context, **kwargs):
              try:
                  sns = event['Records'][0]['Sns']
              except Exception:
                  raise Exception('Unsupported event format.')
              if required_topics and not any((topic_name in sns['TopicArn'] for topic_name in required_topics)):
                  raise Exception('Message received not from expected topic.')
              try:
                  message_body = json.loads(sns.get('Message'))
              except Exception as err:
                  raise Exception(f'Could not decode message. ({err})')
  
              kwargs['message'] = message_body
  
              return handler(event, context, **kwargs)
  
          return handler_wrapper
  
      return subscriber_handler
code_tokens: def subscriber ( required_topics = None ) : def subscriber_handler ( handler ) : def handler_wrapper ( event , context , ** kwargs ) : try : sns = event [ 'Records' ] [ 0 ] [ 'Sns' ] except Exception : raise Exception ( 'Unsupported event format.' ) if required_topics and not any ( ( topic_name in sns [ 'TopicArn' ] for topic_name in required_topics ) ) : raise Exception ( 'Message received not from expected topic.' ) try : message_body = json . loads ( sns . get ( 'Message' ) ) except Exception as err : raise Exception ( f'Could not decode message. ({err})' ) kwargs [ 'message' ] = message_body return handler ( event , context , ** kwargs ) return handler_wrapper return subscriber_handler
short_docstring: Decorator that will grab messages from sns location in event body.
short_docstring_tokens: Decorator that will grab messages from sns location in event body .
comment: """ Decorator that will grab messages from sns location in event body.
  
      Args:
          required_topics (iterable): Handler must be triggered by one of these Topics
  
      Returns:
          handler (func): a lambda handler function that is namespace aware
      """