You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.9 KiB
42 lines
1.9 KiB
from fastapi import FastAPI
|
|
from fastapi.responses import HTMLResponse
|
|
from fastapi.requests import Request
|
|
from fastapi import Query
|
|
|
|
from pymongo.asynchronous.database import AsyncDatabase
|
|
from extra.MessageDTO import MessageDTO
|
|
from typing import List, Annotated
|
|
from pymongo import DESCENDING
|
|
|
|
class WebExtension:
|
|
MESSAGE_PORTNUM = 1
|
|
app: FastAPI
|
|
dbStore: AsyncDatabase
|
|
def __init__(self, core):
|
|
self.core = core
|
|
self.app = core.app
|
|
|
|
@self.app.get(f"{self.core.context}/packet/stats")
|
|
@self.core.authManager.authRequest()
|
|
async def findPacketsAndGroupCount(request: Request,
|
|
after: float = Query(-1),
|
|
before: float = Query(-1),
|
|
nums: List[int] = Query([]),
|
|
portnums: List[int] = Query([]),
|
|
packetsPerNode:bool = Query(False),
|
|
packetsSumNode:bool = Query(False),
|
|
devices: List[str] = Query([]),
|
|
ignore_host: bool = Query(True)):
|
|
gl = await self.core.dbService.findPacketsAndGroupCount(after, before, nums, portnums, packetsPerNode, packetsSumNode, devices, ignore_host)
|
|
return gl
|
|
|
|
@self.app.get(f"{self.core.context}/packet/signal")
|
|
@self.core.authManager.authRequest()
|
|
async def findPacketsAndGroupCount(request: Request,
|
|
after: float = Query(-1),
|
|
before: float = Query(-1),
|
|
nums: List[int] = Query([]),
|
|
devices: List[str] = Query([]),
|
|
ignore_host: bool = Query(True)):
|
|
gl = await self.core.dbService.findPacketsSignals(after, before, nums, devices, ignore_host)
|
|
return gl
|