Mappings & processing WIP
This commit is contained in:
parent
120e929469
commit
1d7c4c2dfd
4 changed files with 11 additions and 3 deletions
|
|
@ -1,3 +1,4 @@
|
|||
from automapper import mapper
|
||||
from fastapi import APIRouter, Depends
|
||||
from fastapi_utils.cbv import cbv
|
||||
from starlette.responses import JSONResponse, Response
|
||||
|
|
@ -5,6 +6,7 @@ from starlette.responses import JSONResponse, Response
|
|||
from app.api.models import Request
|
||||
from app.core.core import WebhookProcessor
|
||||
from app.core.injects import AutowireSupport
|
||||
from app.model.webhook import WebhookEvent
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
|
@ -20,8 +22,9 @@ class APIv1:
|
|||
|
||||
@router.get("/health", summary="Health check")
|
||||
async def health(self) -> JSONResponse:
|
||||
return JSONResponse({"status": "ok"})
|
||||
return JSONResponse({"status": self.webhook_service.health})
|
||||
|
||||
@router.post("/ci", summary="CI Webhook")
|
||||
async def ci(self, request: Request):
|
||||
self.webhook_service.process_ci_event(mapper.to(WebhookEvent).map(request))
|
||||
return Response(status_code=201)
|
||||
|
|
|
|||
|
|
@ -3,10 +3,11 @@ from typing import Annotated
|
|||
from injectable import injectable, autowired, Autowired
|
||||
|
||||
from app.model.healthcheck import HealthCheck
|
||||
from app.model.webhook import WebhookEvent
|
||||
from app.services import DockerService, GitService, Passwords
|
||||
|
||||
|
||||
# @injectable
|
||||
@injectable
|
||||
class WebhookProcessor:
|
||||
@autowired
|
||||
def __init__(self, docker: Annotated[DockerService, Autowired],
|
||||
|
|
@ -16,6 +17,9 @@ class WebhookProcessor:
|
|||
self._git = git
|
||||
self._keepass = keepass
|
||||
|
||||
def process_ci_event(self, event: WebhookEvent):
|
||||
pass
|
||||
|
||||
@property
|
||||
def health(self) -> HealthCheck:
|
||||
return HealthCheck(
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ from typing import List
|
|||
|
||||
|
||||
@dataclass
|
||||
class WebhookRequest:
|
||||
class WebhookEvent:
|
||||
_id: str
|
||||
commit: str
|
||||
message: str
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue