1
|
from typing import List, Optional
|
2
|
from datetime import datetime, date
|
3
|
from pydantic import BaseModel
|
4
|
|
5
|
|
6
|
class DeviceLicenseBase(BaseModel):
|
7
|
device_id: int
|
8
|
license_id: int
|
9
|
assigned_datetime: str
|
10
|
|
11
|
|
12
|
class DeviceLicenseCreate(DeviceLicenseBase):
|
13
|
pass
|
14
|
|
15
|
|
16
|
class DeviceLicense(DeviceLicenseCreate):
|
17
|
id: int
|
18
|
|
19
|
class Config:
|
20
|
orm_mode = True
|
21
|
|
22
|
|
23
|
class USBLogBase(BaseModel):
|
24
|
timestamp: datetime
|
25
|
status: str
|
26
|
|
27
|
|
28
|
class USBLogCreate(USBLogBase):
|
29
|
pass
|
30
|
|
31
|
|
32
|
class USBLog(USBLogBase):
|
33
|
id: int
|
34
|
device_id: int
|
35
|
pc_id: int
|
36
|
|
37
|
class Config:
|
38
|
orm_mode = True
|
39
|
|
40
|
|
41
|
class DeviceBase(BaseModel):
|
42
|
vendor_id: str
|
43
|
product_id: str
|
44
|
serial_number: str
|
45
|
|
46
|
|
47
|
class DeviceCreate(DeviceBase):
|
48
|
pass
|
49
|
|
50
|
|
51
|
class Device(DeviceCreate):
|
52
|
id: int
|
53
|
assigned: bool
|
54
|
logs: List[USBLog] = []
|
55
|
licenses: List[DeviceLicense] = []
|
56
|
|
57
|
class Config:
|
58
|
orm_mode = True
|
59
|
|
60
|
|
61
|
class LDLogBase(BaseModel):
|
62
|
timestamp: datetime
|
63
|
status: str
|
64
|
|
65
|
|
66
|
class LDLogCreate(LDLogBase):
|
67
|
pass
|
68
|
|
69
|
|
70
|
class LDLog(LDLogCreate):
|
71
|
id: int
|
72
|
head_id: int
|
73
|
body_id: int
|
74
|
|
75
|
class Config:
|
76
|
orm_mode = True
|
77
|
|
78
|
|
79
|
class BodyDeviceBase(BaseModel):
|
80
|
serial_number: str
|
81
|
|
82
|
|
83
|
class BodyDeviceCreate(BodyDeviceBase):
|
84
|
pass
|
85
|
|
86
|
|
87
|
class BodyDevice(BodyDeviceCreate):
|
88
|
id: int
|
89
|
logs: List[LDLog] = []
|
90
|
|
91
|
class Config:
|
92
|
orm_mode = True
|
93
|
|
94
|
|
95
|
class HeadDeviceBase(BaseModel):
|
96
|
serial_number: str
|
97
|
|
98
|
|
99
|
class HeadDeviceCreate(HeadDeviceBase):
|
100
|
pass
|
101
|
|
102
|
|
103
|
class HeadDevice(HeadDeviceCreate):
|
104
|
id: int
|
105
|
logs: List[LDLog] = []
|
106
|
|
107
|
class Config:
|
108
|
orm_mode = True
|
109
|
|
110
|
|
111
|
class PCBase(BaseModel):
|
112
|
username: str
|
113
|
hostname: str
|
114
|
|
115
|
|
116
|
class PCCreate(PCBase):
|
117
|
pass
|
118
|
|
119
|
|
120
|
class PC(PCCreate):
|
121
|
id: int
|
122
|
assigned: bool
|
123
|
logs_pc: List[USBLog] = []
|
124
|
|
125
|
class Config:
|
126
|
orm_mode = True
|
127
|
|
128
|
|
129
|
class TeamBase(BaseModel):
|
130
|
name: str
|
131
|
|
132
|
|
133
|
class TeamCreate(TeamBase):
|
134
|
pass
|
135
|
|
136
|
|
137
|
class Team(TeamCreate):
|
138
|
id: int
|
139
|
pcs: List[PC] = []
|
140
|
|
141
|
class Config:
|
142
|
orm_mode = True
|
143
|
|
144
|
|
145
|
class LicenseBase(BaseModel):
|
146
|
name: str
|
147
|
expiration_date: date
|
148
|
|
149
|
|
150
|
class LicenseCreate(LicenseBase):
|
151
|
pass
|
152
|
|
153
|
|
154
|
class License(LicenseCreate):
|
155
|
id: int
|
156
|
devices: List[DeviceLicense] = []
|
157
|
|
158
|
class Config:
|
159
|
orm_mode = True
|
160
|
|
161
|
|
162
|
class USBTempBase(BaseModel):
|
163
|
username: str
|
164
|
hostname: str
|
165
|
timestamp: str
|
166
|
device: DeviceBase
|
167
|
status: str
|
168
|
|
169
|
|
170
|
class USBTempCreate(USBTempBase):
|
171
|
pass
|
172
|
|
173
|
|
174
|
class USBTemp(USBTempBase):
|
175
|
id: int
|
176
|
device_id: int
|
177
|
|
178
|
class Config:
|
179
|
orm_mode = True
|
180
|
|
181
|
|
182
|
class LDTempBase(BaseModel):
|
183
|
username: str
|
184
|
hostname: str
|
185
|
timestamp: str
|
186
|
head_device: HeadDeviceBase
|
187
|
body_device: BodyDeviceBase
|
188
|
status: str
|
189
|
|
190
|
|
191
|
class LDTempCreate(LDTempBase):
|
192
|
pass
|
193
|
|
194
|
|
195
|
class LDTemp(LDTempCreate):
|
196
|
id: int
|
197
|
head_id: int
|
198
|
body_id: int
|
199
|
|
200
|
class Config:
|
201
|
orm_mode = True
|