Merge branch 'main-v4.3' into merge-main-v4.3-into-v4.4
This commit is contained in:
commit
508e50af63
|
@ -5,6 +5,7 @@
|
||||||
, {load_module,emqx_rule_events,brutal_purge,soft_purge,[]}
|
, {load_module,emqx_rule_events,brutal_purge,soft_purge,[]}
|
||||||
, {load_module,emqx_rule_engine,brutal_purge,soft_purge,[]}
|
, {load_module,emqx_rule_engine,brutal_purge,soft_purge,[]}
|
||||||
, {load_module,emqx_rule_runtime,brutal_purge,soft_purge,[]}
|
, {load_module,emqx_rule_runtime,brutal_purge,soft_purge,[]}
|
||||||
|
, {load_module,emqx_rule_engine_api,brutal_purge,soft_purge,[]}
|
||||||
]},
|
]},
|
||||||
{<<".*">>,[]}],
|
{<<".*">>,[]}],
|
||||||
[{"4.4.0",
|
[{"4.4.0",
|
||||||
|
@ -12,6 +13,7 @@
|
||||||
, {load_module,emqx_rule_events,brutal_purge,soft_purge,[]}
|
, {load_module,emqx_rule_events,brutal_purge,soft_purge,[]}
|
||||||
, {load_module,emqx_rule_engine,brutal_purge,soft_purge,[]}
|
, {load_module,emqx_rule_engine,brutal_purge,soft_purge,[]}
|
||||||
, {load_module,emqx_rule_runtime,brutal_purge,soft_purge,[]}
|
, {load_module,emqx_rule_runtime,brutal_purge,soft_purge,[]}
|
||||||
|
, {load_module,emqx_rule_engine_api,brutal_purge,soft_purge,[]}
|
||||||
]},
|
]},
|
||||||
{<<".*">>,[]}]
|
{<<".*">>,[]}]
|
||||||
}.
|
}.
|
||||||
|
|
|
@ -211,23 +211,35 @@ test_rule_sql(Params) ->
|
||||||
end.
|
end.
|
||||||
|
|
||||||
do_create_rule(Params) ->
|
do_create_rule(Params) ->
|
||||||
case emqx_rule_engine:create_rule(parse_rule_params(Params)) of
|
case parse_rule_params(Params) of
|
||||||
|
{ok, ParsedParams} ->
|
||||||
|
case emqx_rule_engine:create_rule(ParsedParams) of
|
||||||
{ok, Rule} -> return({ok, record_to_map(Rule)});
|
{ok, Rule} -> return({ok, record_to_map(Rule)});
|
||||||
{error, {action_not_found, ActionName}} ->
|
{error, {action_not_found, ActionName}} ->
|
||||||
return({error, 400, ?ERR_NO_ACTION(ActionName)});
|
return({error, 400, ?ERR_NO_ACTION(ActionName)});
|
||||||
{error, Reason} ->
|
{error, Reason} ->
|
||||||
?LOG(error, "~p failed: ~0p", [?FUNCTION_NAME, Reason]),
|
?LOG(error, "~p failed: ~0p", [?FUNCTION_NAME, Reason]),
|
||||||
return({error, 400, ?ERR_BADARGS(Reason)})
|
return({error, 400, ?ERR_BADARGS(Reason)})
|
||||||
|
end;
|
||||||
|
{error, Reason} ->
|
||||||
|
?LOG(error, "~p failed: ~0p", [?FUNCTION_NAME, Reason]),
|
||||||
|
return({error, 400, ?ERR_BADARGS(Reason)})
|
||||||
end.
|
end.
|
||||||
|
|
||||||
update_rule(#{id := Id}, Params) ->
|
update_rule(#{id := Id}, Params) ->
|
||||||
case emqx_rule_engine:update_rule(parse_rule_params(Params, #{id => Id})) of
|
case parse_rule_params(Params, #{id => Id}) of
|
||||||
|
{ok, ParsedParams} ->
|
||||||
|
case emqx_rule_engine:update_rule(ParsedParams) of
|
||||||
{ok, Rule} -> return({ok, record_to_map(Rule)});
|
{ok, Rule} -> return({ok, record_to_map(Rule)});
|
||||||
{error, {not_found, RuleId}} ->
|
{error, {not_found, RuleId}} ->
|
||||||
return({error, 400, ?ERR_NO_RULE(RuleId)});
|
return({error, 400, ?ERR_NO_RULE(RuleId)});
|
||||||
{error, Reason} ->
|
{error, Reason} ->
|
||||||
?LOG(error, "~p failed: ~0p", [?FUNCTION_NAME, Reason]),
|
?LOG(error, "~p failed: ~0p", [?FUNCTION_NAME, Reason]),
|
||||||
return({error, 400, ?ERR_BADARGS(Reason)})
|
return({error, 400, ?ERR_BADARGS(Reason)})
|
||||||
|
end;
|
||||||
|
{error, Reason} ->
|
||||||
|
?LOG(error, "~p failed: ~0p", [?FUNCTION_NAME, Reason]),
|
||||||
|
return({error, 400, ?ERR_BADARGS(Reason)})
|
||||||
end.
|
end.
|
||||||
|
|
||||||
list_rules(_Bindings, _Params) ->
|
list_rules(_Bindings, _Params) ->
|
||||||
|
@ -481,7 +493,9 @@ printable_actions(Actions) ->
|
||||||
parse_rule_params(Params) ->
|
parse_rule_params(Params) ->
|
||||||
parse_rule_params(Params, #{description => <<"">>}).
|
parse_rule_params(Params, #{description => <<"">>}).
|
||||||
parse_rule_params([], Rule) ->
|
parse_rule_params([], Rule) ->
|
||||||
Rule;
|
{ok, Rule};
|
||||||
|
parse_rule_params([{<<"id">>, <<>>} | _], _) ->
|
||||||
|
{error, {empty_string_not_allowed, id}};
|
||||||
parse_rule_params([{<<"id">>, Id} | Params], Rule) ->
|
parse_rule_params([{<<"id">>, Id} | Params], Rule) ->
|
||||||
parse_rule_params(Params, Rule#{id => Id});
|
parse_rule_params(Params, Rule#{id => Id});
|
||||||
parse_rule_params([{<<"rawsql">>, RawSQL} | Params], Rule) ->
|
parse_rule_params([{<<"rawsql">>, RawSQL} | Params], Rule) ->
|
||||||
|
@ -516,6 +530,8 @@ parse_resource_params(Params) ->
|
||||||
parse_resource_params(Params, #{config => #{}, description => <<"">>}).
|
parse_resource_params(Params, #{config => #{}, description => <<"">>}).
|
||||||
parse_resource_params([], Res) ->
|
parse_resource_params([], Res) ->
|
||||||
{ok, Res};
|
{ok, Res};
|
||||||
|
parse_resource_params([{<<"id">>, <<>>} | _], _Res) ->
|
||||||
|
{error, {empty_string_not_allowed, id}};
|
||||||
parse_resource_params([{<<"id">>, Id} | Params], Res) ->
|
parse_resource_params([{<<"id">>, Id} | Params], Res) ->
|
||||||
parse_resource_params(Params, Res#{id => Id});
|
parse_resource_params(Params, Res#{id => Id});
|
||||||
parse_resource_params([{<<"type">>, ResourceType} | Params], Res) ->
|
parse_resource_params([{<<"type">>, ResourceType} | Params], Res) ->
|
||||||
|
|
Loading…
Reference in New Issue