From 5c079f8355b8d1ad582a780f24f7e59e9afb6fe3 Mon Sep 17 00:00:00 2001 From: Oliver Scotten Date: Wed, 17 Jan 2024 20:02:22 -0500 Subject: [PATCH] Fixed target/get/targets --- app/routes/target/target.py | 38 ++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/app/routes/target/target.py b/app/routes/target/target.py index a9d36f6..73dccbf 100644 --- a/app/routes/target/target.py +++ b/app/routes/target/target.py @@ -60,17 +60,21 @@ async def create_target( LOGGER.error(f"GMP Error: {err}") return ErrorResponse("Internal Server Error") -@ROUTER.get("/get/{target_id}") -async def get_target( +@ROUTER.get("/get/targets") +async def get_targets( current_user: Annotated[Auth.User, Depends(Auth.get_current_active_user)], - target_id: str, - tasks: Optional[bool] = None + filter_string: Optional[str] = None, + filter_id: Optional[str] = None, + trash: Optional[bool] = None, + tasks: Optional[bool] = None, ): - """Request a single target + """Request a list of targets Arguments: - target_id: UUID of an existing target + filter_string: Filter term to use for the query + filter_id: UUID of an existing filter to use for the query + trash: Whether to get the trashcan targets instead tasks: Whether to include list of tasks that use the target Returns: @@ -79,26 +83,22 @@ async def get_target( with Gmp(connection=UnixSocketConnection()) as gmp: gmp.authenticate(username=current_user.username, password=Auth.get_admin_password()) try: - return gmp.get_target(target_id=target_id, tasks=tasks) + return gmp.get_targets(filter_string=filter_string,filter_id=filter_id,trash=trash,tasks=tasks) except Exception as err: LOGGER.error(f"GMP Error: {err}") return ErrorResponse("Internal Server Error") - -@ROUTER.get("/get/targets") -async def get_targets( + +@ROUTER.get("/get/{target_id}") +async def get_target( current_user: Annotated[Auth.User, Depends(Auth.get_current_active_user)], - filter_string: Optional[str] = None, - filter_id: Optional[str] = None, - trash: Optional[bool] = None, - tasks: Optional[bool] = None, + target_id: str, + tasks: Optional[bool] = None ): - """Request a list of targets + """Request a single target Arguments: - filter_string: Filter term to use for the query - filter_id: UUID of an existing filter to use for the query - trash: Whether to get the trashcan targets instead + target_id: UUID of an existing target tasks: Whether to include list of tasks that use the target Returns: @@ -107,7 +107,7 @@ async def get_targets( with Gmp(connection=UnixSocketConnection()) as gmp: gmp.authenticate(username=current_user.username, password=Auth.get_admin_password()) try: - return gmp.get_targets(filter_string=filter_string,filter_id=filter_id,trash=trash,tasks=tasks) + return gmp.get_target(target_id=target_id, tasks=tasks) except Exception as err: LOGGER.error(f"GMP Error: {err}") return ErrorResponse("Internal Server Error")