def METHOD_NAME(request):
    metrics = request.find_service(IMetricsService, context=None)
    data = request.json_body
    # Check to ensure that the Type is what we expect.
    if data.get("Type") != "Notification":
        raise HTTPBadRequest("Expected Type of Notification")
    try:
        _verify_sns_message(request, data)
    except requests.HTTPError:
        metrics.increment("warehouse.ses.sns_verify.error")
        raise HTTPServiceUnavailable from None
    event_exists = request.db.query(
        exists().where(Event.event_id == data["MessageId"])
    ).scalar()
    if event_exists:
        return Response()
    message = json.loads(data["Message"])
    message_id = message["mail"]["messageId"]
    try:
        email = (
            request.db.query(EmailMessage)
            .filter(EmailMessage.message_id == message_id)
            .one()
        )
    except NoResultFound:
        raise HTTPBadRequest("Unknown messageId")
    # Load our state machine from the status in the database, process any
    # transition we have from this event, and then save the result.
    machine = EmailStatus.load(email)
    if message["notificationType"] == "Delivery":
        machine.deliver()
    elif (
        message["notificationType"] == "Bounce"
        and message["bounce"]["bounceType"] == "Permanent"
    ):
        machine.bounce()
    elif message["notificationType"] == "Bounce":
        machine.soft_bounce()
    elif message["notificationType"] == "Complaint":
        machine.complain()
    else:
        raise HTTPBadRequest("Unknown notificationType")
    email = machine.save()
    # Save our event to the database.
    request.db.add(
        Event(
            email=email,
            event_id=data["MessageId"],
            event_type=EventTypes(message["notificationType"]),
            data=message[message["notificationType"].lower()],
        )
    )
    return Response()