This repository has been archived on 2020-08-14. You can view files and clone it, but cannot push or open issues or pull requests.
statuspage/app/schemas.py
surtur fc0051b243
feat: added complete CRUD functionality for service and user
* aside from slight refactors there have been route changes
  (/api/v1/service/ --> /api/v1/service)
* added helper little function for grabbing user and service ids
* refactored a couple of return statements
* added separate models for updates
* adjusted error handling behaviour: more general 422 is now returned
  (previously 404 was used) --> hopefully leaking less information
* updates are divided into multiple queries **as of now**, mainly due to
  my sqlalchemy amateurism: can't figure out how to construct a proper
  multi-column-update query programatically
2020-08-07 02:00:35 +02:00

64 lines
1.1 KiB
Python

import time
from typing import List, Optional
from pydantic import BaseModel
class ServiceBase(BaseModel):
name: str
owner_id: int
is_private: bool = True
description: Optional[str] = None
service_type: int
url: str
is_active: bool = True
class Service(BaseModel):
created_unix: float
updated_unix: float = None
class ServiceCreate(ServiceBase):
pass
class ServiceUpdate(ServiceBase):
name: Optional[str]
owner_id: Optional[int]
is_private: Optional[bool]
description: Optional[str]
service_type: Optional[int]
url: Optional[str]
is_active: Optional[bool]
class Service(ServiceBase):
pass
class Config:
orm_mode = True
class UserBase(BaseModel):
name: str
full_name: Optional[str] = None
is_active: bool = True
class User(BaseModel):
created_unix: float
updated_unix: float = None
last_login_unix: float = None
class UserCreate(UserBase):
password: str
class UserUpdate(UserBase):
name: Optional[str]
full_name: Optional[str]
password: Optional[str]
is_active: Optional[bool]
class User(UserBase):
pass
class Config:
orm_mode = True