|
|
@@ -26,6 +26,9 @@
|
|
|
-import(hoconsc, [mk/2, array/1, enum/1]).
|
|
|
-import(emqx_utils, [redact/1]).
|
|
|
|
|
|
+-define(ROOT_KEY_ACTIONS, actions).
|
|
|
+-define(ROOT_KEY_SOURCES, sources).
|
|
|
+
|
|
|
%% Swagger specs from hocon schema
|
|
|
-export([
|
|
|
api_spec/0,
|
|
|
@@ -48,7 +51,14 @@
|
|
|
]).
|
|
|
|
|
|
%% BpAPI / RPC Targets
|
|
|
--export([lookup_from_local_node/2, get_metrics_from_local_node/2]).
|
|
|
+-export([
|
|
|
+ lookup_from_local_node/2,
|
|
|
+ get_metrics_from_local_node/2,
|
|
|
+ lookup_from_local_node_v6/3,
|
|
|
+ get_metrics_from_local_node_v6/3
|
|
|
+]).
|
|
|
+
|
|
|
+-define(BPAPI_NAME, emqx_bridge).
|
|
|
|
|
|
-define(BRIDGE_NOT_FOUND(BRIDGE_TYPE, BRIDGE_NAME),
|
|
|
?NOT_FOUND(
|
|
|
@@ -393,16 +403,51 @@ schema("/action_types") ->
|
|
|
}.
|
|
|
|
|
|
'/actions'(post, #{body := #{<<"type">> := BridgeType, <<"name">> := BridgeName} = Conf0}) ->
|
|
|
- case emqx_bridge_v2:lookup(BridgeType, BridgeName) of
|
|
|
- {ok, _} ->
|
|
|
- ?BAD_REQUEST('ALREADY_EXISTS', <<"bridge already exists">>);
|
|
|
- {error, not_found} ->
|
|
|
- Conf = filter_out_request_body(Conf0),
|
|
|
- create_bridge(BridgeType, BridgeName, Conf)
|
|
|
- end;
|
|
|
+ handle_create(?ROOT_KEY_ACTIONS, BridgeType, BridgeName, Conf0);
|
|
|
'/actions'(get, _Params) ->
|
|
|
- Nodes = mria:running_nodes(),
|
|
|
- NodeReplies = emqx_bridge_proto_v5:v2_list_bridges_on_nodes(Nodes),
|
|
|
+ handle_list(?ROOT_KEY_ACTIONS).
|
|
|
+
|
|
|
+'/actions/:id'(get, #{bindings := #{id := Id}}) ->
|
|
|
+ ?TRY_PARSE_ID(Id, lookup_from_all_nodes(?ROOT_KEY_ACTIONS, BridgeType, BridgeName, 200));
|
|
|
+'/actions/:id'(put, #{bindings := #{id := Id}, body := Conf0}) ->
|
|
|
+ handle_update(?ROOT_KEY_ACTIONS, Id, Conf0);
|
|
|
+'/actions/:id'(delete, #{bindings := #{id := Id}, query_string := Qs}) ->
|
|
|
+ handle_delete(?ROOT_KEY_ACTIONS, Id, Qs).
|
|
|
+
|
|
|
+'/actions/:id/metrics'(get, #{bindings := #{id := Id}}) ->
|
|
|
+ ?TRY_PARSE_ID(Id, get_metrics_from_all_nodes(?ROOT_KEY_ACTIONS, BridgeType, BridgeName)).
|
|
|
+
|
|
|
+'/actions/:id/metrics/reset'(put, #{bindings := #{id := Id}}) ->
|
|
|
+ handle_reset_metrics(?ROOT_KEY_ACTIONS, Id).
|
|
|
+
|
|
|
+'/actions/:id/enable/:enable'(put, #{bindings := #{id := Id, enable := Enable}}) ->
|
|
|
+ handle_disable_enable(?ROOT_KEY_ACTIONS, Id, Enable).
|
|
|
+
|
|
|
+'/actions/:id/:operation'(post, #{
|
|
|
+ bindings :=
|
|
|
+ #{id := Id, operation := Op}
|
|
|
+}) ->
|
|
|
+ handle_operation(?ROOT_KEY_ACTIONS, Id, Op).
|
|
|
+
|
|
|
+'/nodes/:node/actions/:id/:operation'(post, #{
|
|
|
+ bindings :=
|
|
|
+ #{id := Id, operation := Op, node := Node}
|
|
|
+}) ->
|
|
|
+ handle_node_operation(?ROOT_KEY_ACTIONS, Node, Id, Op).
|
|
|
+
|
|
|
+'/actions_probe'(post, Request) ->
|
|
|
+ handle_probe(?ROOT_KEY_ACTIONS, Request).
|
|
|
+
|
|
|
+'/action_types'(get, _Request) ->
|
|
|
+ ?OK(emqx_bridge_v2_schema:types()).
|
|
|
+
|
|
|
+%%------------------------------------------------------------------------------
|
|
|
+%% Handlers
|
|
|
+%%------------------------------------------------------------------------------
|
|
|
+
|
|
|
+handle_list(ConfRootKey) ->
|
|
|
+ Nodes = emqx:running_nodes(),
|
|
|
+ NodeReplies = emqx_bridge_proto_v6:v2_list_bridges_on_nodes_v6(Nodes, ConfRootKey),
|
|
|
case is_ok(NodeReplies) of
|
|
|
{ok, NodeBridges} ->
|
|
|
AllBridges = [
|
|
|
@@ -414,34 +459,44 @@ schema("/action_types") ->
|
|
|
?INTERNAL_ERROR(Reason)
|
|
|
end.
|
|
|
|
|
|
-'/actions/:id'(get, #{bindings := #{id := Id}}) ->
|
|
|
- ?TRY_PARSE_ID(Id, lookup_from_all_nodes(BridgeType, BridgeName, 200));
|
|
|
-'/actions/:id'(put, #{bindings := #{id := Id}, body := Conf0}) ->
|
|
|
+handle_create(ConfRootKey, Type, Name, Conf0) ->
|
|
|
+ case emqx_bridge_v2:lookup(ConfRootKey, Type, Name) of
|
|
|
+ {ok, _} ->
|
|
|
+ ?BAD_REQUEST('ALREADY_EXISTS', <<"bridge already exists">>);
|
|
|
+ {error, not_found} ->
|
|
|
+ Conf = filter_out_request_body(Conf0),
|
|
|
+ create_bridge(ConfRootKey, Type, Name, Conf)
|
|
|
+ end.
|
|
|
+
|
|
|
+handle_update(ConfRootKey, Id, Conf0) ->
|
|
|
Conf1 = filter_out_request_body(Conf0),
|
|
|
?TRY_PARSE_ID(
|
|
|
Id,
|
|
|
- case emqx_bridge_v2:lookup(BridgeType, BridgeName) of
|
|
|
+ case emqx_bridge_v2:lookup(ConfRootKey, BridgeType, BridgeName) of
|
|
|
{ok, _} ->
|
|
|
RawConf = emqx:get_raw_config([bridges, BridgeType, BridgeName], #{}),
|
|
|
Conf = emqx_utils:deobfuscate(Conf1, RawConf),
|
|
|
- update_bridge(BridgeType, BridgeName, Conf);
|
|
|
+ update_bridge(ConfRootKey, BridgeType, BridgeName, Conf);
|
|
|
{error, not_found} ->
|
|
|
?BRIDGE_NOT_FOUND(BridgeType, BridgeName)
|
|
|
end
|
|
|
- );
|
|
|
-'/actions/:id'(delete, #{bindings := #{id := Id}, query_string := Qs}) ->
|
|
|
+ ).
|
|
|
+
|
|
|
+handle_delete(ConfRootKey, Id, QueryStringOpts) ->
|
|
|
?TRY_PARSE_ID(
|
|
|
Id,
|
|
|
case emqx_bridge_v2:lookup(BridgeType, BridgeName) of
|
|
|
{ok, _} ->
|
|
|
AlsoDeleteActions =
|
|
|
- case maps:get(<<"also_delete_dep_actions">>, Qs, <<"false">>) of
|
|
|
+ case maps:get(<<"also_delete_dep_actions">>, QueryStringOpts, <<"false">>) of
|
|
|
<<"true">> -> true;
|
|
|
true -> true;
|
|
|
_ -> false
|
|
|
end,
|
|
|
case
|
|
|
- emqx_bridge_v2:check_deps_and_remove(BridgeType, BridgeName, AlsoDeleteActions)
|
|
|
+ emqx_bridge_v2:check_deps_and_remove(
|
|
|
+ ConfRootKey, BridgeType, BridgeName, AlsoDeleteActions
|
|
|
+ )
|
|
|
of
|
|
|
ok ->
|
|
|
?NO_CONTENT;
|
|
|
@@ -465,23 +520,22 @@ schema("/action_types") ->
|
|
|
end
|
|
|
).
|
|
|
|
|
|
-'/actions/:id/metrics'(get, #{bindings := #{id := Id}}) ->
|
|
|
- ?TRY_PARSE_ID(Id, get_metrics_from_all_nodes(BridgeType, BridgeName)).
|
|
|
-
|
|
|
-'/actions/:id/metrics/reset'(put, #{bindings := #{id := Id}}) ->
|
|
|
+handle_reset_metrics(ConfRootKey, Id) ->
|
|
|
?TRY_PARSE_ID(
|
|
|
Id,
|
|
|
begin
|
|
|
ActionType = emqx_bridge_v2:bridge_v2_type_to_connector_type(BridgeType),
|
|
|
- ok = emqx_bridge_v2:reset_metrics(ActionType, BridgeName),
|
|
|
+ ok = emqx_bridge_v2:reset_metrics(ConfRootKey, ActionType, BridgeName),
|
|
|
?NO_CONTENT
|
|
|
end
|
|
|
).
|
|
|
|
|
|
-'/actions/:id/enable/:enable'(put, #{bindings := #{id := Id, enable := Enable}}) ->
|
|
|
+handle_disable_enable(ConfRootKey, Id, Enable) ->
|
|
|
?TRY_PARSE_ID(
|
|
|
Id,
|
|
|
- case emqx_bridge_v2:disable_enable(enable_func(Enable), BridgeType, BridgeName) of
|
|
|
+ case
|
|
|
+ emqx_bridge_v2:disable_enable(ConfRootKey, enable_func(Enable), BridgeType, BridgeName)
|
|
|
+ of
|
|
|
{ok, _} ->
|
|
|
?NO_CONTENT;
|
|
|
{error, {pre_config_update, _, bridge_not_found}} ->
|
|
|
@@ -495,41 +549,37 @@ schema("/action_types") ->
|
|
|
end
|
|
|
).
|
|
|
|
|
|
-'/actions/:id/:operation'(post, #{
|
|
|
- bindings :=
|
|
|
- #{id := Id, operation := Op}
|
|
|
-}) ->
|
|
|
+handle_operation(ConfRootKey, Id, Op) ->
|
|
|
?TRY_PARSE_ID(
|
|
|
Id,
|
|
|
begin
|
|
|
OperFunc = operation_func(all, Op),
|
|
|
- Nodes = mria:running_nodes(),
|
|
|
- call_operation_if_enabled(all, OperFunc, [Nodes, BridgeType, BridgeName])
|
|
|
+ Nodes = emqx:running_nodes(),
|
|
|
+ call_operation_if_enabled(all, OperFunc, [Nodes, ConfRootKey, BridgeType, BridgeName])
|
|
|
end
|
|
|
).
|
|
|
|
|
|
-'/nodes/:node/actions/:id/:operation'(post, #{
|
|
|
- bindings :=
|
|
|
- #{id := Id, operation := Op, node := Node}
|
|
|
-}) ->
|
|
|
+handle_node_operation(ConfRootKey, Node, Id, Op) ->
|
|
|
?TRY_PARSE_ID(
|
|
|
Id,
|
|
|
case emqx_utils:safe_to_existing_atom(Node, utf8) of
|
|
|
{ok, TargetNode} ->
|
|
|
OperFunc = operation_func(TargetNode, Op),
|
|
|
- call_operation_if_enabled(TargetNode, OperFunc, [TargetNode, BridgeType, BridgeName]);
|
|
|
+ call_operation_if_enabled(TargetNode, OperFunc, [
|
|
|
+ TargetNode, ConfRootKey, BridgeType, BridgeName
|
|
|
+ ]);
|
|
|
{error, _} ->
|
|
|
?NOT_FOUND(<<"Invalid node name: ", Node/binary>>)
|
|
|
end
|
|
|
).
|
|
|
|
|
|
-'/actions_probe'(post, Request) ->
|
|
|
+handle_probe(ConfRootKey, Request) ->
|
|
|
RequestMeta = #{module => ?MODULE, method => post, path => "/actions_probe"},
|
|
|
case emqx_dashboard_swagger:filter_check_request_and_translate_body(Request, RequestMeta) of
|
|
|
- {ok, #{body := #{<<"type">> := ConnType} = Params}} ->
|
|
|
+ {ok, #{body := #{<<"type">> := Type} = Params}} ->
|
|
|
Params1 = maybe_deobfuscate_bridge_probe(Params),
|
|
|
Params2 = maps:remove(<<"type">>, Params1),
|
|
|
- case emqx_bridge_v2:create_dry_run(ConnType, Params2) of
|
|
|
+ case emqx_bridge_v2:create_dry_run(ConfRootKey, Type, Params2) of
|
|
|
ok ->
|
|
|
?NO_CONTENT;
|
|
|
{error, #{kind := validation_error} = Reason0} ->
|
|
|
@@ -548,9 +598,7 @@ schema("/action_types") ->
|
|
|
redact(BadRequest)
|
|
|
end.
|
|
|
|
|
|
-'/action_types'(get, _Request) ->
|
|
|
- ?OK(emqx_bridge_v2_schema:types()).
|
|
|
-
|
|
|
+%%% API helpers
|
|
|
maybe_deobfuscate_bridge_probe(#{<<"type">> := ActionType, <<"name">> := BridgeName} = Params) ->
|
|
|
case emqx_bridge_v2:lookup(ActionType, BridgeName) of
|
|
|
{ok, #{raw_config := RawConf}} ->
|
|
|
@@ -564,7 +612,6 @@ maybe_deobfuscate_bridge_probe(#{<<"type">> := ActionType, <<"name">> := BridgeN
|
|
|
maybe_deobfuscate_bridge_probe(Params) ->
|
|
|
Params.
|
|
|
|
|
|
-%%% API helpers
|
|
|
is_ok(ok) ->
|
|
|
ok;
|
|
|
is_ok(OkResult = {ok, _}) ->
|
|
|
@@ -587,9 +634,16 @@ is_ok(ResL) ->
|
|
|
end.
|
|
|
|
|
|
%% bridge helpers
|
|
|
-lookup_from_all_nodes(BridgeType, BridgeName, SuccCode) ->
|
|
|
- Nodes = mria:running_nodes(),
|
|
|
- case is_ok(emqx_bridge_proto_v5:v2_lookup_from_all_nodes(Nodes, BridgeType, BridgeName)) of
|
|
|
+-spec lookup_from_all_nodes(emqx_bridge_v2:root_cfg_key(), _, _, _) -> _.
|
|
|
+lookup_from_all_nodes(ConfRootKey, BridgeType, BridgeName, SuccCode) ->
|
|
|
+ Nodes = emqx:running_nodes(),
|
|
|
+ case
|
|
|
+ is_ok(
|
|
|
+ emqx_bridge_proto_v6:v2_lookup_from_all_nodes_v6(
|
|
|
+ Nodes, ConfRootKey, BridgeType, BridgeName
|
|
|
+ )
|
|
|
+ )
|
|
|
+ of
|
|
|
{ok, [{ok, _} | _] = Results} ->
|
|
|
{SuccCode, format_bridge_info([R || {ok, R} <- Results])};
|
|
|
{ok, [{error, not_found} | _]} ->
|
|
|
@@ -598,10 +652,10 @@ lookup_from_all_nodes(BridgeType, BridgeName, SuccCode) ->
|
|
|
?INTERNAL_ERROR(Reason)
|
|
|
end.
|
|
|
|
|
|
-get_metrics_from_all_nodes(ActionType, ActionName) ->
|
|
|
+get_metrics_from_all_nodes(ConfRootKey, Type, Name) ->
|
|
|
Nodes = emqx:running_nodes(),
|
|
|
Result = maybe_unwrap(
|
|
|
- emqx_bridge_proto_v5:v2_get_metrics_from_all_nodes(Nodes, ActionType, ActionName)
|
|
|
+ emqx_bridge_proto_v6:v2_get_metrics_from_all_nodes_v6(Nodes, ConfRootKey, Type, Name)
|
|
|
),
|
|
|
case Result of
|
|
|
Metrics when is_list(Metrics) ->
|
|
|
@@ -610,22 +664,25 @@ get_metrics_from_all_nodes(ActionType, ActionName) ->
|
|
|
?INTERNAL_ERROR(Reason)
|
|
|
end.
|
|
|
|
|
|
-operation_func(all, start) -> v2_start_bridge_to_all_nodes;
|
|
|
-operation_func(_Node, start) -> v2_start_bridge_to_node.
|
|
|
+operation_func(all, start) -> v2_start_bridge_to_all_nodes_v6;
|
|
|
+operation_func(_Node, start) -> v2_start_bridge_to_node_v6;
|
|
|
+operation_func(all, lookup) -> v2_lookup_from_all_nodes_v6;
|
|
|
+operation_func(all, list) -> v2_list_bridges_on_nodes_v6;
|
|
|
+operation_func(all, get_metrics) -> v2_get_metrics_from_all_nodes_v6.
|
|
|
|
|
|
-call_operation_if_enabled(NodeOrAll, OperFunc, [Nodes, BridgeType, BridgeName]) ->
|
|
|
- try is_enabled_bridge(BridgeType, BridgeName) of
|
|
|
+call_operation_if_enabled(NodeOrAll, OperFunc, [Nodes, ConfRootKey, BridgeType, BridgeName]) ->
|
|
|
+ try is_enabled_bridge(ConfRootKey, BridgeType, BridgeName) of
|
|
|
false ->
|
|
|
?BRIDGE_NOT_ENABLED;
|
|
|
true ->
|
|
|
- call_operation(NodeOrAll, OperFunc, [Nodes, BridgeType, BridgeName])
|
|
|
+ call_operation(NodeOrAll, OperFunc, [Nodes, ConfRootKey, BridgeType, BridgeName])
|
|
|
catch
|
|
|
throw:not_found ->
|
|
|
?BRIDGE_NOT_FOUND(BridgeType, BridgeName)
|
|
|
end.
|
|
|
|
|
|
-is_enabled_bridge(BridgeType, BridgeName) ->
|
|
|
- try emqx_bridge_v2:lookup(BridgeType, binary_to_existing_atom(BridgeName)) of
|
|
|
+is_enabled_bridge(ConfRootKey, BridgeType, BridgeName) ->
|
|
|
+ try emqx_bridge_v2:lookup(ConfRootKey, BridgeType, binary_to_existing_atom(BridgeName)) of
|
|
|
{ok, #{raw_config := ConfMap}} ->
|
|
|
maps:get(<<"enable">>, ConfMap, false);
|
|
|
{error, not_found} ->
|
|
|
@@ -637,7 +694,7 @@ is_enabled_bridge(BridgeType, BridgeName) ->
|
|
|
throw(not_found)
|
|
|
end.
|
|
|
|
|
|
-call_operation(NodeOrAll, OperFunc, Args = [_Nodes, BridgeType, BridgeName]) ->
|
|
|
+call_operation(NodeOrAll, OperFunc, Args = [_Nodes, _ConfRootKey, BridgeType, BridgeName]) ->
|
|
|
case is_ok(do_bpapi_call(NodeOrAll, OperFunc, Args)) of
|
|
|
Ok when Ok =:= ok; is_tuple(Ok), element(1, Ok) =:= ok ->
|
|
|
?NO_CONTENT;
|
|
|
@@ -668,12 +725,12 @@ call_operation(NodeOrAll, OperFunc, Args = [_Nodes, BridgeType, BridgeName]) ->
|
|
|
|
|
|
do_bpapi_call(all, Call, Args) ->
|
|
|
maybe_unwrap(
|
|
|
- do_bpapi_call_vsn(emqx_bpapi:supported_version(emqx_bridge), Call, Args)
|
|
|
+ do_bpapi_call_vsn(emqx_bpapi:supported_version(?BPAPI_NAME), Call, Args)
|
|
|
);
|
|
|
do_bpapi_call(Node, Call, Args) ->
|
|
|
- case lists:member(Node, mria:running_nodes()) of
|
|
|
+ case lists:member(Node, emqx:running_nodes()) of
|
|
|
true ->
|
|
|
- do_bpapi_call_vsn(emqx_bpapi:supported_version(Node, emqx_bridge), Call, Args);
|
|
|
+ do_bpapi_call_vsn(emqx_bpapi:supported_version(Node, ?BPAPI_NAME), Call, Args);
|
|
|
false ->
|
|
|
{error, {node_not_found, Node}}
|
|
|
end.
|
|
|
@@ -681,7 +738,7 @@ do_bpapi_call(Node, Call, Args) ->
|
|
|
do_bpapi_call_vsn(Version, Call, Args) ->
|
|
|
case is_supported_version(Version, Call) of
|
|
|
true ->
|
|
|
- apply(emqx_bridge_proto_v5, Call, Args);
|
|
|
+ apply(emqx_bridge_proto_v6, Call, Args);
|
|
|
false ->
|
|
|
{error, not_implemented}
|
|
|
end.
|
|
|
@@ -689,7 +746,12 @@ do_bpapi_call_vsn(Version, Call, Args) ->
|
|
|
is_supported_version(Version, Call) ->
|
|
|
lists:member(Version, supported_versions(Call)).
|
|
|
|
|
|
-supported_versions(_Call) -> [5].
|
|
|
+supported_versions(_Call) -> bpapi_version_range(6, latest).
|
|
|
+
|
|
|
+%% [From, To] (inclusive on both ends)
|
|
|
+bpapi_version_range(From, latest) ->
|
|
|
+ ThisNodeVsn = emqx_bpapi:supported_version(node(), ?BPAPI_NAME),
|
|
|
+ lists:seq(From, ThisNodeVsn).
|
|
|
|
|
|
maybe_unwrap({error, not_implemented}) ->
|
|
|
{error, not_implemented};
|
|
|
@@ -767,10 +829,22 @@ lookup_from_local_node(BridgeType, BridgeName) ->
|
|
|
Error -> Error
|
|
|
end.
|
|
|
|
|
|
+%% RPC Target
|
|
|
+-spec lookup_from_local_node_v6(emqx_bridge_v2:root_cfg_key(), _, _) -> _.
|
|
|
+lookup_from_local_node_v6(ConfRootKey, BridgeType, BridgeName) ->
|
|
|
+ case emqx_bridge_v2:lookup(ConfRootKey, BridgeType, BridgeName) of
|
|
|
+ {ok, Res} -> {ok, format_resource(Res, node())};
|
|
|
+ Error -> Error
|
|
|
+ end.
|
|
|
+
|
|
|
%% RPC Target
|
|
|
get_metrics_from_local_node(ActionType, ActionName) ->
|
|
|
format_metrics(emqx_bridge_v2:get_metrics(ActionType, ActionName)).
|
|
|
|
|
|
+%% RPC Target
|
|
|
+get_metrics_from_local_node_v6(ConfRootKey, Type, Name) ->
|
|
|
+ format_metrics(emqx_bridge_v2:get_metrics(ConfRootKey, Type, Name)).
|
|
|
+
|
|
|
%% resource
|
|
|
format_resource(
|
|
|
#{
|
|
|
@@ -938,13 +1012,13 @@ format_resource_data(error, Error, Result) ->
|
|
|
format_resource_data(K, V, Result) ->
|
|
|
Result#{K => V}.
|
|
|
|
|
|
-create_bridge(BridgeType, BridgeName, Conf) ->
|
|
|
- create_or_update_bridge(BridgeType, BridgeName, Conf, 201).
|
|
|
+create_bridge(ConfRootKey, BridgeType, BridgeName, Conf) ->
|
|
|
+ create_or_update_bridge(ConfRootKey, BridgeType, BridgeName, Conf, 201).
|
|
|
|
|
|
-update_bridge(BridgeType, BridgeName, Conf) ->
|
|
|
- create_or_update_bridge(BridgeType, BridgeName, Conf, 200).
|
|
|
+update_bridge(ConfRootKey, BridgeType, BridgeName, Conf) ->
|
|
|
+ create_or_update_bridge(ConfRootKey, BridgeType, BridgeName, Conf, 200).
|
|
|
|
|
|
-create_or_update_bridge(BridgeType, BridgeName, Conf, HttpStatusCode) ->
|
|
|
+create_or_update_bridge(ConfRootKey, BridgeType, BridgeName, Conf, HttpStatusCode) ->
|
|
|
Check =
|
|
|
try
|
|
|
is_binary(BridgeType) andalso emqx_resource:validate_type(BridgeType),
|
|
|
@@ -955,15 +1029,15 @@ create_or_update_bridge(BridgeType, BridgeName, Conf, HttpStatusCode) ->
|
|
|
end,
|
|
|
case Check of
|
|
|
ok ->
|
|
|
- do_create_or_update_bridge(BridgeType, BridgeName, Conf, HttpStatusCode);
|
|
|
+ do_create_or_update_bridge(ConfRootKey, BridgeType, BridgeName, Conf, HttpStatusCode);
|
|
|
BadRequest ->
|
|
|
BadRequest
|
|
|
end.
|
|
|
|
|
|
-do_create_or_update_bridge(BridgeType, BridgeName, Conf, HttpStatusCode) ->
|
|
|
- case emqx_bridge_v2:create(BridgeType, BridgeName, Conf) of
|
|
|
+do_create_or_update_bridge(ConfRootKey, BridgeType, BridgeName, Conf, HttpStatusCode) ->
|
|
|
+ case emqx_bridge_v2:create(ConfRootKey, BridgeType, BridgeName, Conf) of
|
|
|
{ok, _} ->
|
|
|
- lookup_from_all_nodes(BridgeType, BridgeName, HttpStatusCode);
|
|
|
+ lookup_from_all_nodes(ConfRootKey, BridgeType, BridgeName, HttpStatusCode);
|
|
|
{error, {PreOrPostConfigUpdate, _HandlerMod, Reason}} when
|
|
|
PreOrPostConfigUpdate =:= pre_config_update;
|
|
|
PreOrPostConfigUpdate =:= post_config_update
|