Beispiel #1
0
def get_release_history(release):
    history_table = dbo.releases.history
    order_by = [history_table.timestamp.desc()]
    history_helper = HistoryHelper(hist_table=history_table,
                                   order_by=order_by,
                                   get_object_callback=lambda: _get_release(release),
                                   history_filters_callback=_get_filters,
                                   process_revisions_callback=process_release_revisions)
    try:
        return history_helper.get_history()
    except (ValueError, AssertionError) as e:
        log.warning("Bad input: %s", json.dumps(e.args))
        return problem(400, "Bad Request", "Invalid input", ext={"data": e.args})
Beispiel #2
0
def get_release_history(release):
    history_table = dbo.releases.history
    order_by = [history_table.timestamp.desc()]
    history_helper = HistoryHelper(
        hist_table=history_table,
        order_by=order_by,
        get_object_callback=lambda: _get_release(release),
        history_filters_callback=_get_filters,
        process_revisions_callback=_process_revisions)
    try:
        return history_helper.get_history()
    except (ValueError, AssertionError) as e:
        log.warning("Bad input: %s", json.dumps(e.args))
        return Response(status=400, response=json.dumps({"data": e.args}))
Beispiel #3
0
def get_rule_history(id_or_alias):
    history_table = dbo.rules.history
    order_by = [history_table.timestamp.desc()]
    history_helper = HistoryHelper(hist_table=history_table,
                                   order_by=order_by,
                                   get_object_callback=lambda: dbo.rules.getRule(id_or_alias),
                                   history_filters_callback=_get_filters,
                                   process_revisions_callback=_process_revisions,
                                   obj_not_found_msg='Requested rule does not exist')
    try:
        return history_helper.get_history(response_key='rules')
    except (ValueError, AssertionError) as msg:
        log.warning("Bad input: %s", msg)
        return Response(status=400, response=str(msg))
Beispiel #4
0
def _get_histories(table, obj, process_revisions_callback=None):
    history_table = table
    order_by = [history_table.timestamp.desc()]
    history_helper = HistoryHelper(hist_table=history_table,
                                   order_by=order_by,
                                   get_object_callback=lambda: obj,
                                   history_filters_callback=_get_filters,
                                   obj_not_found_msg='No history found',
                                   process_revisions_callback=process_revisions_callback)
    try:
        return history_helper.get_history()
    except (ValueError, AssertionError) as msg:
        log.warning("Bad input: %s", msg)
        return problem(400, "Bad Request", "Error occurred when trying to fetch histories",
                       ext={"exception": str(msg)})
Beispiel #5
0
def get_rule_history(id_or_alias):
    history_table = dbo.rules.history
    order_by = [history_table.timestamp.desc()]
    history_helper = HistoryHelper(
        hist_table=history_table,
        order_by=order_by,
        get_object_callback=lambda: dbo.rules.getRule(id_or_alias),
        history_filters_callback=_get_filters,
        process_revisions_callback=_process_revisions,
        obj_not_found_msg='Requested rule does not exist')
    try:
        return history_helper.get_history(response_key='rules')
    except (ValueError, AssertionError) as msg:
        log.warning("Bad input: %s", msg)
        return Response(status=400, response=str(msg))
Beispiel #6
0
def get_rule_history(rule_id):
    history_table = dbo.rules.history
    order_by = [history_table.timestamp.desc()]
    history_helper = HistoryHelper(hist_table=history_table,
                                   order_by=order_by,
                                   get_object_callback=lambda: dbo.rules.getRule(rule_id),
                                   history_filters_callback=_get_filters,
                                   obj_not_found_msg='Requested rule does not exist')
    try:
        return history_helper.get_history(response_key='rules')
    except (ValueError, AssertionError) as msg:
        log.warning("Bad input: %s", msg)
        return problem(400, "Bad Request", "Error occurred when trying to fetch"
                                           " Rule's revisions having rule_id {0}".format(rule_id),
                       ext={"exception": str(msg)})
Beispiel #7
0
def get_rule_history(rule_id):
    history_table = dbo.rules.history
    order_by = [history_table.timestamp.desc()]
    history_helper = HistoryHelper(
        hist_table=history_table,
        order_by=order_by,
        get_object_callback=lambda: dbo.rules.getRule(rule_id),
        history_filters_callback=_get_filters,
        obj_not_found_msg="Requested rule does not exist",
    )
    try:
        return history_helper.get_history(response_key="rules")
    except (ValueError, AssertionError) as msg:
        log.warning("Bad input: %s", msg)
        return problem(
            400, "Bad Request", "Error occurred when trying to fetch" " Rule's revisions having rule_id {0}".format(rule_id), ext={"exception": str(msg)}
        )
Beispiel #8
0
def _get_histories(table, obj, process_revisions_callback=None):
    history_table = table
    order_by = [history_table.timestamp.desc()]
    history_helper = HistoryHelper(
        hist_table=history_table,
        order_by=order_by,
        get_object_callback=lambda: obj,
        history_filters_callback=_get_filters,
        obj_not_found_msg='No history found',
        process_revisions_callback=process_revisions_callback)
    try:
        return history_helper.get_history()
    except (ValueError, AssertionError) as msg:
        log.warning("Bad input: %s", msg)
        return problem(400,
                       "Bad Request",
                       "Error occurred when trying to fetch histories",
                       ext={"exception": str(msg)})