-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathcustom_dimension.py
156 lines (132 loc) · 4.5 KB
/
custom_dimension.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
from enum import Enum
from typing import List, Optional
from kentik_api.public.errors import IncompleteObjectError
from kentik_api.public.types import ID, PermissiveEnumMeta
# pylint: disable=too-many-instance-attributes
class Populator:
class Direction(Enum, metaclass=PermissiveEnumMeta):
SRC = "SRC"
DST = "DST"
EITHER = "EITHER"
# pylint: disable=too-many-arguments
def __init__(
self,
value: str,
direction: Direction,
device_name: Optional[str] = None,
interface_name: Optional[str] = None,
addr: Optional[str] = None,
port: Optional[str] = None,
tcp_flags: Optional[str] = None,
protocol: Optional[str] = None,
asn: Optional[str] = None,
nexthop_asn: Optional[str] = None,
nexthop: Optional[str] = None,
bgp_aspath: Optional[str] = None,
bgp_community: Optional[str] = None,
device_type: Optional[str] = None,
site: Optional[str] = None,
lasthop_as_name: Optional[str] = None,
nexthop_as_name: Optional[str] = None,
mac: Optional[str] = None,
country: Optional[str] = None,
vlans: Optional[str] = None,
id: Optional[ID] = None,
company_id: Optional[ID] = None,
user: Optional[str] = None,
dimension_id: Optional[ID] = None,
mac_count: Optional[int] = None,
addr_count: Optional[int] = None,
created_date: Optional[str] = None,
updated_date: Optional[str] = None,
) -> None:
# read-write
self.value = value
self.direction = direction
self.device_name = device_name
self.interface_name = interface_name
self.addr = addr
self.port = port
self.tcp_flags = tcp_flags
self.protocol = protocol
self.asn = asn
self.nexthop_asn = nexthop_asn
self.nexthop = nexthop
self.bgp_aspath = bgp_aspath
self.bgp_community = bgp_community
self.device_type = device_type
self.site = site
self.lasthop_as_name = lasthop_as_name
self.nexthop_as_name = nexthop_as_name
self.mac = mac
self.country = country
self.vlans = vlans
# read-only
self._id = id
self._company_id = company_id
self._dimension_id = dimension_id
self._user = user
self._mac_count = mac_count
self._addr_count = addr_count
self._created_date = created_date
self._updated_date = updated_date
# pylint: enable=too-many-arguments
@property
def id(self) -> ID:
if self._id is None:
raise IncompleteObjectError("", self.__class__.__name__, "_id is required")
return self._id
@property
def company_id(self) -> Optional[ID]:
return self._company_id
@property
def dimension_id(self) -> ID:
if self._dimension_id is None:
raise IncompleteObjectError("", self.__class__.__name__, "_dimension_id is required")
return self._dimension_id
@property
def user(self) -> Optional[str]:
return self._user
@property
def mac_count(self) -> Optional[int]:
return self._mac_count
@property
def addr_count(self) -> Optional[int]:
return self._addr_count
@property
def created_date(self) -> Optional[str]:
return self._created_date
@property
def updated_date(self) -> Optional[str]:
return self._updated_date
# pylint: enable=too-many-instance-attributes
class CustomDimension:
# pylint: disable=too-many-arguments
def __init__(
self,
name: Optional[str] = None,
display_name: Optional[str] = None,
type: Optional[str] = None,
populators: Optional[List[Populator]] = None,
id: Optional[ID] = None,
company_id: Optional[ID] = None,
) -> None:
# read-write
# name must start with c_ and be unique even against deleted dimensions
# (deleted names are retained for 1 year)
self.name = name
self.display_name = display_name
self.type = type
self.populators = populators
# read-only
self._id = id
self._company_id = company_id
# pylint: enable=too-many-arguments
@property
def id(self) -> ID:
if self._id is None:
raise IncompleteObjectError("", self.__class__.__name__, "_id is required")
return self._id
@property
def company_id(self) -> Optional[ID]:
return self._company_id