Compare commits

...

3 commits

Author SHA1 Message Date
e44e2bd627 docs: global docstrings
Issue: #13
2026-05-28 14:59:27 +01:00
43cb7e700d docs: user docstrings
Issue: #13
2026-05-28 14:55:44 +01:00
d852bda091 docs: service docstrings
Issue: #13
2026-05-28 14:41:11 +01:00
20 changed files with 58 additions and 98 deletions

View file

@ -1,8 +1,10 @@
""" """
Global configurations: import settings, app_configs Global configurations
Classes: Exports:
- CustomBaseSettings - Base class to be used by all modules for loading configs - CustomBaseSettings - Base class to be used by all modules for loading configs
- settings: Global configurations object
- app_configs: Dict generated from configs, used in app initialisation
""" """
from typing import Any from typing import Any

View file

@ -1,3 +1,10 @@
"""
Global Pydantic schemas
Exports:
- CustomBaseModel: Schema used for all other Pydantic models
- ResourceName
"""
from pydantic import BaseModel from pydantic import BaseModel
from typing import Optional from typing import Optional

View file

@ -1,7 +1,3 @@
""" """
Configurations for <this module> Configurations for the services module
Configurations:
- List: Description
- Configs: Description
""" """

View file

@ -1,7 +1,3 @@
""" """
Constants and error codes for <this module> Constants for the services module
Constants:
- List: Description
- Consts: Description
""" """

View file

@ -1,13 +1,9 @@
""" """
Router dependencies for <this module> Dependencies related to the services module
Classes: Exports:
- List: Description - service_model_query_dependency: service_model: Gets service model from db, if it exists. Uses service_id from query param.
- Classes: Description - service_model_body_dependency: service_model: Gets service model from db, if it exists. Uses service_id from request body.
Functions:
- List: Description
- Functions: Description
""" """
from typing import Annotated from typing import Annotated
from fastapi import Depends, Query from fastapi import Depends, Query

View file

@ -1,9 +1,8 @@
""" """
Module specific exceptions for <this module> Exceptions related to the services module
Exceptions: Exceptions:
- List: Description - ServiceNotFoundException: Takes an optional service_id int
- Exceptions: Description
""" """
from typing import Optional from typing import Optional

View file

@ -2,8 +2,8 @@
Database models for the services module Database models for the services module
Models: Models:
- List: Description - Service:
- Models: Description - id[PK], name[U], api_key[U]
""" """
from sqlalchemy import Column, Integer, String from sqlalchemy import Column, Integer, String

View file

@ -1,9 +1,11 @@
""" """
Router endpoints for <this module> Router endpoints for the services module
Endpoints: Endpoints:
- List: Description - [GET](/): [root user]: Get a list of all services(id, name)
- Endpoints: Description - [POST](/): [super admin]: Register a new service(name) on the hub, returns the API key for the service to access the hub.
- [PATCH](/key): [super_admin]: Refreshes the API key for a service(id), returning a new one.
- [DELETE](/): [super_admin]: Removes a service(id) from the hub.
""" """
from fastapi import APIRouter, status from fastapi import APIRouter, status
from psycopg.errors import UniqueViolation from psycopg.errors import UniqueViolation

View file

@ -1,9 +1,10 @@
""" """
Pydantic models for the service module Pydantic models for service module
Models: Models follow the nomenclature of:
- List: Description - Sub-models: "<Resource><Opt:>Schema"
- Models: Description - Mixins: "<Attribute>Mixin"
- Models: "<Module><Method><Resource><Opt:Resource><Direction>" ie "ServiceGetServiceResponse"
""" """
from pydantic import ConfigDict from pydantic import ConfigDict

View file

@ -1,11 +1,3 @@
""" """
Module specific business logic for <this module> Business logic for the services module
Classes:
- List: Description
- Classes: Description
Functions:
- List: Description
- Functions: Description
""" """

View file

