fix: generate connector & exhook & retainer api response code
This commit is contained in:
parent
60f107f91f
commit
4d4348759d
|
@ -117,7 +117,7 @@ param_path_id() ->
|
||||||
[{id, mk(binary(),
|
[{id, mk(binary(),
|
||||||
#{ in => path
|
#{ in => path
|
||||||
, example => <<"mqtt:my_mqtt_connector">>
|
, example => <<"mqtt:my_mqtt_connector">>
|
||||||
, desc => <<"The connector Id. Must be of format {type}:{name}">>
|
, description => <<"The connector Id. Must be of format {type}:{name}">>
|
||||||
})}].
|
})}].
|
||||||
|
|
||||||
schema("/connectors_test") ->
|
schema("/connectors_test") ->
|
||||||
|
|
|
@ -92,12 +92,11 @@ stop_listeners() ->
|
||||||
%% internal
|
%% internal
|
||||||
|
|
||||||
apps() ->
|
apps() ->
|
||||||
[emqx_management].
|
[App || {App, _, _} <- application:loaded_applications(),
|
||||||
% [App || {App, _, _} <- application:loaded_applications(),
|
case re:run(atom_to_list(App), "^emqx") of
|
||||||
% case re:run(atom_to_list(App), "^emqx") of
|
{match,[{0,4}]} -> true;
|
||||||
% {match,[{0,4}]} -> true;
|
_ -> false
|
||||||
% _ -> false
|
end].
|
||||||
% end].
|
|
||||||
|
|
||||||
listeners() ->
|
listeners() ->
|
||||||
[begin
|
[begin
|
||||||
|
|
|
@ -120,7 +120,7 @@ schema("/exhooks/:name/move") ->
|
||||||
}.
|
}.
|
||||||
|
|
||||||
fields(move_req) ->
|
fields(move_req) ->
|
||||||
[{position, mk(string(), #{ desc => <<"The target position to be moved.">>
|
[{position, mk(string(), #{ description => <<"The target position to be moved.">>
|
||||||
, example => <<"front">>})}];
|
, example => <<"front">>})}];
|
||||||
|
|
||||||
fields(detail_server_info) ->
|
fields(detail_server_info) ->
|
||||||
|
@ -131,9 +131,9 @@ fields(detail_server_info) ->
|
||||||
] ++ emqx_exhook_schema:server_config();
|
] ++ emqx_exhook_schema:server_config();
|
||||||
|
|
||||||
fields(list_hook_info) ->
|
fields(list_hook_info) ->
|
||||||
[ {name, mk(binary(), #{desc => <<"The hook's name">>})}
|
[ {name, mk(binary(), #{description => <<"The hook's name">>})}
|
||||||
, {params, mk(map(name, binary()),
|
, {params, mk(map(name, binary()),
|
||||||
#{desc => <<"The parameters used when the hook is registered">>})}
|
#{description => <<"The parameters used when the hook is registered">>})}
|
||||||
, {metrics, mk(ref(metrics), #{})}
|
, {metrics, mk(ref(metrics), #{})}
|
||||||
, {node_metrics, mk(array(ref(node_metrics)), #{})}
|
, {node_metrics, mk(array(ref(node_metrics)), #{})}
|
||||||
];
|
];
|
||||||
|
@ -149,9 +149,9 @@ fields(node_status) ->
|
||||||
];
|
];
|
||||||
|
|
||||||
fields(hook_info) ->
|
fields(hook_info) ->
|
||||||
[ {name, mk(binary(), #{desc => <<"The hook's name">>})}
|
[ {name, mk(binary(), #{description => <<"The hook's name">>})}
|
||||||
, {params, mk(map(name, binary()),
|
, {params, mk(map(name, binary()),
|
||||||
#{desc => <<"The parameters used when the hook is registered">>})}
|
#{description => <<"The parameters used when the hook is registered">>})}
|
||||||
];
|
];
|
||||||
|
|
||||||
fields(metrics) ->
|
fields(metrics) ->
|
||||||
|
|
|
@ -55,7 +55,7 @@ schema(?PREFIX) ->
|
||||||
description => <<"Update retainer config">>,
|
description => <<"Update retainer config">>,
|
||||||
'requestBody' => mk(conf_schema(), #{desc => "The config content"}),
|
'requestBody' => mk(conf_schema(), #{desc => "The config content"}),
|
||||||
responses => #{200 => mk(conf_schema(), #{desc => "Update configs successfully"}),
|
responses => #{200 => mk(conf_schema(), #{desc => "Update configs successfully"}),
|
||||||
404 => error_codes(['UPDATE_FAILED'], <<"Update config failed">>)
|
400 => error_codes(['UPDATE_FAILED'], <<"Update config failed">>)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -66,7 +66,7 @@ schema(?PREFIX ++ "/messages") ->
|
||||||
description => <<"List retained messages">>,
|
description => <<"List retained messages">>,
|
||||||
parameters => page_params(),
|
parameters => page_params(),
|
||||||
responses => #{200 => mk(array(ref(message_summary)), #{desc => "The result list"}),
|
responses => #{200 => mk(array(ref(message_summary)), #{desc => "The result list"}),
|
||||||
405 => error_codes(['ACTION_NOT_ALLOWED'], <<"Unsupported backend">>)
|
400 => error_codes(['BAD_REQUEST'], <<"Unsupported backend">>)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -78,14 +78,14 @@ schema(?PREFIX ++ "/message/:topic") ->
|
||||||
parameters => parameters(),
|
parameters => parameters(),
|
||||||
responses => #{200 => mk(ref(message), #{desc => "Details of the message"}),
|
responses => #{200 => mk(ref(message), #{desc => "Details of the message"}),
|
||||||
404 => error_codes(['NOT_FOUND'], <<"Viewed message doesn't exist">>),
|
404 => error_codes(['NOT_FOUND'], <<"Viewed message doesn't exist">>),
|
||||||
405 => error_codes(['ACTION_NOT_ALLOWED'], <<"Unsupported backend">>)
|
400 => error_codes(['BAD_REQUEST'], <<"Unsupported backend">>)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
delete => #{tags => ?TAGS,
|
delete => #{tags => ?TAGS,
|
||||||
description => <<"Delete matching messages">>,
|
description => <<"Delete matching messages">>,
|
||||||
parameters => parameters(),
|
parameters => parameters(),
|
||||||
responses => #{204 => <<>>,
|
responses => #{204 => <<>>,
|
||||||
405 => error_codes(['ACTION_NOT_ALLOWED'],
|
400 => error_codes(['BAD_REQUEST'],
|
||||||
<<"Unsupported backend">>)
|
<<"Unsupported backend">>)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -191,8 +191,5 @@ check_backend(Type, Params, Cont) ->
|
||||||
built_in_database ->
|
built_in_database ->
|
||||||
Cont(Type, Params);
|
Cont(Type, Params);
|
||||||
_ ->
|
_ ->
|
||||||
{405,
|
{400, 'BAD_REQUEST', <<"This API only support built in database">>}
|
||||||
#{code => <<"ACTION_NOT_ALLOWED">>,
|
|
||||||
message => <<"This API only for built in database">>}
|
|
||||||
}
|
|
||||||
end.
|
end.
|
||||||
|
|
Loading…
Reference in New Issue