From 19222ee946495edd6ae7ec973479e7e830059bd6 Mon Sep 17 00:00:00 2001 From: Scott Idem Date: Tue, 9 Mar 2021 18:37:30 -0500 Subject: [PATCH] Working on general POST, PATCH, SELECT list, SELECT, and DELETE template functions. --- app/main.py | 94 +++++++++++++++++++++- app/routers/archive.py | 126 ++++++++++++++++++++++++++++++ app/routers/archive_content.py | 126 ++++++++++++++++++++++++++++++ app/routers/event.py | 126 ++++++++++++++++++++++++++++++ app/routers/event_exhibit.py | 126 ++++++++++++++++++++++++++++++ app/routers/event_registration.py | 126 ++++++++++++++++++++++++++++++ app/routers/event_session.py | 126 ++++++++++++++++++++++++++++++ app/routers/membership.py | 126 ++++++++++++++++++++++++++++++ app/routers/order.py | 126 ++++++++++++++++++++++++++++++ app/routers/order_cart.py | 126 ++++++++++++++++++++++++++++++ app/routers/organization.py | 126 ++++++++++++++++++++++++++++++ app/routers/site.py | 126 ++++++++++++++++++++++++++++++ 12 files changed, 1477 insertions(+), 3 deletions(-) create mode 100644 app/routers/archive.py create mode 100644 app/routers/archive_content.py create mode 100644 app/routers/event.py create mode 100644 app/routers/event_exhibit.py create mode 100644 app/routers/event_registration.py create mode 100644 app/routers/event_session.py create mode 100644 app/routers/membership.py create mode 100644 app/routers/order.py create mode 100644 app/routers/order_cart.py create mode 100644 app/routers/organization.py create mode 100644 app/routers/site.py diff --git a/app/main.py b/app/main.py index 0c7b69f..e35afd0 100644 --- a/app/main.py +++ b/app/main.py @@ -18,7 +18,7 @@ from .lib_general import * from .log import * # Import the routers here first: -from .routers import api_crud, account, address, contact, page, person, post, post_comment, product, user, websockets # , items, journals +from .routers import api_crud, account, address, archive, archive_content, contact, event, event_exhibit, event_registration, membership, order, order_cart, organization, page, person, post, post_comment, product, site, user, websockets # , items, journals from .db_sql import db @@ -69,6 +69,22 @@ app.include_router( #dependencies=[Depends(get_account_header)], #responses={404: {'description': 'Not found'}}, ) +app.include_router( + archive.router, + prefix='/archive', + tags=['Archive'], + #dependencies=[Depends(get_token_header)], + #dependencies=[Depends(get_account_header)], + #responses={404: {'description': 'Not found'}}, +) +app.include_router( + archive_content.router, + prefix='/archive/content', + tags=['Archive Content'], + #dependencies=[Depends(get_token_header)], + #dependencies=[Depends(get_account_header)], + #responses={404: {'description': 'Not found'}}, +) app.include_router( contact.router, prefix='/contact', @@ -77,6 +93,70 @@ app.include_router( #dependencies=[Depends(get_account_header)], #responses={404: {'description': 'Not found'}}, ) +app.include_router( + event.router, + prefix='/event', + tags=['Event'], + #dependencies=[Depends(get_token_header)], + #dependencies=[Depends(get_account_header)], + #responses={404: {'description': 'Not found'}}, +) +app.include_router( + event_exhibit.router, + prefix='/event_exhibit', + tags=['Event Exhibit'], + #dependencies=[Depends(get_token_header)], + #dependencies=[Depends(get_account_header)], + #responses={404: {'description': 'Not found'}}, +) +app.include_router( + event_registration.router, + prefix='/event_registration', + tags=['Event Registration'], + #dependencies=[Depends(get_token_header)], + #dependencies=[Depends(get_account_header)], + #responses={404: {'description': 'Not found'}}, +) +# app.include_router( +# event_session.router, +# prefix='/event_session', +# tags=['Event Session'], +# #dependencies=[Depends(get_token_header)], +# #dependencies=[Depends(get_account_header)], +# #responses={404: {'description': 'Not found'}}, +# ) +app.include_router( + membership.router, + prefix='/membership', + tags=['Membership'], + #dependencies=[Depends(get_token_header)], + #dependencies=[Depends(get_account_header)], + #responses={404: {'description': 'Not found'}}, +) +app.include_router( + order.router, + prefix='/order', + tags=['Order'], + #dependencies=[Depends(get_token_header)], + #dependencies=[Depends(get_account_header)], + #responses={404: {'description': 'Not found'}}, +) +app.include_router( + order_cart.router, + prefix='/order/cart', + tags=['Order Cart'], + #dependencies=[Depends(get_token_header)], + #dependencies=[Depends(get_account_header)], + #responses={404: {'description': 'Not found'}}, +) +app.include_router( + organization.router, + prefix='/organization', + tags=['Organization'], + #dependencies=[Depends(get_token_header)], + #dependencies=[Depends(get_account_header)], + #responses={404: {'description': 'Not found'}}, +) app.include_router( page.router, prefix='/page', @@ -103,8 +183,8 @@ app.include_router( ) app.include_router( post_comment.router, - prefix='/post_comment', - tags=['Post_Comment'], + prefix='/post/comment', + tags=['Post Comment'], #dependencies=[Depends(get_token_header)], #dependencies=[Depends(get_account_header)], #responses={404: {'description': 'Not found'}}, @@ -117,6 +197,14 @@ app.include_router( #dependencies=[Depends(get_account_header)], #responses={404: {'description': 'Not found'}}, ) +app.include_router( + site.router, + prefix='/site', + tags=['Site'], + #dependencies=[Depends(get_token_header)], + #dependencies=[Depends(get_account_header)], + #responses={404: {'description': 'Not found'}}, +) app.include_router( user.router, prefix='/user', diff --git a/app/routers/archive.py b/app/routers/archive.py new file mode 100644 index 0000000..842e4b2 --- /dev/null +++ b/app/routers/archive.py @@ -0,0 +1,126 @@ +import datetime +#from datetime import datetime, time, timedelta +from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, status +from pydantic import BaseModel, EmailStr, Field +from typing import Dict, List, Optional, Set, Union + +from ..lib_general import * +from ..log import * +from app.config import settings +from app.db_sql import * + +from .api_crud import delete_obj_template, get_obj_template, get_obj_li_template, patch_obj_template, post_obj_template + +from ..models.archive_model import Archive_Base +from ..models.response_model import * + + +router = APIRouter() + + +@router.post('', response_model=Resp_Body_Base) +async def post_archive_obj( + obj: Archive_Base, + x_account_id: str = Header(...), + return_obj: Optional[bool] = True, + by_alias: Optional[bool] = True, + exclude_unset: Optional[bool] = True, + ): + log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL + log.debug(locals()) + + obj_type = 'archive' + 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 + + +@router.patch('/{obj_id}', response_model=Resp_Body_Base) +async def patch_archive_obj( + obj_id: str = Query(..., min_length=1, max_length=22), + obj: Archive_Base = None, + x_account_id: Optional[str] = Header(..., ), + return_obj: Optional[bool] = True, + by_alias: Optional[bool] = True, + exclude_unset: Optional[bool] = True, + ): + log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL + log.debug(locals()) + + obj_type = 'archive' + 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 + + +@router.get('/list', response_model=Resp_Body_Base) +async def get_archive_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), + x_account_id: str = Header(...), + by_alias: Optional[bool] = True, + exclude_unset: Optional[bool] = True, + ): + log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL + log.debug(locals()) + + obj_type = 'archive' + 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 + + +@router.get('/{obj_id}', response_model=Resp_Body_Base) +async def get_archive_obj( + obj_id: str = Query(..., min_length=1, max_length=22), + x_account_id: str = Header(...), + by_alias: Optional[bool] = True, + exclude_unset: Optional[bool] = True, + ): + log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL + log.debug(locals()) + + obj_type = 'archive' + result = get_obj_template( + obj_type=obj_type, + obj_id=obj_id, + by_alias=True, + exclude_unset=True, + ) + return result + + +@router.delete('/{obj_id}', response_model=Resp_Body_Base) +async def delete_archive_obj( + obj_id: str = Query(..., min_length=1, max_length=22), + x_account_id: str = Header(...), + ): + log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL + log.debug(locals()) + + obj_type = 'archive' + result = delete_obj_template( + obj_type=obj_type, + obj_id=obj_id, + ) + return result \ No newline at end of file diff --git a/app/routers/archive_content.py b/app/routers/archive_content.py new file mode 100644 index 0000000..bf5ca8f --- /dev/null +++ b/app/routers/archive_content.py @@ -0,0 +1,126 @@ +import datetime +#from datetime import datetime, time, timedelta +from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, status +from pydantic import BaseModel, EmailStr, Field +from typing import Dict, List, Optional, Set, Union + +from ..lib_general import * +from ..log import * +from app.config import settings +from app.db_sql import * + +from .api_crud import delete_obj_template, get_obj_template, get_obj_li_template, patch_obj_template, post_obj_template + +from ..models.archive_content_model import Archive_Content_Base +from ..models.response_model import * + + +router = APIRouter() + + +@router.post('', response_model=Resp_Body_Base) +async def post_archive_content_obj( + obj: Archive_Content_Base, + x_account_id: str = Header(...), + return_obj: Optional[bool] = True, + by_alias: Optional[bool] = True, + exclude_unset: Optional[bool] = True, + ): + log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL + log.debug(locals()) + + obj_type = 'archive_content' + 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 + + +@router.patch('/{obj_id}', response_model=Resp_Body_Base) +async def patch_archive_content_obj( + obj_id: str = Query(..., min_length=1, max_length=22), + obj: Archive_Content_Base = None, + x_account_id: Optional[str] = Header(..., ), + return_obj: Optional[bool] = True, + by_alias: Optional[bool] = True, + exclude_unset: Optional[bool] = True, + ): + log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL + log.debug(locals()) + + obj_type = 'archive_content' + 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 + + +@router.get('/list', response_model=Resp_Body_Base) +async def get_archive_content_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), + x_account_id: str = Header(...), + by_alias: Optional[bool] = True, + exclude_unset: Optional[bool] = True, + ): + log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL + log.debug(locals()) + + obj_type = 'archive_content' + 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 + + +@router.get('/{obj_id}', response_model=Resp_Body_Base) +async def get_archive_content_obj( + obj_id: str = Query(..., min_length=1, max_length=22), + x_account_id: str = Header(...), + by_alias: Optional[bool] = True, + exclude_unset: Optional[bool] = True, + ): + log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL + log.debug(locals()) + + obj_type = 'archive_content' + result = get_obj_template( + obj_type=obj_type, + obj_id=obj_id, + by_alias=True, + exclude_unset=True, + ) + return result + + +@router.delete('/{obj_id}', response_model=Resp_Body_Base) +async def delete_archive_content_obj( + obj_id: str = Query(..., min_length=1, max_length=22), + x_account_id: str = Header(...), + ): + log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL + log.debug(locals()) + + obj_type = 'archive_content' + result = delete_obj_template( + obj_type=obj_type, + obj_id=obj_id, + ) + return result \ No newline at end of file diff --git a/app/routers/event.py b/app/routers/event.py new file mode 100644 index 0000000..86eb678 --- /dev/null +++ b/app/routers/event.py @@ -0,0 +1,126 @@ +import datetime +#from datetime import datetime, time, timedelta +from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, status +from pydantic import BaseModel, EmailStr, Field +from typing import Dict, List, Optional, Set, Union + +from ..lib_general import * +from ..log import * +from app.config import settings +from app.db_sql import * + +from .api_crud import delete_obj_template, get_obj_template, get_obj_li_template, patch_obj_template, post_obj_template + +from ..models.event_model import Event_Base +from ..models.response_model import * + + +router = APIRouter() + + +@router.post('', response_model=Resp_Body_Base) +async def post_event_obj( + obj: Event_Base, + x_account_id: str = Header(...), + return_obj: Optional[bool] = True, + by_alias: Optional[bool] = True, + exclude_unset: Optional[bool] = True, + ): + log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL + log.debug(locals()) + + obj_type = 'event' + 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 + + +@router.patch('/{obj_id}', response_model=Resp_Body_Base) +async def patch_event_obj( + obj_id: str = Query(..., min_length=1, max_length=22), + obj: Event_Base = None, + x_account_id: Optional[str] = Header(..., ), + return_obj: Optional[bool] = True, + by_alias: Optional[bool] = True, + exclude_unset: Optional[bool] = True, + ): + log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL + log.debug(locals()) + + obj_type = 'event' + 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 + + +@router.get('/list', response_model=Resp_Body_Base) +async def get_event_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), + x_account_id: str = Header(...), + by_alias: Optional[bool] = True, + exclude_unset: Optional[bool] = True, + ): + log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL + log.debug(locals()) + + obj_type = 'event' + 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 + + +@router.get('/{obj_id}', response_model=Resp_Body_Base) +async def get_event_obj( + obj_id: str = Query(..., min_length=1, max_length=22), + x_account_id: str = Header(...), + by_alias: Optional[bool] = True, + exclude_unset: Optional[bool] = True, + ): + log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL + log.debug(locals()) + + obj_type = 'event' + result = get_obj_template( + obj_type=obj_type, + obj_id=obj_id, + by_alias=True, + exclude_unset=True, + ) + return result + + +@router.delete('/{obj_id}', response_model=Resp_Body_Base) +async def delete_event_obj( + obj_id: str = Query(..., min_length=1, max_length=22), + x_account_id: str = Header(...), + ): + log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL + log.debug(locals()) + + obj_type = 'event' + result = delete_obj_template( + obj_type=obj_type, + obj_id=obj_id, + ) + return result \ No newline at end of file diff --git a/app/routers/event_exhibit.py b/app/routers/event_exhibit.py new file mode 100644 index 0000000..75481bd --- /dev/null +++ b/app/routers/event_exhibit.py @@ -0,0 +1,126 @@ +import datetime +#from datetime import datetime, time, timedelta +from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, status +from pydantic import BaseModel, EmailStr, Field +from typing import Dict, List, Optional, Set, Union + +from ..lib_general import * +from ..log import * +from app.config import settings +from app.db_sql import * + +from .api_crud import delete_obj_template, get_obj_template, get_obj_li_template, patch_obj_template, post_obj_template + +from ..models.event_exhibit_model import Event_Exhibit_Base +from ..models.response_model import * + + +router = APIRouter() + + +@router.post('', response_model=Resp_Body_Base) +async def post_event_exhibit_obj( + obj: Event_Exhibit_Base, + x_account_id: str = Header(...), + return_obj: Optional[bool] = True, + by_alias: Optional[bool] = True, + exclude_unset: Optional[bool] = True, + ): + log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL + log.debug(locals()) + + obj_type = 'event_exhibit' + 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 + + +@router.patch('/{obj_id}', response_model=Resp_Body_Base) +async def patch_event_exhibit_obj( + obj_id: str = Query(..., min_length=1, max_length=22), + obj: Event_Exhibit_Base = None, + x_account_id: Optional[str] = Header(..., ), + return_obj: Optional[bool] = True, + by_alias: Optional[bool] = True, + exclude_unset: Optional[bool] = True, + ): + log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL + log.debug(locals()) + + obj_type = 'event_exhibit' + 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 + + +@router.get('/list', response_model=Resp_Body_Base) +async def get_event_exhibit_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), + x_account_id: str = Header(...), + by_alias: Optional[bool] = True, + exclude_unset: Optional[bool] = True, + ): + log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL + log.debug(locals()) + + obj_type = 'event_exhibit' + 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 + + +@router.get('/{obj_id}', response_model=Resp_Body_Base) +async def get_event_exhibit_obj( + obj_id: str = Query(..., min_length=1, max_length=22), + x_account_id: str = Header(...), + by_alias: Optional[bool] = True, + exclude_unset: Optional[bool] = True, + ): + log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL + log.debug(locals()) + + obj_type = 'event_exhibit' + result = get_obj_template( + obj_type=obj_type, + obj_id=obj_id, + by_alias=True, + exclude_unset=True, + ) + return result + + +@router.delete('/{obj_id}', response_model=Resp_Body_Base) +async def delete_event_exhibit_obj( + obj_id: str = Query(..., min_length=1, max_length=22), + x_account_id: str = Header(...), + ): + log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL + log.debug(locals()) + + obj_type = 'event_exhibit' + result = delete_obj_template( + obj_type=obj_type, + obj_id=obj_id, + ) + return result \ No newline at end of file diff --git a/app/routers/event_registration.py b/app/routers/event_registration.py new file mode 100644 index 0000000..713fcf3 --- /dev/null +++ b/app/routers/event_registration.py @@ -0,0 +1,126 @@ +import datetime +#from datetime import datetime, time, timedelta +from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, status +from pydantic import BaseModel, EmailStr, Field +from typing import Dict, List, Optional, Set, Union + +from ..lib_general import * +from ..log import * +from app.config import settings +from app.db_sql import * + +from .api_crud import delete_obj_template, get_obj_template, get_obj_li_template, patch_obj_template, post_obj_template + +from ..models.event_registration_model import Event_Registration_Base +from ..models.response_model import * + + +router = APIRouter() + + +@router.post('', response_model=Resp_Body_Base) +async def post_event_registration_obj( + obj: Event_Registration_Base, + x_account_id: str = Header(...), + return_obj: Optional[bool] = True, + by_alias: Optional[bool] = True, + exclude_unset: Optional[bool] = True, + ): + log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL + log.debug(locals()) + + obj_type = 'event_registration' + 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 + + +@router.patch('/{obj_id}', response_model=Resp_Body_Base) +async def patch_event_registration_obj( + obj_id: str = Query(..., min_length=1, max_length=22), + obj: Event_Registration_Base = None, + x_account_id: Optional[str] = Header(..., ), + return_obj: Optional[bool] = True, + by_alias: Optional[bool] = True, + exclude_unset: Optional[bool] = True, + ): + log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL + log.debug(locals()) + + obj_type = 'event_registration' + 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 + + +@router.get('/list', response_model=Resp_Body_Base) +async def get_event_registration_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), + x_account_id: str = Header(...), + by_alias: Optional[bool] = True, + exclude_unset: Optional[bool] = True, + ): + log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL + log.debug(locals()) + + obj_type = 'event_registration' + 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 + + +@router.get('/{obj_id}', response_model=Resp_Body_Base) +async def get_event_registration_obj( + obj_id: str = Query(..., min_length=1, max_length=22), + x_account_id: str = Header(...), + by_alias: Optional[bool] = True, + exclude_unset: Optional[bool] = True, + ): + log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL + log.debug(locals()) + + obj_type = 'event_registration' + result = get_obj_template( + obj_type=obj_type, + obj_id=obj_id, + by_alias=True, + exclude_unset=True, + ) + return result + + +@router.delete('/{obj_id}', response_model=Resp_Body_Base) +async def delete_event_registration_obj( + obj_id: str = Query(..., min_length=1, max_length=22), + x_account_id: str = Header(...), + ): + log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL + log.debug(locals()) + + obj_type = 'event_registration' + result = delete_obj_template( + obj_type=obj_type, + obj_id=obj_id, + ) + return result \ No newline at end of file diff --git a/app/routers/event_session.py b/app/routers/event_session.py new file mode 100644 index 0000000..9701ece --- /dev/null +++ b/app/routers/event_session.py @@ -0,0 +1,126 @@ +import datetime +#from datetime import datetime, time, timedelta +from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, status +from pydantic import BaseModel, EmailStr, Field +from typing import Dict, List, Optional, Set, Union + +from ..lib_general import * +from ..log import * +from app.config import settings +from app.db_sql import * + +from .api_crud import delete_obj_template, get_obj_template, get_obj_li_template, patch_obj_template, post_obj_template + +from ..models.event_session_model import Event_Session_Base +from ..models.response_model import * + + +router = APIRouter() + + +@router.post('', response_model=Resp_Body_Base) +async def post_event_session_obj( + obj: Event_Session_Base, + x_account_id: str = Header(...), + return_obj: Optional[bool] = True, + by_alias: Optional[bool] = True, + exclude_unset: Optional[bool] = True, + ): + log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL + log.debug(locals()) + + obj_type = 'event_session' + 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 + + +@router.patch('/{obj_id}', response_model=Resp_Body_Base) +async def patch_event_session_obj( + obj_id: str = Query(..., min_length=1, max_length=22), + obj: Event_Session_Base = None, + x_account_id: Optional[str] = Header(..., ), + return_obj: Optional[bool] = True, + by_alias: Optional[bool] = True, + exclude_unset: Optional[bool] = True, + ): + log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL + log.debug(locals()) + + obj_type = 'event_session' + 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 + + +@router.get('/list', response_model=Resp_Body_Base) +async def get_event_session_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), + x_account_id: str = Header(...), + by_alias: Optional[bool] = True, + exclude_unset: Optional[bool] = True, + ): + log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL + log.debug(locals()) + + obj_type = 'event_session' + 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 + + +@router.get('/{obj_id}', response_model=Resp_Body_Base) +async def get_event_session_obj( + obj_id: str = Query(..., min_length=1, max_length=22), + x_account_id: str = Header(...), + by_alias: Optional[bool] = True, + exclude_unset: Optional[bool] = True, + ): + log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL + log.debug(locals()) + + obj_type = 'event_session' + result = get_obj_template( + obj_type=obj_type, + obj_id=obj_id, + by_alias=True, + exclude_unset=True, + ) + return result + + +@router.delete('/{obj_id}', response_model=Resp_Body_Base) +async def delete_event_session_obj( + obj_id: str = Query(..., min_length=1, max_length=22), + x_account_id: str = Header(...), + ): + log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL + log.debug(locals()) + + obj_type = 'event_session' + result = delete_obj_template( + obj_type=obj_type, + obj_id=obj_id, + ) + return result \ No newline at end of file diff --git a/app/routers/membership.py b/app/routers/membership.py new file mode 100644 index 0000000..9c17b40 --- /dev/null +++ b/app/routers/membership.py @@ -0,0 +1,126 @@ +import datetime +#from datetime import datetime, time, timedelta +from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, status +from pydantic import BaseModel, EmailStr, Field +from typing import Dict, List, Optional, Set, Union + +from ..lib_general import * +from ..log import * +from app.config import settings +from app.db_sql import * + +from .api_crud import delete_obj_template, get_obj_template, get_obj_li_template, patch_obj_template, post_obj_template + +from ..models.membership_model import Membership_Base +from ..models.response_model import * + + +router = APIRouter() + + +@router.post('', response_model=Resp_Body_Base) +async def post_membership_obj( + obj: Membership_Base, + x_account_id: str = Header(...), + return_obj: Optional[bool] = True, + by_alias: Optional[bool] = True, + exclude_unset: Optional[bool] = True, + ): + log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL + log.debug(locals()) + + obj_type = 'membership' + 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 + + +@router.patch('/{obj_id}', response_model=Resp_Body_Base) +async def patch_membership_obj( + obj_id: str = Query(..., min_length=1, max_length=22), + obj: Membership_Base = None, + x_account_id: Optional[str] = Header(..., ), + return_obj: Optional[bool] = True, + by_alias: Optional[bool] = True, + exclude_unset: Optional[bool] = True, + ): + log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL + log.debug(locals()) + + obj_type = 'membership' + 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 + + +@router.get('/list', response_model=Resp_Body_Base) +async def get_membership_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), + x_account_id: str = Header(...), + by_alias: Optional[bool] = True, + exclude_unset: Optional[bool] = True, + ): + log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL + log.debug(locals()) + + obj_type = 'membership' + 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 + + +@router.get('/{obj_id}', response_model=Resp_Body_Base) +async def get_membership_obj( + obj_id: str = Query(..., min_length=1, max_length=22), + x_account_id: str = Header(...), + by_alias: Optional[bool] = True, + exclude_unset: Optional[bool] = True, + ): + log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL + log.debug(locals()) + + obj_type = 'membership' + result = get_obj_template( + obj_type=obj_type, + obj_id=obj_id, + by_alias=True, + exclude_unset=True, + ) + return result + + +@router.delete('/{obj_id}', response_model=Resp_Body_Base) +async def delete_membership_obj( + obj_id: str = Query(..., min_length=1, max_length=22), + x_account_id: str = Header(...), + ): + log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL + log.debug(locals()) + + obj_type = 'membership' + result = delete_obj_template( + obj_type=obj_type, + obj_id=obj_id, + ) + return result \ No newline at end of file diff --git a/app/routers/order.py b/app/routers/order.py new file mode 100644 index 0000000..828f0ec --- /dev/null +++ b/app/routers/order.py @@ -0,0 +1,126 @@ +import datetime +#from datetime import datetime, time, timedelta +from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, status +from pydantic import BaseModel, EmailStr, Field +from typing import Dict, List, Optional, Set, Union + +from ..lib_general import * +from ..log import * +from app.config import settings +from app.db_sql import * + +from .api_crud import delete_obj_template, get_obj_template, get_obj_li_template, patch_obj_template, post_obj_template + +from ..models.order_model import Order_Base +from ..models.response_model import * + + +router = APIRouter() + + +@router.post('', response_model=Resp_Body_Base) +async def post_order_obj( + obj: Order_Base, + x_account_id: str = Header(...), + return_obj: Optional[bool] = True, + by_alias: Optional[bool] = True, + exclude_unset: Optional[bool] = True, + ): + log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL + log.debug(locals()) + + obj_type = 'order' + 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 + + +@router.patch('/{obj_id}', response_model=Resp_Body_Base) +async def patch_order_obj( + obj_id: str = Query(..., min_length=1, max_length=22), + obj: Order_Base = None, + x_account_id: Optional[str] = Header(..., ), + return_obj: Optional[bool] = True, + by_alias: Optional[bool] = True, + exclude_unset: Optional[bool] = True, + ): + log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL + log.debug(locals()) + + obj_type = 'order' + 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 + + +@router.get('/list', response_model=Resp_Body_Base) +async def get_order_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), + x_account_id: str = Header(...), + by_alias: Optional[bool] = True, + exclude_unset: Optional[bool] = True, + ): + log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL + log.debug(locals()) + + obj_type = 'order' + 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 + + +@router.get('/{obj_id}', response_model=Resp_Body_Base) +async def get_order_obj( + obj_id: str = Query(..., min_length=1, max_length=22), + x_account_id: str = Header(...), + by_alias: Optional[bool] = True, + exclude_unset: Optional[bool] = True, + ): + log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL + log.debug(locals()) + + obj_type = 'order' + result = get_obj_template( + obj_type=obj_type, + obj_id=obj_id, + by_alias=True, + exclude_unset=True, + ) + return result + + +@router.delete('/{obj_id}', response_model=Resp_Body_Base) +async def delete_order_obj( + obj_id: str = Query(..., min_length=1, max_length=22), + x_account_id: str = Header(...), + ): + log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL + log.debug(locals()) + + obj_type = 'order' + result = delete_obj_template( + obj_type=obj_type, + obj_id=obj_id, + ) + return result \ No newline at end of file diff --git a/app/routers/order_cart.py b/app/routers/order_cart.py new file mode 100644 index 0000000..d327738 --- /dev/null +++ b/app/routers/order_cart.py @@ -0,0 +1,126 @@ +import datetime +#from datetime import datetime, time, timedelta +from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, status +from pydantic import BaseModel, EmailStr, Field +from typing import Dict, List, Optional, Set, Union + +from ..lib_general import * +from ..log import * +from app.config import settings +from app.db_sql import * + +from .api_crud import delete_obj_template, get_obj_template, get_obj_li_template, patch_obj_template, post_obj_template + +from ..models.order_cart_model import Order_Cart_Base +from ..models.response_model import * + + +router = APIRouter() + + +@router.post('', response_model=Resp_Body_Base) +async def post_order_cart_obj( + obj: Order_Cart_Base, + x_account_id: str = Header(...), + return_obj: Optional[bool] = True, + by_alias: Optional[bool] = True, + exclude_unset: Optional[bool] = True, + ): + log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL + log.debug(locals()) + + obj_type = 'order_cart' + 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 + + +@router.patch('/{obj_id}', response_model=Resp_Body_Base) +async def patch_order_cart_obj( + obj_id: str = Query(..., min_length=1, max_length=22), + obj: Order_Cart_Base = None, + x_account_id: Optional[str] = Header(..., ), + return_obj: Optional[bool] = True, + by_alias: Optional[bool] = True, + exclude_unset: Optional[bool] = True, + ): + log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL + log.debug(locals()) + + obj_type = 'order_cart' + 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 + + +@router.get('/list', response_model=Resp_Body_Base) +async def get_order_cart_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), + x_account_id: str = Header(...), + by_alias: Optional[bool] = True, + exclude_unset: Optional[bool] = True, + ): + log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL + log.debug(locals()) + + obj_type = 'order_cart' + 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 + + +@router.get('/{obj_id}', response_model=Resp_Body_Base) +async def get_order_cart_obj( + obj_id: str = Query(..., min_length=1, max_length=22), + x_account_id: str = Header(...), + by_alias: Optional[bool] = True, + exclude_unset: Optional[bool] = True, + ): + log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL + log.debug(locals()) + + obj_type = 'order_cart' + result = get_obj_template( + obj_type=obj_type, + obj_id=obj_id, + by_alias=True, + exclude_unset=True, + ) + return result + + +@router.delete('/{obj_id}', response_model=Resp_Body_Base) +async def delete_order_cart_obj( + obj_id: str = Query(..., min_length=1, max_length=22), + x_account_id: str = Header(...), + ): + log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL + log.debug(locals()) + + obj_type = 'order_cart' + result = delete_obj_template( + obj_type=obj_type, + obj_id=obj_id, + ) + return result \ No newline at end of file diff --git a/app/routers/organization.py b/app/routers/organization.py new file mode 100644 index 0000000..8bfca8f --- /dev/null +++ b/app/routers/organization.py @@ -0,0 +1,126 @@ +import datetime +#from datetime import datetime, time, timedelta +from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, status +from pydantic import BaseModel, EmailStr, Field +from typing import Dict, List, Optional, Set, Union + +from ..lib_general import * +from ..log import * +from app.config import settings +from app.db_sql import * + +from .api_crud import delete_obj_template, get_obj_template, get_obj_li_template, patch_obj_template, post_obj_template + +from ..models.organization_model import Organization_Base +from ..models.response_model import * + + +router = APIRouter() + + +@router.post('', response_model=Resp_Body_Base) +async def post_organization_obj( + obj: Organization_Base, + x_account_id: str = Header(...), + return_obj: Optional[bool] = True, + by_alias: Optional[bool] = True, + exclude_unset: Optional[bool] = True, + ): + log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL + log.debug(locals()) + + obj_type = 'organization' + 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 + + +@router.patch('/{obj_id}', response_model=Resp_Body_Base) +async def patch_organization_obj( + obj_id: str = Query(..., min_length=1, max_length=22), + obj: Organization_Base = None, + x_account_id: Optional[str] = Header(..., ), + return_obj: Optional[bool] = True, + by_alias: Optional[bool] = True, + exclude_unset: Optional[bool] = True, + ): + log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL + log.debug(locals()) + + obj_type = 'organization' + 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 + + +@router.get('/list', response_model=Resp_Body_Base) +async def get_organization_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), + x_account_id: str = Header(...), + by_alias: Optional[bool] = True, + exclude_unset: Optional[bool] = True, + ): + log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL + log.debug(locals()) + + obj_type = 'organization' + 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 + + +@router.get('/{obj_id}', response_model=Resp_Body_Base) +async def get_organization_obj( + obj_id: str = Query(..., min_length=1, max_length=22), + x_account_id: str = Header(...), + by_alias: Optional[bool] = True, + exclude_unset: Optional[bool] = True, + ): + log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL + log.debug(locals()) + + obj_type = 'organization' + result = get_obj_template( + obj_type=obj_type, + obj_id=obj_id, + by_alias=True, + exclude_unset=True, + ) + return result + + +@router.delete('/{obj_id}', response_model=Resp_Body_Base) +async def delete_organization_obj( + obj_id: str = Query(..., min_length=1, max_length=22), + x_account_id: str = Header(...), + ): + log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL + log.debug(locals()) + + obj_type = 'organization' + result = delete_obj_template( + obj_type=obj_type, + obj_id=obj_id, + ) + return result \ No newline at end of file diff --git a/app/routers/site.py b/app/routers/site.py new file mode 100644 index 0000000..609a307 --- /dev/null +++ b/app/routers/site.py @@ -0,0 +1,126 @@ +import datetime +#from datetime import datetime, time, timedelta +from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, status +from pydantic import BaseModel, EmailStr, Field +from typing import Dict, List, Optional, Set, Union + +from ..lib_general import * +from ..log import * +from app.config import settings +from app.db_sql import * + +from .api_crud import delete_obj_template, get_obj_template, get_obj_li_template, patch_obj_template, post_obj_template + +from ..models.site_model import Site_Base +from ..models.response_model import * + + +router = APIRouter() + + +@router.post('', response_model=Resp_Body_Base) +async def post_site_obj( + obj: Site_Base, + x_account_id: str = Header(...), + return_obj: Optional[bool] = True, + by_alias: Optional[bool] = True, + exclude_unset: Optional[bool] = True, + ): + log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL + log.debug(locals()) + + obj_type = 'site' + 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 + + +@router.patch('/{obj_id}', response_model=Resp_Body_Base) +async def patch_site_obj( + obj_id: str = Query(..., min_length=1, max_length=22), + obj: Site_Base = None, + x_account_id: Optional[str] = Header(..., ), + return_obj: Optional[bool] = True, + by_alias: Optional[bool] = True, + exclude_unset: Optional[bool] = True, + ): + log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL + log.debug(locals()) + + obj_type = 'site' + 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 + + +@router.get('/list', response_model=Resp_Body_Base) +async def get_site_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), + x_account_id: str = Header(...), + by_alias: Optional[bool] = True, + exclude_unset: Optional[bool] = True, + ): + log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL + log.debug(locals()) + + obj_type = 'site' + 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 + + +@router.get('/{obj_id}', response_model=Resp_Body_Base) +async def get_site_obj( + obj_id: str = Query(..., min_length=1, max_length=22), + x_account_id: str = Header(...), + by_alias: Optional[bool] = True, + exclude_unset: Optional[bool] = True, + ): + log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL + log.debug(locals()) + + obj_type = 'site' + result = get_obj_template( + obj_type=obj_type, + obj_id=obj_id, + by_alias=True, + exclude_unset=True, + ) + return result + + +@router.delete('/{obj_id}', response_model=Resp_Body_Base) +async def delete_site_obj( + obj_id: str = Query(..., min_length=1, max_length=22), + x_account_id: str = Header(...), + ): + log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL + log.debug(locals()) + + obj_type = 'site' + result = delete_obj_template( + obj_type=obj_type, + obj_id=obj_id, + ) + return result \ No newline at end of file