@app.route('/webhooks/stackdriver', methods=['OPTIONS', 'POST'])
@cross_origin()
@auth_required
def stackdriver():

    hook_started = webhook_timer.start_timer()
    try:
        state, incomingAlert = parse_stackdriver(request.data)
    except __HOLE__ as e:
        webhook_timer.stop_timer(hook_started)
        return jsonify(status="error", message=str(e)), 400

    if g.get('customer', None):
        incomingAlert.customer = g.get('customer')

    if state == 'acknowledged':
        try:
            alert = db.set_status(id=incomingAlert.id, status='ack', text='acknowledged via Stackdriver')
        except Exception as e:
            webhook_timer.stop_timer(hook_started)
            return jsonify(status="error", message=str(e)), 500
    else:
        try:
            alert = process_alert(incomingAlert)
        except RejectException as e:
            webhook_timer.stop_timer(hook_started)
            return jsonify(status="error", message=str(e)), 403
        except Exception as e:
            webhook_timer.stop_timer(hook_started)
            return jsonify(status="error", message=str(e)), 500

    webhook_timer.stop_timer(hook_started)

    if alert:
        body = alert.get_body()
        body['href'] = absolute_url('/alert/' + alert.id)
        return jsonify(status="ok", id=alert.id, alert=body), 201, {'Location': body['href']}
    else:
        return jsonify(status="error", message="notification from stackdriver failed"), 500
dataset/ETHPy150Open guardian/alerta/alerta/app/webhooks/views.py/stackdriver