Compare commits
No commits in common. "e44e2bd6277670471b1f97f87d7bc3b66801df5a" and "71f26a4c9b0e89562ea7124dead2b2fa54cffd1b" have entirely different histories.
e44e2bd627
...
71f26a4c9b
20 changed files with 98 additions and 58 deletions
|
|
@ -1,10 +1,8 @@
|
||||||
"""
|
"""
|
||||||
Global configurations
|
Global configurations: import settings, app_configs
|
||||||
|
|
||||||
Exports:
|
Classes:
|
||||||
- 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
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,3 @@
|
||||||
"""
|
|
||||||
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
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,7 @@
|
||||||
"""
|
"""
|
||||||
Configurations for the services module
|
Configurations for <this module>
|
||||||
|
|
||||||
|
Configurations:
|
||||||
|
- List: Description
|
||||||
|
- Configs: Description
|
||||||
"""
|
"""
|
||||||
|
|
@ -1,3 +1,7 @@
|
||||||
"""
|
"""
|
||||||
Constants for the services module
|
Constants and error codes for <this module>
|
||||||
|
|
||||||
|
Constants:
|
||||||
|
- List: Description
|
||||||
|
- Consts: Description
|
||||||
"""
|
"""
|
||||||
|
|
@ -1,9 +1,13 @@
|
||||||
"""
|
"""
|
||||||
Dependencies related to the services module
|
Router dependencies for <this module>
|
||||||
|
|
||||||
Exports:
|
Classes:
|
||||||
- service_model_query_dependency: service_model: Gets service model from db, if it exists. Uses service_id from query param.
|
- List: Description
|
||||||
- service_model_body_dependency: service_model: Gets service model from db, if it exists. Uses service_id from request body.
|
- Classes: Description
|
||||||
|
|
||||||
|
Functions:
|
||||||
|
- List: Description
|
||||||
|
- Functions: Description
|
||||||
"""
|
"""
|
||||||
from typing import Annotated
|
from typing import Annotated
|
||||||
from fastapi import Depends, Query
|
from fastapi import Depends, Query
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
"""
|
"""
|
||||||
Exceptions related to the services module
|
Module specific exceptions for <this module>
|
||||||
|
|
||||||
Exceptions:
|
Exceptions:
|
||||||
- ServiceNotFoundException: Takes an optional service_id int
|
- List: Description
|
||||||
|
- Exceptions: Description
|
||||||
"""
|
"""
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@
|
||||||
Database models for the services module
|
Database models for the services module
|
||||||
|
|
||||||
Models:
|
Models:
|
||||||
- Service:
|
- List: Description
|
||||||
- id[PK], name[U], api_key[U]
|
- Models: Description
|
||||||
"""
|
"""
|
||||||
from sqlalchemy import Column, Integer, String
|
from sqlalchemy import Column, Integer, String
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,9 @@
|
||||||
"""
|
"""
|
||||||
Router endpoints for the services module
|
Router endpoints for <this module>
|
||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
- [GET](/): [root user]: Get a list of all services(id, name)
|
- List: Description
|
||||||
- [POST](/): [super admin]: Register a new service(name) on the hub, returns the API key for the service to access the hub.
|
- Endpoints: Description
|
||||||
- [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
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,9 @@
|
||||||
"""
|
"""
|
||||||
Pydantic models for service module
|
Pydantic models for the service module
|
||||||
|
|
||||||
Models follow the nomenclature of:
|
Models:
|
||||||
- Sub-models: "<Resource><Opt:>Schema"
|
- List: Description
|
||||||
- Mixins: "<Attribute>Mixin"
|
- Models: Description
|
||||||
- Models: "<Module><Method><Resource><Opt:Resource><Direction>" ie "ServiceGetServiceResponse"
|
|
||||||
"""
|
"""
|
||||||
from pydantic import ConfigDict
|
from pydantic import ConfigDict
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,11 @@
|
||||||
"""
|
"""
|
||||||
Business logic for the services module
|
Module specific business logic for <this module>
|
||||||
|
|
||||||
|
Classes:
|
||||||
|
- List: Description
|
||||||
|
- Classes: Description
|
||||||
|
|
||||||
|
Functions:
|
||||||
|
- List: Description
|
||||||
|
- Functions: Description
|
||||||
"""
|
"""
|
||||||
|
|
@ -1,8 +1,13 @@
|
||||||
"""
|
"""
|
||||||
Non-business logic reusable functions and classes for the services module
|
Non-business logic reusable functions and classes for <this module>
|
||||||
|
|
||||||
Exports:
|
Classes:
|
||||||
- generate_api_key(): returns a new UUID
|
- List: Description
|
||||||
|
- Classes: Description
|
||||||
|
|
||||||
|
Functions:
|
||||||
|
- List: Description
|
||||||
|
- Functions: Description
|
||||||
"""
|
"""
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,7 @@
|
||||||
"""
|
"""
|
||||||
Configurations for the user module
|
Configurations for user module
|
||||||
|
|
||||||
|
Configurations:
|
||||||
|
- List: Description
|
||||||
|
- Configs: Description
|
||||||
"""
|
"""
|
||||||
|
|
@ -1,3 +1,7 @@
|
||||||
"""
|
"""
|
||||||
Constants for the user module
|
Constants and error codes for user module
|
||||||
|
|
||||||
|
Constants:
|
||||||
|
- List: Description
|
||||||
|
- Consts: Description
|
||||||
"""
|
"""
|
||||||
|
|
@ -1,10 +1,13 @@
|
||||||
"""
|
"""
|
||||||
Dependencies related to the user module
|
Router dependencies for user module
|
||||||
|
|
||||||
Exports:
|
Classes:
|
||||||
- user_model_claims_dependency: user_model: Gets user model from db, if it exists. Uses db_id from user claims.
|
- List: Description
|
||||||
- user_model_query_dependency: user_model: Gets user model from db, if it exists. Uses user_id from query param
|
- Classes: Description
|
||||||
- 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
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
"""
|
"""
|
||||||
Exceptions related to the user module
|
Module specific exceptions for user module
|
||||||
|
|
||||||
Exceptions:
|
Exceptions:
|
||||||
- UserNotFoundException: Takes an optional user_id int
|
- List: Description
|
||||||
|
- Exceptions: Description
|
||||||
"""
|
"""
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,7 @@
|
||||||
Database models for user module
|
Database models for user module
|
||||||
|
|
||||||
Models:
|
Models:
|
||||||
- User:
|
- User - id[pk], email, first_name, last_name, oidc_id
|
||||||
- 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
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,15 @@
|
||||||
"""
|
"""
|
||||||
Router endpoints for the user module
|
Router endpoints for user module
|
||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
- [GET](/user/self/claims): [OIDC claims]: Returns all OIDC claims associated with the currently logged-in user.
|
- [get]/self/claims - Retrieves user's OIDC claims
|
||||||
- [GET](/user/self/db): [OIDC claims]: Returns details about the currently logged-in user from the hub db.
|
- [get]/self/db - Retrieves the user data from the db that corresponds to the current OIDC user
|
||||||
- [GET](/user/): [super admin]: Returns user(id) details.
|
- [get]/self/orgs - Retrieves all organisations associated with the current user
|
||||||
- [DELETE](/user/): [super admin]: Removes a User(id) from the hub database.
|
- [get]/self/orgs/admin - Retrieves only admin organisations for the current user
|
||||||
|
- [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
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,9 @@
|
||||||
"""
|
"""
|
||||||
Pydantic models for the user module
|
Pydantic models for 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
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,11 @@
|
||||||
"""
|
"""
|
||||||
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: Creates a User record from OIDC claims, or updates user details
|
- add_user_to_db
|
||||||
"""
|
"""
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,11 @@
|
||||||
"""
|
"""
|
||||||
Non-business logic reusable functions and classes for the user module
|
Non-business logic reusable functions and classes for user module
|
||||||
|
|
||||||
|
Classes:
|
||||||
|
- List: Description
|
||||||
|
- Classes: Description
|
||||||
|
|
||||||
|
Functions:
|
||||||
|
- List: Description
|
||||||
|
- Functions: Description
|
||||||
"""
|
"""
|
||||||
Loading…
Add table
Add a link
Reference in a new issue