Skip to content

Commit

Permalink
Merge pull request #220 from ninoseki/status-endpoint
Browse files Browse the repository at this point in the history
refactor: introduce status API endpoint
  • Loading branch information
ninoseki authored Mar 9, 2024
2 parents 1eaf554 + 32063a3 commit 0571b7c
Show file tree
Hide file tree
Showing 17 changed files with 750 additions and 610 deletions.
3 changes: 2 additions & 1 deletion backend/api/api.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from fastapi import APIRouter

from backend.api.endpoints import analyze, cache, lookup, submit
from backend.api.endpoints import analyze, cache, lookup, status, submit

api_router = APIRouter()
api_router.include_router(analyze.router, prefix="/analyze", tags=["analyze"])
api_router.include_router(submit.router, prefix="/submit", tags=["submit"])
api_router.include_router(lookup.router, prefix="/lookup", tags=["lookup"])
api_router.include_router(cache.router, prefix="/cache", tags=["cache"])
api_router.include_router(status.router, prefix="/status", tags=["status"])
22 changes: 22 additions & 0 deletions backend/api/endpoints/status.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from fastapi import APIRouter

from backend import dependencies, schemas

router = APIRouter()


@router.get("/")
async def get_status(
optional_redis: dependencies.OptionalRedis,
optional_email_rep: dependencies.OptionalEmailRep,
optional_inquest: dependencies.OptionalInQuest,
optional_vt: dependencies.OptionalVirusTotal,
optional_urlscan: dependencies.OptionalUrlScan,
) -> schemas.Status:
return schemas.Status(
cache=optional_redis is not None,
vt=optional_vt is not None,
inquest=optional_inquest is not None,
email_rep=optional_email_rep is not None,
urlscan=optional_urlscan is not None,
)
1 change: 1 addition & 0 deletions backend/schemas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from .payload import FilePayload, Payload # noqa: F401
from .response import Response # noqa: F401
from .spamassasin import SpamAssassinDetail, SpamAssassinReport # noqa: F401
from .status import Status # noqa: F401
from .submission import SubmissionResult # noqa: F401
from .urlscan import UrlScanLookup # noqa: F401
from .verdict import Verdict, VerdictDetail # noqa: F401
19 changes: 19 additions & 0 deletions backend/schemas/status.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from pydantic import Field

from .api_model import APIModel


class Status(APIModel):
cache: bool = Field(default=False, description="Whether cache is enabled or not")
vt: bool = Field(
default=False, description="Whether VirusTotal integration is enabled or not"
)
inquest: bool = Field(
default=False, description="Whether InQuest integration is enabled or not"
)
urlscan: bool = Field(
default=False, description="Whether urlscan.io integration is enabled or not"
)
email_rep: bool = Field(
default=False, description="Whether EmailRep integration is enabled or not"
)
Loading

0 comments on commit 0571b7c

Please sign in to comment.