add get public and storage feature
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
from fastapi import APIRouter, Depends, HTTPException, status
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.dependencies import get_auth_db, get_current_auth_session
|
||||
from app.schemas.public_ip import PublicIPCheckResponse
|
||||
from app.services.auth import AuthenticatedSession
|
||||
from app.services.public_ip import check_public_ipv4
|
||||
|
||||
router = APIRouter(tags=["public-ip"])
|
||||
|
||||
|
||||
@router.get("/public-ip/check", response_model=PublicIPCheckResponse)
|
||||
def run_public_ip_check(
|
||||
session: Session = Depends(get_auth_db),
|
||||
current_auth: AuthenticatedSession | None = Depends(get_current_auth_session),
|
||||
) -> PublicIPCheckResponse:
|
||||
if current_auth is None:
|
||||
raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail="authentication required")
|
||||
|
||||
result = check_public_ipv4(session)
|
||||
return PublicIPCheckResponse(
|
||||
status=result.status,
|
||||
checked_at=result.checked_at,
|
||||
changed=result.changed,
|
||||
)
|
||||
Reference in New Issue
Block a user