def lambda_handler()

in src/pipeline_alerts_function/app.py [0:0]


def lambda_handler(event, context):

    print("Event received: ", json.dumps(event))

    post_message = assemble_message(event)

    try: 
      webhook_call_response = call_webhook_endpoint(post_message)
    except Exception as e:
        print(f"Error: Failed to send pipeline alert.")
        print(e)
        raise e

    if webhook_call_response.status_code == 200: 
      return {
          "statusCode": 200,
          "body": json.dumps({
              "message": "Pipeline alert sent."
          })
      }
    else:
      return {
          "statusCode": 400,
          "body": json.dumps({
              "message": "Error: Failed to send pipeline alert."
          })
      }