-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathitems.py
59 lines (47 loc) · 1.29 KB
/
items.py
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
from pydantic import BaseModel, Field
from typing import Dict, List, Optional
from uuid import UUID, uuid4
# item model
class ItemModel(BaseModel):
#id: UUID = Field(default_factory=uuid4,alias='_id')
#id: UUID = Field(alias='_id')
id: str = Field(alias='_id')
group: str = "default"
fields: Dict = {}
class Config:
allow_population_by_field_name = True
# create item model
# not needed anymore
#class ItemCreateModel(BaseModel):
# id: Optional[UUID] = Field(default_factory=uuid4,alias='_id')
# group: Optional[str] = "default"
# fields: Dict = {}
#
# class Config:
# allow_population_by_field_name = True
# update item model
class ItemPutModel(BaseModel):
group: str
fields: Dict
class ItemPatchModel(BaseModel):
group: Optional[str] = None
fields: Optional[Dict] = None
# item creation model
class ItemCreationResponseModel(BaseModel):
success: bool
items_created: int
items_ids: List[str]
# items count model
class ItemsCountResponseModel(BaseModel):
count: int
# items put/replace model
class ItemPutResponseModel(BaseModel):
successful: bool
items_updated: int
# items patch/update model
class ItemPatchResponseModel(ItemPutResponseModel):
pass
# items put/replace model
class ItemDeleteResponseModel(BaseModel):
successful: bool
items_deleted: int