forked from Netflix/dispatch
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
37 lines (23 loc) · 916 Bytes
/
models.py
File metadata and controls
37 lines (23 loc) · 916 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from pydantic import validator, Field
from typing import Optional
from sqlalchemy import Column, Integer, ForeignKey
from dispatch.database.core import Base
from dispatch.messaging.strings import STORAGE_DESCRIPTION
from dispatch.models import ResourceBase, ResourceMixin
class Storage(Base, ResourceMixin):
id = Column(Integer, primary_key=True)
incident_id = Column(Integer, ForeignKey("incident.id", ondelete="CASCADE"))
case_id = Column(Integer, ForeignKey("case.id", ondelete="CASCADE"))
# Pydantic models...
class StorageBase(ResourceBase):
pass
class StorageCreate(StorageBase):
pass
class StorageUpdate(StorageBase):
pass
class StorageRead(StorageBase):
description: Optional[str] = Field(None, nullable=True)
@validator("description", pre=True, always=True)
def set_description(cls, v):
"""Sets the description"""
return STORAGE_DESCRIPTION