44 lines
1.1 KiB
Python
44 lines
1.1 KiB
Python
"""
|
|
工作手机SDK v3.0 - 抓包 API
|
|
"""
|
|
|
|
from fastapi import APIRouter, HTTPException
|
|
from pydantic import BaseModel
|
|
from typing import Optional, List
|
|
from services.capture_service import (
|
|
start_capture,
|
|
stop_capture,
|
|
get_capture_status,
|
|
get_capture_data,
|
|
)
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
class StartCaptureRequest(BaseModel):
|
|
device_id: str
|
|
|
|
|
|
class StopCaptureRequest(BaseModel):
|
|
device_id: str
|
|
|
|
|
|
@router.post("/api/v3/capture/start", response_model=dict)
|
|
async def api_start_capture(req: StartCaptureRequest):
|
|
return start_capture(req.device_id)
|
|
|
|
|
|
@router.post("/api/v3/capture/stop", response_model=dict)
|
|
async def api_stop_capture(req: StopCaptureRequest):
|
|
return stop_capture(req.device_id)
|
|
|
|
|
|
@router.get("/api/v3/capture/status/{device_id}", response_model=dict)
|
|
async def api_capture_status(device_id: str):
|
|
return get_capture_status(device_id)
|
|
|
|
|
|
@router.get("/api/v3/capture/data/{device_id}", response_model=dict)
|
|
async def api_capture_data(device_id: str, limit: int = 100, since: Optional[float] = None):
|
|
return get_capture_data(device_id, limit=limit, since_ts=since)
|