Updates for hosted file sections and general code clean up.
This commit is contained in:
@@ -14,7 +14,7 @@ from app.db_sql import sql_insert, sql_update, sql_insert_or_update, sql_select,
|
||||
from app.methods.hosted_file_methods import create_hosted_file_obj, load_hosted_file_obj, save_file, create_hosted_file_link
|
||||
|
||||
from app.models.hosted_file_models import Hosted_File_Base
|
||||
from app.models.response_models import mk_resp
|
||||
from app.models.response_models import Resp_Body_Base, mk_resp
|
||||
|
||||
|
||||
router = APIRouter()
|
||||
@@ -388,4 +388,36 @@ async def test_upload_files(
|
||||
)
|
||||
log.debug(file_info)
|
||||
|
||||
return mk_resp(data=False, status_code=501, response=response)
|
||||
return mk_resp(data=False, status_code=501, response=response)
|
||||
|
||||
|
||||
# ### BEGIN ### API Hosted File ### get_hosted_file_obj() ###
|
||||
# Updated 2021-09-07
|
||||
@router.get('/{hosted_file_id}', response_model=Resp_Body_Base)
|
||||
async def get_hosted_file_obj(
|
||||
hosted_file_id: str = Query(..., min_length=11, max_length=22),
|
||||
enabled: str = 'enabled', # enabled, disabled, all; For now this covers any included objects or object lists
|
||||
x_account_id: str = Header(...),
|
||||
by_alias: Optional[bool] = True,
|
||||
exclude_unset: Optional[bool] = True,
|
||||
response: Response = Response,
|
||||
):
|
||||
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
if hosted_file_id := redis_lookup_id_random(record_id_random=hosted_file_id, table_name='hosted_file'): pass
|
||||
else:
|
||||
return mk_resp(data=None, status_code=404)
|
||||
|
||||
if hosted_file_obj := load_hosted_file_obj(
|
||||
hosted_file_id = hosted_file_id,
|
||||
enabled = enabled,
|
||||
):
|
||||
hosted_file_dict = hosted_file_obj.dict(by_alias=by_alias, exclude_unset=exclude_unset)
|
||||
pass
|
||||
else:
|
||||
return mk_resp(data=False, status_code=400, response=response) # Bad Request
|
||||
|
||||
return mk_resp(data=hosted_file_dict)
|
||||
#return mk_resp(data=hosted_file_obj)
|
||||
# ### END ### API Hosted File ### get_hosted_file_obj() ###
|
||||
|
||||
Reference in New Issue
Block a user