summaryrefslogtreecommitdiff
path: root/src/main.py
diff options
context:
space:
mode:
authorKristofer Hallin <kristofer@sunet.se>2022-01-04 21:20:09 +0100
committerKristofer Hallin <kristofer@sunet.se>2022-01-04 21:20:09 +0100
commit725968e03a7fdef32fecd748c7144fe572abeec1 (patch)
tree209e75e017e5b31decdb23a812818a7614dc5511 /src/main.py
parentb74745607c07a3980da705342271af49288eaeae (diff)
More job related things.feature.job_scheduler
Diffstat (limited to 'src/main.py')
-rwxr-xr-xsrc/main.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/main.py b/src/main.py
index 4454f7d..fada6e9 100755
--- a/src/main.py
+++ b/src/main.py
@@ -28,6 +28,8 @@ app.add_middleware(
# TODO: X-Total-Count
+scheduler = JobScheduler()
+
@app.middleware("http")
async def mock_x_total_count_header(request: Request, call_next):
@@ -147,9 +149,7 @@ async def get_key(key=None, Authorize: AuthJWT = Depends()):
@app.post('/sc/v0/add')
async def add(data: Request, Authorize: AuthJWT = Depends()):
- # Maybe we should protect this enpoint too and let the scanner use
- # a JWT token as well.
- # Authorize.jwt_required()
+ Authorize.jwt_required()
json_data = await data.json()
@@ -180,6 +180,15 @@ async def jobs_get(Authorize: AuthJWT = Depends()):
return JSONResponse(content={"status": "success", "jobs": data})
+@app.get('/sc/v0/jobs/{job_id}')
+async def jobs_get_id(job_id, Authorize: AuthJWT = Depends()):
+ Authorize.jwt_required()
+
+ data = [JobScheduler.get_job(job_id)]
+
+ return JSONResponse(content={"status": "success", "jobs": data})
+
+
def main(standalone=False):
if not standalone:
return app