|
@@ -88,16 +88,18 @@ get_response_body_schema() ->
|
|
|
bridge_info_examples(get)).
|
|
bridge_info_examples(get)).
|
|
|
|
|
|
|
|
param_path_operation() ->
|
|
param_path_operation() ->
|
|
|
- path_param(operation, enum([start, stop, restart]), <<"start">>).
|
|
|
|
|
|
|
+ {operation, mk(enum([start, stop, restart]),
|
|
|
|
|
+ #{ in => path
|
|
|
|
|
+ , required => true
|
|
|
|
|
+ , example => <<"start">>
|
|
|
|
|
+ })}.
|
|
|
|
|
|
|
|
param_path_id() ->
|
|
param_path_id() ->
|
|
|
- path_param(id, binary(), <<"http:my_http_bridge">>).
|
|
|
|
|
-
|
|
|
|
|
-path_param(Name, Type, Example) ->
|
|
|
|
|
- {Name, mk(Type,
|
|
|
|
|
|
|
+ {id, mk(binary(),
|
|
|
#{ in => path
|
|
#{ in => path
|
|
|
, required => true
|
|
, required => true
|
|
|
- , example => Example
|
|
|
|
|
|
|
+ , example => <<"http:my_http_bridge">>
|
|
|
|
|
+ , desc => <<"The bridge Id. Must be of format {type}:{name}">>
|
|
|
})}.
|
|
})}.
|
|
|
|
|
|
|
|
bridge_info_array_example(Method) ->
|
|
bridge_info_array_example(Method) ->
|
|
@@ -140,7 +142,6 @@ method_example(Type, Direction, get) ->
|
|
|
_ -> "my_" ++ SDir ++ "_" ++ SType ++ "_bridge"
|
|
_ -> "my_" ++ SDir ++ "_" ++ SType ++ "_bridge"
|
|
|
end,
|
|
end,
|
|
|
#{
|
|
#{
|
|
|
- id => bin(SType ++ ":" ++ SName),
|
|
|
|
|
type => bin(SType),
|
|
type => bin(SType),
|
|
|
name => bin(SName),
|
|
name => bin(SName),
|
|
|
metrics => ?METRICS(0, 0, 0, 0, 0, 0),
|
|
metrics => ?METRICS(0, 0, 0, 0, 0, 0),
|
|
@@ -216,7 +217,7 @@ schema("/bridges") ->
|
|
|
post => #{
|
|
post => #{
|
|
|
tags => [<<"bridges">>],
|
|
tags => [<<"bridges">>],
|
|
|
summary => <<"Create Bridge">>,
|
|
summary => <<"Create Bridge">>,
|
|
|
- description => <<"Create a new bridge">>,
|
|
|
|
|
|
|
+ description => <<"Create a new bridge by type and name">>,
|
|
|
requestBody => emqx_dashboard_swagger:schema_with_examples(
|
|
requestBody => emqx_dashboard_swagger:schema_with_examples(
|
|
|
emqx_bridge_schema:post_request(),
|
|
emqx_bridge_schema:post_request(),
|
|
|
bridge_info_examples(post)),
|
|
bridge_info_examples(post)),
|
|
@@ -243,7 +244,7 @@ schema("/bridges/:id") ->
|
|
|
put => #{
|
|
put => #{
|
|
|
tags => [<<"bridges">>],
|
|
tags => [<<"bridges">>],
|
|
|
summary => <<"Update Bridge">>,
|
|
summary => <<"Update Bridge">>,
|
|
|
- description => <<"Update a bridge">>,
|
|
|
|
|
|
|
+ description => <<"Update a bridge by Id">>,
|
|
|
parameters => [param_path_id()],
|
|
parameters => [param_path_id()],
|
|
|
requestBody => emqx_dashboard_swagger:schema_with_examples(
|
|
requestBody => emqx_dashboard_swagger:schema_with_examples(
|
|
|
emqx_bridge_schema:put_request(),
|
|
emqx_bridge_schema:put_request(),
|
|
@@ -257,7 +258,7 @@ schema("/bridges/:id") ->
|
|
|
delete => #{
|
|
delete => #{
|
|
|
tags => [<<"bridges">>],
|
|
tags => [<<"bridges">>],
|
|
|
summary => <<"Delete Bridge">>,
|
|
summary => <<"Delete Bridge">>,
|
|
|
- description => <<"Delete a bridge">>,
|
|
|
|
|
|
|
+ description => <<"Delete a bridge by Id">>,
|
|
|
parameters => [param_path_id()],
|
|
parameters => [param_path_id()],
|
|
|
responses => #{
|
|
responses => #{
|
|
|
204 => <<"Bridge deleted">>
|
|
204 => <<"Bridge deleted">>
|
|
@@ -271,7 +272,7 @@ schema("/bridges/:id/operation/:operation") ->
|
|
|
post => #{
|
|
post => #{
|
|
|
tags => [<<"bridges">>],
|
|
tags => [<<"bridges">>],
|
|
|
summary => <<"Start/Stop/Restart Bridge">>,
|
|
summary => <<"Start/Stop/Restart Bridge">>,
|
|
|
- description => <<"Start/Stop/Restart bridges on a specific node">>,
|
|
|
|
|
|
|
+ description => <<"Start/Stop/Restart bridges on a specific node.">>,
|
|
|
parameters => [
|
|
parameters => [
|
|
|
param_path_id(),
|
|
param_path_id(),
|
|
|
param_path_operation()
|
|
param_path_operation()
|
|
@@ -425,7 +426,6 @@ format_resp(#{id := Id, raw_config := RawConf,
|
|
|
{Type, BridgeName} = emqx_bridge:parse_bridge_id(Id),
|
|
{Type, BridgeName} = emqx_bridge:parse_bridge_id(Id),
|
|
|
IsConnected = fun(connected) -> connected; (_) -> disconnected end,
|
|
IsConnected = fun(connected) -> connected; (_) -> disconnected end,
|
|
|
RawConf#{
|
|
RawConf#{
|
|
|
- id => Id,
|
|
|
|
|
type => Type,
|
|
type => Type,
|
|
|
name => maps:get(<<"name">>, RawConf, BridgeName),
|
|
name => maps:get(<<"name">>, RawConf, BridgeName),
|
|
|
node => node(),
|
|
node => node(),
|