예제 #1
0
파일: views.py 프로젝트: yekeqiang/alerta
def get_heartbeat(id):

    try:
        heartbeat = db.get_heartbeat(id=id)
    except Exception as e:
        return jsonify(status="error", message=str(e)), 500

    if heartbeat:
        body = heartbeat.get_body()
        body['href'] = request.base_url
        return jsonify(status="ok", total=1, heartbeat=body)
    else:
        return jsonify(status="error", message="not found", total=0, heartbeat=None), 404
예제 #2
0
파일: views.py 프로젝트: hscale/alerta
def get_heartbeat(id):

    try:
        heartbeat = db.get_heartbeat(id=id)
    except Exception as e:
        return jsonify(status="error", message=str(e)), 500

    if heartbeat:
        if g.get('role', None) != 'admin' and not heartbeat.customer == g.get('customer', None):
            return jsonify(status="error", message="not found", total=0, alert=None), 404
        body = heartbeat.get_body()
        body['href'] = absolute_url('/hearbeat/' + heartbeat.id)
        return jsonify(status="ok", total=1, heartbeat=body)
    else:
        return jsonify(status="error", message="not found", total=0, heartbeat=None), 404
예제 #3
0
def get_heartbeat(id):

    customer = g.get('customer', None)

    try:
        heartbeat = db.get_heartbeat(id=id, customer=customer)
    except Exception as e:
        return jsonify(status="error", message=str(e)), 500

    if heartbeat:
        body = heartbeat.get_body()
        body['href'] = absolute_url('/hearbeat/' + heartbeat.id)
        return jsonify(status="ok", total=1, heartbeat=body)
    else:
        return jsonify(status="error", message="not found", total=0, heartbeat=None), 404
예제 #4
0
파일: views.py 프로젝트: wangbodong/alerta
def get_heartbeat(id):

    customer = g.get('customer', None)

    try:
        heartbeat = db.get_heartbeat(id=id, customer=customer)
    except Exception as e:
        return jsonify(status="error", message=str(e)), 500

    if heartbeat:
        body = heartbeat.get_body()
        body['href'] = absolute_url('/hearbeat/' + heartbeat.id)
        return jsonify(status="ok", total=1, heartbeat=body)
    else:
        return jsonify(status="error", message="not found", total=0, heartbeat=None), 404
예제 #5
0
파일: views.py 프로젝트: brynmathias/alerta
def get_heartbeat(id):

    try:
        heartbeat = db.get_heartbeat(id=id)
    except Exception as e:
        return jsonify(status="error", message=str(e)), 500

    if heartbeat:
        if g.get('role', None) != 'admin' and not heartbeat.customer == g.get('customer', None):
            return jsonify(status="error", message="not found", total=0, alert=None), 404
        body = heartbeat.get_body()
        body['href'] = request.base_url
        return jsonify(status="ok", total=1, heartbeat=body)
    else:
        return jsonify(status="error", message="not found", total=0, heartbeat=None), 404
예제 #6
0
def get_heartbeat(id):

    try:
        heartbeat = db.get_heartbeat(id=id)
    except Exception as e:
        return jsonify(status="error", message=str(e)), 500

    if heartbeat:
        body = heartbeat.get_body()
        body['href'] = request.base_url
        return jsonify(status="ok", total=1, heartbeat=body)
    else:
        return jsonify(status="error",
                       message="not found",
                       total=0,
                       heartbeat=None), 404
예제 #7
0
파일: views.py 프로젝트: garysmi2/alerta
def get_heartbeat(tenant,id):

    tenant = generateDBName(tenant)

    try:
        heartbeat = db.get_heartbeat(tenant, id=id)
    except Exception as e:
        return jsonify(status="error", message=str(e)), 500

    if heartbeat:
        if g.get('role', None) != 'admin' and not heartbeat.customer == g.get('customer', None):
            return jsonify(status="error", message="not found", total=0, alert=None), 404
        body = heartbeat.get_body()
        body['href'] = request.base_url
        return jsonify(status="ok", total=1, heartbeat=body)
    else:
        return jsonify(status="error", message="not found", total=0, heartbeat=None), 404
예제 #8
0
 def find_by_id(id: str, customers: List[str]=None) -> Optional['Heartbeat']:
     return Heartbeat.from_db(db.get_heartbeat(id, customers))
예제 #9
0
 def get(id, customer=None):
     return Heartbeat.from_db(db.get_heartbeat(id, customer))
예제 #10
0
파일: heartbeat.py 프로젝트: 3IWOH/alerta
 def find_by_id(id, customer=None):
     return Heartbeat.from_db(db.get_heartbeat(id, customer))
예제 #11
0
 def find_by_id(id, customers=None):
     return Heartbeat.from_db(db.get_heartbeat(id, customers))