diff --git a/app/admin/router.py b/app/admin/router.py index 808b4a0..f0ad215 100644 --- a/app/admin/router.py +++ b/app/admin/router.py @@ -7,7 +7,7 @@ from app.auth import validate_jwt router = APIRouter( - prefix="/api", + prefix="/admin", tags=["Admin"], ) diff --git a/app/applicants/models.py b/app/applicants/models.py index 1010286..284e495 100644 --- a/app/applicants/models.py +++ b/app/applicants/models.py @@ -1,4 +1,4 @@ -from sqlalchemy import Column, Date, Integer, String +from sqlalchemy import Column, Date, DateTime, Integer, String, Text, func from sqlalchemy.orm import relationship from app.db import Base @@ -8,20 +8,27 @@ class DBApplicant(Base): __tablename__ = "applicants" id = Column(Integer, primary_key=True, index=True) - first_name = Column(String, nullable=False) - last_name = Column(String, nullable=False) - middle_name = Column(String, nullable=True) - gender = Column(String, nullable=False) + first_name = Column(String(50), index=True, nullable=False) + last_name = Column(String(50), index=True, nullable=False) + middle_name = Column(String(50), nullable=True) + gender = Column(String(20), nullable=False) date_of_birth = Column(Date, nullable=False) - ssn = Column(String, nullable=False, unique=True) - email = Column(String, nullable=True) - home_phone = Column(String, nullable=True) - mobile_phone = Column(String, nullable=True) - address = Column(String, nullable=True) - city = Column(String, nullable=True) - state = Column(String, nullable=True) - zip = Column(String, nullable=True) - country = Column(String, nullable=False) - created_at = Column(Date, nullable=False) - updated_at = Column(Date, nullable=False) + ssn = Column(String(11), nullable=False, unique=True) + email = Column(String(254), nullable=True) + home_phone = Column(String(20), nullable=True) + mobile_phone = Column(String(20), nullable=True) + address = Column(Text, nullable=True) + city = Column(String(100), nullable=True) + state = Column(String(50), nullable=True) + zip = Column(String(10), nullable=True) + country = Column(String(100), nullable=False) + created_at = Column( + DateTime(timezone=True), server_default=func.now(), nullable=False + ) + updated_at = Column( + DateTime(timezone=True), + server_default=func.now(), + onupdate=func.now(), + nullable=False, + ) case = relationship("DBCase", back_populates="applicant") diff --git a/app/applicants/router.py b/app/applicants/router.py index 79b3971..933b848 100644 --- a/app/applicants/router.py +++ b/app/applicants/router.py @@ -5,11 +5,16 @@ from starlette import status import app.applicants.services as service -from app.applicants.schemas import Applicant, ApplicantBase, ApplicantPayload +from app.applicants.schemas import ( + ApplicantCreate, + ApplicantListResponse, + ApplicantResponse, + ApplicantUpdate, +) from app.db import get_db router = APIRouter( - prefix="/api", + prefix="/applicants", tags=["Applicants"], responses={404: {"description": "Endpoint not found"}}, ) @@ -18,36 +23,34 @@ db_session = Annotated[Session, Depends(get_db)] -@router.get( - "/applicants", status_code=status.HTTP_200_OK, response_model=ApplicantPayload -) +@router.get("/", status_code=status.HTTP_200_OK, response_model=ApplicantListResponse) async def get_applicants(db: db_session, page_number: int = 0, page_size: int = 100): return service.get_items(db, page_number, page_size) -@router.get( - "/applicants/{id}", status_code=status.HTTP_200_OK, response_model=Applicant -) -async def get_applicant(id: int, db: db_session): - return service.get_item(db, id) +@router.post("/", status_code=status.HTTP_201_CREATED, response_model=ApplicantResponse) +async def create_applicant(applicant: ApplicantCreate, db: db_session): + db_applicant = service.create_item(db, applicant) + return db_applicant -@router.put( - "/applicants/{id}", status_code=status.HTTP_200_OK, response_model=Applicant +@router.get( + "/{applicant_id}", status_code=status.HTTP_200_OK, response_model=ApplicantResponse ) -async def update_applicant(id: int, applicant: ApplicantBase, db: db_session): - db_applicant = service.update_item(db, id, applicant) - return db_applicant +async def get_applicant(applicant_id: int, db: db_session): + return service.get_item(db, applicant_id) -@router.post( - "/applicants", status_code=status.HTTP_201_CREATED, response_model=Applicant +@router.put( + "/{applicant_id}", status_code=status.HTTP_200_OK, response_model=ApplicantResponse ) -async def create_applicant(applicant: ApplicantBase, db: db_session): - db_applicant = service.create_item(db, applicant) +async def update_applicant( + applicant_id: int, applicant: ApplicantUpdate, db: db_session +): + db_applicant = service.update_item(db, applicant_id, applicant) return db_applicant -@router.delete("/applicants/{id}", status_code=status.HTTP_204_NO_CONTENT) -async def delete_applicant(id: int, db: db_session): - service.delete_item(db, id) +@router.delete("/{applicant_id}", status_code=status.HTTP_204_NO_CONTENT) +async def delete_applicant(applicant_id: int, db: db_session): + service.delete_item(db, applicant_id) diff --git a/app/applicants/schemas.py b/app/applicants/schemas.py index 0da4c30..b100438 100644 --- a/app/applicants/schemas.py +++ b/app/applicants/schemas.py @@ -1,16 +1,37 @@ from datetime import date, datetime -from pydantic import BaseModel, ConfigDict +from pydantic import BaseModel, ConfigDict, Field # Pydantic Models class ApplicantBase(BaseModel): - first_name: str - last_name: str - middle_name: str | None = None - gender: str + first_name: str = Field(..., min_length=1, max_length=50) + last_name: str = Field(..., min_length=1, max_length=50) + middle_name: str | None = Field(None, min_length=1, max_length=50) + gender: str = Field(..., min_length=1, max_length=20) date_of_birth: date - ssn: str + ssn: str = Field(..., min_length=9, max_length=11) + email: str | None = Field(None, max_length=254) + home_phone: str | None = Field(None, max_length=20) + mobile_phone: str | None = Field(None, max_length=20) + address: str | None = Field(None, max_length=200) + city: str | None = Field(None, max_length=100) + state: str | None = Field(None, max_length=50) + zip: str | None = Field(None, max_length=10) + country: str = Field("USA", max_length=100) + + +class ApplicantCreate(ApplicantBase): + pass + + +class ApplicantUpdate(BaseModel): + first_name: str | None = None + last_name: str | None = None + middle_name: str | None = None + gender: str | None = None + date_of_birth: date | None = None + ssn: str | None = None email: str | None = None home_phone: str | None = None mobile_phone: str | None = None @@ -18,18 +39,18 @@ class ApplicantBase(BaseModel): city: str | None = None state: str | None = None zip: str | None = None - country: str = "USA" + country: str | None = None -class Applicant(ApplicantBase): +class ApplicantResponse(ApplicantBase): model_config = ConfigDict(from_attributes=True) - id: int | None = None + id: int created_at: datetime updated_at: datetime -class ApplicantPayload(BaseModel): - items: list[Applicant] +class ApplicantListResponse(BaseModel): + items: list[ApplicantResponse] item_count: int = 0 page_count: int = 0 prev_page: int | None = None diff --git a/app/applicants/services.py b/app/applicants/services.py index 7b78483..752bf48 100644 --- a/app/applicants/services.py +++ b/app/applicants/services.py @@ -1,10 +1,8 @@ -from datetime import datetime - from fastapi import HTTPException from sqlalchemy.orm import Session from app.applicants.models import DBApplicant -from app.applicants.schemas import ApplicantBase +from app.applicants.schemas import ApplicantCreate, ApplicantUpdate from app.utils import get_next_page, get_page_count, get_prev_page @@ -21,42 +19,30 @@ def get_items(db: Session, page_number: int, page_size: int): } +def create_item(db: Session, applicant: ApplicantCreate): + db_applicant = DBApplicant(**applicant.model_dump()) + db.add(db_applicant) + db.commit() + db.refresh(db_applicant) + + return db_applicant + + def get_item(db: Session, applicant_id: int): return db.query(DBApplicant).where(DBApplicant.id == applicant_id).first() -def update_item(db: Session, id: int, applicant: ApplicantBase): +def update_item(db: Session, id: int, applicant: ApplicantUpdate): db_applicant = db.query(DBApplicant).filter(DBApplicant.id == id).first() if db_applicant is None: - raise HTTPException(status_code=404, detail="Applicant not founds") - - db_applicant.first_name = applicant.first_name - db_applicant.last_name = applicant.last_name - db_applicant.middle_name = applicant.middle_name - db_applicant.gender = applicant.gender - db_applicant.date_of_birth = applicant.date_of_birth - db_applicant.ssn = applicant.ssn - db_applicant.email = applicant.email - db_applicant.home_phone = applicant.home_phone - db_applicant.mobile_phone = applicant.mobile_phone - db_applicant.address = applicant.address - db_applicant.city = applicant.city - db_applicant.state = applicant.state - db_applicant.zip = applicant.zip - db_applicant.country = applicant.country - db_applicant.date_of_birth = applicant.date_of_birth - db_applicant.updated_at = datetime.now() - db.add(db_applicant) - db.commit() - db.refresh(db_applicant) - - return db_applicant + raise HTTPException(status_code=404, detail="Applicant not found") + # Only update fields that are provided (not None) + update_data = applicant.model_dump(exclude_unset=True) + for field, value in update_data.items(): + if value is not None: + setattr(db_applicant, field, value) -def create_item(db: Session, applicant: ApplicantBase): - db_applicant = DBApplicant(**applicant.model_dump()) - db_applicant.created_at = datetime.now() - db_applicant.updated_at = datetime.now() db.add(db_applicant) db.commit() db.refresh(db_applicant) @@ -67,7 +53,9 @@ def create_item(db: Session, applicant: ApplicantBase): def delete_item(db: Session, id: int): db_applicant = db.query(DBApplicant).filter(DBApplicant.id == id).first() if db_applicant is None: - raise HTTPException(status_code=404, detail="Applicant not founds") + raise HTTPException(status_code=404, detail="Applicant not found") db.query(DBApplicant).filter(DBApplicant.id == id).delete() db.commit() + + return None diff --git a/app/cases/models.py b/app/cases/models.py index f398e11..59e9147 100644 --- a/app/cases/models.py +++ b/app/cases/models.py @@ -1,4 +1,4 @@ -from sqlalchemy import Column, Date, ForeignKey, Integer, String +from sqlalchemy import Column, DateTime, ForeignKey, Integer, String, func from sqlalchemy.orm import relationship from app.db import Base @@ -9,10 +9,17 @@ class DBCase(Base): __tablename__ = "cases" id = Column(Integer, primary_key=True, index=True) - status = Column(String, nullable=False) - assigned_to = Column(String, nullable=True) - created_at = Column(Date, nullable=False) - updated_at = Column(Date, nullable=False) + status = Column(String(50), nullable=False) + assigned_to = Column(String(255), nullable=True) + created_at = Column( + DateTime(timezone=True), server_default=func.now(), nullable=False + ) + updated_at = Column( + DateTime(timezone=True), + server_default=func.now(), + onupdate=func.now(), + nullable=False, + ) applicant_id = Column( Integer, ForeignKey("applicants.id", ondelete="CASCADE"), nullable=False ) diff --git a/app/cases/router.py b/app/cases/router.py index 16581ed..c350dc1 100644 --- a/app/cases/router.py +++ b/app/cases/router.py @@ -5,11 +5,17 @@ from starlette import status import app.cases.services as service -from app.cases.schemas import Case, CaseBase, CasePayload, CaseWithApplicant +from app.cases.schemas import ( + CaseCreate, + CaseListResponse, + CaseResponse, + CaseUpdate, + CaseWithApplicant, +) from app.db import get_db router = APIRouter( - prefix="/api", + prefix="/cases", tags=["Cases"], responses={404: {"description": "Endpoint not found"}}, ) @@ -18,30 +24,30 @@ db_session = Annotated[Session, Depends(get_db)] -@router.get("/cases", status_code=status.HTTP_200_OK, response_model=CasePayload) +@router.get("/", status_code=status.HTTP_200_OK, response_model=CaseListResponse) async def get_cases(db: db_session, page_number: int = 0, page_size: int = 100): return service.get_items(db, page_number, page_size) -@router.get( - "/cases/{id}", status_code=status.HTTP_200_OK, response_model=CaseWithApplicant -) -async def get_case(id: int, db: db_session): - return service.get_item(db, id) +@router.post("/", status_code=status.HTTP_201_CREATED, response_model=CaseResponse) +async def create_case(case: CaseCreate, db: db_session): + db_case = service.create_item(db, case) + return db_case -@router.put("/cases/{id}", status_code=status.HTTP_200_OK, response_model=Case) -async def update_case(id: int, case: CaseBase, db: db_session): - db_case = service.update_item(db, id, case) - return db_case +@router.get( + "/{case_id}", status_code=status.HTTP_200_OK, response_model=CaseWithApplicant +) +async def get_case(case_id: int, db: db_session): + return service.get_item(db, case_id) -@router.post("/cases", status_code=status.HTTP_201_CREATED, response_model=Case) -async def create_case(case: CaseBase, db: db_session): - db_case = service.create_item(db, case) +@router.put("/{case_id}", status_code=status.HTTP_200_OK, response_model=CaseResponse) +async def update_case(case_id: int, case: CaseUpdate, db: db_session): + db_case = service.update_item(db, case_id, case) return db_case -@router.delete("/cases/{id}", status_code=status.HTTP_204_NO_CONTENT) -async def delete_case(id: int, db: db_session): - service.delete_item(db, id) +@router.delete("/{case_id}", status_code=status.HTTP_204_NO_CONTENT) +async def delete_case(case_id: int, db: db_session): + service.delete_item(db, case_id) diff --git a/app/cases/schemas.py b/app/cases/schemas.py index 302aa04..9f4b838 100644 --- a/app/cases/schemas.py +++ b/app/cases/schemas.py @@ -1,32 +1,44 @@ from datetime import datetime from typing import Literal -from pydantic import BaseModel, ConfigDict +from pydantic import BaseModel, ConfigDict, Field -from app.applicants.schemas import Applicant +from app.applicants.schemas import ApplicantResponse + +# Constants +CASE_STATUS = Literal["Not Started", "In Progress", "Approved", "Denied"] # Pydantic Models class CaseBase(BaseModel): - status: Literal["Not Started", "In Progress", "Approved", "Denied"] + status: CASE_STATUS + assigned_to: str | None = Field(None, min_length=1, max_length=255) + + +class CaseCreate(CaseBase): + applicant_id: int + + +class CaseUpdate(BaseModel): + status: CASE_STATUS | None = None assigned_to: str | None = None - applicant_id: int | None = None -class Case(CaseBase): +class CaseResponse(CaseBase): model_config = ConfigDict(from_attributes=True) - id: int | None = None + id: int + applicant_id: int created_at: datetime updated_at: datetime -class CaseWithApplicant(Case): - applicant: Applicant | None = None +class CaseWithApplicant(CaseResponse): + applicant: ApplicantResponse | None = None -class CasePayload(BaseModel): +class CaseListResponse(BaseModel): items: list[CaseWithApplicant] - item_count: int = 0 - page_count: int = 0 + item_count: int + page_count: int prev_page: int | None = None next_page: int | None = None diff --git a/app/cases/services.py b/app/cases/services.py index 957f67e..41bb63b 100644 --- a/app/cases/services.py +++ b/app/cases/services.py @@ -1,10 +1,8 @@ -from datetime import datetime - from fastapi import HTTPException from sqlalchemy.orm import Session, joinedload from app.cases.models import DBCase -from app.cases.schemas import CaseBase +from app.cases.schemas import CaseCreate, CaseUpdate from app.utils import get_next_page, get_page_count, get_prev_page @@ -21,6 +19,15 @@ def get_items(db: Session, page_number: int, page_size: int): } +def create_item(db: Session, case: CaseCreate): + db_case = DBCase(**case.model_dump()) + db.add(db_case) + db.commit() + db.refresh(db_case) + + return db_case + + def get_item(db: Session, case_id: int): case = ( db.query(DBCase) @@ -58,6 +65,7 @@ def get_item(db: Session, case_id: int): return { "id": case.id, "status": case.status, + "applicant_id": case.applicant_id, "applicant": applicant_data, "assigned_to": case.assigned_to, "created_at": case.created_at, @@ -65,25 +73,16 @@ def get_item(db: Session, case_id: int): } -def update_item(db: Session, id: int, case: CaseBase): +def update_item(db: Session, id: int, case: CaseUpdate): db_case = db.query(DBCase).filter(DBCase.id == id).first() if db_case is None: - raise HTTPException(status_code=404, detail="Case not founds") - - db_case.status = case.status - db_case.assigned_to = case.assigned_to - db_case.updated_at = datetime.now() - db.add(db_case) - db.commit() - db.refresh(db_case) - - return db_case + raise HTTPException(status_code=404, detail="Case not found") + if case.status is not None: + db_case.status = case.status + if case.assigned_to is not None: + db_case.assigned_to = case.assigned_to -def create_item(db: Session, case: CaseBase): - db_case = DBCase(**case.model_dump()) - db_case.created_at = datetime.now() - db_case.updated_at = datetime.now() db.add(db_case) db.commit() db.refresh(db_case) @@ -94,7 +93,9 @@ def create_item(db: Session, case: CaseBase): def delete_item(db: Session, id: int): db_case = db.query(DBCase).filter(DBCase.id == id).first() if db_case is None: - raise HTTPException(status_code=404, detail="Case not founds") + raise HTTPException(status_code=404, detail="Case not found") db.query(DBCase).filter(DBCase.id == id).delete() db.commit() + + return None diff --git a/app/health/router.py b/app/health/router.py index 51d79aa..a88daa4 100644 --- a/app/health/router.py +++ b/app/health/router.py @@ -2,11 +2,11 @@ from starlette import status router = APIRouter( - prefix="/api", + prefix="/health", tags=["Health"], ) -@router.get("/health", status_code=status.HTTP_200_OK) +@router.get("/", status_code=status.HTTP_200_OK) def get_health(): return {"health": "healthy"} diff --git a/app/users/models.py b/app/users/models.py index 979d3d1..f3ed166 100644 --- a/app/users/models.py +++ b/app/users/models.py @@ -1,4 +1,4 @@ -from sqlalchemy import Boolean, Column, DateTime, Integer, String +from sqlalchemy import Boolean, Column, DateTime, Integer, String, func from app.db import Base @@ -8,14 +8,19 @@ class DBUser(Base): __tablename__ = "users" id = Column(Integer, primary_key=True, index=True) - user_id = Column(String, nullable=False) - first_name = Column(String, nullable=False) - last_name = Column(String, nullable=False) - display_name = Column(String, nullable=False) - email = Column(String, unique=True, index=True) + user_id = Column(String(100), nullable=False) + first_name = Column(String(100), nullable=False) + last_name = Column(String(100), nullable=False) + display_name = Column(String(200), nullable=False) + email = Column(String(254), unique=True, index=True) hashed_password = Column(String) is_active = Column(Boolean, default=True) - created = Column(DateTime, nullable=False) - created_by = Column(String, nullable=False) - modified = Column(DateTime, nullable=False) - modified_by = Column(String, nullable=False) + created = Column(DateTime(timezone=True), server_default=func.now(), nullable=False) + created_by = Column(String(100), nullable=False) + modified = Column( + DateTime(timezone=True), + server_default=func.now(), + onupdate=func.now(), + nullable=False, + ) + modified_by = Column(String(100), nullable=False) diff --git a/app/users/router.py b/app/users/router.py index bad31f9..cfb0df9 100644 --- a/app/users/router.py +++ b/app/users/router.py @@ -6,10 +6,10 @@ import app.users.services as service from app.db import get_db -from app.users.schemas import User, UserPayload +from app.users.schemas import UserCreate, UserListResponse, UserResponse, UserUpdate router = APIRouter( - prefix="/api", + prefix="/users", tags=["Users"], responses={404: {"description": "Endpoint not found"}}, ) @@ -19,31 +19,31 @@ @router.get( - "/users", + "/", status_code=status.HTTP_200_OK, - response_model=UserPayload, + response_model=UserListResponse, ) async def get_items(db: db_session, page_number: int = 0, page_size: int = 100): return service.get_items(db, page_number, page_size) -@router.get("/users/{id}", status_code=status.HTTP_200_OK, response_model=User) +@router.post("/", status_code=status.HTTP_201_CREATED, response_model=UserResponse) +async def create_item(item: UserCreate, db: db_session): + db_item = service.create_item(db, item) + return db_item + + +@router.get("/{id}", status_code=status.HTTP_200_OK, response_model=UserResponse) async def get_item(id: int, db: db_session): return service.get_item(db, id) -@router.put("/users/{id}", status_code=status.HTTP_200_OK, response_model=User) -async def update_item(id: int, item: User, db: db_session): +@router.put("/{id}", status_code=status.HTTP_200_OK, response_model=UserResponse) +async def update_item(id: int, item: UserUpdate, db: db_session): db_item = service.update_item(db, id, item) return db_item -@router.post("/users", status_code=status.HTTP_201_CREATED, response_model=User) -async def create_item(item: User, db: db_session): - db_item = service.create_item(db, item) - return db_item - - -@router.delete("/users/{id}", status_code=status.HTTP_204_NO_CONTENT) +@router.delete("/{id}", status_code=status.HTTP_204_NO_CONTENT) async def delete_item(id: int, db: db_session): service.delete_item(db, id) diff --git a/app/users/schemas.py b/app/users/schemas.py index 013af52..caf42e8 100644 --- a/app/users/schemas.py +++ b/app/users/schemas.py @@ -1,26 +1,43 @@ from datetime import datetime -from pydantic import BaseModel, ConfigDict +from pydantic import BaseModel, ConfigDict, Field # Pydantic Models -class User(BaseModel): - model_config = ConfigDict(from_attributes=True) - id: int | None = None - user_id: str - first_name: str - last_name: str - display_name: str - email: str +class UserBase(BaseModel): + user_id: str = Field(..., min_length=1, max_length=100) + first_name: str = Field(..., min_length=1, max_length=100) + last_name: str = Field(..., min_length=1, max_length=100) + display_name: str = Field(..., min_length=1, max_length=200) + email: str = Field(..., min_length=1, max_length=254) is_active: bool = True - created: datetime | None = None - created_by: str - modified: datetime | None = None - modified_by: str + created_by: str = Field(..., min_length=1, max_length=100) + modified_by: str = Field(..., min_length=1, max_length=100) + + +class UserCreate(UserBase): + hashed_password: str | None = None + + +class UserUpdate(BaseModel): + user_id: str | None = Field(None, min_length=1, max_length=100) + first_name: str | None = Field(None, min_length=1, max_length=100) + last_name: str | None = Field(None, min_length=1, max_length=100) + display_name: str | None = Field(None, min_length=1, max_length=200) + email: str | None = Field(None, min_length=1, max_length=254) + is_active: bool | None = None + modified_by: str | None = Field(None, min_length=1, max_length=100) + + +class UserResponse(UserBase): + model_config = ConfigDict(from_attributes=True) + id: int + created: datetime + modified: datetime -class UserPayload(BaseModel): - items: list[User] +class UserListResponse(BaseModel): + items: list[UserResponse] item_count: int = 0 page_count: int = 0 prev_page: int | None = None diff --git a/app/users/services.py b/app/users/services.py index c3e5849..98173cc 100644 --- a/app/users/services.py +++ b/app/users/services.py @@ -1,10 +1,8 @@ -from datetime import datetime - from fastapi import HTTPException from sqlalchemy.orm import Session from app.users.models import DBUser -from app.users.schemas import User +from app.users.schemas import UserCreate, UserUpdate from app.utils import get_next_page, get_page_count, get_prev_page @@ -21,33 +19,32 @@ def get_items(db: Session, page_number: int, page_size: int): } +def create_item(db: Session, item: UserCreate): + db_item = DBUser(**item.model_dump(exclude={"hashed_password"})) + if item.hashed_password: + db_item.hashed_password = item.hashed_password + db.add(db_item) + db.commit() + db.refresh(db_item) + + return db_item + + def get_item(db: Session, item_id: int): return db.query(DBUser).where(DBUser.id == item_id).first() -def update_item(db: Session, id: int, item: User): +def update_item(db: Session, id: int, item: UserUpdate): db_item = db.query(DBUser).filter(DBUser.id == id).first() if db_item is None: raise HTTPException(status_code=404, detail="Item not found") - db_item.first_name = item.first_name - db_item.last_name = item.last_name - db_item.display_name = item.display_name - db_item.email = item.email - db_item.is_active = item.is_active - db_item.modified = datetime.now() - db_item.modified_by = item.modified_by - db.add(db_item) - db.commit() - db.refresh(db_item) + # Only update fields that are provided (not None) + update_data = item.model_dump(exclude_unset=True) + for field, value in update_data.items(): + if value is not None: + setattr(db_item, field, value) - return db_item - - -def create_item(db: Session, item: User): - db_item = DBUser(**item.model_dump()) - db_item.created = datetime.now() - db_item.modified = datetime.now() db.add(db_item) db.commit() db.refresh(db_item) @@ -62,3 +59,5 @@ def delete_item(db: Session, id: int): db.query(DBUser).filter(DBUser.id == id).delete() db.commit() + + return None diff --git a/docs/index.html b/docs/index.html index 3bbb2f4..afc8f13 100644 --- a/docs/index.html +++ b/docs/index.html @@ -2054,6 +2054,9 @@ .fElSEN{border-radius:2px;word-break:break-word;background-color:rgba(51,51,51,0.05);color:rgba(51,51,51,0.9);padding:0 5px;border:1px solid rgba(51,51,51,0.1);font-family:Courier,monospace;}/*!sc*/ .sc-ckTSus + .sc-ckTSus{margin-left:0;}/*!sc*/ data-styled.g68[id="sc-ckTSus"]{content:"fElSEN,"}/*!sc*/ +.gHBwqe{border-radius:2px;background-color:rgba(104,104,207,0.05);color:rgba(50,50,159,0.9);margin:0 5px;padding:0 5px;border:1px solid rgba(50,50,159,0.1);}/*!sc*/ +.sc-FRrlG + .sc-FRrlG{margin-left:0;}/*!sc*/ +data-styled.g70[id="sc-FRrlG"]{content:"gHBwqe,"}/*!sc*/ .dPrSxx:after{content:' and ';font-weight:normal;}/*!sc*/ .dPrSxx:last-child:after{content:none;}/*!sc*/ .dPrSxx a{-webkit-text-decoration:auto;text-decoration:auto;color:#32329f;}/*!sc*/ @@ -2189,7 +2192,7 @@ -

FastAPI (0.1.0)

Download OpenAPI specification:Download

Cases

Get Cases

query Parameters
page_number
integer (Page Number)
Default: 0
page_size
integer (Page Size)
Default: 100

Responses

FastAPI (0.1.0)

Download OpenAPI specification:Download

Cases

Get Cases

query Parameters
page_number
integer (Page Number)
Default: 0
page_size
integer (Page Size)
Default: 100

Responses

Response samples

Content type
application/json
{
  • "items": [
    ],
  • "item_count": 0,
  • "page_count": 0,
  • "prev_page": 0,
  • "next_page": 0
}

Create Case

Request Body schema: application/json
status
required
string (Status)
Enum: "Not Started" "In Progress" "Approved" "Denied"
Assigned To (string) or Assigned To (null) (Assigned To)
Applicant Id (integer) or Applicant Id (null) (Applicant Id)

Responses

Response samples

Content type
application/json
{
  • "items": [
    ],
  • "item_count": 0,
  • "page_count": 0,
  • "prev_page": 0,
  • "next_page": 0
}

Create Case

Request Body schema: application/json
status
required
string (Status)
Enum: "Not Started" "In Progress" "Approved" "Denied"
Assigned To (string) or Assigned To (null) (Assigned To)
applicant_id
required
integer (Applicant Id)

Responses

Request samples

Content type
application/json
{
  • "status": "Not Started",
  • "assigned_to": "string",
  • "applicant_id": 0
}

Response samples

Content type
application/json
{
  • "status": "Not Started",
  • "assigned_to": "string",
  • "applicant_id": 0,
  • "id": 0,
  • "created_at": "2019-08-24T14:15:22Z",
  • "updated_at": "2019-08-24T14:15:22Z"
}

Get Case

path Parameters
id
required
integer (Id)

Responses

Request samples

Content type
application/json
{
  • "status": "Not Started",
  • "assigned_to": "string",
  • "applicant_id": 0
}

Response samples

Content type
application/json
{
  • "status": "Not Started",
  • "assigned_to": "string",
  • "id": 0,
  • "applicant_id": 0,
  • "created_at": "2019-08-24T14:15:22Z",
  • "updated_at": "2019-08-24T14:15:22Z"
}

Get Case

path Parameters
case_id
required
integer (Case Id)

Responses

Response samples

Content type
application/json
{
  • "status": "Not Started",
  • "assigned_to": "string",
  • "applicant_id": 0,
  • "id": 0,
  • "created_at": "2019-08-24T14:15:22Z",
  • "updated_at": "2019-08-24T14:15:22Z",
  • "applicant": {
    }
}

Update Case

path Parameters
id
required
integer (Id)
Request Body schema: application/json
status
required
string (Status)
Enum: "Not Started" "In Progress" "Approved" "Denied"
Assigned To (string) or Assigned To (null) (Assigned To)
Applicant Id (integer) or Applicant Id (null) (Applicant Id)

Responses

Response samples

Content type
application/json
{
  • "status": "Not Started",
  • "assigned_to": "string",
  • "id": 0,
  • "applicant_id": 0,
  • "created_at": "2019-08-24T14:15:22Z",
  • "updated_at": "2019-08-24T14:15:22Z",
  • "applicant": {
    }
}

Update Case

path Parameters
case_id
required
integer (Case Id)
Request Body schema: application/json
Status (string) or Status (null) (Status)
Assigned To (string) or Assigned To (null) (Assigned To)

Responses

Request samples

Content type
application/json
{
  • "status": "Not Started",
  • "assigned_to": "string",
  • "applicant_id": 0
}

Response samples

Content type
application/json
{
  • "status": "Not Started",
  • "assigned_to": "string",
  • "applicant_id": 0,
  • "id": 0,
  • "created_at": "2019-08-24T14:15:22Z",
  • "updated_at": "2019-08-24T14:15:22Z"
}

Delete Case

path Parameters
id
required
integer (Id)

Responses

Request samples

Content type
application/json
{
  • "status": "Not Started",
  • "assigned_to": "string"
}

Response samples

Content type
application/json
{
  • "status": "Not Started",
  • "assigned_to": "string",
  • "id": 0,
  • "applicant_id": 0,
  • "created_at": "2019-08-24T14:15:22Z",
  • "updated_at": "2019-08-24T14:15:22Z"
}

Delete Case

path Parameters
case_id
required
integer (Case Id)

Responses

Response samples

Content type
application/json
{
  • "detail": [
    ]
}

Applicants

Get Applicants

query Parameters
page_number
integer (Page Number)
Default: 0
page_size
integer (Page Size)
Default: 100

Responses

Response samples

Content type
application/json
{
  • "detail": [
    ]
}

Applicants

Get Applicants

query Parameters
page_number
integer (Page Number)
Default: 0
page_size
integer (Page Size)
Default: 100

Responses

Response samples

Content type
application/json
{
  • "items": [
    ],
  • "item_count": 0,
  • "page_count": 0,
  • "prev_page": 0,
  • "next_page": 0
}

Create Applicant

Request Body schema: application/json
first_name
required
string (First Name)
last_name
required
string (Last Name)
Middle Name (string) or Middle Name (null) (Middle Name)
gender
required
string (Gender)
date_of_birth
required
string <date> (Date Of Birth)
ssn
required
string (Ssn)
Email (string) or Email (null) (Email)
Home Phone (string) or Home Phone (null) (Home Phone)
Mobile Phone (string) or Mobile Phone (null) (Mobile Phone)
Address (string) or Address (null) (Address)
City (string) or City (null) (City)
State (string) or State (null) (State)
Zip (string) or Zip (null) (Zip)
country
string (Country)
Default: "USA"

Responses

Response samples

Content type
application/json
{
  • "items": [
    ],
  • "item_count": 0,
  • "page_count": 0,
  • "prev_page": 0,
  • "next_page": 0
}

Create Applicant

Request Body schema: application/json
first_name
required
string (First Name) [ 1 .. 50 ] characters
last_name
required
string (Last Name) [ 1 .. 50 ] characters
Middle Name (string) or Middle Name (null) (Middle Name)
gender
required
string (Gender) [ 1 .. 20 ] characters
date_of_birth
required
string <date> (Date Of Birth)
ssn
required
string (Ssn) [ 9 .. 11 ] characters
Email (string) or Email (null) (Email)
Home Phone (string) or Home Phone (null) (Home Phone)
Mobile Phone (string) or Mobile Phone (null) (Mobile Phone)
Address (string) or Address (null) (Address)
City (string) or City (null) (City)
State (string) or State (null) (State)
Zip (string) or Zip (null) (Zip)
country
string (Country) <= 100 characters
Default: "USA"

Responses

Request samples

Content type
application/json
{
  • "first_name": "string",
  • "last_name": "string",
  • "middle_name": "string",
  • "gender": "string",
  • "date_of_birth": "2019-08-24",
  • "ssn": "string",
  • "email": "string",
  • "home_phone": "string",
  • "mobile_phone": "string",
  • "address": "string",
  • "city": "string",
  • "state": "string",
  • "zip": "string",
  • "country": "USA"
}

Response samples

Content type
application/json
{
  • "first_name": "string",
  • "last_name": "string",
  • "middle_name": "string",
  • "gender": "string",
  • "date_of_birth": "2019-08-24",
  • "ssn": "string",
  • "email": "string",
  • "home_phone": "string",
  • "mobile_phone": "string",
  • "address": "string",
  • "city": "string",
  • "state": "string",
  • "zip": "string",
  • "country": "USA",
  • "id": 0,
  • "created_at": "2019-08-24T14:15:22Z",
  • "updated_at": "2019-08-24T14:15:22Z"
}

Get Applicant

path Parameters
id
required
integer (Id)

Responses

Request samples

Content type
application/json
{
  • "first_name": "string",
  • "last_name": "string",
  • "middle_name": "string",
  • "gender": "string",
  • "date_of_birth": "2019-08-24",
  • "ssn": "stringstr",
  • "email": "string",
  • "home_phone": "string",
  • "mobile_phone": "string",
  • "address": "string",
  • "city": "string",
  • "state": "string",
  • "zip": "string",
  • "country": "USA"
}

Response samples

Content type
application/json
{
  • "first_name": "string",
  • "last_name": "string",
  • "middle_name": "string",
  • "gender": "string",
  • "date_of_birth": "2019-08-24",
  • "ssn": "stringstr",
  • "email": "string",
  • "home_phone": "string",
  • "mobile_phone": "string",
  • "address": "string",
  • "city": "string",
  • "state": "string",
  • "zip": "string",
  • "country": "USA",
  • "id": 0,
  • "created_at": "2019-08-24T14:15:22Z",
  • "updated_at": "2019-08-24T14:15:22Z"
}

Get Applicant

path Parameters
applicant_id
required
integer (Applicant Id)

Responses

Response samples

Content type
application/json
{
  • "first_name": "string",
  • "last_name": "string",
  • "middle_name": "string",
  • "gender": "string",
  • "date_of_birth": "2019-08-24",
  • "ssn": "string",
  • "email": "string",
  • "home_phone": "string",
  • "mobile_phone": "string",
  • "address": "string",
  • "city": "string",
  • "state": "string",
  • "zip": "string",
  • "country": "USA",
  • "id": 0,
  • "created_at": "2019-08-24T14:15:22Z",
  • "updated_at": "2019-08-24T14:15:22Z"
}

Update Applicant

path Parameters
id
required
integer (Id)
Request Body schema: application/json
first_name
required
string (First Name)
last_name
required
string (Last Name)
Middle Name (string) or Middle Name (null) (Middle Name)
gender
required
string (Gender)
date_of_birth
required
string <date> (Date Of Birth)
ssn
required
string (Ssn)
Email (string) or Email (null) (Email)
Home Phone (string) or Home Phone (null) (Home Phone)
Mobile Phone (string) or Mobile Phone (null) (Mobile Phone)
Address (string) or Address (null) (Address)
City (string) or City (null) (City)
State (string) or State (null) (State)
Zip (string) or Zip (null) (Zip)
country
string (Country)
Default: "USA"

Responses

Response samples

Content type
application/json
{
  • "first_name": "string",
  • "last_name": "string",
  • "middle_name": "string",
  • "gender": "string",
  • "date_of_birth": "2019-08-24",
  • "ssn": "stringstr",
  • "email": "string",
  • "home_phone": "string",
  • "mobile_phone": "string",
  • "address": "string",
  • "city": "string",
  • "state": "string",
  • "zip": "string",
  • "country": "USA",
  • "id": 0,
  • "created_at": "2019-08-24T14:15:22Z",
  • "updated_at": "2019-08-24T14:15:22Z"
}

Update Applicant

path Parameters
applicant_id
required
integer (Applicant Id)
Request Body schema: application/json
First Name (string) or First Name (null) (First Name)
Last Name (string) or Last Name (null) (Last Name)
Middle Name (string) or Middle Name (null) (Middle Name)
Gender (string) or Gender (null) (Gender)
Date Of Birth (string) or Date Of Birth (null) (Date Of Birth)
Ssn (string) or Ssn (null) (Ssn)
Email (string) or Email (null) (Email)
Home Phone (string) or Home Phone (null) (Home Phone)
Mobile Phone (string) or Mobile Phone (null) (Mobile Phone)
Address (string) or Address (null) (Address)
City (string) or City (null) (City)
State (string) or State (null) (State)
Zip (string) or Zip (null) (Zip)
Country (string) or Country (null) (Country)

Responses

Request samples

Content type
application/json
{
  • "first_name": "string",
  • "last_name": "string",
  • "middle_name": "string",
  • "gender": "string",
  • "date_of_birth": "2019-08-24",
  • "ssn": "string",
  • "email": "string",
  • "home_phone": "string",
  • "mobile_phone": "string",
  • "address": "string",
  • "city": "string",
  • "state": "string",
  • "zip": "string",
  • "country": "USA"
}

Response samples

Content type
application/json
{
  • "first_name": "string",
  • "last_name": "string",
  • "middle_name": "string",
  • "gender": "string",
  • "date_of_birth": "2019-08-24",
  • "ssn": "string",
  • "email": "string",
  • "home_phone": "string",
  • "mobile_phone": "string",
  • "address": "string",
  • "city": "string",
  • "state": "string",
  • "zip": "string",
  • "country": "USA",
  • "id": 0,
  • "created_at": "2019-08-24T14:15:22Z",
  • "updated_at": "2019-08-24T14:15:22Z"
}

Delete Applicant

path Parameters
id
required
integer (Id)

Responses

Request samples

Content type
application/json
{
  • "first_name": "string",
  • "last_name": "string",
  • "middle_name": "string",
  • "gender": "string",
  • "date_of_birth": "2019-08-24",
  • "ssn": "string",
  • "email": "string",
  • "home_phone": "string",
  • "mobile_phone": "string",
  • "address": "string",
  • "city": "string",
  • "state": "string",
  • "zip": "string",
  • "country": "string"
}

Response samples

Content type
application/json
{
  • "first_name": "string",
  • "last_name": "string",
  • "middle_name": "string",
  • "gender": "string",
  • "date_of_birth": "2019-08-24",
  • "ssn": "stringstr",
  • "email": "string",
  • "home_phone": "string",
  • "mobile_phone": "string",
  • "address": "string",
  • "city": "string",
  • "state": "string",
  • "zip": "string",
  • "country": "USA",
  • "id": 0,
  • "created_at": "2019-08-24T14:15:22Z",
  • "updated_at": "2019-08-24T14:15:22Z"
}

Delete Applicant

path Parameters
applicant_id
required
integer (Applicant Id)

Responses

Response samples

Content type
application/json
{
  • "detail": [
    ]
}

Users

Get Items

query Parameters
page_number
integer (Page Number)
Default: 0
page_size
integer (Page Size)
Default: 100

Responses

Response samples

Content type
application/json
{
  • "detail": [
    ]
}

Users

Get Items

query Parameters
page_number
integer (Page Number)
Default: 0
page_size
integer (Page Size)
Default: 100

Responses

Response samples

Content type
application/json
{
  • "items": [
    ],
  • "item_count": 0,
  • "page_count": 0,
  • "prev_page": 0,
  • "next_page": 0
}

Create Item

Request Body schema: application/json
Id (integer) or Id (null) (Id)
user_id
required
string (User Id)
first_name
required
string (First Name)
last_name
required
string (Last Name)
display_name
required
string (Display Name)
email
required
string (Email)
is_active
boolean (Is Active)
Default: true
Created (string) or Created (null) (Created)
created_by
required
string (Created By)
Modified (string) or Modified (null) (Modified)
modified_by
required
string (Modified By)

Responses

Response samples

Content type
application/json
{
  • "items": [
    ],
  • "item_count": 0,
  • "page_count": 0,
  • "prev_page": 0,
  • "next_page": 0
}

Create Item

Request Body schema: application/json
user_id
required
string (User Id) [ 1 .. 100 ] characters
first_name
required
string (First Name) [ 1 .. 100 ] characters
last_name
required
string (Last Name) [ 1 .. 100 ] characters
display_name
required
string (Display Name) [ 1 .. 200 ] characters
email
required
string (Email) [ 1 .. 254 ] characters
is_active
boolean (Is Active)
Default: true
created_by
required
string (Created By) [ 1 .. 100 ] characters
modified_by
required
string (Modified By) [ 1 .. 100 ] characters
Hashed Password (string) or Hashed Password (null) (Hashed Password)

Responses

Request samples

Content type
application/json
{
  • "id": 0,
  • "user_id": "string",
  • "first_name": "string",
  • "last_name": "string",
  • "display_name": "string",
  • "email": "string",
  • "is_active": true,
  • "created": "2019-08-24T14:15:22Z",
  • "created_by": "string",
  • "modified": "2019-08-24T14:15:22Z",
  • "modified_by": "string"
}

Response samples

Content type
application/json
{
  • "id": 0,
  • "user_id": "string",
  • "first_name": "string",
  • "last_name": "string",
  • "display_name": "string",
  • "email": "string",
  • "is_active": true,
  • "created": "2019-08-24T14:15:22Z",
  • "created_by": "string",
  • "modified": "2019-08-24T14:15:22Z",
  • "modified_by": "string"
}

Get Item

path Parameters
id
required
integer (Id)

Responses

Request samples

Content type
application/json
{
  • "user_id": "string",
  • "first_name": "string",
  • "last_name": "string",
  • "display_name": "string",
  • "email": "string",
  • "is_active": true,
  • "created_by": "string",
  • "modified_by": "string",
  • "hashed_password": "string"
}

Response samples

Content type
application/json
{
  • "user_id": "string",
  • "first_name": "string",
  • "last_name": "string",
  • "display_name": "string",
  • "email": "string",
  • "is_active": true,
  • "created_by": "string",
  • "modified_by": "string",
  • "id": 0,
  • "created": "2019-08-24T14:15:22Z",
  • "modified": "2019-08-24T14:15:22Z"
}

Get Item

path Parameters
id
required
integer (Id)

Responses

Response samples

Content type
application/json
{
  • "id": 0,
  • "user_id": "string",
  • "first_name": "string",
  • "last_name": "string",
  • "display_name": "string",
  • "email": "string",
  • "is_active": true,
  • "created": "2019-08-24T14:15:22Z",
  • "created_by": "string",
  • "modified": "2019-08-24T14:15:22Z",
  • "modified_by": "string"
}

Update Item

path Parameters
id
required
integer (Id)
Request Body schema: application/json
Id (integer) or Id (null) (Id)
user_id
required
string (User Id)
first_name
required
string (First Name)
last_name
required
string (Last Name)
display_name
required
string (Display Name)
email
required
string (Email)
is_active
boolean (Is Active)
Default: true
Created (string) or Created (null) (Created)
created_by
required
string (Created By)
Modified (string) or Modified (null) (Modified)
modified_by
required
string (Modified By)

Responses

Response samples

Content type
application/json
{
  • "user_id": "string",
  • "first_name": "string",
  • "last_name": "string",
  • "display_name": "string",
  • "email": "string",
  • "is_active": true,
  • "created_by": "string",
  • "modified_by": "string",
  • "id": 0,
  • "created": "2019-08-24T14:15:22Z",
  • "modified": "2019-08-24T14:15:22Z"
}

Update Item

path Parameters
id
required
integer (Id)
Request Body schema: application/json
User Id (string) or User Id (null) (User Id)
First Name (string) or First Name (null) (First Name)
Last Name (string) or Last Name (null) (Last Name)
Display Name (string) or Display Name (null) (Display Name)
Email (string) or Email (null) (Email)
Is Active (boolean) or Is Active (null) (Is Active)
Modified By (string) or Modified By (null) (Modified By)

Responses

Request samples

Content type
application/json
{
  • "id": 0,
  • "user_id": "string",
  • "first_name": "string",
  • "last_name": "string",
  • "display_name": "string",
  • "email": "string",
  • "is_active": true,
  • "created": "2019-08-24T14:15:22Z",
  • "created_by": "string",
  • "modified": "2019-08-24T14:15:22Z",
  • "modified_by": "string"
}

Response samples

Content type
application/json
{
  • "id": 0,
  • "user_id": "string",
  • "first_name": "string",
  • "last_name": "string",
  • "display_name": "string",
  • "email": "string",
  • "is_active": true,
  • "created": "2019-08-24T14:15:22Z",
  • "created_by": "string",
  • "modified": "2019-08-24T14:15:22Z",
  • "modified_by": "string"
}

Delete Item

path Parameters
id
required
integer (Id)

Responses

Request samples

Content type
application/json
{
  • "user_id": "string",
  • "first_name": "string",
  • "last_name": "string",
  • "display_name": "string",
  • "email": "string",
  • "is_active": true,
  • "modified_by": "string"
}

Response samples

Content type
application/json
{
  • "user_id": "string",
  • "first_name": "string",
  • "last_name": "string",
  • "display_name": "string",
  • "email": "string",
  • "is_active": true,
  • "created_by": "string",
  • "modified_by": "string",
  • "id": 0,
  • "created": "2019-08-24T14:15:22Z",
  • "modified": "2019-08-24T14:15:22Z"
}

Delete Item

path Parameters
id
required
integer (Id)

Responses

Response samples

Content type
application/json
{
  • "detail": [
    ]
}

Admin

Get Current User

Authorizations:
HTTPBearer

Responses

Response samples

Content type
application/json
null

Health

Get Health

Responses

Response samples

Content type
application/json
null
+

Response samples

Content type
application/json
{
  • "detail": [
    ]
}

Admin

Get Current User

Authorizations:
HTTPBearer

Responses

Response samples

Content type
application/json
null

Health

Get Health

Responses

Response samples

Content type
application/json
null