Skip to content
Snippets Groups Projects
Commit fb478ff1 authored by penenadpi's avatar penenadpi
Browse files

Fixed initial API

parent 6b8e7c41
No related branches found
No related tags found
No related merge requests found
......@@ -3,14 +3,10 @@ import sys
print("SHOW ALL RESULTS")
URL = "http://127.0.0.1:8000/new_user"
uuids = {
"userid": "8357c950-78d3-4a15-94c6-f911116dcd10",
"selected": "[]"
"userid": "8357c950-78d3-4a15-94c6-f911116dcd10"
}
response = requests.post(URL, uuids)
......
......@@ -2,7 +2,7 @@ import functools
import io
import os
from typing import Optional, List, Union
import uuid
import yaml
from content_size_limit_asgi import ContentSizeLimitMiddleware
from fastapi import FastAPI, File, Form, UploadFile, status
......@@ -13,7 +13,7 @@ from iac_scan_runner.scan_response_type import ScanResponseType
from iac_scan_runner.scan_runner import ScanRunner
from pydantic import SecretStr
from iac_scan_runner.results_persistence import ResultsPersistence
from iac_scan_runner.user_configuration import UserConfiguration
# create an API instance
app = FastAPI(
docs_url="/swagger",
......@@ -205,7 +205,7 @@ async def delete_scan_result(uuid: str) -> JSONResponse:
@app.post("/new_user", summary="Retrieve particular scan result by given uuid", responses={200: {}, 400: {"model": str}})
async def get_new_user(uuid: str, selected: list ) -> JSONResponse:
async def post_new_user() -> JSONResponse:
"""
Retrieve a particular scan result (GET method)
:param uuid: Identifier of a saved scan record
......@@ -213,11 +213,11 @@ async def get_new_user(uuid: str, selected: list ) -> JSONResponse:
"""
try:
user_configs = UserConfiguration()
if(uuid):
user_configs.new_user(uuid, selected)
else:
selected = []
random_userid = str(uuid.uuid4())
user_configs.new_user(random_userid, selected)
return JSONResponse(status_code=status.HTTP_200_OK, content="New user created")
user_configs.new_config(random_userid, selected)
return JSONResponse(status_code=status.HTTP_200_OK, content=f"New user created with id: {random_userid}")
except Exception as e:
return JSONResponse(status_code=status.HTTP_400_BAD_REQUEST, content=str(e))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment