fix(connector): add type and name in repsonse of GET /connectors
This commit is contained in:
parent
8be2aaf72c
commit
9b34f6f9a3
|
@ -209,7 +209,7 @@ schema("/connectors/:id") ->
|
||||||
end.
|
end.
|
||||||
|
|
||||||
'/connectors'(get, _Request) ->
|
'/connectors'(get, _Request) ->
|
||||||
{200, emqx_connector:list()};
|
{200, [format_resp(Conn) || Conn <- emqx_connector:list()]};
|
||||||
|
|
||||||
'/connectors'(post, #{body := #{<<"type">> := ConnType} = Params}) ->
|
'/connectors'(post, #{body := #{<<"type">> := ConnType} = Params}) ->
|
||||||
ConnName = maps:get(<<"name">>, Params, emqx_misc:gen_id()),
|
ConnName = maps:get(<<"name">>, Params, emqx_misc:gen_id()),
|
||||||
|
@ -264,10 +264,16 @@ error_msg(Code, Msg) when is_binary(Msg) ->
|
||||||
error_msg(Code, Msg) ->
|
error_msg(Code, Msg) ->
|
||||||
#{code => Code, message => bin(io_lib:format("~p", [Msg]))}.
|
#{code => Code, message => bin(io_lib:format("~p", [Msg]))}.
|
||||||
|
|
||||||
|
format_resp(#{<<"id">> := Id} = RawConf) ->
|
||||||
|
format_resp(Id, RawConf).
|
||||||
|
|
||||||
format_resp(ConnId, RawConf) ->
|
format_resp(ConnId, RawConf) ->
|
||||||
NumOfBridges = length(emqx_bridge:list_bridges_by_connector(ConnId)),
|
NumOfBridges = length(emqx_bridge:list_bridges_by_connector(ConnId)),
|
||||||
|
{Type, Name} = emqx_connector:parse_connector_id(ConnId),
|
||||||
RawConf#{
|
RawConf#{
|
||||||
<<"id">> => ConnId,
|
<<"id">> => ConnId,
|
||||||
|
<<"type">> => Type,
|
||||||
|
<<"name">> => Name,
|
||||||
<<"num_of_bridges">> => NumOfBridges
|
<<"num_of_bridges">> => NumOfBridges
|
||||||
}.
|
}.
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
%% http://www.apache.org/licenses/LICENSE-2.0
|
%% http://www.apache.org/licenses/LICENSE-2.0
|
||||||
%%
|
%%
|
||||||
%% Unless required by applicable law or agreed to in writing, software
|
%% Unless required by applicable law or agreed to in writing, software
|
||||||
%% cluster_shareload under the License is cluster_shareload on an "AS IS" BASIS,
|
%% distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
%% See the License for the specific language governing permissions and
|
%% See the License for the specific language governing permissions and
|
||||||
%% limitations under the License.
|
%% limitations under the License.
|
||||||
|
|
Loading…
Reference in New Issue