-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathdevice_label.py
64 lines (47 loc) · 1.48 KB
/
device_label.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
60
61
62
63
64
from dataclasses import dataclass, field
from datetime import datetime
from typing import List, Optional
from kentik_api.internal.datetime_zulu import from_iso_format_zulu
from kentik_api.public.defaults import DEFAULT_ID
from kentik_api.public.types import ID
@dataclass(frozen=True)
class DeviceItem:
id: ID
device_name: str
device_subtype: str
device_type: Optional[str]
# pylint: disable=too-many-instance-attributes
@dataclass
class DeviceLabel:
# read-write
name: str
color: str
# read-only
_devices: List[DeviceItem] = field(default_factory=list)
_id: ID = DEFAULT_ID
_user_id: Optional[ID] = DEFAULT_ID
_company_id: ID = DEFAULT_ID
_created_date: str = ""
_updated_date: str = ""
@classmethod
def new(cls, name: str, color: str):
return cls(name=name, color=color)
@property
def id(self) -> ID:
return self._id
@property
def user_id(self) -> Optional[ID]:
return self._user_id
@property
def company_id(self) -> ID:
return self._company_id
@property
def devices(self) -> List[DeviceItem]:
return self._devices
@property
def created_date(self) -> Optional[datetime]:
return from_iso_format_zulu(self._created_date) if self._created_date else None
@property
def updated_date(self) -> Optional[datetime]:
return from_iso_format_zulu(self._updated_date) if self._updated_date else None
# pylint: enable=too-many-instance-attributes