Esempio n. 1
0
def list_pets():
    decision = query_opa("GET", ["pets"])
    if not decision.defined:
        raise flask.abort(403)

    sql = opa.splice(SELECT='pets.*', FROM='pets', decision=decision)

    return query_db(sql)
Esempio n. 2
0
def get_pet(pet_id):
    decision = query_opa("GET", ["pets", pet_id])
    if not decision.defined:
        raise flask.abort(403)

    sql = opa.splice(SELECT='pets.*',
                     FROM='pets',
                     WHERE='pets.id=?',
                     decision=decision)

    result = query_db(sql, args=(pet_id, ), one=True)
    if result is None:
        raise flask.abort(404)

    return result