From b2a1c8f85af40318641648fb60c922cc18f50f28 Mon Sep 17 00:00:00 2001 From: Scott Idem Date: Tue, 18 Jan 2022 14:12:33 -0500 Subject: [PATCH] Moving things to use the common_route_params --- app/routers/account.py | 28 ++++++++++++---------------- app/routers/person.py | 3 ++- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/app/routers/account.py b/app/routers/account.py index d4ec411..c6142f7 100644 --- a/app/routers/account.py +++ b/app/routers/account.py @@ -27,11 +27,10 @@ router = APIRouter() @router.post('', response_model=Resp_Body_Base) async def post_account_obj( obj: Account_Base, - x_account_id: str = Header(...), + return_obj: Optional[bool] = True, - by_alias: Optional[bool] = True, - exclude_unset: Optional[bool] = True, - response: Response = Response, + + commons: Common_Route_Params = Depends(common_route_params), ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -51,12 +50,11 @@ async def post_account_obj( @router.patch('/{obj_id}', response_model=Resp_Body_Base) async def patch_account_obj( obj: Account_Base, - obj_id: str = Query(..., min_length=1, max_length=22), - x_account_id: Optional[str] = Header(..., ), + obj_id: str = Query(..., min_length=11, max_length=22), + return_obj: Optional[bool] = True, - by_alias: Optional[bool] = True, - exclude_unset: Optional[bool] = True, - response: Response = Response, + + commons: Common_Route_Params = Depends(common_route_params), ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -98,7 +96,6 @@ async def get_account_obj_li( inc_site_list: bool = False, inc_site_domain_list: bool = False, inc_user_list: bool = False, - return_obj: bool = True, commons: Common_Route_Params = Depends(common_route_params), ): @@ -152,7 +149,7 @@ async def get_account_obj_li( # Working well as of 2021-06-11. Using as a template for other routes. @router.get('/{account_id}', response_model=Resp_Body_Base) async def get_account_obj_new( - account_id: str = Query(..., min_length=1, max_length=22), + account_id: str = Query(..., min_length=11, max_length=22), inc_account_cfg: bool = False, # Priority l1 inc_address: bool = False, # Under contact inc_address_list: bool = False, @@ -327,9 +324,8 @@ async def get_account_obj_new( @router.delete('/{obj_id}', response_model=Resp_Body_Base) async def delete_account_obj( - obj_id: str = Query(..., min_length=1, max_length=22), - x_account_id: str = Header(...), - response: Response = Response, + obj_id: str = Query(..., min_length=11, max_length=22), + commons: Common_Route_Params = Depends(common_route_params), ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -352,9 +348,9 @@ async def get_account_cfg_obj( log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) - # print(x_account_id) + # print(commons.x_account_id) - if account_id := redis_lookup_id_random(record_id_random=x_account_id, table_name='account'): pass + if account_id := redis_lookup_id_random(record_id_random=commons.x_account_id, table_name='account'): pass else: return mk_resp(data=None, status_code=404, status_message=f'The Account ID was not found. Account ID: {account_id}', response=commons.response) if sys_module: diff --git a/app/routers/person.py b/app/routers/person.py index 577df66..07835cd 100644 --- a/app/routers/person.py +++ b/app/routers/person.py @@ -357,7 +357,8 @@ async def patch_person_obj( @router.get('/person/list', response_model=Resp_Body_Base) async def get_person_obj_li( for_obj_type: Optional[str] = Query(None, min_length=2, max_length=50), - for_obj_id: Optional[str] = Query(None, min_length=1, max_length=22), + for_obj_id: Optional[str] = Query(None, min_length=11, max_length=22), + commons: Common_Route_Params = Depends(common_route_params), ): log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL