Пример #1
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
Пример #2
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:
        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
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
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
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
 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))