refactor: remove emqx_bridge_v2_enterprise.erl
This commit is contained in:
parent
e93b71d8d5
commit
ca3e5eab11
|
@ -98,21 +98,11 @@ get_response_body_schema() ->
|
||||||
).
|
).
|
||||||
|
|
||||||
bridge_info_examples(Method) ->
|
bridge_info_examples(Method) ->
|
||||||
maps:merge(
|
emqx_bridge_v2_schema:examples(Method).
|
||||||
emqx_bridge_v2_schema:examples(Method),
|
|
||||||
emqx_enterprise_bridge_examples(Method)
|
|
||||||
).
|
|
||||||
|
|
||||||
bridge_info_array_example(Method) ->
|
bridge_info_array_example(Method) ->
|
||||||
lists:map(fun(#{value := Config}) -> Config end, maps:values(bridge_info_examples(Method))).
|
lists:map(fun(#{value := Config}) -> Config end, maps:values(bridge_info_examples(Method))).
|
||||||
|
|
||||||
-if(?EMQX_RELEASE_EDITION == ee).
|
|
||||||
emqx_enterprise_bridge_examples(Method) ->
|
|
||||||
emqx_bridge_v2_enterprise:examples(Method).
|
|
||||||
-else.
|
|
||||||
emqx_enterprise_bridge_examples(_Method) -> #{}.
|
|
||||||
-endif.
|
|
||||||
|
|
||||||
param_path_id() ->
|
param_path_id() ->
|
||||||
{id,
|
{id,
|
||||||
mk(
|
mk(
|
||||||
|
|
|
@ -82,9 +82,9 @@ schema_modules() ->
|
||||||
].
|
].
|
||||||
|
|
||||||
examples(Method) ->
|
examples(Method) ->
|
||||||
EnterpriseExamples = emqx_bridge_v2_enterprise:examples(Method),
|
ActionExamples = emqx_bridge_v2_schema:examples(Method),
|
||||||
RegisteredExamples = registered_examples(Method),
|
RegisteredExamples = registered_examples(Method),
|
||||||
maps:merge(EnterpriseExamples, RegisteredExamples).
|
maps:merge(ActionExamples, RegisteredExamples).
|
||||||
|
|
||||||
registered_examples(Method) ->
|
registered_examples(Method) ->
|
||||||
MergeFun =
|
MergeFun =
|
||||||
|
|
|
@ -1,42 +0,0 @@
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Copyright (c) 2022-2023 EMQ Technologies Co., Ltd. All Rights Reserved.
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
-module(emqx_bridge_v2_enterprise).
|
|
||||||
|
|
||||||
-if(?EMQX_RELEASE_EDITION == ee).
|
|
||||||
|
|
||||||
-import(hoconsc, [mk/2, enum/1, ref/2]).
|
|
||||||
|
|
||||||
-export([
|
|
||||||
api_schemas/1,
|
|
||||||
examples/1,
|
|
||||||
fields/1
|
|
||||||
]).
|
|
||||||
|
|
||||||
examples(Method) ->
|
|
||||||
MergeFun =
|
|
||||||
fun(Example, Examples) ->
|
|
||||||
maps:merge(Examples, Example)
|
|
||||||
end,
|
|
||||||
Fun =
|
|
||||||
fun(Module, Examples) ->
|
|
||||||
ConnectorExamples = erlang:apply(Module, bridge_v2_examples, [Method]),
|
|
||||||
lists:foldl(MergeFun, Examples, ConnectorExamples)
|
|
||||||
end,
|
|
||||||
lists:foldl(Fun, #{}, schema_modules()).
|
|
||||||
|
|
||||||
schema_modules() ->
|
|
||||||
[].
|
|
||||||
|
|
||||||
fields(actions) ->
|
|
||||||
action_structs().
|
|
||||||
|
|
||||||
action_structs() ->
|
|
||||||
[].
|
|
||||||
|
|
||||||
api_schemas(_Method) ->
|
|
||||||
[].
|
|
||||||
|
|
||||||
-else.
|
|
||||||
|
|
||||||
-endif.
|
|
|
@ -33,46 +33,11 @@
|
||||||
|
|
||||||
-export([types/0, types_sc/0]).
|
-export([types/0, types_sc/0]).
|
||||||
|
|
||||||
-export([enterprise_api_schemas/1]).
|
|
||||||
|
|
||||||
-export_type([action_type/0]).
|
-export_type([action_type/0]).
|
||||||
|
|
||||||
%% Should we explicitly list them here so dialyzer may be more helpful?
|
%% Should we explicitly list them here so dialyzer may be more helpful?
|
||||||
-type action_type() :: atom().
|
-type action_type() :: atom().
|
||||||
|
|
||||||
-if(?EMQX_RELEASE_EDITION == ee).
|
|
||||||
-spec enterprise_api_schemas(Method) -> [{_Type :: binary(), ?R_REF(module(), Method)}] when
|
|
||||||
Method :: string().
|
|
||||||
enterprise_api_schemas(Method) ->
|
|
||||||
%% We *must* do this to ensure the module is really loaded, especially when we use
|
|
||||||
%% `call_hocon' from `nodetool' to generate initial configurations.
|
|
||||||
_ = emqx_bridge_v2_enterprise:module_info(),
|
|
||||||
case erlang:function_exported(emqx_bridge_v2_enterprise, api_schemas, 1) of
|
|
||||||
true -> emqx_bridge_v2_enterprise:api_schemas(Method);
|
|
||||||
false -> []
|
|
||||||
end.
|
|
||||||
|
|
||||||
enterprise_fields_actions() ->
|
|
||||||
%% We *must* do this to ensure the module is really loaded, especially when we use
|
|
||||||
%% `call_hocon' from `nodetool' to generate initial configurations.
|
|
||||||
_ = emqx_bridge_v2_enterprise:module_info(),
|
|
||||||
case erlang:function_exported(emqx_bridge_v2_enterprise, fields, 1) of
|
|
||||||
true ->
|
|
||||||
emqx_bridge_v2_enterprise:fields(actions);
|
|
||||||
false ->
|
|
||||||
[]
|
|
||||||
end.
|
|
||||||
|
|
||||||
-else.
|
|
||||||
|
|
||||||
-spec enterprise_api_schemas(Method) -> [{_Type :: binary(), ?R_REF(module(), Method)}] when
|
|
||||||
Method :: string().
|
|
||||||
enterprise_api_schemas(_Method) -> [].
|
|
||||||
|
|
||||||
enterprise_fields_actions() -> [].
|
|
||||||
|
|
||||||
-endif.
|
|
||||||
|
|
||||||
%%======================================================================================
|
%%======================================================================================
|
||||||
%% For HTTP APIs
|
%% For HTTP APIs
|
||||||
get_response() ->
|
get_response() ->
|
||||||
|
@ -85,9 +50,8 @@ post_request() ->
|
||||||
api_schema("post").
|
api_schema("post").
|
||||||
|
|
||||||
api_schema(Method) ->
|
api_schema(Method) ->
|
||||||
EE = ?MODULE:enterprise_api_schemas(Method),
|
|
||||||
APISchemas = registered_api_schemas(Method),
|
APISchemas = registered_api_schemas(Method),
|
||||||
hoconsc:union(bridge_api_union(EE ++ APISchemas)).
|
hoconsc:union(bridge_api_union(APISchemas)).
|
||||||
|
|
||||||
registered_api_schemas(Method) ->
|
registered_api_schemas(Method) ->
|
||||||
RegisteredSchemas = emqx_action_info:registered_schema_modules(),
|
RegisteredSchemas = emqx_action_info:registered_schema_modules(),
|
||||||
|
@ -145,8 +109,7 @@ roots() ->
|
||||||
end.
|
end.
|
||||||
|
|
||||||
fields(actions) ->
|
fields(actions) ->
|
||||||
enterprise_fields_actions() ++
|
registered_schema_fields().
|
||||||
registered_schema_fields().
|
|
||||||
|
|
||||||
registered_schema_fields() ->
|
registered_schema_fields() ->
|
||||||
[
|
[
|
||||||
|
|
Loading…
Reference in New Issue