Adds new REST API v2/

Addresses #5269
This commit is contained in:
Simone Mainardi 2021-07-08 09:57:46 +02:00
parent 1f24dec3e3
commit b117e8a23a
178 changed files with 6639 additions and 124 deletions

View file

@ -376,7 +376,7 @@ print[[
</form>
<div style="float:left">
<form action="/lua/rest/v1/get/pool/config.lua" class="form-inline" method="GET" data-ays-ignore="true">
<form action="/lua/rest/v2/get/pool/config.lua" class="form-inline" method="GET" data-ays-ignore="true">
<input type="hidden" name="ifid" value="]] print(tostring(ifId)) print[[" />
<input type="hidden" name="download" value="true" />
<button type="submit" class="btn btn-secondary"><span>]] print(i18n("host_pools.config_export")) print[[</span></button>
@ -519,7 +519,7 @@ print[[
$button.removeAttr("disabled");
} else {
// Submit configuration file
$.post(`${http_prefix}/lua/rest/v1/set/pool/config.lua`, {
$.post(`${http_prefix}/lua/rest/v2/set/pool/config.lua`, {
csrf: import_csrf,
JSON: JSON.stringify(json_conf)
})

View file

@ -71,7 +71,7 @@ page_utils.print_navbar(i18n("pools.pools"), url, {
-- ************************************* ------
local ALL_POOL_GET_ENDPOINT = '/lua/rest/v1/get/pools.lua'
local ALL_POOL_GET_ENDPOINT = '/lua/rest/v2/get/pools.lua'
local pool_types = {
@ -126,10 +126,10 @@ for _, entry in ipairs(menu.entries) do
end
local rest_endpoints = {
get_all_pools = (page == "all" and ALL_POOL_GET_ENDPOINT or string.format(ntop.getHttpPrefix() .. "/lua/rest/v1/get/%s/pools.lua", pool_type)),
add_pool = string.format(ntop.getHttpPrefix() .. "/lua/rest/v1/add/%s/pool.lua", pool_type),
edit_pool = string.format(ntop.getHttpPrefix() .. "/lua/rest/v1/edit/%s/pool.lua", pool_type),
delete_pool = string.format(ntop.getHttpPrefix() .. "/lua/rest/v1/delete/%s/pool.lua", pool_type),
get_all_pools = (page == "all" and ALL_POOL_GET_ENDPOINT or string.format(ntop.getHttpPrefix() .. "/lua/rest/v2/get/%s/pools.lua", pool_type)),
add_pool = string.format(ntop.getHttpPrefix() .. "/lua/rest/v2/add/%s/pool.lua", pool_type),
edit_pool = string.format(ntop.getHttpPrefix() .. "/lua/rest/v2/edit/%s/pool.lua", pool_type),
delete_pool = string.format(ntop.getHttpPrefix() .. "/lua/rest/v2/delete/%s/pool.lua", pool_type),
}
local context = {