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 import APIRouter, Depends
|
||||||
from fastapi_utils.cbv import cbv
|
from fastapi_utils.cbv import cbv
|
||||||
from starlette.responses import JSONResponse, Response
|
from starlette.responses import JSONResponse, Response
|
||||||
|
|
@ -5,6 +6,7 @@ from starlette.responses import JSONResponse, Response
|
||||||
from app.api.models import Request
|
from app.api.models import Request
|
||||||
from app.core.core import WebhookProcessor
|
from app.core.core import WebhookProcessor
|
||||||
from app.core.injects import AutowireSupport
|
from app.core.injects import AutowireSupport
|
||||||
|
from app.model.webhook import WebhookEvent
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
|
||||||
|
|
@ -20,8 +22,9 @@ class APIv1:
|
||||||
|
|
||||||
@router.get("/health", summary="Health check")
|
@router.get("/health", summary="Health check")
|
||||||
async def health(self) -> JSONResponse:
|
async def health(self) -> JSONResponse:
|
||||||
return JSONResponse({"status": "ok"})
|
return JSONResponse({"status": self.webhook_service.health})
|
||||||
|
|
||||||
@router.post("/ci", summary="CI Webhook")
|
@router.post("/ci", summary="CI Webhook")
|
||||||
async def ci(self, request: Request):
|
async def ci(self, request: Request):
|
||||||
|
self.webhook_service.process_ci_event(mapper.to(WebhookEvent).map(request))
|
||||||
return Response(status_code=201)
|
return Response(status_code=201)
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,11 @@ from typing import Annotated
|
||||||
from injectable import injectable, autowired, Autowired
|
from injectable import injectable, autowired, Autowired
|
||||||
|
|
||||||
from app.model.healthcheck import HealthCheck
|
from app.model.healthcheck import HealthCheck
|
||||||
|
from app.model.webhook import WebhookEvent
|
||||||
from app.services import DockerService, GitService, Passwords
|
from app.services import DockerService, GitService, Passwords
|
||||||
|
|
||||||
|
|
||||||
# @injectable
|
@injectable
|
||||||
class WebhookProcessor:
|
class WebhookProcessor:
|
||||||
@autowired
|
@autowired
|
||||||
def __init__(self, docker: Annotated[DockerService, Autowired],
|
def __init__(self, docker: Annotated[DockerService, Autowired],
|
||||||
|
|
@ -16,6 +17,9 @@ class WebhookProcessor:
|
||||||
self._git = git
|
self._git = git
|
||||||
self._keepass = keepass
|
self._keepass = keepass
|
||||||
|
|
||||||
|
def process_ci_event(self, event: WebhookEvent):
|
||||||
|
pass
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def health(self) -> HealthCheck:
|
def health(self) -> HealthCheck:
|
||||||
return HealthCheck(
|
return HealthCheck(
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ from typing import List
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class WebhookRequest:
|
class WebhookEvent:
|
||||||
_id: str
|
_id: str
|
||||||
commit: str
|
commit: str
|
||||||
message: str
|
message: str
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ dependencies = [
|
||||||
"pykeepass>=4.1.1.post1",
|
"pykeepass>=4.1.1.post1",
|
||||||
"docker>=7.1.0",
|
"docker>=7.1.0",
|
||||||
"injectable==4.0.1",
|
"injectable==4.0.1",
|
||||||
|
"py-automapper>=2.2.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[project.optional-dependencies]
|
[project.optional-dependencies]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue