diff --git a/src/_module_template/config.py b/src/_module_template/config.py index 45d3182..4be170e 100644 --- a/src/_module_template/config.py +++ b/src/_module_template/config.py @@ -1,5 +1,7 @@ """ -Configurations for the module +Configurations for -Exports: +Configurations: + - List: Description + - Configs: Description """ \ No newline at end of file diff --git a/src/_module_template/constants.py b/src/_module_template/constants.py index cc72009..e1df957 100644 --- a/src/_module_template/constants.py +++ b/src/_module_template/constants.py @@ -1,5 +1,7 @@ """ -Constants for the module +Constants and error codes for -Exports: +Constants: + - List: Description + - Consts: Description """ \ No newline at end of file diff --git a/src/_module_template/dependencies.py b/src/_module_template/dependencies.py index 71750bc..7447aaf 100644 --- a/src/_module_template/dependencies.py +++ b/src/_module_template/dependencies.py @@ -1,6 +1,11 @@ """ -Dependencies related to the module +Router dependencies for -Exports: - - : : +Classes: + - List: Description + - Classes: Description + +Functions: + - List: Description + - Functions: Description """ \ No newline at end of file diff --git a/src/_module_template/exceptions.py b/src/_module_template/exceptions.py index 402940a..5debbb4 100644 --- a/src/_module_template/exceptions.py +++ b/src/_module_template/exceptions.py @@ -1,6 +1,7 @@ """ -Exceptions related to the modules +Module specific exceptions for Exceptions: - - : Details e.g. optional params + - List: Description + - Exceptions: Description """ \ No newline at end of file diff --git a/src/_module_template/models.py b/src/_module_template/models.py index d03c882..6d2494b 100644 --- a/src/_module_template/models.py +++ b/src/_module_template/models.py @@ -1,9 +1,7 @@ """ -Database models for the module +Database models for Models: - - : - - - - - - + - List: Description + - Models: Description """ \ No newline at end of file diff --git a/src/_module_template/router.py b/src/_module_template/router.py index d96d7ee..2eb8569 100644 --- a/src/_module_template/router.py +++ b/src/_module_template/router.py @@ -1,12 +1,13 @@ """ -Router endpoints for the module +Router endpoints for -Exports: - - router: fastapi.APIRouter +Endpoints: + - List: Description + - Endpoints: Description """ from fastapi import APIRouter -router = APIRouter( +_router = APIRouter( tags=[""], -) +) \ No newline at end of file diff --git a/src/_module_template/schemas.py b/src/_module_template/schemas.py index 71cfc07..a074c75 100644 --- a/src/_module_template/schemas.py +++ b/src/_module_template/schemas.py @@ -1,8 +1,7 @@ """ -Pydantic models for the module +Pydantic models for -Models follow the nomenclature of: -- Sub-models: "Schema" -- Mixins: "Mixin" -- Models: "" ie "" +Models: + - List: Description + - Models: Description """ \ No newline at end of file diff --git a/src/_module_template/service.py b/src/_module_template/service.py index 139a237..7365fa9 100644 --- a/src/_module_template/service.py +++ b/src/_module_template/service.py @@ -1,5 +1,11 @@ """ -Module specific business logic for the module +Module specific business logic for -Exports: +Classes: + - List: Description + - Classes: Description + +Functions: + - List: Description + - Functions: Description """ \ No newline at end of file diff --git a/src/_module_template/utils.py b/src/_module_template/utils.py index 4e99ff6..f2da15a 100644 --- a/src/_module_template/utils.py +++ b/src/_module_template/utils.py @@ -1,3 +1,11 @@ """ -Non-business logic reusable functions and classes for the module +Non-business logic reusable functions and classes for + +Classes: + - List: Description + - Classes: Description + +Functions: + - List: Description + - Functions: Description """ \ No newline at end of file diff --git a/src/main.py b/src/main.py index 0092af0..3995edf 100644 --- a/src/main.py +++ b/src/main.py @@ -31,11 +31,7 @@ tags_metadata = [ { "name": "User", "description": "User related operations, includes getting information about the current user", - }, - { - "name": "Service", - "description": "Services related operations, includes registering services and reissuing API keys", - }, + } ] diff --git a/src/service/router.py b/src/service/router.py index e05a92e..bf01a87 100644 --- a/src/service/router.py +++ b/src/service/router.py @@ -26,29 +26,16 @@ router = APIRouter( prefix="/service", ) -@router.get("/", status_code=status.HTTP_200_OK, response_model=ServiceGetServiceResponse, responses={ - status.HTTP_200_OK: {"description": "Successful retrieval from database"}, - status.HTTP_401_UNAUTHORIZED: {"description": "Unauthorized"}, -}) +@router.get("/", response_model=ServiceGetServiceResponse) async def get_all_services(db: db_dependency, org_model: org_model_root_claim_query_dependency): - """ - Returns the ID and name of all services registered to the hub. - """ permission_models = db.query(Service).all() return {"services": permission_models} -@router.post("/", status_code=status.HTTP_200_OK, response_model=ServicePostServiceResponse, responses={ - status.HTTP_200_OK: {"description": "Successfully registered a new service"}, - status.HTTP_401_UNAUTHORIZED: {"description": "Unauthorized"}, - status.HTTP_409_CONFLICT: {"description": "Service with this name already exists"}, -}) -async def register_service(db: db_dependency, su: super_admin_dependency, request_model: ServicePostServiceRequest): - """ - Registers a new service to the hub, generating and returning an API key for it. - """ +@router.post("/", response_model=ServicePostServiceResponse) +async def register_service(db: db_dependency, su: super_admin_dependency, service_request: ServicePostServiceRequest): key = generate_api_key() - service_model = Service(name=request_model.name, api_key=key) + service_model = Service(name=service_request.name, api_key=key) db.add(service_model) try: @@ -61,14 +48,8 @@ async def register_service(db: db_dependency, su: super_admin_dependency, reques db.commit() return {"service": response} -@router.patch("/key", status_code=status.HTTP_200_OK, response_model=ServicePatchKeyResponse, responses={ - status.HTTP_200_OK: {"description": "Successful update of API key"}, - status.HTTP_401_UNAUTHORIZED: {"description": "Unauthorized"}, -}) +@router.patch("/key", response_model=ServicePatchKeyResponse) async def regenerate_api_key(db: db_dependency, su: super_admin_dependency, service_model: service_model_body_dependency, request_model: ServicePatchKeyRequest): - """ - Generates and returns a new API key for the service to access the hub. - """ key = generate_api_key() service_model.api_key = key @@ -77,13 +58,7 @@ async def regenerate_api_key(db: db_dependency, su: super_admin_dependency, serv db.commit() return {"service": response} -@router.delete("/", status_code=status.HTTP_204_NO_CONTENT, responses={ - status.HTTP_204_NO_CONTENT: {"description": "Successfully removed service from db"}, - status.HTTP_401_UNAUTHORIZED: {"description": "Unauthorized"}, -}) +@router.delete("/", status_code=status.HTTP_204_NO_CONTENT) async def remove_service(db: db_dependency, service_model: service_model_body_dependency, su: super_admin_dependency, request_model: ServiceDeleteServiceRequest): - """ - Removes a service from the hub. - """ db.delete(service_model) db.commit()