Slowly getting things back to normal after FastAPI upgrade

This commit is contained in:
Scott Idem
2024-04-26 17:43:56 -04:00
parent e38b3cfe7a
commit d3f5f51458
4 changed files with 771 additions and 40 deletions

View File

@@ -18,11 +18,185 @@ router = APIRouter()
# Working on the basic API CRUD - STI 2021-03-08
# obj_type_l1: str = Path(min_length=2, max_length=50),
# obj_type_l2: str = Path(min_length=2, max_length=50),
# obj_type_l3: str = Path(min_length=2, max_length=50),
# for_obj_type: Optional[str] = Query(None, max_length=50),
# for_obj_id: Optional[str] = Query(None, max_length=22),
# tbl_alt: Optional[str] = Query('default', max_length=50), # This is used as a lookup for the real SQL database table or view name to use.
# mdl_alt: Optional[str] = Query('default', max_length=50), # This is used as a lookup for the real Python Pydantic model name to use.
# # use_alt_table: bool = False, # NOTE: This will use table_name_alt if they exist. -2023-11-17
# # use_alt_base: bool = False, # NOTE: This will use base_name_alt if they exist. -2023-11-17
# # field_qry_li: str = Query(None, max_length=150), # JSON formatted key value pair list of fields to search.
# # fulltext_qry_li: str = Query(None, max_length=150), # JSON formatted key value pair list of fields to search.
# # fulltext_qry_field_li: str = Header(None), # Json formatted string list of fields to search. It is not ideal that this is in the header. Need a better option, but this is currently a GET request.
# # fulltext_qry_str: str = Query(None, max_length=150),
# 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),
# # include: Optional[list] = [],
# # exclude: Optional[list] = [],
# # exclude_none: Optional[bool] = True,
# # Get the "json" param from the query string. This is a JSON formatted string of the data to be inserted.
# jp: Optional[Union[str, None]] = None,
# file_type: str = 'CSV', # CSV, Excel
# return_file: Optional[bool] = False,
# commons: Common_Route_Params = Depends(common_route_params),
# Updated 2023-07-06
@router.get('/{obj_type_l1}/list')
async def get_obj_li_l1(
obj_type_l1: str = Path(min_length=2, max_length=50),
for_obj_type: Optional[str] = Query(None, max_length=50),
for_obj_id: Optional[str] = Query(None, max_length=22),
tbl_alt: Optional[str] = Query('default', max_length=50), # This is used as a lookup for the real SQL database table or view name to use.
mdl_alt: Optional[str] = Query('default', max_length=50), # This is used as a lookup for the real Python Pydantic model name to use.
# use_alt_table: bool = False, # NOTE: This will use table_name_alt if they exist. -2023-11-17
# use_alt_base: bool = False, # NOTE: This will use base_name_alt if they exist. -2023-11-17
# field_qry_li: str = Query(None, max_length=150), # JSON formatted key value pair list of fields to search.
# fulltext_qry_li: str = Query(None, max_length=150), # JSON formatted key value pair list of fields to search.
# fulltext_qry_field_li: str = Header(None), # Json formatted string list of fields to search. It is not ideal that this is in the header. Need a better option, but this is currently a GET request.
# fulltext_qry_str: str = Query(None, max_length=150),
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),
# include: Optional[list] = [],
# exclude: Optional[list] = [],
# exclude_none: Optional[bool] = True,
# Get the "json" param from the query string. This is a JSON formatted string of the data to be inserted.
jp: Optional[Union[str, None]] = None,
file_type: str = 'CSV', # CSV, Excel
return_file: Optional[bool] = False,
commons: Common_Route_Params = Depends(common_route_params),
):
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
# ### SECTION ### Call generic function to get the list of objects
return handle_get_obj_li(
obj_type_l1=obj_type_l1,
for_obj_type=for_obj_type,
for_obj_id=for_obj_id,
tbl_alt=tbl_alt,
mdl_alt=mdl_alt,
hidden=hidden,
order_by_li=order_by_li,
jp=jp,
file_type=file_type,
return_file=return_file,
commons=commons,
)
@router.get('/{obj_type_l1}/{obj_type_l2}/list')
async def get_obj_li_l2(
obj_type_l1: str = Path(min_length=2, max_length=50),
obj_type_l2: str = Path(min_length=2, max_length=50),
for_obj_type: Optional[str] = Query(None, max_length=50),
for_obj_id: Optional[str] = Query(None, max_length=22),
tbl_alt: Optional[str] = Query('default', max_length=50), # This is used as a lookup for the real SQL database table or view name to use.
mdl_alt: Optional[str] = Query('default', max_length=50), # This is used as a lookup for the real Python Pydantic model name to use.
# use_alt_table: bool = False, # NOTE: This will use table_name_alt if they exist. -2023-11-17
# use_alt_base: bool = False, # NOTE: This will use base_name_alt if they exist. -2023-11-17
# field_qry_li: str = Query(None, max_length=150), # JSON formatted key value pair list of fields to search.
# fulltext_qry_li: str = Query(None, max_length=150), # JSON formatted key value pair list of fields to search.
# fulltext_qry_field_li: str = Header(None), # Json formatted string list of fields to search. It is not ideal that this is in the header. Need a better option, but this is currently a GET request.
# fulltext_qry_str: str = Query(None, max_length=150),
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),
# include: Optional[list] = [],
# exclude: Optional[list] = [],
# exclude_none: Optional[bool] = True,
# Get the "json" param from the query string. This is a JSON formatted string of the data to be inserted.
jp: Optional[Union[str, None]] = None,
file_type: str = 'CSV', # CSV, Excel
return_file: Optional[bool] = False,
commons: Common_Route_Params = Depends(common_route_params),
):
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
# ### SECTION ### Call generic function to get the list of objects
return handle_get_obj_li(
obj_type_l1=obj_type_l1,
obj_type_l2=obj_type_l2,
for_obj_type=for_obj_type,
for_obj_id=for_obj_id,
tbl_alt=tbl_alt,
mdl_alt=mdl_alt,
hidden=hidden,
order_by_li=order_by_li,
jp=jp,
file_type=file_type,
return_file=return_file,
commons=commons,
)
@router.get('/{obj_type_l1}/{obj_type_l2}/{obj_type_l3}/list')
async def get_obj_li(
async def get_obj_li_l3(
obj_type_l1: str = Path(min_length=2, max_length=50),
obj_type_l2: str = Path(min_length=2, max_length=50),
obj_type_l3: str = Path(min_length=2, max_length=50),
@@ -67,6 +241,54 @@ async def get_obj_li(
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
# ### SECTION ### Call generic function to get the list of objects
return handle_get_obj_li(
obj_type_l1=obj_type_l1,
obj_type_l2=obj_type_l2,
obj_type_l3=obj_type_l3,
for_obj_type=for_obj_type,
for_obj_id=for_obj_id,
tbl_alt=tbl_alt,
mdl_alt=mdl_alt,
hidden=hidden,
order_by_li=order_by_li,
jp=jp,
file_type=file_type,
return_file=return_file,
commons=commons,
)
def handle_get_obj_li(
obj_type_l1: str,
obj_type_l2: Optional[str] = None,
obj_type_l3: Optional[str] = None,
for_obj_type: Optional[str] = None,
for_obj_id: Optional[str] = None,
tbl_alt: Optional[str] = 'default',
mdl_alt: Optional[str] = 'default',
hidden: str = 'not_hidden',
order_by_li: Optional[str] = None,
jp: Optional[Union[str, None]] = None,
file_type: str = 'CSV',
return_file: Optional[bool] = False,
commons: Common_Route_Params = Depends(common_route_params),
):
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
import urllib
# This should be a dict list of fields with a list of values to search for using FULLTEXT.