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:
Scott Idem
2026-03-24 19:22:45 -04:00
parent c7f1341b1e
commit 8eb699efe5
6 changed files with 501 additions and 472 deletions

View File

@@ -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() ###