From 0e169af45691ec0a7322e15d33e95664941c99d1 Mon Sep 17 00:00:00 2001 From: luxferre Date: Thu, 28 May 2026 13:22:24 +0100 Subject: [PATCH] docs: iam docstrings Issue: #13 --- src/iam/config.py | 6 +----- src/iam/constants.py | 6 +----- src/iam/dependencies.py | 13 +++++-------- src/iam/exceptions.py | 6 +++--- src/iam/models.py | 7 +++++-- src/iam/router.py | 16 +++++++++++++--- src/iam/schemas.py | 7 ++++--- src/iam/service.py | 5 +++-- src/iam/utils.py | 10 +--------- 9 files changed, 36 insertions(+), 40 deletions(-) diff --git a/src/iam/config.py b/src/iam/config.py index 4be170e..165dc07 100644 --- a/src/iam/config.py +++ b/src/iam/config.py @@ -1,7 +1,3 @@ """ -Configurations for - -Configurations: - - List: Description - - Configs: Description +Configurations for the IAM module """ \ No newline at end of file diff --git a/src/iam/constants.py b/src/iam/constants.py index e1df957..0dc94e7 100644 --- a/src/iam/constants.py +++ b/src/iam/constants.py @@ -1,7 +1,3 @@ """ -Constants and error codes for - -Constants: - - List: Description - - Consts: Description +Constants for the IAM module """ \ No newline at end of file diff --git a/src/iam/dependencies.py b/src/iam/dependencies.py index 24ae1ab..37b8e87 100644 --- a/src/iam/dependencies.py +++ b/src/iam/dependencies.py @@ -1,13 +1,10 @@ """ -Router dependencies for the IAM module +Dependencies for the IAM module -Classes: - - List: Description - - Classes: Description - -Functions: - - List: Description - - Functions: Description +Exports: + - group_model_query_dependency: group_model: Gets group model from db, if it exists. Uses group_id from query param. + - group_model_body_dependency: group_model: Gets group model from db, if it exists. Uses group_id from request body. + - perm_model_body_dependency: perm_model: Gets perm model from db, if it exists. Uses perm_id from request body. """ from typing import Annotated, Optional diff --git a/src/iam/exceptions.py b/src/iam/exceptions.py index 5c97b9a..84a77ed 100644 --- a/src/iam/exceptions.py +++ b/src/iam/exceptions.py @@ -1,9 +1,9 @@ """ -Module specific exceptions for the IAM module +Exceptions related to the IAM module Exceptions: - - List: Description - - Exceptions: Description + - GroupNotFoundException: Takes an optional group_id int + - PermNotFoundException: Takes an optional perm_id int """ from typing import Optional diff --git a/src/iam/models.py b/src/iam/models.py index 83d1ae2..ea12c0f 100644 --- a/src/iam/models.py +++ b/src/iam/models.py @@ -2,8 +2,11 @@ Database models for the IAM module Models: - - List: Description - - Models: Description + - Permission: + - id[PK], resource[U1], action[U1], service_id[FK][U1] + - service_rel: ORM relationship over service_id FK + - group_rel: ORM relationship backpops to Group.permission_rel + - service_name: Calc property service_rel.name """ from sqlalchemy import Column, Integer, String, ForeignKey, UniqueConstraint from sqlalchemy.orm import relationship diff --git a/src/iam/router.py b/src/iam/router.py index 4b2bbb4..feb4f3e 100644 --- a/src/iam/router.py +++ b/src/iam/router.py @@ -1,9 +1,19 @@ """ -Router endpoints for +Router endpoints for IAM Endpoints: - - List: Description - - Endpoints: Description + - [POST](/iam/can_act_on_resource): [API key & user claim]: Service access point to verify user permissions + - [GET](/iam/group/permissions): [root user]: Gets list of perms(service, resource, action) the given group(id) has + - [DELETE](/iam/group/permissions): [root user]: Removes a given perm(id) from the given group(id) + - [GET](/iam/group/users): [root user]: Gets a list of users(id, name, email) that are assigned to the given group(id) + - [POST](/iam/group): [root user]: Creates a new group for the given org(id) + - [PUT](/iam/group/permission): [root user]: Assigns a perm(id) to the given group(id) + - [PUT](/iam/group/user): [root user]: Assigns a user(id) to a group(id) + - [DELETE](/iam/group/user): [root user]: Removes a user(id) from the given group(id) + - [GET](/iam/permissions): [root user]: Gets a list of all permissions + - [POST](/iam/permission): [super admin]: Creates a new permission + - [DELETE](/iam/permission): [super admin]: Removes a permission + - [GET](/iam/permissions/search): [root user]: Returns a list of permissions matching a filter(service|resource|action) """ from fastapi import APIRouter, status from sqlalchemy.exc import IntegrityError diff --git a/src/iam/schemas.py b/src/iam/schemas.py index f6cd7bb..1b1d4d2 100644 --- a/src/iam/schemas.py +++ b/src/iam/schemas.py @@ -1,9 +1,10 @@ """ Pydantic models for the IAM module -Models: - - List: Description - - Models: Description +Models follow the nomenclature of: +- Sub-models: "Response" +- Mixins: "Mixin" +- Models: "" ie "IAMGetGroupPermissionsResponse" """ from typing import Optional diff --git a/src/iam/service.py b/src/iam/service.py index 1607cd0..b1d416b 100644 --- a/src/iam/service.py +++ b/src/iam/service.py @@ -1,7 +1,8 @@ """ -Module specific business logic for +Business logic reusable functions related to IAM -Exports service_key_dependency +Exports: + - service_key_dependency: bool: verifies request headers contain the correct api key for the service """ from typing import Annotated diff --git a/src/iam/utils.py b/src/iam/utils.py index 5afbb54..d948f09 100644 --- a/src/iam/utils.py +++ b/src/iam/utils.py @@ -1,11 +1,3 @@ """ -Non-business logic reusable functions and classes for - -Classes: - - List: Description - - Classes: Description - -Functions: - - List: Description - - Functions: Description +Non-business logic reusable functions and classes for the IAM module """