Moving things to use the common_route_params

This commit is contained in:
Scott Idem
2022-01-18 14:12:33 -05:00
parent 15c1d6b463
commit b2a1c8f85a
2 changed files with 14 additions and 17 deletions

View File

@@ -27,11 +27,10 @@ router = APIRouter()
@router.post('', response_model=Resp_Body_Base) @router.post('', response_model=Resp_Body_Base)
async def post_account_obj( async def post_account_obj(
obj: Account_Base, obj: Account_Base,
x_account_id: str = Header(...),
return_obj: Optional[bool] = True, return_obj: Optional[bool] = True,
by_alias: Optional[bool] = True,
exclude_unset: Optional[bool] = True, commons: Common_Route_Params = Depends(common_route_params),
response: Response = Response,
): ):
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals()) log.debug(locals())
@@ -51,12 +50,11 @@ async def post_account_obj(
@router.patch('/{obj_id}', response_model=Resp_Body_Base) @router.patch('/{obj_id}', response_model=Resp_Body_Base)
async def patch_account_obj( async def patch_account_obj(
obj: Account_Base, obj: Account_Base,
obj_id: str = Query(..., min_length=1, max_length=22), obj_id: str = Query(..., min_length=11, max_length=22),
x_account_id: Optional[str] = Header(..., ),
return_obj: Optional[bool] = True, return_obj: Optional[bool] = True,
by_alias: Optional[bool] = True,
exclude_unset: Optional[bool] = True, commons: Common_Route_Params = Depends(common_route_params),
response: Response = Response,
): ):
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals()) log.debug(locals())
@@ -98,7 +96,6 @@ async def get_account_obj_li(
inc_site_list: bool = False, inc_site_list: bool = False,
inc_site_domain_list: bool = False, inc_site_domain_list: bool = False,
inc_user_list: bool = False, inc_user_list: bool = False,
return_obj: bool = True,
commons: Common_Route_Params = Depends(common_route_params), 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. # Working well as of 2021-06-11. Using as a template for other routes.
@router.get('/{account_id}', response_model=Resp_Body_Base) @router.get('/{account_id}', response_model=Resp_Body_Base)
async def get_account_obj_new( 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_account_cfg: bool = False, # Priority l1
inc_address: bool = False, # Under contact inc_address: bool = False, # Under contact
inc_address_list: bool = False, inc_address_list: bool = False,
@@ -327,9 +324,8 @@ async def get_account_obj_new(
@router.delete('/{obj_id}', response_model=Resp_Body_Base) @router.delete('/{obj_id}', response_model=Resp_Body_Base)
async def delete_account_obj( async def delete_account_obj(
obj_id: str = Query(..., min_length=1, max_length=22), obj_id: str = Query(..., min_length=11, max_length=22),
x_account_id: str = Header(...), commons: Common_Route_Params = Depends(common_route_params),
response: Response = Response,
): ):
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals()) log.debug(locals())
@@ -352,9 +348,9 @@ async def get_account_cfg_obj(
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals()) 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) 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: if sys_module:

View File

@@ -357,7 +357,8 @@ async def patch_person_obj(
@router.get('/person/list', response_model=Resp_Body_Base) @router.get('/person/list', response_model=Resp_Body_Base)
async def get_person_obj_li( async def get_person_obj_li(
for_obj_type: Optional[str] = Query(None, min_length=2, max_length=50), 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), commons: Common_Route_Params = Depends(common_route_params),
): ):
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL