feat(emqx_bridge): shorten operation endpoint URLs
This shortens and simplifies URLs for performing bridge operations so that the API looks more congruent.
This commit is contained in:
parent
a26c05f4f6
commit
c2fd1a4482
|
@ -36,8 +36,8 @@
|
||||||
-export([
|
-export([
|
||||||
'/bridges'/2,
|
'/bridges'/2,
|
||||||
'/bridges/:id'/2,
|
'/bridges/:id'/2,
|
||||||
'/bridges/:id/operation/:operation'/2,
|
'/bridges/:id/:operation'/2,
|
||||||
'/nodes/:node/bridges/:id/operation/:operation'/2,
|
'/nodes/:node/bridges/:id/:operation'/2,
|
||||||
'/bridges/:id/reset_metrics'/2
|
'/bridges/:id/reset_metrics'/2
|
||||||
]).
|
]).
|
||||||
|
|
||||||
|
@ -66,8 +66,8 @@ paths() ->
|
||||||
[
|
[
|
||||||
"/bridges",
|
"/bridges",
|
||||||
"/bridges/:id",
|
"/bridges/:id",
|
||||||
"/bridges/:id/operation/:operation",
|
"/bridges/:id/:operation",
|
||||||
"/nodes/:node/bridges/:id/operation/:operation",
|
"/nodes/:node/bridges/:id/:operation",
|
||||||
"/bridges/:id/reset_metrics"
|
"/bridges/:id/reset_metrics"
|
||||||
].
|
].
|
||||||
|
|
||||||
|
@ -348,9 +348,9 @@ schema("/bridges/:id/reset_metrics") ->
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
schema("/bridges/:id/operation/:operation") ->
|
schema("/bridges/:id/:operation") ->
|
||||||
#{
|
#{
|
||||||
'operationId' => '/bridges/:id/operation/:operation',
|
'operationId' => '/bridges/:id/:operation',
|
||||||
post => #{
|
post => #{
|
||||||
tags => [<<"bridges">>],
|
tags => [<<"bridges">>],
|
||||||
summary => <<"Enable/Disable/Stop/Restart Bridge">>,
|
summary => <<"Enable/Disable/Stop/Restart Bridge">>,
|
||||||
|
@ -366,9 +366,9 @@ schema("/bridges/:id/operation/:operation") ->
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
schema("/nodes/:node/bridges/:id/operation/:operation") ->
|
schema("/nodes/:node/bridges/:id/:operation") ->
|
||||||
#{
|
#{
|
||||||
'operationId' => '/nodes/:node/bridges/:id/operation/:operation',
|
'operationId' => '/nodes/:node/bridges/:id/:operation',
|
||||||
post => #{
|
post => #{
|
||||||
tags => [<<"bridges">>],
|
tags => [<<"bridges">>],
|
||||||
summary => <<"Stop/Restart Bridge">>,
|
summary => <<"Stop/Restart Bridge">>,
|
||||||
|
@ -485,7 +485,7 @@ lookup_from_local_node(BridgeType, BridgeName) ->
|
||||||
Error -> Error
|
Error -> Error
|
||||||
end.
|
end.
|
||||||
|
|
||||||
'/bridges/:id/operation/:operation'(post, #{
|
'/bridges/:id/:operation'(post, #{
|
||||||
bindings :=
|
bindings :=
|
||||||
#{id := Id, operation := Op}
|
#{id := Id, operation := Op}
|
||||||
}) ->
|
}) ->
|
||||||
|
@ -513,7 +513,7 @@ lookup_from_local_node(BridgeType, BridgeName) ->
|
||||||
end
|
end
|
||||||
).
|
).
|
||||||
|
|
||||||
'/nodes/:node/bridges/:id/operation/:operation'(post, #{
|
'/nodes/:node/bridges/:id/:operation'(post, #{
|
||||||
bindings :=
|
bindings :=
|
||||||
#{id := Id, operation := Op, node := Node}
|
#{id := Id, operation := Op, node := Node}
|
||||||
}) ->
|
}) ->
|
||||||
|
|
|
@ -600,9 +600,9 @@ t_with_redact_update(_Config) ->
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
operation_path(node, Oper, BridgeID) ->
|
operation_path(node, Oper, BridgeID) ->
|
||||||
uri(["nodes", node(), "bridges", BridgeID, "operation", Oper]);
|
uri(["nodes", node(), "bridges", BridgeID, Oper]);
|
||||||
operation_path(cluster, Oper, BridgeID) ->
|
operation_path(cluster, Oper, BridgeID) ->
|
||||||
uri(["bridges", BridgeID, "operation", Oper]).
|
uri(["bridges", BridgeID, Oper]).
|
||||||
|
|
||||||
str(S) when is_list(S) -> S;
|
str(S) when is_list(S) -> S;
|
||||||
str(S) when is_binary(S) -> binary_to_list(S).
|
str(S) when is_binary(S) -> binary_to_list(S).
|
||||||
|
|
Loading…
Reference in New Issue