Updates to CRUD...
This commit is contained in:
@@ -173,26 +173,20 @@ async def get_obj_li(
|
||||
for_obj_type: Optional[str] = Query(None, max_length=50),
|
||||
for_obj_id: Optional[str] = Query(None, max_length=22),
|
||||
|
||||
# enabled: str = 'enabled',
|
||||
hidden: str = 'not_hidden', # hidden, not_hidden, all,
|
||||
# order_by_li: dict = None,
|
||||
order_by_li: str = Header(None), # Json formatted string in a key value format. It is not ideal that this is in the header. Need a better option, but this is currently a GET request.
|
||||
|
||||
# dh_order_by_li: str = Header(None),
|
||||
# dh_testing: str = Header(None),
|
||||
# h_order_by_li: str = Header(None),
|
||||
# h_testing: str = Header(None),
|
||||
# limit: int = 10000,
|
||||
# offset: int = 0,
|
||||
|
||||
# x_account_id: str = Header(...),
|
||||
# by_alias: Optional[bool] = True,
|
||||
# include: Optional[list] = [],
|
||||
# exclude: Optional[list] = [],
|
||||
# exclude_unset: Optional[bool] = False,
|
||||
# exclude_none: Optional[bool] = True,
|
||||
# response: Response = Response,
|
||||
|
||||
commons: Common_Route_Params = Depends(common_route_params), # Switch to this later... sooner
|
||||
commons: Common_Route_Params = Depends(common_route_params),
|
||||
):
|
||||
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
@@ -267,7 +261,7 @@ async def get_obj_li(
|
||||
else: return mk_resp(data=None, response=commons.response, status_code=404)
|
||||
|
||||
|
||||
#@router.get('/{obj_type_l1}/{obj_id_int}')
|
||||
# Updated 2023-11-03
|
||||
@router.get('/{obj_type_l1}/{obj_id}')
|
||||
@router.get('/{obj_type_l1}/{obj_type_l2}/{obj_id}')
|
||||
@router.get('/{obj_type_l1}/{obj_type_l2}/{obj_type_l3}/{obj_id}')
|
||||
@@ -277,21 +271,17 @@ async def get_obj(
|
||||
obj_type_l3: str=None,
|
||||
obj_id: str=None,
|
||||
|
||||
for_obj_type: Optional[str] = Query(None, max_length=50),
|
||||
for_obj_id: Optional[str] = Query(None, max_length=22),
|
||||
# for_obj_type: Optional[str] = Query(None, max_length=50), # NOTE: This is not currently used. It is here for future use.
|
||||
# for_obj_id: Optional[str] = Query(None, max_length=22), # NOTE: This is not currently used. It is here for future use.
|
||||
|
||||
# qry_str: Optional[str] = Query(None, max_length=50),
|
||||
# qry_int: Optional[int] = None,
|
||||
|
||||
x_account_id: str = Header(...),
|
||||
by_alias: Optional[bool] = True,
|
||||
# include: Optional[list] = [],
|
||||
# exclude: Optional[list] = [],
|
||||
exclude_unset: Optional[bool] = True,
|
||||
exclude_none: Optional[bool] = True,
|
||||
response: Response = Response,
|
||||
# exclude_none: Optional[bool] = True,
|
||||
|
||||
# commons: Common_Route_Params = Depends(common_route_params), # Switch to this later... sooner
|
||||
commons: Common_Route_Params = Depends(common_route_params),
|
||||
):
|
||||
"""
|
||||
Simple select object type with an ID:
|
||||
@@ -315,8 +305,8 @@ async def get_obj(
|
||||
debug_data['obj_type_l2'] = obj_type_l2
|
||||
debug_data['obj_type_l3'] = obj_type_l3
|
||||
debug_data['obj_id'] = obj_id
|
||||
debug_data['for_obj_type'] = for_obj_type
|
||||
debug_data['for_obj_id'] = for_obj_id
|
||||
# debug_data['for_obj_type'] = for_obj_type
|
||||
# debug_data['for_obj_id'] = for_obj_id
|
||||
|
||||
log.debug(debug_data)
|
||||
|
||||
@@ -327,24 +317,24 @@ async def get_obj(
|
||||
#table_name = obj_type_li[obj_name]['table_name']
|
||||
pass
|
||||
else:
|
||||
return mk_resp(data=False, status_code=400, response=response)
|
||||
return mk_resp(data=False, status_code=400, response=commons.response)
|
||||
elif obj_type_l1 and obj_type_l2:
|
||||
obj_name = f'{obj_type_l1}_{obj_type_l2}'
|
||||
if obj_name in obj_type_li:
|
||||
#table_name = obj_type_li[obj_name]['table_name']
|
||||
pass
|
||||
else:
|
||||
return mk_resp(data=False, status_code=400, response=response)
|
||||
return mk_resp(data=False, status_code=400, response=commons.response)
|
||||
elif obj_type_l1:
|
||||
obj_name = f'{obj_type_l1}'
|
||||
if obj_name in obj_type_li:
|
||||
#table_name = obj_type_li[obj_name]['table_name']
|
||||
pass
|
||||
else:
|
||||
return mk_resp(data=False, status_code=400, response=response)
|
||||
return mk_resp(data=False, status_code=400, response=commons.response)
|
||||
else:
|
||||
log.warning('We should not be here')
|
||||
return mk_resp(data=False, status_code=400, response=response)
|
||||
return mk_resp(data=False, status_code=400, response=commons.response)
|
||||
|
||||
table_name = obj_type_li[obj_name]['table_name']
|
||||
|
||||
@@ -353,12 +343,12 @@ async def get_obj(
|
||||
log.debug(sql_result)
|
||||
|
||||
base_name = obj_type_li[obj_name]['base_name']
|
||||
resp_data = base_name(**sql_result).dict(by_alias=by_alias, exclude_unset=exclude_unset)
|
||||
resp_data = base_name(**sql_result).dict(by_alias=commons.by_alias, exclude_unset=commons.exclude_unset)
|
||||
|
||||
return mk_resp(data=resp_data, response=response) #, details=debug_data)
|
||||
return mk_resp(data=resp_data, response=commons.response) #, details=debug_data)
|
||||
else:
|
||||
log.debug(sql_result)
|
||||
return mk_resp(data=False, status_code=404, response=response)
|
||||
return mk_resp(data=False, status_code=404, response=commons.response)
|
||||
|
||||
|
||||
# ### BEGIN ### API CRUD ### patch_obj() ###
|
||||
|
||||
Reference in New Issue
Block a user