Example #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
Example #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
Example #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
Example #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
Example #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
Example #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
Example #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
Example #8
0
 def find_by_id(id: str, customers: List[str]=None) -> Optional['Heartbeat']:
     return Heartbeat.from_db(db.get_heartbeat(id, customers))
Example #9
0
 def get(id, customer=None):
     return Heartbeat.from_db(db.get_heartbeat(id, customer))
Example #10
0
 def find_by_id(id, customer=None):
     return Heartbeat.from_db(db.get_heartbeat(id, customer))
Example #11
0
 def find_by_id(id, customers=None):
     return Heartbeat.from_db(db.get_heartbeat(id, customers))