fix(plugin): plugin's mgmt api schema codes
This commit is contained in:
parent
6af651cf2f
commit
71cdcc860a
|
@ -105,7 +105,7 @@ schema("/plugins/install") ->
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
responses => #{
|
responses => #{
|
||||||
200 => <<"OK">>,
|
204 => <<"Install plugin successfully">>,
|
||||||
400 => emqx_dashboard_swagger:error_codes(
|
400 => emqx_dashboard_swagger:error_codes(
|
||||||
['UNEXPECTED_ERROR', 'ALREADY_INSTALLED', 'BAD_PLUGIN_INFO']
|
['UNEXPECTED_ERROR', 'ALREADY_INSTALLED', 'BAD_PLUGIN_INFO']
|
||||||
)
|
)
|
||||||
|
@ -117,7 +117,7 @@ schema("/plugins/:name") ->
|
||||||
'operationId' => plugin,
|
'operationId' => plugin,
|
||||||
get => #{
|
get => #{
|
||||||
summary => <<"Get a plugin description">>,
|
summary => <<"Get a plugin description">>,
|
||||||
description => "Describs plugin according to its `release.json` and `README.md`.",
|
description => "Describe a plugin according to its `release.json` and `README.md`.",
|
||||||
tags => ?TAGS,
|
tags => ?TAGS,
|
||||||
parameters => [hoconsc:ref(name)],
|
parameters => [hoconsc:ref(name)],
|
||||||
responses => #{
|
responses => #{
|
||||||
|
@ -152,7 +152,7 @@ schema("/plugins/:name/:action") ->
|
||||||
{action, hoconsc:mk(hoconsc:enum([start, stop]), #{desc => "Action", in => path})}
|
{action, hoconsc:mk(hoconsc:enum([start, stop]), #{desc => "Action", in => path})}
|
||||||
],
|
],
|
||||||
responses => #{
|
responses => #{
|
||||||
200 => <<"OK">>,
|
204 => <<"Trigger action successfully">>,
|
||||||
404 => emqx_dashboard_swagger:error_codes(['NOT_FOUND'], <<"Plugin Not Found">>)
|
404 => emqx_dashboard_swagger:error_codes(['NOT_FOUND'], <<"Plugin Not Found">>)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -161,13 +161,13 @@ schema("/plugins/:name/move") ->
|
||||||
#{
|
#{
|
||||||
'operationId' => update_boot_order,
|
'operationId' => update_boot_order,
|
||||||
post => #{
|
post => #{
|
||||||
summary => <<"Move plugin within plugin hiearchy">>,
|
summary => <<"Move plugin within plugin hierarchy">>,
|
||||||
description => "Setting the boot order of plugins.",
|
description => "Setting the boot order of plugins.",
|
||||||
tags => ?TAGS,
|
tags => ?TAGS,
|
||||||
parameters => [hoconsc:ref(name)],
|
parameters => [hoconsc:ref(name)],
|
||||||
'requestBody' => move_request_body(),
|
'requestBody' => move_request_body(),
|
||||||
responses => #{
|
responses => #{
|
||||||
200 => <<"OK">>,
|
204 => <<"Boot order changed successfully">>,
|
||||||
400 => emqx_dashboard_swagger:error_codes(['MOVE_FAILED'], <<"Move failed">>)
|
400 => emqx_dashboard_swagger:error_codes(['MOVE_FAILED'], <<"Move failed">>)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -382,7 +382,7 @@ do_install_package(FileName, Bin) ->
|
||||||
{[_ | _] = Res, []} = emqx_mgmt_api_plugins_proto_v2:install_package(Nodes, FileName, Bin),
|
{[_ | _] = Res, []} = emqx_mgmt_api_plugins_proto_v2:install_package(Nodes, FileName, Bin),
|
||||||
case lists:filter(fun(R) -> R =/= ok end, Res) of
|
case lists:filter(fun(R) -> R =/= ok end, Res) of
|
||||||
[] ->
|
[] ->
|
||||||
{200};
|
{204};
|
||||||
Filtered ->
|
Filtered ->
|
||||||
%% crash if we have unexpected errors or results
|
%% crash if we have unexpected errors or results
|
||||||
[] = lists:filter(
|
[] = lists:filter(
|
||||||
|
@ -425,7 +425,7 @@ update_boot_order(post, #{bindings := #{name := Name}, body := Body}) ->
|
||||||
Position ->
|
Position ->
|
||||||
case emqx_plugins:ensure_enabled(Name, Position, _ConfLocation = global) of
|
case emqx_plugins:ensure_enabled(Name, Position, _ConfLocation = global) of
|
||||||
ok ->
|
ok ->
|
||||||
{200};
|
{204};
|
||||||
{error, Reason} ->
|
{error, Reason} ->
|
||||||
{400, #{
|
{400, #{
|
||||||
code => 'MOVE_FAILED',
|
code => 'MOVE_FAILED',
|
||||||
|
|
|
@ -271,7 +271,7 @@ install_plugin(FilePath) ->
|
||||||
Token
|
Token
|
||||||
)
|
)
|
||||||
of
|
of
|
||||||
{ok, {{"HTTP/1.1", 200, "OK"}, _Headers, <<>>}} -> ok;
|
{ok, {{"HTTP/1.1", 204, "No Content"}, _Headers, <<>>}} -> ok;
|
||||||
Error -> Error
|
Error -> Error
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -288,7 +288,7 @@ install_plugin(Config, FilePath) ->
|
||||||
Auth
|
Auth
|
||||||
)
|
)
|
||||||
of
|
of
|
||||||
{ok, {{"HTTP/1.1", 200, "OK"}, _Headers, <<>>}} -> ok;
|
{ok, {{"HTTP/1.1", 204, "No Content"}, _Headers, <<>>}} -> ok;
|
||||||
Error -> Error
|
Error -> Error
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue