-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathuser.py
79 lines (64 loc) · 1.93 KB
/
user.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
from dataclasses import dataclass, field
from datetime import datetime
from typing import Dict, 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
# pylint: disable=too-many-instance-attributes
@dataclass
class User:
# read-write
username: str
full_name: str
email: str
email_service: bool
email_product: bool
role: str = ""
# read-only
_company_id: ID = DEFAULT_ID
_filters: Dict = field(default_factory=dict)
_saved_filters: List = field(default_factory=list)
_id: ID = DEFAULT_ID
_last_login: str = ""
_created_date: str = ""
_updated_date: str = ""
@classmethod
def new(
cls,
username: str,
full_name: str,
user_email: str,
email_service: bool,
email_product: bool,
role: str = "",
):
return cls(
username=username,
full_name=full_name,
email=user_email,
email_service=email_service,
email_product=email_product,
role=role,
)
@property
def company_id(self) -> ID:
return self._company_id
@property
def filters(self) -> Dict:
return self._filters
@property
def saved_filters(self) -> List:
return self._saved_filters
@property
def id(self) -> ID:
return self._id
@property
def last_login(self) -> Optional[datetime]:
return from_iso_format_zulu(self._last_login) if self._last_login else None
@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