Exemplo n.º 1
0
def rules():
    '''
    GET:
      List all rules in the system
    POST:
      Create a new rule in the system
    '''
    if request.method == 'POST':
        try:
            rule_json = rule_validator.validate_new_rule(request.get_json())
            rule = rule_wrapper.create_rule(rule_json)
            response = jsonify(rule=rule)
            response.status_code = 201
            return response
        except NFTValidationError as e:
            return abort(400, e)
        except NFTError as e:
            return abort(500, e)
    else:
        return jsonify(rules=rule_wrapper.list_all_rules())
Exemplo n.º 2
0
def list_all_chains():
    chains = chain_parser.parse_chains(nft_utils.nft_get_json_command())
    rules = rule_wrapper.list_all_rules()
    chains = nft_utils.join_chains_with_rules(chains, rules)
    return chains
Exemplo n.º 3
0
def list_all_chains():
    chains = chain_parser.parse_chains(nft_utils.nft_get_json_command())
    rules = rule_wrapper.list_all_rules()
    chains = nft_utils.join_chains_with_rules(chains, rules)
    return chains