@ -1,13 +1,8 @@
""" """
Non-business logic reusable functions and classes for <this module> Non-business logic reusable functions and classes for the services module
Classes: Exports:
- List: Description - generate_api_key(): returns a new UUID
- Classes: Description
Functions:
- List: Description
- Functions: Description
""" """
import uuid import uuid

View file

@ -1,7 +1,3 @@
""" """
Configurations for user module Configurations for the user module
Configurations:
- List: Description
- Configs: Description
""" """

View file

@ -1,7 +1,3 @@
""" """
Constants and error codes for user module Constants for the user module
Constants:
- List: Description
- Consts: Description
""" """

View file

@ -1,13 +1,10 @@
""" """
Router dependencies for user module Dependencies related to the user module
Classes: Exports:
- List: Description - user_model_claims_dependency: user_model: Gets user model from db, if it exists. Uses db_id from user claims.
- Classes: Description - user_model_query_dependency: user_model: Gets user model from db, if it exists. Uses user_id from query param
- user_model_body_dependency: user_model: Gets user model from db, if it exists. Uses user_id from request body.
Functions:
- List: Description
- Functions: Description
""" """
from typing import Annotated from typing import Annotated
from fastapi import Depends, Query from fastapi import Depends, Query

View file

@ -1,9 +1,8 @@
""" """
Module specific exceptions for user module Exceptions related to the user module
Exceptions: Exceptions:
- List: Description - UserNotFoundException: Takes an optional user_id int
- Exceptions: Description
""" """
from typing import Optional from typing import Optional

View file

@ -2,7 +2,12 @@
Database models for user module Database models for user module
Models: Models:
- User - id[pk], email, first_name, last_name, oidc_id - User:
- id[PK], email, first_name, last_name, oidc_id
- organisation_rel: ORM relationship to Organisation via OrgUsers table
- group_rel: ORM relationship to Group via UserGroups table
- organisations: Calc property list of organisation_rel.name
- groups: Calc property dict of {group_rel.org_rel.name: group_rel.name}
""" """
from collections import defaultdict from collections import defaultdict

View file

@ -1,15 +1,11 @@
""" """
Router endpoints for user module Router endpoints for the user module
Endpoints: Endpoints:
- [get]/self/claims - Retrieves user's OIDC claims - [GET](/user/self/claims): [OIDC claims]: Returns all OIDC claims associated with the currently logged-in user.
- [get]/self/db - Retrieves the user data from the db that corresponds to the current OIDC user - [GET](/user/self/db): [OIDC claims]: Returns details about the currently logged-in user from the hub db.
- [get]/self/orgs - Retrieves all organisations associated with the current user - [GET](/user/): [super admin]: Returns user(id) details.
- [get]/self/orgs/admin - Retrieves only admin organisations for the current user - [DELETE](/user/): [super admin]: Removes a User(id) from the hub database.
- [get]/{user_id} - Retrieves a specific user by their ID
- [get]/{user_id}/orgs - Retrieves all organisations associated with a specific user
- [get]/{user_id}/orgs/admin - Retrieves only admin organisations for a specific user
- [delete]/{user_id} - Deletes a user from the db by their db ID
""" """
from fastapi import APIRouter from fastapi import APIRouter
from starlette import status from starlette import status

View file

@ -1,9 +1,5 @@
""" """
Pydantic models for user module Pydantic models for the user module
Models:
- List: Description
- Models: Description
""" """
from typing import Optional from typing import Optional
from src.schemas import CustomBaseModel from src.schemas import CustomBaseModel

View file

@ -1,11 +1,8 @@
""" """
Module specific business logic for user module Module specific business logic for user module
Functions:
- add_user_to_db
Exports: Exports:
- add_user_to_db - add_user_to_db: Creates a User record from OIDC claims, or updates user details
""" """
from typing import Any from typing import Any

View file

@ -1,11 +1,3 @@
""" """
Non-business logic reusable functions and classes for user module Non-business logic reusable functions and classes for the user module
Classes:
- List: Description
- Classes: Description
Functions:
- List: Description
- Functions: Description
""" """