refactoring nodes -> hosts
This commit is contained in:
@@ -2,7 +2,7 @@ from fastapi import FastAPI
|
|||||||
import tomllib
|
import tomllib
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from routers import ip, tariffs, nodes
|
from routers import hosts, ip, tariffs
|
||||||
|
|
||||||
logging.basicConfig(level=logging.INFO)
|
logging.basicConfig(level=logging.INFO)
|
||||||
|
|
||||||
@@ -23,4 +23,4 @@ async def health_check():
|
|||||||
|
|
||||||
app.include_router(ip.router)
|
app.include_router(ip.router)
|
||||||
app.include_router(tariffs.router)
|
app.include_router(tariffs.router)
|
||||||
app.include_router(nodes.router)
|
app.include_router(hosts.router)
|
||||||
@@ -6,11 +6,19 @@ from remnawave.models.hosts import GetAllHostsResponseDto
|
|||||||
|
|
||||||
logging.basicConfig(level=logging.INFO)
|
logging.basicConfig(level=logging.INFO)
|
||||||
|
|
||||||
router = APIRouter(prefix='/api/v1', tags=['nodes'])
|
router = APIRouter(prefix='/api/v1', tags=['hosts'])
|
||||||
remnawave = RemnawaveSDK(base_url='http://remnawave:3000', token=getenv('REMNAWAVE_API_TOKEN'))
|
remnawave = RemnawaveSDK(base_url='http://remnawave:3000', token=getenv('REMNAWAVE_API_TOKEN'))
|
||||||
|
|
||||||
@router.get('/nodes')
|
@router.get('/hosts')
|
||||||
async def get_nodes():
|
async def get_nodes():
|
||||||
hosts: GetAllHostsResponseDto = await remnawave.hosts.get_all_hosts()
|
hosts: GetAllHostsResponseDto = await remnawave.hosts.get_all_hosts()
|
||||||
|
return [
|
||||||
|
|
||||||
return hosts.root
|
{
|
||||||
|
'name': host.remark,
|
||||||
|
'address': host.address,
|
||||||
|
'port': host.port
|
||||||
|
}
|
||||||
|
|
||||||
|
for host in hosts.root if not host.is_disabled and not host.is_hidden
|
||||||
|
]
|
||||||
Reference in New Issue
Block a user