refactor(routers): comment out legacy endpoints across multiple routers
Disabled legacy routes that are superseded by V3 equivalents. Code is commented out (not deleted) pending final verification and cleanup pass. - registry.py: remove sql, lookup (/lu), websockets, websockets_redis; clean up dead imports (contact, event_person, etc.) - data_store.py: comment out legacy CRUD and code-lookup endpoints; keep V3 code-lookup routes active; add TODO for action path rename - api.py: comment out Api_Base CRUD, get_id (internal ID leak), and sql_test (debug) endpoints - aether_cfg.py: comment out legacy Flask cfg endpoint - user.py: comment out legacy user endpoints - util_email.py: minor cleanup Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -39,24 +39,24 @@ async def get_aether_cfg_obj(
|
||||
return mk_resp(data=None, status_code=404, response=commons.response)
|
||||
|
||||
|
||||
@router.get('/aether/flask/cfg/{aether_flask_cfg_id}', response_model=Resp_Body_Base)
|
||||
async def get_aether_flask_cfg_obj(
|
||||
aether_flask_cfg_id: int,
|
||||
# aether_flask_cfg_id: str = Path(min_length=11, max_length=22),
|
||||
# @router.get('/aether/flask/cfg/{aether_flask_cfg_id}', response_model=Resp_Body_Base)
|
||||
# async def get_aether_flask_cfg_obj(
|
||||
# aether_flask_cfg_id: int,
|
||||
# # aether_flask_cfg_id: str = Path(min_length=11, max_length=22),
|
||||
|
||||
# NOTE: The x_account_id header value is not required.
|
||||
# commons: Common_Route_Params = Depends(common_route_params),
|
||||
commons: Common_Route_Params_No_Account_ID = Depends(common_route_params_no_account_id),
|
||||
):
|
||||
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
# # NOTE: The x_account_id header value is not required.
|
||||
# # commons: Common_Route_Params = Depends(common_route_params),
|
||||
# commons: Common_Route_Params_No_Account_ID = Depends(common_route_params_no_account_id),
|
||||
# ):
|
||||
# log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
# log.debug(locals())
|
||||
|
||||
if sql_select_result := sql_select(
|
||||
table_name = 'cfg_flask',
|
||||
record_id = aether_flask_cfg_id,
|
||||
as_list = False,
|
||||
max_count = 1,
|
||||
):
|
||||
return mk_resp(data=sql_select_result, response=commons.response)
|
||||
else:
|
||||
return mk_resp(data=None, status_code=404, response=commons.response)
|
||||
# if sql_select_result := sql_select(
|
||||
# table_name = 'cfg_flask',
|
||||
# record_id = aether_flask_cfg_id,
|
||||
# as_list = False,
|
||||
# max_count = 1,
|
||||
# ):
|
||||
# return mk_resp(data=sql_select_result, response=commons.response)
|
||||
# else:
|
||||
# return mk_resp(data=None, status_code=404, response=commons.response)
|
||||
|
||||
@@ -62,13 +62,13 @@ async def authenticate_passcode(
|
||||
|
||||
if matched_role:
|
||||
log.info(f"Auth Success: Verified '{matched_role}' passcode for site {site_id}")
|
||||
|
||||
|
||||
# 4. Resolve Account Context
|
||||
account_id_random = record.get('account_id_random')
|
||||
if not account_id_random:
|
||||
if account_id_int := record.get('account_id'):
|
||||
account_id_random = get_id_random(record_id=account_id_int, table_name='account')
|
||||
|
||||
|
||||
# 5. Mint JWT
|
||||
payload = {
|
||||
'account_id': account_id_random,
|
||||
@@ -81,13 +81,13 @@ async def authenticate_passcode(
|
||||
'role': matched_role
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
token = sign_jwt(
|
||||
secret_key=settings.JWT_KEY,
|
||||
ttl=3600 * 24, # 24 hour session
|
||||
**payload
|
||||
)
|
||||
|
||||
|
||||
return mk_resp(data={'jwt': token, 'account_id': account_id_random, 'role': matched_role}, response=response)
|
||||
else:
|
||||
log.warning(f"Auth Failed: Invalid passcode for site {site_id}")
|
||||
@@ -167,6 +167,8 @@ async def get_api_temp_token(
|
||||
|
||||
# --- Jitsi Token ---
|
||||
|
||||
# NOTE: This is still actively used by IDAA for their video conferences using self hosted Jitsi. Thi is actually live. We do need to change the app secret once things have stabilized.
|
||||
|
||||
JWT_APP_ID = "my_jitsi_app_id"
|
||||
JWT_APP_SECRET = "my_jitsi_app_secret-9876543210"
|
||||
JITSI_DOMAIN = "jitsi.dgrzone.com"
|
||||
@@ -211,40 +213,43 @@ async def create_jitsi_jwt(request_data: JitsiTokenRequest = Body(...)):
|
||||
raise HTTPException(status_code=500, detail=f"Failed to create JWT: {str(e)}")
|
||||
|
||||
# --- Api_Base CRUD ---
|
||||
# LEGACY (disabled) - superseded by V3 CRUD: /v3/crud/api/
|
||||
|
||||
@router.post('', response_model=Resp_Body_Base)
|
||||
async def post_api_obj(obj: Api_Base, x_account_id: str = Header(...)):
|
||||
return post_obj_template(obj_type='api', data=obj.dict(by_alias=False, exclude_unset=True), return_obj=True)
|
||||
# @router.post('', response_model=Resp_Body_Base)
|
||||
# async def post_api_obj(obj: Api_Base, x_account_id: str = Header(...)):
|
||||
# return post_obj_template(obj_type='api', data=obj.dict(by_alias=False, exclude_unset=True), return_obj=True)
|
||||
|
||||
@router.patch('/{obj_id}', response_model=Resp_Body_Base)
|
||||
async def patch_api_obj(obj_id: str, obj: Api_Base, x_account_id: str = Header(...)):
|
||||
data = obj.dict(by_alias=False, exclude_unset=True)
|
||||
data['id'] = redis_lookup_id_random(record_id_random=obj_id, table_name='api')
|
||||
return patch_obj_template(obj_type='api', data=data, obj_id=obj_id, return_obj=True)
|
||||
# @router.patch('/{obj_id}', response_model=Resp_Body_Base)
|
||||
# async def patch_api_obj(obj_id: str, obj: Api_Base, x_account_id: str = Header(...)):
|
||||
# data = obj.dict(by_alias=False, exclude_unset=True)
|
||||
# data['id'] = redis_lookup_id_random(record_id_random=obj_id, table_name='api')
|
||||
# return patch_obj_template(obj_type='api', data=data, obj_id=obj_id, return_obj=True)
|
||||
|
||||
@router.get('/list', response_model=Resp_Body_Base)
|
||||
async def get_api_obj_li(for_obj_type: Optional[str] = Query(None), for_obj_id: Optional[str] = Query(None), x_account_id: str = Header(...)):
|
||||
return get_obj_li_template(obj_type='api', for_obj_type=for_obj_type, for_obj_id=for_obj_id)
|
||||
# @router.get('/list', response_model=Resp_Body_Base)
|
||||
# async def get_api_obj_li(for_obj_type: Optional[str] = Query(None), for_obj_id: Optional[str] = Query(None), x_account_id: str = Header(...)):
|
||||
# return get_obj_li_template(obj_type='api', for_obj_type=for_obj_type, for_obj_id=for_obj_id)
|
||||
|
||||
@router.get('/{obj_id}', response_model=Resp_Body_Base)
|
||||
async def get_api_obj(obj_id: str, x_account_id: str = Header(...)):
|
||||
return get_obj_template(obj_type='api', obj_id=obj_id)
|
||||
# @router.get('/{obj_id}', response_model=Resp_Body_Base)
|
||||
# async def get_api_obj(obj_id: str, x_account_id: str = Header(...)):
|
||||
# return get_obj_template(obj_type='api', obj_id=obj_id)
|
||||
|
||||
@router.delete('/{obj_id}', response_model=Resp_Body_Base)
|
||||
async def delete_api_obj(obj_id: str, x_account_id: str = Header(...)):
|
||||
return delete_obj_template(obj_type='api', obj_id=obj_id)
|
||||
# @router.delete('/{obj_id}', response_model=Resp_Body_Base)
|
||||
# async def delete_api_obj(obj_id: str, x_account_id: str = Header(...)):
|
||||
# return delete_obj_template(obj_type='api', obj_id=obj_id)
|
||||
|
||||
@router.get('/get_id/{object_type}/{object_id_random}', response_model=Resp_Body_Base)
|
||||
async def get_api_object_id(object_type: str, object_id_random: str):
|
||||
if object_id := redis_lookup_id_random(record_id_random=object_id_random, table_name=object_type):
|
||||
return mk_resp(data={ 'object_id': object_id})
|
||||
return mk_resp(data=None, status_code=404)
|
||||
# LEGACY (disabled) - exposes internal integer IDs, breaks id_random abstraction
|
||||
# @router.get('/get_id/{object_type}/{object_id_random}', response_model=Resp_Body_Base)
|
||||
# async def get_api_object_id(object_type: str, object_id_random: str):
|
||||
# if object_id := redis_lookup_id_random(record_id_random=object_id_random, table_name=object_type):
|
||||
# return mk_resp(data={ 'object_id': object_id})
|
||||
# return mk_resp(data=None, status_code=404)
|
||||
|
||||
@router.get('/sql_test', tags=['Testing'])
|
||||
async def sql_test(response: Response = Response):
|
||||
sql = text("SELECT NOW() as current_time, VERSION() as version")
|
||||
try:
|
||||
result = db.execute(sql).fetchone()
|
||||
return mk_resp(data={"current_time": str(result[0]), "version": result[1]})
|
||||
except Exception as e:
|
||||
return mk_resp(data=False, status_code=500, details=str(e), response=response)
|
||||
# LEGACY (disabled) - testing/debug endpoint
|
||||
# @router.get('/sql_test', tags=['Testing'])
|
||||
# async def sql_test(response: Response = Response):
|
||||
# sql = text("SELECT NOW() as current_time, VERSION() as version")
|
||||
# try:
|
||||
# result = db.execute(sql).fetchone()
|
||||
# return mk_resp(data={"current_time": str(result[0]), "version": result[1]})
|
||||
# except Exception as e:
|
||||
# return mk_resp(data=False, status_code=500, details=str(e), response=response)
|
||||
@@ -24,119 +24,125 @@ router = APIRouter()
|
||||
|
||||
|
||||
# ### BEGIN ### API Data Store Routers ### post_data_store_obj() ###
|
||||
# LEGACY (disabled) - superseded by V3 CRUD: POST /v3/crud/data_store/
|
||||
# Updated 2026-01-28
|
||||
@router.post('/data_store', response_model=Resp_Body_Base)
|
||||
async def post_data_store_obj(
|
||||
data_store_obj: Data_Store_Base,
|
||||
|
||||
return_obj: bool = True,
|
||||
|
||||
commons: Common_Route_Params = Depends(common_route_params),
|
||||
):
|
||||
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
# ### SECTION ### Secondary data validation
|
||||
# None
|
||||
|
||||
# ### SECTION ### Process data
|
||||
if data_store_id := create_update_data_store_obj(
|
||||
data_store_dict_obj = data_store_obj,
|
||||
): pass
|
||||
else:
|
||||
log.warning('Likely bad request')
|
||||
return mk_resp(data=False, status_code=400, response=commons.response, status_message='Not created. Something failed while processing the data. Check the field names and data types.') # Bad Request
|
||||
|
||||
# ### SECTION ### Return successful results
|
||||
if return_obj:
|
||||
data_store_obj = load_data_store_obj(
|
||||
data_store_id = data_store_id,
|
||||
)
|
||||
data = data_store_obj
|
||||
else:
|
||||
data_store_id_random = get_id_random(record_id=data_store_id, table_name='data_store')
|
||||
data = {}
|
||||
data['data_store_id'] = data_store_id
|
||||
data['data_store_id_random'] = data_store_id_random
|
||||
return mk_resp(data=data, response=commons.response)
|
||||
# @router.post('/data_store', response_model=Resp_Body_Base)
|
||||
# async def post_data_store_obj(
|
||||
# data_store_obj: Data_Store_Base,
|
||||
#
|
||||
# return_obj: bool = True,
|
||||
#
|
||||
# commons: Common_Route_Params = Depends(common_route_params),
|
||||
# ):
|
||||
# log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
# log.debug(locals())
|
||||
#
|
||||
# # ### SECTION ### Secondary data validation
|
||||
# # None
|
||||
#
|
||||
# # ### SECTION ### Process data
|
||||
# if data_store_id := create_update_data_store_obj(
|
||||
# data_store_dict_obj = data_store_obj,
|
||||
# ): pass
|
||||
# else:
|
||||
# log.warning('Likely bad request')
|
||||
# return mk_resp(data=False, status_code=400, response=commons.response, status_message='Not created. Something failed while processing the data. Check the field names and data types.') # Bad Request
|
||||
#
|
||||
# # ### SECTION ### Return successful results
|
||||
# if return_obj:
|
||||
# data_store_obj = load_data_store_obj(
|
||||
# data_store_id = data_store_id,
|
||||
# )
|
||||
# data = data_store_obj
|
||||
# else:
|
||||
# data_store_id_random = get_id_random(record_id=data_store_id, table_name='data_store')
|
||||
# data = {}
|
||||
# data['data_store_id'] = data_store_id
|
||||
# data['data_store_id_random'] = data_store_id_random
|
||||
# return mk_resp(data=data, response=commons.response)
|
||||
# ### END ### API Data Store Routers ### post_data_store_obj() ###
|
||||
|
||||
|
||||
# ### BEGIN ### API Data Store Routers ### patch_data_store_obj() ###
|
||||
# LEGACY (disabled) - superseded by V3 CRUD: PATCH /v3/crud/data_store/{id}
|
||||
# Updated 2022-03-11
|
||||
@router.patch('/data_store/{data_store_id}', response_model=Resp_Body_Base)
|
||||
async def patch_data_store_obj(
|
||||
data_store_obj: Data_Store_Base,
|
||||
data_store_id: str = Path(min_length=11, max_length=22),
|
||||
|
||||
return_obj: Optional[bool] = True,
|
||||
|
||||
commons: Common_Route_Params = Depends(common_route_params),
|
||||
):
|
||||
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
# ### SECTION ### Secondary data validation
|
||||
data_store_id_random = data_store_id # This is used later for the response data
|
||||
if data_store_id := redis_lookup_id_random(record_id_random=data_store_id, table_name='data_store'): pass
|
||||
else: return mk_resp(data=None, status_code=404, response=commons.response, status_message='The Data Store ID was invalid or not found.')
|
||||
|
||||
# ### SECTION ### Process data
|
||||
if data_store_up_result := create_update_data_store_obj(
|
||||
data_store_dict_obj = data_store_obj,
|
||||
data_store_id = data_store_id,
|
||||
): pass
|
||||
else:
|
||||
log.warning('Likely bad request')
|
||||
return mk_resp(data=False, status_code=400, response=commons.response, status_message='Not updated. Something failed while processing the data. Check the field names and data types.') # Bad Request
|
||||
|
||||
# ### SECTION ### Return successful results
|
||||
if return_obj:
|
||||
data_store_obj = load_data_store_obj(
|
||||
data_store_id = data_store_id,
|
||||
)
|
||||
data = data_store_obj
|
||||
else:
|
||||
data = {}
|
||||
data['data_store_id'] = data_store_id
|
||||
data['data_store_id_random'] = data_store_id_random
|
||||
return mk_resp(data=data, response=commons.response)
|
||||
# @router.patch('/data_store/{data_store_id}', response_model=Resp_Body_Base)
|
||||
# async def patch_data_store_obj(
|
||||
# data_store_obj: Data_Store_Base,
|
||||
# data_store_id: str = Path(min_length=11, max_length=22),
|
||||
#
|
||||
# return_obj: Optional[bool] = True,
|
||||
#
|
||||
# commons: Common_Route_Params = Depends(common_route_params),
|
||||
# ):
|
||||
# log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
# log.debug(locals())
|
||||
#
|
||||
# # ### SECTION ### Secondary data validation
|
||||
# data_store_id_random = data_store_id # This is used later for the response data
|
||||
# if data_store_id := redis_lookup_id_random(record_id_random=data_store_id, table_name='data_store'): pass
|
||||
# else: return mk_resp(data=None, status_code=404, response=commons.response, status_message='The Data Store ID was invalid or not found.')
|
||||
#
|
||||
# # ### SECTION ### Process data
|
||||
# if data_store_up_result := create_update_data_store_obj(
|
||||
# data_store_dict_obj = data_store_obj,
|
||||
# data_store_id = data_store_id,
|
||||
# ): pass
|
||||
# else:
|
||||
# log.warning('Likely bad request')
|
||||
# return mk_resp(data=False, status_code=400, response=commons.response, status_message='Not updated. Something failed while processing the data. Check the field names and data types.') # Bad Request
|
||||
#
|
||||
# # ### SECTION ### Return successful results
|
||||
# if return_obj:
|
||||
# data_store_obj = load_data_store_obj(
|
||||
# data_store_id = data_store_id,
|
||||
# )
|
||||
# data = data_store_obj
|
||||
# else:
|
||||
# data = {}
|
||||
# data['data_store_id'] = data_store_id
|
||||
# data['data_store_id_random'] = data_store_id_random
|
||||
# return mk_resp(data=data, response=commons.response)
|
||||
# ### END ### API Data Store Routers ### patch_data_store_obj() ###
|
||||
|
||||
|
||||
# ### BEGIN ### API Data Store ### get_data_store_obj() ###
|
||||
# LEGACY (disabled) - superseded by V3 CRUD: GET /v3/crud/data_store/{id}
|
||||
# Updated 2026-01-28
|
||||
@router.get('/data_store/{data_store_id}', response_model=Resp_Body_Base)
|
||||
async def get_data_store_obj(
|
||||
data_store_id: str = Path(min_length=11, max_length=22),
|
||||
|
||||
commons: Common_Route_Params = Depends(common_route_params),
|
||||
):
|
||||
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
# ### SECTION ### Secondary data validation
|
||||
if data_store_id := redis_lookup_id_random(record_id_random=data_store_id, table_name='data_store'): pass
|
||||
else: return mk_resp(data=None, status_code=404, response=commons.response)
|
||||
|
||||
if data_store_rec_result := load_data_store_obj(
|
||||
data_store_id = data_store_id,
|
||||
limit = commons.limit,
|
||||
enabled = commons.enabled,
|
||||
):
|
||||
log.info('Loading successful. Returning result')
|
||||
return mk_resp(data=data_store_rec_result, response=commons.response)
|
||||
elif isinstance(data_store_rec_result, list) or data_store_rec_result is None: # Empty list or None
|
||||
log.info('No results')
|
||||
return mk_resp(data=None, status_code=404, response=commons.response) # Not Found
|
||||
else:
|
||||
log.warning('Likely bad request')
|
||||
return mk_resp(data=False, status_code=400, response=commons.response) # Bad Request
|
||||
# @router.get('/data_store/{data_store_id}', response_model=Resp_Body_Base)
|
||||
# async def get_data_store_obj(
|
||||
# data_store_id: str = Path(min_length=11, max_length=22),
|
||||
#
|
||||
# commons: Common_Route_Params = Depends(common_route_params),
|
||||
# ):
|
||||
# log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
# log.debug(locals())
|
||||
#
|
||||
# # ### SECTION ### Secondary data validation
|
||||
# if data_store_id := redis_lookup_id_random(record_id_random=data_store_id, table_name='data_store'): pass
|
||||
# else: return mk_resp(data=None, status_code=404, response=commons.response)
|
||||
#
|
||||
# if data_store_rec_result := load_data_store_obj(
|
||||
# data_store_id = data_store_id,
|
||||
# limit = commons.limit,
|
||||
# enabled = commons.enabled,
|
||||
# ):
|
||||
# log.info('Loading successful. Returning result')
|
||||
# return mk_resp(data=data_store_rec_result, response=commons.response)
|
||||
# elif isinstance(data_store_rec_result, list) or data_store_rec_result is None: # Empty list or None
|
||||
# log.info('No results')
|
||||
# return mk_resp(data=None, status_code=404, response=commons.response) # Not Found
|
||||
# else:
|
||||
# log.warning('Likely bad request')
|
||||
# return mk_resp(data=False, status_code=400, response=commons.response) # Bad Request
|
||||
# ### END ### API Data Store ### get_data_store_obj() ###
|
||||
|
||||
|
||||
# ### BEGIN ### API Data Store ### get_v3_data_store_obj_w_code() ###
|
||||
# NEW V3 Endpoint for Code Lookup
|
||||
# TODO: Migrate to a dedicated api_v3_actions_data_store.py router and rename path to
|
||||
# /v3/action/data_store/code/{data_store_code} to match the V3 action naming convention.
|
||||
# Requires a coordinated frontend update before the path rename can happen.
|
||||
# Updated 2026-01-28
|
||||
@router.get('/v3/data_store/code/{data_store_code}', response_model=Resp_Body_Base, tags=['Data Store V3'])
|
||||
async def get_v3_data_store_obj_w_code(
|
||||
@@ -156,13 +162,13 @@ async def get_v3_data_store_obj_w_code(
|
||||
Returns a single object if limit=1, otherwise returns a list.
|
||||
"""
|
||||
log.setLevel(logging.INFO)
|
||||
|
||||
|
||||
# Map V3 params to the shared handler
|
||||
v3_commons = Common_Route_Params(
|
||||
x_account_id=account.account_id,
|
||||
x_account_id_random=account.account_id_random,
|
||||
enabled=status_filter.enabled,
|
||||
response=Response()
|
||||
response=Response()
|
||||
)
|
||||
|
||||
return await handle_get_data_store_obj_w_code(
|
||||
@@ -177,57 +183,60 @@ async def get_v3_data_store_obj_w_code(
|
||||
|
||||
|
||||
# ### BEGIN ### API Data Store ### get_data_store_obj_w_code() ###
|
||||
# NOTE: Adding some explanation because this is not quickly obvious how it fully works.
|
||||
# The look up order starts with a required data_store_code. Then the first result that matches the most specific method. The for_type and for_id fields are not required. I think it makes the most sense to be a part of the URL path, not the GET params. Either should work with no problem though.
|
||||
# LEGACY (disabled) - legacy code-based lookup; use GET /v3/data_store/code/{code} instead.
|
||||
# NOTE: The look up order starts with a required data_store_code. Then the first result that matches the most specific method. The for_type and for_id fields are not required. I think it makes the most sense to be a part of the URL path, not the GET params. Either should work with no problem though.
|
||||
# Lookup using: for_type and for_id > account_id > data_store_code
|
||||
# This is a nice way to have global default data along with account and object specific data.
|
||||
# Updated 2023-05-22
|
||||
|
||||
|
||||
@router.get('/data_store/code/{data_store_code}/{for_type}/{for_id}', response_model=Resp_Body_Base)
|
||||
async def get_data_store_obj_w_code_path(
|
||||
data_store_code: str = Path(min_length=3, max_length=50),
|
||||
for_type: Optional[str] = Path(min_length=1, max_length=25),
|
||||
for_id: Optional[str] = Path(min_length=11, max_length=22),
|
||||
limit: int = Query(1, ge=1),
|
||||
|
||||
commons: Common_Route_Params = Depends(common_route_params),
|
||||
):
|
||||
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
log.info('Using path parameters')
|
||||
# ### SECTION ### Call generic function to get the data_store object
|
||||
return await handle_get_data_store_obj_w_code(
|
||||
data_store_code = data_store_code,
|
||||
for_type = for_type,
|
||||
for_id = for_id,
|
||||
commons = commons,
|
||||
limit = limit,
|
||||
)
|
||||
# @router.get('/data_store/code/{data_store_code}/{for_type}/{for_id}', response_model=Resp_Body_Base)
|
||||
# async def get_data_store_obj_w_code_path(
|
||||
# data_store_code: str = Path(min_length=3, max_length=50),
|
||||
# for_type: Optional[str] = Path(min_length=1, max_length=25),
|
||||
# for_id: Optional[str] = Path(min_length=11, max_length=22),
|
||||
# limit: int = Query(1, ge=1),
|
||||
#
|
||||
# commons: Common_Route_Params = Depends(common_route_params),
|
||||
# ):
|
||||
# log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
# log.debug(locals())
|
||||
# log.info('Using path parameters')
|
||||
# # ### SECTION ### Call generic function to get the data_store object
|
||||
# return await handle_get_data_store_obj_w_code(
|
||||
# data_store_code = data_store_code,
|
||||
# for_type = for_type,
|
||||
# for_id = for_id,
|
||||
# commons = commons,
|
||||
# limit = limit,
|
||||
# )
|
||||
|
||||
|
||||
@router.get('/data_store/code/{data_store_code}', response_model=Resp_Body_Base)
|
||||
async def get_data_store_obj_w_code_query(
|
||||
data_store_code: str = Path(min_length=3, max_length=50),
|
||||
for_type: Optional[str] = Query(None, min_length=1, max_length=25),
|
||||
for_id: Optional[str] = Query(None, min_length=11, max_length=22),
|
||||
limit: int = Query(1, ge=1),
|
||||
|
||||
commons: Common_Route_Params = Depends(common_route_params),
|
||||
):
|
||||
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
log.info('Using query parameters')
|
||||
# ### SECTION ### Call generic function to get the data_store object
|
||||
return await handle_get_data_store_obj_w_code(
|
||||
data_store_code = data_store_code,
|
||||
for_type = for_type,
|
||||
for_id = for_id,
|
||||
commons = commons,
|
||||
limit = limit,
|
||||
)
|
||||
# @router.get('/data_store/code/{data_store_code}', response_model=Resp_Body_Base)
|
||||
# async def get_data_store_obj_w_code_query(
|
||||
# data_store_code: str = Path(min_length=3, max_length=50),
|
||||
# for_type: Optional[str] = Query(None, min_length=1, max_length=25),
|
||||
# for_id: Optional[str] = Query(None, min_length=11, max_length=22),
|
||||
# limit: int = Query(1, ge=1),
|
||||
#
|
||||
# commons: Common_Route_Params = Depends(common_route_params),
|
||||
# ):
|
||||
# log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
# log.debug(locals())
|
||||
# log.info('Using query parameters')
|
||||
# # ### SECTION ### Call generic function to get the data_store object
|
||||
# return await handle_get_data_store_obj_w_code(
|
||||
# data_store_code = data_store_code,
|
||||
# for_type = for_type,
|
||||
# for_id = for_id,
|
||||
# commons = commons,
|
||||
# limit = limit,
|
||||
# )
|
||||
# ### END ### API Data Store ### get_data_store_obj_w_code() ###
|
||||
|
||||
|
||||
# TODO: Migrate to a dedicated api_v3_actions_data_store.py router and rename path to
|
||||
# /v3/action/data_store/code/{data_store_code}/search to match the V3 action naming convention.
|
||||
# Requires a coordinated frontend update before the path rename can happen.
|
||||
@router.post('/v3/data_store/code/{data_store_code}/search', response_model=Resp_Body_Base, tags=['Data Store V3'])
|
||||
async def search_v3_data_store_obj_w_code(
|
||||
data_store_code: str,
|
||||
@@ -256,18 +265,18 @@ async def search_v3_data_store_obj_w_code(
|
||||
# 2. Construct the hierarchical search SQL
|
||||
# We must enforce that users only see their own account records OR global defaults (account_id IS NULL)
|
||||
from app.db_sql import sql_enable_part, sql_hidden_part, sql_search_qry_part, sql_limit_offset_part
|
||||
|
||||
|
||||
sql_enabled, data_enabled = sql_enable_part('data_store', status_filter.enabled)
|
||||
sql_hidden, data_hidden = sql_hidden_part('data_store', status_filter.hidden)
|
||||
|
||||
|
||||
# Generate search logic from the SearchQuery model
|
||||
search_sql, search_data = sql_search_qry_part(
|
||||
search_query=search_query,
|
||||
search_query=search_query,
|
||||
table_name='v_data_store'
|
||||
)
|
||||
|
||||
|
||||
sql_limit = sql_limit_offset_part(limit=pagination.limit, offset=pagination.offset)
|
||||
|
||||
|
||||
# Prepare parameter dictionary
|
||||
data = {
|
||||
'code': data_store_code,
|
||||
@@ -342,11 +351,11 @@ async def handle_get_data_store_obj_w_code(
|
||||
):
|
||||
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.info(f'Loading successful. Returning {len(data_store_obj_result)} result(s)')
|
||||
|
||||
|
||||
# If limit=1, return the first object directly (standard lookup behavior)
|
||||
# If limit > 1, return the list of results
|
||||
data = data_store_obj_result[0] if limit == 1 else data_store_obj_result
|
||||
|
||||
|
||||
log.debug(data)
|
||||
return mk_resp(data=data, response=commons.response)
|
||||
elif isinstance(data_store_obj_result, list) or data_store_obj_result is None: # Empty list or None
|
||||
@@ -359,43 +368,44 @@ async def handle_get_data_store_obj_w_code(
|
||||
|
||||
|
||||
# ### BEGIN ### API Data Store ### get_account_obj_data_store_list() ###
|
||||
# LEGACY (disabled) - superseded by V3 CRUD search: POST /v3/crud/data_store/search
|
||||
# Updated 2022-03-11
|
||||
@router.get('/account/{account_id}/data_store/list', response_model=Resp_Body_Base)
|
||||
async def get_account_obj_data_store_list(
|
||||
account_id: str = Path(min_length=11, max_length=22),
|
||||
|
||||
commons: Common_Route_Params = Depends(common_route_params),
|
||||
):
|
||||
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
if account_id := redis_lookup_id_random(record_id_random=account_id, table_name='account'): pass
|
||||
else: return mk_resp(data=None, status_code=404, response=commons.response)
|
||||
|
||||
# Updated 2022-03-11
|
||||
if data_store_rec_list_result := get_data_store_rec_list(
|
||||
account_id = account_id,
|
||||
for_type = 'account',
|
||||
for_id = account_id,
|
||||
enabled = commons.enabled,
|
||||
limit = commons.limit,
|
||||
offset = commons.offset,
|
||||
):
|
||||
data_store_result_list = []
|
||||
for data_store_rec in data_store_rec_list_result:
|
||||
if load_data_store_result := load_data_store_obj(
|
||||
data_store_id = data_store_rec.get('data_store_id', None),
|
||||
enabled = commons.enabled,
|
||||
):
|
||||
data_store_result_list.append(load_data_store_result)
|
||||
else:
|
||||
data_store_result_list.append(None)
|
||||
response_data = data_store_result_list
|
||||
return mk_resp(data=response_data, response=commons.response)
|
||||
elif isinstance(data_store_rec_list_result, list) or data_store_rec_list_result is None: # Empty list or None
|
||||
log.info('No results')
|
||||
return mk_resp(data=None, status_code=404, response=commons.response) # Not Found
|
||||
else:
|
||||
log.warning('Likely bad request')
|
||||
return mk_resp(data=False, status_code=400, response=commons.response) # Bad Request
|
||||
# ### END ### API Data Store ### get_account_obj_data_store_list() ###
|
||||
# @router.get('/account/{account_id}/data_store/list', response_model=Resp_Body_Base)
|
||||
# async def get_account_obj_data_store_list(
|
||||
# account_id: str = Path(min_length=11, max_length=22),
|
||||
#
|
||||
# commons: Common_Route_Params = Depends(common_route_params),
|
||||
# ):
|
||||
# log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
# log.debug(locals())
|
||||
#
|
||||
# if account_id := redis_lookup_id_random(record_id_random=account_id, table_name='account'): pass
|
||||
# else: return mk_resp(data=None, status_code=404, response=commons.response)
|
||||
#
|
||||
# # Updated 2022-03-11
|
||||
# if data_store_rec_list_result := get_data_store_rec_list(
|
||||
# account_id = account_id,
|
||||
# for_type = 'account',
|
||||
# for_id = account_id,
|
||||
# enabled = commons.enabled,
|
||||
# limit = commons.limit,
|
||||
# offset = commons.offset,
|
||||
# ):
|
||||
# data_store_result_list = []
|
||||
# for data_store_rec in data_store_rec_list_result:
|
||||
# if load_data_store_result := load_data_store_obj(
|
||||
# data_store_id = data_store_rec.get('data_store_id', None),
|
||||
# enabled = commons.enabled,
|
||||
# ):
|
||||
# data_store_result_list.append(load_data_store_result)
|
||||
# else:
|
||||
# data_store_result_list.append(None)
|
||||
# response_data = data_store_result_list
|
||||
# return mk_resp(data=response_data, response=commons.response)
|
||||
# elif isinstance(data_store_rec_list_result, list) or data_store_rec_list_result is None: # Empty list or None
|
||||
# log.info('No results')
|
||||
# return mk_resp(data=None, status_code=404, response=commons.response) # Not Found
|
||||
# else:
|
||||
# log.warning('Likely bad request')
|
||||
# return mk_resp(data=False, status_code=400, response=commons.response) # Bad Request
|
||||
# ### END ### API Data Store ### get_account_obj_data_store_list() ###
|
||||
|
||||
@@ -1,16 +1,13 @@
|
||||
from fastapi import FastAPI, Depends
|
||||
from app.routers.dependencies_v3 import DeprecationParams
|
||||
from app.routers import (
|
||||
ae_obj, aether_cfg, api_crud, api_crud_v2, api_crud_v3, api, health, importing, sql,
|
||||
account, contact, data_store,
|
||||
event, event_badge, event_badge_importing, event_badge_template,
|
||||
event_device, event_exhibit, event_exhibit_tracking, event_file, event_importing,
|
||||
event_location, event_person,
|
||||
event_presentation, event_presenter, event_session,
|
||||
flask_cfg, hosted_file, api_v3_actions_hosted_file, api_v3_actions_event_file, api_v3_actions_event_exhibit, api_v3_actions_e_zoom, api_v3_actions_e_novi_mailman, lookup, lookup_v3,
|
||||
organization, page, person,
|
||||
person_user, qr, site, site_domain, user,
|
||||
util_email, websockets, websockets_redis, websockets_v3, e_confex, e_cvent, e_impexium, e_stripe
|
||||
ae_obj, aether_cfg, api_crud_v3, api, health, importing,
|
||||
data_store,
|
||||
event_badge_importing,
|
||||
event_importing,
|
||||
api_v3_actions_hosted_file, api_v3_actions_event_file, api_v3_actions_event_exhibit, api_v3_actions_e_zoom, api_v3_actions_e_novi_mailman, lookup_v3,
|
||||
user,
|
||||
util_email, websockets_v3, e_confex, e_cvent, e_impexium, e_stripe
|
||||
)
|
||||
|
||||
def setup_routers(app: FastAPI):
|
||||
@@ -21,13 +18,13 @@ def setup_routers(app: FastAPI):
|
||||
app.include_router(ae_obj.router, prefix='/ae_obj', tags=['AE Object'])
|
||||
app.include_router(aether_cfg.router, tags=['Aether Config'])
|
||||
# app.include_router(api_crud.router, prefix='/crud', tags=['CRUD v1.2 (Legacy)'], dependencies=[Depends(DeprecationParams)])
|
||||
app.include_router(api_crud_v2.router, prefix='/v2/crud', tags=['CRUD v2.5'], dependencies=[Depends(DeprecationParams)])
|
||||
# app.include_router(api_crud_v2.router, prefix='/v2/crud', tags=['CRUD v2.5'], dependencies=[Depends(DeprecationParams)])
|
||||
app.include_router(api_crud_v3.router, prefix='/v3/crud', tags=['CRUD v3'])
|
||||
|
||||
app.include_router(api.router, prefix='/api', tags=['API'])
|
||||
# app.include_router(flask_cfg.router, prefix='/flask_cfg', tags=['Flask CFG'], dependencies=[Depends(DeprecationParams)])
|
||||
app.include_router(importing.router, prefix='/importing', tags=['Importing'])
|
||||
app.include_router(sql.router, tags=['SQL'])
|
||||
# app.include_router(sql.router, tags=['SQL']) # LEGACY (disabled) - raw SQL select endpoint, testing only
|
||||
# app.include_router(account.router, tags=['Account'], dependencies=[Depends(DeprecationParams)])
|
||||
|
||||
app.include_router(data_store.router, tags=['Data Store'])
|
||||
@@ -38,8 +35,8 @@ def setup_routers(app: FastAPI):
|
||||
|
||||
# app.include_router(event_device.router, tags=['Event Device'], dependencies=[Depends(DeprecationParams)])
|
||||
# app.include_router(event_exhibit.router, tags=['Event Exhibit'], dependencies=[Depends(DeprecationParams)])
|
||||
app.include_router(event_exhibit_tracking.router, tags=['Event Exhibit Tracking'])
|
||||
app.include_router(event_file.router, tags=['Event File'])
|
||||
# app.include_router(event_exhibit_tracking.router, tags=['Event Exhibit Tracking'])
|
||||
# app.include_router(event_file.router, tags=['Event File'])
|
||||
app.include_router(event_importing.router, tags=['Event Importing'])
|
||||
# app.include_router(event_location.router, tags=['Event Location'], dependencies=[Depends(DeprecationParams)])
|
||||
|
||||
@@ -47,13 +44,13 @@ def setup_routers(app: FastAPI):
|
||||
# app.include_router(event_presenter.router, prefix='/event/presenter', tags=['Event Presenter'], dependencies=[Depends(DeprecationParams)])
|
||||
# app.include_router(event_session.router, tags=['Event Session'], dependencies=[Depends(DeprecationParams)])
|
||||
|
||||
app.include_router(hosted_file.router, prefix='/hosted_file', tags=['Hosted File'])
|
||||
# app.include_router(hosted_file.router, prefix='/hosted_file', tags=['Hosted File'])
|
||||
app.include_router(api_v3_actions_hosted_file.router, prefix='/v3/action/hosted_file', tags=['Hosted File (V3 Actions)'])
|
||||
app.include_router(api_v3_actions_event_file.router, prefix='/v3/action/event_file', tags=['Event File (V3 Actions)'])
|
||||
app.include_router(api_v3_actions_event_exhibit.router, prefix='/v3/action/event_exhibit', tags=['Event Exhibit (V3 Actions)'])
|
||||
app.include_router(api_v3_actions_e_zoom.router, prefix='/v3/action/e_zoom', tags=['Zoom Events (V3 Actions)'])
|
||||
app.include_router(api_v3_actions_e_novi_mailman.router, prefix='/v3/action/e_novi_mailman', tags=['Novi-Mailman Bridge (V3 Actions)'])
|
||||
app.include_router(lookup.router, prefix='/lu', tags=['Lookup'])
|
||||
# app.include_router(lookup.router, prefix='/lu', tags=['Lookup']) # LEGACY (disabled) - superseded by /v3/lookup
|
||||
app.include_router(lookup_v3.router, prefix='/v3/lookup', tags=['Lookup V3'])
|
||||
|
||||
# app.include_router(organization.router, prefix='/organization', tags=['Organization'], dependencies=[Depends(DeprecationParams)])
|
||||
@@ -66,8 +63,8 @@ def setup_routers(app: FastAPI):
|
||||
# app.include_router(site_domain.router, tags=['Site Domain'], dependencies=[Depends(DeprecationParams)])
|
||||
app.include_router(user.router, tags=['User'])
|
||||
app.include_router(util_email.router, tags=['Utility: Email'])
|
||||
app.include_router(websockets.router, tags=['Websockets'])
|
||||
app.include_router(websockets_redis.router, tags=['Websockets (Redis)'])
|
||||
# app.include_router(websockets.router, tags=['Websockets']) # LEGACY (disabled) - superseded by Websockets V3
|
||||
# app.include_router(websockets_redis.router, tags=['Websockets (Redis)']) # LEGACY (disabled) - superseded by Websockets V3
|
||||
app.include_router(websockets_v3.router, prefix='/v3', tags=['Websockets V3'])
|
||||
|
||||
app.include_router(e_confex.router, prefix='/e/confex', tags=['External Service: Confex'])
|
||||
|
||||
@@ -20,65 +20,67 @@ from app.models.user_models import User_Base, User_New_Base, User_Out_Base
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.post('/user', response_model=Resp_Body_Base)
|
||||
async def post_user_obj(
|
||||
obj: User_Base,
|
||||
return_obj: Optional[bool] = True,
|
||||
commons: Common_Route_Params = Depends(common_route_params),
|
||||
):
|
||||
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
# @router.post('/user', response_model=Resp_Body_Base)
|
||||
# async def post_user_obj(
|
||||
# obj: User_Base,
|
||||
# return_obj: Optional[bool] = True,
|
||||
# commons: Common_Route_Params = Depends(common_route_params),
|
||||
# ):
|
||||
# log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
# log.debug(locals())
|
||||
|
||||
obj_type = 'user'
|
||||
obj_data_dict = obj.dict(by_alias=False, exclude_unset=True)
|
||||
result = post_obj_template(
|
||||
obj_type = obj_type,
|
||||
data = obj_data_dict,
|
||||
return_obj = True,
|
||||
by_alias = True,
|
||||
exclude_unset = True,
|
||||
)
|
||||
return result
|
||||
# obj_type = 'user'
|
||||
# obj_data_dict = obj.dict(by_alias=False, exclude_unset=True)
|
||||
# result = post_obj_template(
|
||||
# obj_type = obj_type,
|
||||
# data = obj_data_dict,
|
||||
# return_obj = True,
|
||||
# by_alias = True,
|
||||
# exclude_unset = True,
|
||||
# )
|
||||
# return result
|
||||
|
||||
|
||||
# ### BEGIN ### API User ### post_user_obj_new() ###
|
||||
# Updated 2021-08-21 (complete re-write)
|
||||
@router.post('/user/new', response_model=Resp_Body_Base)
|
||||
async def post_user_obj_new(
|
||||
user_obj: User_New_Base,
|
||||
allow_update: bool = False,
|
||||
avoid_dup_username: bool = False,
|
||||
commons: Common_Route_Params = Depends(common_route_params),
|
||||
):
|
||||
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
# # ### BEGIN ### API User ### post_user_obj_new() ###
|
||||
# # Updated 2021-08-21 (complete re-write)
|
||||
# @router.post('/user/new', response_model=Resp_Body_Base)
|
||||
# async def post_user_obj_new(
|
||||
# user_obj: User_New_Base,
|
||||
# allow_update: bool = False,
|
||||
# avoid_dup_username: bool = False,
|
||||
# commons: Common_Route_Params = Depends(common_route_params),
|
||||
# ):
|
||||
# log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
# log.debug(locals())
|
||||
|
||||
if account_id_random := user_obj.account_id_random: pass
|
||||
else: return False
|
||||
# if account_id_random := user_obj.account_id_random: pass
|
||||
# else: return False
|
||||
|
||||
if create_user_obj_result := create_user_obj(account_id=account_id_random, user_dict_obj=user_obj, allow_update=allow_update, avoid_dup_username=avoid_dup_username): pass
|
||||
else: return mk_resp(data=False, status_code=400, response=commons.response, status_message='The user account was not created. This is likely because that username already exists for this account.')
|
||||
# if create_user_obj_result := create_user_obj(account_id=account_id_random, user_dict_obj=user_obj, allow_update=allow_update, avoid_dup_username=avoid_dup_username): pass
|
||||
# else: return mk_resp(data=False, status_code=400, response=commons.response, status_message='The user account was not created. This is likely because that username already exists for this account.')
|
||||
|
||||
if isinstance(create_user_obj_result, int):
|
||||
user_id = create_user_obj_result
|
||||
if return_obj:
|
||||
if load_user_obj_result := load_user_obj(user_id=user_id):
|
||||
data = load_user_obj_result
|
||||
else:
|
||||
data = False
|
||||
else:
|
||||
user_id = create_user_obj_result
|
||||
user_id_random = get_id_random(record_id=user_id, table_name='user')
|
||||
data = {}
|
||||
data['user_id'] = user_id
|
||||
data['user_id_random'] = user_id_random
|
||||
return mk_resp(data=data, response=commons.response, status_message='The user account was created.')
|
||||
else:
|
||||
return mk_resp(data=False, status_code=400, response=commons.response, status_message='The result from trying to create a user account was unexpected.')
|
||||
# ### END ### API User ### post_user_obj_new() ###
|
||||
# if isinstance(create_user_obj_result, int):
|
||||
# user_id = create_user_obj_result
|
||||
# if return_obj:
|
||||
# if load_user_obj_result := load_user_obj(user_id=user_id):
|
||||
# data = load_user_obj_result
|
||||
# else:
|
||||
# data = False
|
||||
# else:
|
||||
# user_id = create_user_obj_result
|
||||
# user_id_random = get_id_random(record_id=user_id, table_name='user')
|
||||
# data = {}
|
||||
# data['user_id'] = user_id
|
||||
# data['user_id_random'] = user_id_random
|
||||
# return mk_resp(data=data, response=commons.response, status_message='The user account was created.')
|
||||
# else:
|
||||
# return mk_resp(data=False, status_code=400, response=commons.response, status_message='The result from trying to create a user account was unexpected.')
|
||||
# # ### END ### API User ### post_user_obj_new() ###
|
||||
|
||||
|
||||
# ### BEGIN ### API User ### user_obj_change_password() ###
|
||||
# NOTE: This is actively in use 2026-03-24 -Scott
|
||||
# This is marked for deprecation and must be migrated to Aether API v3 standards!
|
||||
@router.patch('/user/{user_id}/change_password', response_model=Resp_Body_Base)
|
||||
async def user_obj_change_password(
|
||||
user_id: Union[int,str],
|
||||
@@ -143,35 +145,37 @@ async def user_obj_change_password(
|
||||
# ### END ### API User ### user_obj_change_password() ###
|
||||
|
||||
|
||||
@router.patch('/user/{obj_id}', response_model=Resp_Body_Base)
|
||||
async def patch_user_obj(
|
||||
obj: User_Base,
|
||||
obj_id: str = Path(min_length=11, max_length=22),
|
||||
return_obj: Optional[bool] = True,
|
||||
commons: Common_Route_Params = Depends(common_route_params),
|
||||
):
|
||||
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
# @router.patch('/user/{obj_id}', response_model=Resp_Body_Base)
|
||||
# async def patch_user_obj(
|
||||
# obj: User_Base,
|
||||
# obj_id: str = Path(min_length=11, max_length=22),
|
||||
# return_obj: Optional[bool] = True,
|
||||
# commons: Common_Route_Params = Depends(common_route_params),
|
||||
# ):
|
||||
# log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
# log.debug(locals())
|
||||
|
||||
obj_type = 'user'
|
||||
obj_data_dict = obj.dict(by_alias=False, exclude_unset=True)
|
||||
obj_data_dict['id'] = redis_lookup_id_random(record_id_random=obj_id, table_name=obj_type)
|
||||
obj_data_dict['id_random'] = obj_id
|
||||
result = patch_obj_template(
|
||||
obj_type=obj_type,
|
||||
data=obj_data_dict,
|
||||
obj_id=obj_id,
|
||||
return_obj=True,
|
||||
by_alias=True,
|
||||
exclude_unset=True,
|
||||
)
|
||||
return result
|
||||
# obj_type = 'user'
|
||||
# obj_data_dict = obj.dict(by_alias=False, exclude_unset=True)
|
||||
# obj_data_dict['id'] = redis_lookup_id_random(record_id_random=obj_id, table_name=obj_type)
|
||||
# obj_data_dict['id_random'] = obj_id
|
||||
# result = patch_obj_template(
|
||||
# obj_type=obj_type,
|
||||
# data=obj_data_dict,
|
||||
# obj_id=obj_id,
|
||||
# return_obj=True,
|
||||
# by_alias=True,
|
||||
# exclude_unset=True,
|
||||
# )
|
||||
# return result
|
||||
|
||||
|
||||
# ### BEGIN ### API User Routers ### user_new_auth_key() ###
|
||||
# Generate a new one time use authorization key for login without password
|
||||
# Updated 2022-01-07
|
||||
# @router.get('/user/new_auth_key', response_model=Resp_Body_Base)
|
||||
# NOTE: This is actively in use 2026-03-24
|
||||
# This is marked for deprecation and must be migrated to Aether API v3 standards!
|
||||
@router.get('/user/{user_id}/new_auth_key', response_model=Resp_Body_Base)
|
||||
async def user_new_auth_key(
|
||||
user_id: str = Path(min_length=11, max_length=22),
|
||||
@@ -218,7 +222,8 @@ async def user_new_auth_key(
|
||||
# A new key will need to be requested for a particular user each time.
|
||||
# NOTE: Should this be divided into username/password and user ID/auth key endpoints? Probably vote 2x
|
||||
# Updated 2021-10-06
|
||||
@router.get('/user/authenticate', response_model=Resp_Body_Base)
|
||||
# NOTE: This is actively in use 2026-03-24 -Scott
|
||||
# This is marked for deprecation and must be migrated to Aether API v3 standards!@router.get('/user/authenticate', response_model=Resp_Body_Base)
|
||||
async def user_authenticate(
|
||||
null_account_id: bool = False,
|
||||
user_id: Optional[str] = Query(None, min_length=11, max_length=22),
|
||||
@@ -394,6 +399,8 @@ async def user_authenticate(
|
||||
|
||||
|
||||
# ### BEGIN ### API User ### user_verify_password() ###
|
||||
# NOTE: This may be actively in use 2026-03-24
|
||||
# This is marked for deprecation and must be migrated to Aether API v3 standards!
|
||||
# @router.post('/{user_id}/verify_password', response_model=Resp_Body_Base)
|
||||
@router.post('/user/verify_password', response_model=Resp_Body_Base)
|
||||
async def user_verify_password(
|
||||
@@ -487,82 +494,84 @@ async def user_verify_password(
|
||||
# ### END ### API User ### user_verify_password() ###
|
||||
|
||||
|
||||
# ### BEGIN ### API User ### get_account_user_obj_li() ###
|
||||
# Updated 2021-12-13
|
||||
@router.get('/account/{account_id}/user/list', response_model=Resp_Body_Base)
|
||||
async def get_account_user_obj_li(
|
||||
account_id: str = Path(min_length=11, max_length=22),
|
||||
hidden: str = 'not_hidden', # hidden, not_hidden, all
|
||||
inc_address: bool = False, # Priority l1
|
||||
inc_contact: bool = False, # Priority l1
|
||||
inc_person: bool = False, # Priority l1
|
||||
inc_user_role_list: bool = False, # Priority l1
|
||||
commons: Common_Route_Params = Depends(common_route_params),
|
||||
):
|
||||
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
# # ### BEGIN ### API User ### get_account_user_obj_li() ###
|
||||
# # Updated 2021-12-13
|
||||
# @router.get('/account/{account_id}/user/list', response_model=Resp_Body_Base)
|
||||
# async def get_account_user_obj_li(
|
||||
# account_id: str = Path(min_length=11, max_length=22),
|
||||
# hidden: str = 'not_hidden', # hidden, not_hidden, all
|
||||
# inc_address: bool = False, # Priority l1
|
||||
# inc_contact: bool = False, # Priority l1
|
||||
# inc_person: bool = False, # Priority l1
|
||||
# inc_user_role_list: bool = False, # Priority l1
|
||||
# commons: Common_Route_Params = Depends(common_route_params),
|
||||
# ):
|
||||
# log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
# log.debug(locals())
|
||||
|
||||
if account_id := redis_lookup_id_random(record_id_random=account_id, table_name='account'): pass
|
||||
else: return mk_resp(data=None, status_code=404, response=commons.response)
|
||||
# if account_id := redis_lookup_id_random(record_id_random=account_id, table_name='account'): pass
|
||||
# else: return mk_resp(data=None, status_code=404, response=commons.response)
|
||||
|
||||
# Updated 2021-12-13
|
||||
if user_rec_list_result := get_user_rec_list(
|
||||
account_id = account_id,
|
||||
hidden = hidden, # hidden, not_hidden, all
|
||||
enabled = commons.enabled,
|
||||
limit = commons.limit,
|
||||
):
|
||||
user_result_list = []
|
||||
for user_rec in user_rec_list_result:
|
||||
if load_user_result := load_user_obj(
|
||||
user_id = user_rec.get('user_id', None),
|
||||
enabled = commons.enabled,
|
||||
# hidden = hidden,
|
||||
limit = commons.limit,
|
||||
inc_address = inc_address,
|
||||
inc_contact = inc_contact,
|
||||
inc_person = inc_person,
|
||||
inc_user_role_list = inc_user_role_list,
|
||||
by_alias = commons.by_alias,
|
||||
exclude_unset = commons.exclude_unset,
|
||||
# model_as_dict = model_as_dict,
|
||||
):
|
||||
user_result_list.append(load_user_result)
|
||||
else:
|
||||
user_result_list.append(None)
|
||||
response_data = user_result_list
|
||||
elif isinstance(user_rec_list_result, list) or user_rec_list_result is None: # Empty list or None
|
||||
log.info('No results')
|
||||
return mk_resp(data=False, status_code=404, response=commons.response) # Not Found
|
||||
else:
|
||||
log.warning('Likely bad request')
|
||||
return mk_resp(data=False, status_code=400, response=commons.response) # Bad Request
|
||||
# # Updated 2021-12-13
|
||||
# if user_rec_list_result := get_user_rec_list(
|
||||
# account_id = account_id,
|
||||
# hidden = hidden, # hidden, not_hidden, all
|
||||
# enabled = commons.enabled,
|
||||
# limit = commons.limit,
|
||||
# ):
|
||||
# user_result_list = []
|
||||
# for user_rec in user_rec_list_result:
|
||||
# if load_user_result := load_user_obj(
|
||||
# user_id = user_rec.get('user_id', None),
|
||||
# enabled = commons.enabled,
|
||||
# # hidden = hidden,
|
||||
# limit = commons.limit,
|
||||
# inc_address = inc_address,
|
||||
# inc_contact = inc_contact,
|
||||
# inc_person = inc_person,
|
||||
# inc_user_role_list = inc_user_role_list,
|
||||
# by_alias = commons.by_alias,
|
||||
# exclude_unset = commons.exclude_unset,
|
||||
# # model_as_dict = model_as_dict,
|
||||
# ):
|
||||
# user_result_list.append(load_user_result)
|
||||
# else:
|
||||
# user_result_list.append(None)
|
||||
# response_data = user_result_list
|
||||
# elif isinstance(user_rec_list_result, list) or user_rec_list_result is None: # Empty list or None
|
||||
# log.info('No results')
|
||||
# return mk_resp(data=False, status_code=404, response=commons.response) # Not Found
|
||||
# else:
|
||||
# log.warning('Likely bad request')
|
||||
# return mk_resp(data=False, status_code=400, response=commons.response) # Bad Request
|
||||
|
||||
return mk_resp(data=response_data, response=commons.response)
|
||||
# ### END ### API User ### get_account_user_obj_li() ###
|
||||
# return mk_resp(data=response_data, response=commons.response)
|
||||
# # ### END ### API User ### get_account_user_obj_li() ###
|
||||
|
||||
|
||||
@router.get('/user/list', response_model=Resp_Body_Base)
|
||||
async def get_user_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),
|
||||
commons: Common_Route_Params = Depends(common_route_params),
|
||||
):
|
||||
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
# @router.get('/user/list', response_model=Resp_Body_Base)
|
||||
# async def get_user_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),
|
||||
# commons: Common_Route_Params = Depends(common_route_params),
|
||||
# ):
|
||||
# log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
# log.debug(locals())
|
||||
|
||||
obj_type = 'user'
|
||||
result = get_obj_li_template(
|
||||
obj_type=obj_type,
|
||||
for_obj_type=for_obj_type,
|
||||
for_obj_id=for_obj_id,
|
||||
by_alias=True,
|
||||
exclude_unset=True,
|
||||
)
|
||||
return result
|
||||
# obj_type = 'user'
|
||||
# result = get_obj_li_template(
|
||||
# obj_type=obj_type,
|
||||
# for_obj_type=for_obj_type,
|
||||
# for_obj_id=for_obj_id,
|
||||
# by_alias=True,
|
||||
# exclude_unset=True,
|
||||
# )
|
||||
# return result
|
||||
|
||||
|
||||
# Look up is only for account or person records
|
||||
# NOTE: This may be actively in use 2026-03-24
|
||||
# This is marked for deprecation and must be migrated to Aether API v3 standards!
|
||||
@router.get('/user/lookup', response_model=Resp_Body_Base)
|
||||
async def lookup_user_obj(
|
||||
for_obj_id: Union[int,str],
|
||||
@@ -638,6 +647,8 @@ async def lookup_user_obj(
|
||||
|
||||
|
||||
# Look up a user with an email address for an account
|
||||
# NOTE: This may be actively in use 2026-03-24 -Scott
|
||||
# This is marked for deprecation and must be migrated to Aether API v3 standards!
|
||||
@router.get('/user/lookup_email', response_model=Resp_Body_Base)
|
||||
async def lookup_email(
|
||||
email: str = Query(..., min_length=2, max_length=50),
|
||||
@@ -728,6 +739,8 @@ async def lookup_email(
|
||||
|
||||
# Look up is only for account or person records
|
||||
# Look up a user with a username for an account
|
||||
# NOTE: This may be actively in use 2026-03-24
|
||||
# This is marked for deprecation and must be migrated to Aether API v3 standards!
|
||||
@router.get('/user/lookup_username', response_model=Resp_Body_Base)
|
||||
async def lookup_username(
|
||||
username: str = Query(..., min_length=2, max_length=50),
|
||||
@@ -799,6 +812,8 @@ async def lookup_username(
|
||||
# This requires the user_id and root_url or base_url.
|
||||
# This endpoint will generate a new user auth_key and send the email to the user's email address.
|
||||
# Updated 2025-04-08
|
||||
# NOTE: This is actively in use 2026-03-24 -Scott
|
||||
# This is marked for deprecation and must be migrated to Aether API v3 standards!
|
||||
# @router.get('/user/email_auth_key_url', response_model=Resp_Body_Base)
|
||||
@router.get('/user/{user_id}/email_auth_key_url', response_model=Resp_Body_Base)
|
||||
async def email_auth_key_url(
|
||||
@@ -830,69 +845,69 @@ async def email_auth_key_url(
|
||||
# ### END ### API User ### email_auth_key_url() ###
|
||||
|
||||
|
||||
# ### BEGIN ### API User ### get_user_obj() ###
|
||||
# Updated 2022-01-05
|
||||
@router.get('/user/{user_id}', response_model=Resp_Body_Base)
|
||||
async def get_user_obj(
|
||||
user_id: str = Path(min_length=11, max_length=22),
|
||||
inc_address: bool = False, # Priority l1
|
||||
# inc_archive_list: bool = False, # Priority l3
|
||||
inc_contact: bool = False, # Priority l1
|
||||
inc_event_list: bool = False, # Priority l1
|
||||
# inc_hosted_file_list: bool = False, # Priority l3
|
||||
inc_journal_list: bool = False, # Priority l2
|
||||
# inc_journal_entry_list: bool = False, # Priority l3
|
||||
inc_membership_person: bool = False, # Priority l2
|
||||
# inc_membership_list: bool = False, # ???
|
||||
inc_order_line_list: bool = False, # Priority l1
|
||||
inc_order_list: bool = False, # Priority l1
|
||||
inc_order_cart_list: bool = False, # Priority l1
|
||||
inc_organization: bool = False, # Priority l1
|
||||
# inc_organization_list: bool = False,
|
||||
inc_person: bool = False, # Priority l1
|
||||
# inc_person_list: bool = False,
|
||||
inc_post_list: bool = False, # Priority l2
|
||||
inc_post_comment_list: bool = False, # Priority l3
|
||||
inc_user_role_list: bool = False, # Priority l1
|
||||
commons: Common_Route_Params = Depends(common_route_params),
|
||||
):
|
||||
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
# # ### BEGIN ### API User ### get_user_obj() ###
|
||||
# # Updated 2022-01-05
|
||||
# @router.get('/user/{user_id}', response_model=Resp_Body_Base)
|
||||
# async def get_user_obj(
|
||||
# user_id: str = Path(min_length=11, max_length=22),
|
||||
# inc_address: bool = False, # Priority l1
|
||||
# # inc_archive_list: bool = False, # Priority l3
|
||||
# inc_contact: bool = False, # Priority l1
|
||||
# inc_event_list: bool = False, # Priority l1
|
||||
# # inc_hosted_file_list: bool = False, # Priority l3
|
||||
# inc_journal_list: bool = False, # Priority l2
|
||||
# # inc_journal_entry_list: bool = False, # Priority l3
|
||||
# inc_membership_person: bool = False, # Priority l2
|
||||
# # inc_membership_list: bool = False, # ???
|
||||
# inc_order_line_list: bool = False, # Priority l1
|
||||
# inc_order_list: bool = False, # Priority l1
|
||||
# inc_order_cart_list: bool = False, # Priority l1
|
||||
# inc_organization: bool = False, # Priority l1
|
||||
# # inc_organization_list: bool = False,
|
||||
# inc_person: bool = False, # Priority l1
|
||||
# # inc_person_list: bool = False,
|
||||
# inc_post_list: bool = False, # Priority l2
|
||||
# inc_post_comment_list: bool = False, # Priority l3
|
||||
# inc_user_role_list: bool = False, # Priority l1
|
||||
# commons: Common_Route_Params = Depends(common_route_params),
|
||||
# ):
|
||||
# log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
# log.debug(locals())
|
||||
|
||||
if user_id := redis_lookup_id_random(record_id_random=user_id, table_name='user'): pass
|
||||
else: return mk_resp(data=None, status_code=404, response=commons.response)
|
||||
# if user_id := redis_lookup_id_random(record_id_random=user_id, table_name='user'): pass
|
||||
# else: return mk_resp(data=None, status_code=404, response=commons.response)
|
||||
|
||||
if user_result := load_user_obj(
|
||||
user_id = user_id,
|
||||
limit = commons.limit,
|
||||
model_as_dict = True, # NOTE: returning model as a dict
|
||||
enabled = commons.enabled,
|
||||
inc_address = inc_address,
|
||||
# inc_archive_list = inc_archive_list,
|
||||
inc_contact = inc_contact,
|
||||
inc_event_list = inc_event_list,
|
||||
# inc_hosted_file_list = inc_hosted_file_list,
|
||||
# inc_journal_list = inc_journal_list,
|
||||
# inc_journal_entry_list = inc_journal_entry_list,
|
||||
# inc_membership_person = inc_membership_person,
|
||||
# inc_membership_list = inc_membership_list, # ???
|
||||
inc_order_line_list = inc_order_line_list,
|
||||
inc_order_list = inc_order_list,
|
||||
inc_order_cart_list = inc_order_cart_list,
|
||||
# inc_organization = inc_organization,
|
||||
# inc_organization_list = inc_organization_list,
|
||||
inc_person = inc_person,
|
||||
# inc_person_list = inc_person_list,
|
||||
# inc_post_list = inc_post_list,
|
||||
# inc_post_comment_list = inc_post_comment_list,
|
||||
inc_user_role_list = inc_user_role_list,
|
||||
):
|
||||
response_data = user_result
|
||||
else:
|
||||
return mk_resp(data=False, status_code=400, response=commons.response) # Bad Request
|
||||
# if user_result := load_user_obj(
|
||||
# user_id = user_id,
|
||||
# limit = commons.limit,
|
||||
# model_as_dict = True, # NOTE: returning model as a dict
|
||||
# enabled = commons.enabled,
|
||||
# inc_address = inc_address,
|
||||
# # inc_archive_list = inc_archive_list,
|
||||
# inc_contact = inc_contact,
|
||||
# inc_event_list = inc_event_list,
|
||||
# # inc_hosted_file_list = inc_hosted_file_list,
|
||||
# # inc_journal_list = inc_journal_list,
|
||||
# # inc_journal_entry_list = inc_journal_entry_list,
|
||||
# # inc_membership_person = inc_membership_person,
|
||||
# # inc_membership_list = inc_membership_list, # ???
|
||||
# inc_order_line_list = inc_order_line_list,
|
||||
# inc_order_list = inc_order_list,
|
||||
# inc_order_cart_list = inc_order_cart_list,
|
||||
# # inc_organization = inc_organization,
|
||||
# # inc_organization_list = inc_organization_list,
|
||||
# inc_person = inc_person,
|
||||
# # inc_person_list = inc_person_list,
|
||||
# # inc_post_list = inc_post_list,
|
||||
# # inc_post_comment_list = inc_post_comment_list,
|
||||
# inc_user_role_list = inc_user_role_list,
|
||||
# ):
|
||||
# response_data = user_result
|
||||
# else:
|
||||
# return mk_resp(data=False, status_code=400, response=commons.response) # Bad Request
|
||||
|
||||
return mk_resp(data=response_data, response=commons.response)
|
||||
# ### END ### API User ### get_user_obj() ###
|
||||
# return mk_resp(data=response_data, response=commons.response)
|
||||
# # ### END ### API User ### get_user_obj() ###
|
||||
|
||||
|
||||
# # ### BEGIN ### API User ### get_user_obj_order_list() ###
|
||||
@@ -962,17 +977,17 @@ async def get_user_obj(
|
||||
# # ### END ### API User ### get_user_obj_order_list() ###
|
||||
|
||||
|
||||
@router.delete('/user/{obj_id}', response_model=Resp_Body_Base)
|
||||
async def delete_user_obj(
|
||||
obj_id: str = Path(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())
|
||||
# @router.delete('/user/{obj_id}', response_model=Resp_Body_Base)
|
||||
# async def delete_user_obj(
|
||||
# obj_id: str = Path(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())
|
||||
|
||||
obj_type = 'user'
|
||||
result = delete_obj_template(
|
||||
obj_type=obj_type,
|
||||
obj_id=obj_id,
|
||||
)
|
||||
return result
|
||||
# obj_type = 'user'
|
||||
# result = delete_obj_template(
|
||||
# obj_type=obj_type,
|
||||
# obj_id=obj_id,
|
||||
# )
|
||||
# return result
|
||||
@@ -20,6 +20,8 @@ router = APIRouter()
|
||||
|
||||
# ### BEGIN ### API Utility: Email ### util_email_send_obj() ###
|
||||
# Updated 2023-06-27
|
||||
# NOTE: This is actively in use 2026-03-24 -Scott
|
||||
# This is marked for deprecation and must be migrated to Aether API v3 standards!
|
||||
@router.post('/util/email/send', response_model=Resp_Body_Base)
|
||||
async def util_email_send_obj(
|
||||
email_send_obj: Email_Send_Base,
|
||||
|
||||
Reference in New Issue
Block a user