refactoring nodes -> hosts
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
from fastapi import APIRouter
|
||||
import logging
|
||||
from os import getenv
|
||||
from remnawave import RemnawaveSDK
|
||||
from remnawave.models.hosts import GetAllHostsResponseDto
|
||||
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
|
||||
router = APIRouter(prefix='/api/v1', tags=['hosts'])
|
||||
remnawave = RemnawaveSDK(base_url='http://remnawave:3000', token=getenv('REMNAWAVE_API_TOKEN'))
|
||||
|
||||
@router.get('/hosts')
|
||||
async def get_nodes():
|
||||
hosts: GetAllHostsResponseDto = await remnawave.hosts.get_all_hosts()
|
||||
return [
|
||||
|
||||
{
|
||||
'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