1
|
from typing import List, Optional
|
2
|
|
3
|
from pydantic import BaseModel
|
4
|
|
5
|
|
6
|
|
7
|
class DeviceLicenseBase(BaseModel):
|
8
|
device_id: int
|
9
|
license_id: int
|
10
|
assigned_datetime: str
|
11
|
|
12
|
|
13
|
class DeviceLicenseCreate(DeviceLicenseBase):
|
14
|
pass
|
15
|
|
16
|
|
17
|
class DeviceLicense(DeviceLicenseCreate):
|
18
|
id: int
|
19
|
|
20
|
class Config:
|
21
|
orm_mode = True
|
22
|
|
23
|
|
24
|
class USBLogBase(BaseModel):
|
25
|
timestamp: str
|
26
|
status: str
|
27
|
|
28
|
|
29
|
class USBLogCreate(USBLogBase):
|
30
|
pass
|
31
|
|
32
|
|
33
|
class USBLog(USBLogBase):
|
34
|
id: int
|
35
|
device_id: int
|
36
|
pc_id: int
|
37
|
|
38
|
class Config:
|
39
|
orm_mode = True
|
40
|
|
41
|
|
42
|
class DeviceBase(BaseModel):
|
43
|
vendor_id: int
|
44
|
product_id: int
|
45
|
serial_number: str
|
46
|
|
47
|
|
48
|
class DeviceCreate(DeviceBase):
|
49
|
pass
|
50
|
|
51
|
|
52
|
class Device(DeviceBase):
|
53
|
id: int
|
54
|
logs: List[USBLog] = []
|
55
|
licenses: List[DeviceLicense] = []
|
56
|
|
57
|
class Config:
|
58
|
orm_mode = True
|
59
|
|
60
|
|
61
|
class PCBase(BaseModel):
|
62
|
username: str
|
63
|
hostname: str
|
64
|
|
65
|
|
66
|
class PCCreate(PCBase):
|
67
|
pass
|
68
|
|
69
|
|
70
|
class PC(PCCreate):
|
71
|
id: int
|
72
|
logs_pc: List[USBLog] = []
|
73
|
|
74
|
class Config:
|
75
|
orm_mode = True
|
76
|
|
77
|
|
78
|
class LicenseBase(BaseModel):
|
79
|
name: str
|
80
|
expiration_date: str
|
81
|
|
82
|
|
83
|
class LicenseCreate(LicenseBase):
|
84
|
pass
|
85
|
|
86
|
|
87
|
class License(LicenseCreate):
|
88
|
id: int
|
89
|
devices: List[DeviceLicense] = []
|
90
|
|
91
|
class Config:
|
92
|
orm_mode = True
|
93
|
|
94
|
|
95
|
class USBTempBase(BaseModel):
|
96
|
username: str
|
97
|
hostname: str
|
98
|
timestamp: str
|
99
|
device: DeviceBase
|
100
|
status: str
|
101
|
|
102
|
|
103
|
class USBTempCreate(USBTempBase):
|
104
|
pass
|
105
|
|
106
|
|
107
|
class USBTemp(USBTempBase):
|
108
|
id: int
|
109
|
device_id: int
|
110
|
|
111
|
class Config:
|
112
|
orm_mode = True
|