diff --git a/apps/emqx_connector/src/emqx_connector_api.erl b/apps/emqx_connector/src/emqx_connector_api.erl index 2b77d7ac2..9db9f2a93 100644 --- a/apps/emqx_connector/src/emqx_connector_api.erl +++ b/apps/emqx_connector/src/emqx_connector_api.erl @@ -209,7 +209,7 @@ schema("/connectors/:id") -> end. '/connectors'(get, _Request) -> - {200, emqx_connector:list()}; + {200, [format_resp(Conn) || Conn <- emqx_connector:list()]}; '/connectors'(post, #{body := #{<<"type">> := ConnType} = Params}) -> 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) -> #{code => Code, message => bin(io_lib:format("~p", [Msg]))}. +format_resp(#{<<"id">> := Id} = RawConf) -> + format_resp(Id, RawConf). + format_resp(ConnId, RawConf) -> NumOfBridges = length(emqx_bridge:list_bridges_by_connector(ConnId)), + {Type, Name} = emqx_connector:parse_connector_id(ConnId), RawConf#{ <<"id">> => ConnId, + <<"type">> => Type, + <<"name">> => Name, <<"num_of_bridges">> => NumOfBridges }. diff --git a/apps/emqx_connector/src/mqtt/emqx_connector_mqtt_schema.erl b/apps/emqx_connector/src/mqtt/emqx_connector_mqtt_schema.erl index 2338129d1..a29acb8f8 100644 --- a/apps/emqx_connector/src/mqtt/emqx_connector_mqtt_schema.erl +++ b/apps/emqx_connector/src/mqtt/emqx_connector_mqtt_schema.erl @@ -8,7 +8,7 @@ %% http://www.apache.org/licenses/LICENSE-2.0 %% %% 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. %% See the License for the specific language governing permissions and %% limitations under the License.