import datetime #from datetime import datetime, time, timedelta from fastapi import APIRouter, Body, Depends, Header, HTTPException, Path, Query, Response, status from pydantic import BaseModel, EmailStr, Field from typing import Dict, List, Optional, Set, Union from app.lib_general import log, logging, common_route_params, Common_Route_Params, common_route_params_no_account_id, Common_Route_Params_No_Account_ID from app.config import settings from app.db_sql import sql_enable_part, sql_insert, sql_update, sql_insert_or_update, sql_limit_offset_part, sql_select, sql_delete, redis_lookup_id_random # from app.models.aether_cfg_models import Aether_Cfg_Base from app.models.response_models import Resp_Body_Base, mk_resp router = APIRouter() @router.get('/aether/cfg/{aether_cfg_id}', response_model=Resp_Body_Base) async def get_aether_cfg_obj( aether_cfg_id: int, # aether_cfg_id: str = Path(min_length=11, max_length=22), # commons: Common_Route_Params = Depends(common_route_params), commons: Common_Route_Params_No_Account_ID = Depends(common_route_params_no_account_id), # x_account_id: str = Header(None, min_length=11, max_length=22), # response: Response = Response, ): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) if sql_select_result := sql_select( table_name = 'cfg', record_id = aether_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) @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()) 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)