Add pool_name_only param to v2/get/host/pool_by_member.lua

This commit is contained in:
Alfredo Cardigliano 2024-06-17 11:55:30 +02:00
parent a3c32acf23
commit 196e65ff7e
3 changed files with 17 additions and 1 deletions

View file

@ -328,6 +328,7 @@ end
-- @brief Get one or all pools
function pools_rest_utils.get_pool_by_member(pools)
local member = fixPoolMemberFormat(_POST["member"])
local pool_name_only = toboolean(_POST["pool_name_only"])
if not member then
rest_utils.answer(rest_utils.consts.err.invalid_args)
@ -340,7 +341,14 @@ function pools_rest_utils.get_pool_by_member(pools)
local s = pools:create()
local cur_pool = s:get_pool_by_member(member)
if cur_pool then
res = cur_pool
if pool_name_only then
res = {
pool_id = cur_pool.pool_id,
name = cur_pool.name,
}
else
res = cur_pool
end
end
local rc = rest_utils.consts.success.ok