Projekt

Obecné

Profil

Stáhnout (4.47 KB) Statistiky
| Větev: | Tag: | Revize:
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
    """
18
    Class used for creating and reading devices_licenses entries
19
    """
20
    id: int
21

    
22
    class Config:
23
        orm_mode = True
24

    
25

    
26
class USBLogBase(BaseModel):
27
    timestamp: datetime
28
    status: str
29

    
30

    
31
class USBLogCreate(USBLogBase):
32
    pass
33

    
34

    
35
class USBLog(USBLogBase):
36
    """
37
    Class used for creating and reading usb_logs entries
38
    """
39
    id: int
40
    device_id: int
41
    pc_id: int
42

    
43
    class Config:
44
        orm_mode = True
45

    
46

    
47
class DeviceBase(BaseModel):
48
    vendor_id: str
49
    product_id: str
50
    serial_number: str
51
    inventory_number: str
52
    comment: str
53

    
54

    
55
class DeviceCreate(DeviceBase):
56
    pass
57

    
58

    
59
class Device(DeviceCreate):
60
    """
61
    Class used for creating and reading devices entries
62
    """
63
    id: int
64
    logs: List[USBLog] = []
65
    licenses: List[DeviceLicense] = []
66

    
67
    class Config:
68
        orm_mode = True
69

    
70

    
71
class DeviceTemp(BaseModel):
72
    """
73
    Class used for reading data from client
74
    """
75
    vendor_id: str
76
    product_id: str
77
    serial_number: str
78

    
79

    
80
class LDLogBase(BaseModel):
81
    timestamp: datetime
82
    status: str
83

    
84

    
85
class LDLogCreate(LDLogBase):
86
    pass
87

    
88

    
89
class LDLog(LDLogCreate):
90
    """
91
    Class used for creating and reading ld_logs entries
92
    """
93
    id: int
94
    head_id: int
95
    body_id: int
96

    
97
    class Config:
98
        orm_mode = True
99

    
100

    
101
class BodyDeviceBase(BaseModel):
102
    serial_number: str
103
    inventory_number: str
104
    comment: str
105

    
106

    
107
class BodyDeviceCreate(BodyDeviceBase):
108
    pass
109

    
110

    
111
class BodyDevice(BodyDeviceCreate):
112
    """
113
    Class used for creating and reading body_devices entries
114
    """
115
    id: int
116
    logs: List[LDLog] = []
117

    
118
    class Config:
119
        orm_mode = True
120

    
121

    
122
class BodyDeviceTemp(BaseModel):
123
    """
124
    Class used for reading body device data from client
125
    """
126
    serial_number: str
127

    
128

    
129
class HeadDeviceBase(BaseModel):
130
    serial_number: str
131
    inventory_number: str
132
    comment: str
133

    
134

    
135
class HeadDeviceCreate(HeadDeviceBase):
136
    pass
137

    
138

    
139
class HeadDevice(HeadDeviceCreate):
140
    """
141
    Class used for creating and reading head_devices entries
142
    """
143
    id: int
144
    logs: List[LDLog] = []
145

    
146
    class Config:
147
        orm_mode = True
148

    
149

    
150
class HeadDeviceTemp(BaseModel):
151
    """
152
    Class used for reading head device data from client
153
    """
154
    serial_number: str
155

    
156

    
157
class PCBase(BaseModel):
158
    username: str
159
    hostname: str
160

    
161

    
162
class PCCreate(PCBase):
163
    pass
164

    
165

    
166
class PC(PCCreate):
167
    """
168
    Class used for creating and reading pc entries
169
    """
170
    id: int
171
    logs_pc: List[USBLog] = []
172
    logs_ld: List[LDLog] = []
173

    
174
    class Config:
175
        orm_mode = True
176

    
177

    
178
class TeamBase(BaseModel):
179
    name: str
180

    
181

    
182
class TeamCreate(TeamBase):
183
    pass
184

    
185

    
186
class Team(TeamCreate):
187
    """
188
    Class used for creating and reading team entries
189
    """
190
    id: int
191
    devices: List[Device] = []
192

    
193
    class Config:
194
        orm_mode = True
195

    
196

    
197
class LicenseBase(BaseModel):
198
    name: str
199
    license_id: str
200
    expiration_date: date
201

    
202

    
203
class LicenseCreate(LicenseBase):
204
    pass
205

    
206

    
207
class License(LicenseCreate):
208
    """
209
    Class used for creating and reading licenses entries
210
    """
211
    id: int
212
    devices: List[DeviceLicense] = []
213
    head_devices: List[HeadDevice] = []
214
    body_devices: List[BodyDevice] = []
215

    
216
    class Config:
217
        orm_mode = True
218

    
219

    
220
class USBTempBase(BaseModel):
221
    """
222
    Class used for reading data from keyman detecting client messages
223
    """
224
    username: str
225
    hostname: str
226
    timestamp: str
227
    device: DeviceTemp
228
    status: str
229

    
230

    
231
class USBTempCreate(USBTempBase):
232
    pass
233

    
234

    
235
class USBTemp(USBTempBase):
236
    id: int
237
    device_id: int
238

    
239
    class Config:
240
        orm_mode = True
241

    
242

    
243
class LDTempBase(BaseModel):
244
    """
245
    Class used for reading data from debugger detecting client messages
246
    """
247
    username: str
248
    hostname: str
249
    timestamp: str
250
    head_device: HeadDeviceTemp
251
    body_device: BodyDeviceTemp
252
    status: str
253

    
254

    
255
class LDTempCreate(LDTempBase):
256
    pass
257

    
258

    
259
class LDTemp(LDTempCreate):
260
    id: int
261
    head_id: int
262
    body_id: int
263

    
264
    class Config:
265
        orm_mode = True
266

    
267

    
268
class UserBase(BaseModel):
269
    """
270
    Classes used for creating new User entry
271
    """
272
    username: str
273
    password: str
274
    role: str
275

    
276

    
277
class UserCreate(UserBase):
278
    pass
279

    
280

    
281
class User(UserCreate):
282
    id: int
283

    
284
    class Config:
285
        orm_mode = True
(6-6/6)