"""Lambda module.""" from content_utils.logging.logger import ContentLambdaLogger import sentry_sdk from sentry_sdk.integrations.aws_lambda import AwsLambdaIntegration from src import config from src import vapi if config.SENTRY_DSN: sentry_sdk.init( dsn=config.SENTRY_DSN, environment=config.ENVIRONMENT, integrations=[AwsLambdaIntegration(timeout_warning=True)] ) lambda_logger = ContentLambdaLogger(config.app_logger) def handler(event, context): """Lambda Entry point.""" lambda_logger.start() lambda_logger.set_data(**event) try: applied = vapi.apply_revisions_legacy(event.get('review_queue_id')) if applied: lambda_logger.set_data(status='success', result='Successfully applied.') else: lambda_logger.set_data(status='success', result='Successfully exited.') except Exception as e: lambda_logger.set_data(status='error', result=str(e)) raise e finally: lambda_logger.end() return applied