nbforager 0.8.0__tar.gz → 0.8.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {nbforager-0.8.0 → nbforager-0.8.1}/PKG-INFO +2 -2
- {nbforager-0.8.0 → nbforager-0.8.1}/nbforager/api/connector.py +4 -0
- nbforager-0.8.1/nbforager/constants.py +283 -0
- {nbforager-0.8.0 → nbforager-0.8.1}/nbforager/helpers.py +2 -275
- {nbforager-0.8.0 → nbforager-0.8.1}/nbforager/nb_api.py +13 -15
- {nbforager-0.8.0 → nbforager-0.8.1}/nbforager/types_.py +3 -3
- {nbforager-0.8.0 → nbforager-0.8.1}/pyproject.toml +2 -2
- {nbforager-0.8.0 → nbforager-0.8.1}/LICENSE.txt +0 -0
- {nbforager-0.8.0 → nbforager-0.8.1}/README.rst +0 -0
- {nbforager-0.8.0 → nbforager-0.8.1}/nbforager/__init__.py +0 -0
- {nbforager-0.8.0 → nbforager-0.8.1}/nbforager/api/__init__.py +0 -0
- {nbforager-0.8.0 → nbforager-0.8.1}/nbforager/api/base_ac.py +0 -0
- {nbforager-0.8.0 → nbforager-0.8.1}/nbforager/api/base_c.py +0 -0
- {nbforager-0.8.0 → nbforager-0.8.1}/nbforager/api/circuits.py +0 -0
- {nbforager-0.8.0 → nbforager-0.8.1}/nbforager/api/core.py +0 -0
- {nbforager-0.8.0 → nbforager-0.8.1}/nbforager/api/dcim.py +0 -0
- {nbforager-0.8.0 → nbforager-0.8.1}/nbforager/api/extended_get.py +0 -0
- {nbforager-0.8.0 → nbforager-0.8.1}/nbforager/api/extras.py +0 -0
- {nbforager-0.8.0 → nbforager-0.8.1}/nbforager/api/ip_addresses.py +0 -0
- {nbforager-0.8.0 → nbforager-0.8.1}/nbforager/api/ipam.py +0 -0
- {nbforager-0.8.0 → nbforager-0.8.1}/nbforager/api/plugins_ca.py +0 -0
- {nbforager-0.8.0 → nbforager-0.8.1}/nbforager/api/status.py +0 -0
- {nbforager-0.8.0 → nbforager-0.8.1}/nbforager/api/tenancy.py +0 -0
- {nbforager-0.8.0 → nbforager-0.8.1}/nbforager/api/users.py +0 -0
- {nbforager-0.8.0 → nbforager-0.8.1}/nbforager/api/virtualization.py +0 -0
- {nbforager-0.8.0 → nbforager-0.8.1}/nbforager/api/wireless.py +0 -0
- {nbforager-0.8.0 → nbforager-0.8.1}/nbforager/exceptions.py +0 -0
- {nbforager-0.8.0 → nbforager-0.8.1}/nbforager/foragers/__init__.py +0 -0
- {nbforager-0.8.0 → nbforager-0.8.1}/nbforager/foragers/base_fa.py +0 -0
- {nbforager-0.8.0 → nbforager-0.8.1}/nbforager/foragers/circuits.py +0 -0
- {nbforager-0.8.0 → nbforager-0.8.1}/nbforager/foragers/core.py +0 -0
- {nbforager-0.8.0 → nbforager-0.8.1}/nbforager/foragers/dcim.py +0 -0
- {nbforager-0.8.0 → nbforager-0.8.1}/nbforager/foragers/extras.py +0 -0
- {nbforager-0.8.0 → nbforager-0.8.1}/nbforager/foragers/forager.py +0 -0
- {nbforager-0.8.0 → nbforager-0.8.1}/nbforager/foragers/ipam.py +0 -0
- {nbforager-0.8.0 → nbforager-0.8.1}/nbforager/foragers/ipv4.py +0 -0
- {nbforager-0.8.0 → nbforager-0.8.1}/nbforager/foragers/joiner.py +0 -0
- {nbforager-0.8.0 → nbforager-0.8.1}/nbforager/foragers/tenancy.py +0 -0
- {nbforager-0.8.0 → nbforager-0.8.1}/nbforager/foragers/users.py +0 -0
- {nbforager-0.8.0 → nbforager-0.8.1}/nbforager/foragers/virtualization.py +0 -0
- {nbforager-0.8.0 → nbforager-0.8.1}/nbforager/foragers/wireless.py +0 -0
- {nbforager-0.8.0 → nbforager-0.8.1}/nbforager/log.py +0 -0
- {nbforager-0.8.0 → nbforager-0.8.1}/nbforager/messages.py +0 -0
- {nbforager-0.8.0 → nbforager-0.8.1}/nbforager/nb_cache.py +0 -0
- {nbforager-0.8.0 → nbforager-0.8.1}/nbforager/nb_forager.py +0 -0
- {nbforager-0.8.0 → nbforager-0.8.1}/nbforager/nb_tree.py +0 -0
- {nbforager-0.8.0 → nbforager-0.8.1}/nbforager/parser/__init__.py +0 -0
- {nbforager-0.8.0 → nbforager-0.8.1}/nbforager/parser/nb_custom.py +0 -0
- {nbforager-0.8.0 → nbforager-0.8.1}/nbforager/parser/nb_parser.py +0 -0
- {nbforager-0.8.0 → nbforager-0.8.1}/nbforager/parser/nb_value.py +0 -0
- {nbforager-0.8.0 → nbforager-0.8.1}/nbforager/py.typed +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: nbforager
|
3
|
-
Version: 0.8.
|
3
|
+
Version: 0.8.1
|
4
4
|
Summary: Python package designed to assist in working with the Netbox REST API. The filter parameters are identical to those in the Web UI filter form. It replaces brief data with full information, and Netbox objects are represented as a recursive multidimensional dictionary.
|
5
5
|
License: Apache-2.0
|
6
6
|
Keywords: netbox
|
@@ -23,7 +23,7 @@ Requires-Dist: requests (>=2,<3)
|
|
23
23
|
Requires-Dist: tabulate (>=0.9,<0.10)
|
24
24
|
Requires-Dist: vhelpers (>=0.3)
|
25
25
|
Project-URL: Bug Tracker, https://github.com/vladimirs-git/nbforager/issues
|
26
|
-
Project-URL: Download URL, https://github.com/vladimirs-git/nbforager/archive/refs/tags/0.8.
|
26
|
+
Project-URL: Download URL, https://github.com/vladimirs-git/nbforager/archive/refs/tags/0.8.1.tar.gz
|
27
27
|
Project-URL: homepage, https://github.com/vladimirs-git/nbforager
|
28
28
|
Project-URL: repository, https://github.com/vladimirs-git/nbforager
|
29
29
|
Description-Content-Type: text/x-rst
|
@@ -5,6 +5,7 @@
|
|
5
5
|
from __future__ import annotations
|
6
6
|
|
7
7
|
import json
|
8
|
+
from typing import Generator
|
8
9
|
|
9
10
|
from requests import Response
|
10
11
|
from vhelpers import vdict
|
@@ -169,3 +170,6 @@ class Connector(BaseC):
|
|
169
170
|
html: str = response.content.decode("utf-8")
|
170
171
|
data: DAny = dict(json.loads(html))
|
171
172
|
return data
|
173
|
+
|
174
|
+
|
175
|
+
GConnector = Generator[Connector, None, None]
|
@@ -0,0 +1,283 @@
|
|
1
|
+
"""Constants for apps and models."""
|
2
|
+
|
3
|
+
from nbforager.types_ import DLStr
|
4
|
+
|
5
|
+
APPS = (
|
6
|
+
"circuits",
|
7
|
+
"core",
|
8
|
+
"dcim",
|
9
|
+
"extras",
|
10
|
+
"ipam",
|
11
|
+
"plugins",
|
12
|
+
"tenancy",
|
13
|
+
"users",
|
14
|
+
"virtualization",
|
15
|
+
"wireless",
|
16
|
+
)
|
17
|
+
"""Application names for NetBox v3.5."""
|
18
|
+
|
19
|
+
DEPENDENT_MODELS: DLStr = {
|
20
|
+
"circuits/circuit-terminations": [
|
21
|
+
"circuits/circuits",
|
22
|
+
"circuits/provider-networks",
|
23
|
+
"dcim/cable-terminations",
|
24
|
+
"dcim/sites",
|
25
|
+
"extras/tags",
|
26
|
+
],
|
27
|
+
"circuits/circuit-types": ["extras/tags"],
|
28
|
+
"circuits/circuits": [
|
29
|
+
"circuits/circuit-types",
|
30
|
+
"circuits/provider-accounts",
|
31
|
+
"circuits/providers",
|
32
|
+
"extras/tags",
|
33
|
+
"tenancy/tenants",
|
34
|
+
],
|
35
|
+
"circuits/provider-accounts": ["circuits/providers", "extras/tags"],
|
36
|
+
"circuits/provider-networks": ["circuits/providers", "extras/tags"],
|
37
|
+
"circuits/providers": ["extras/tags", "ipam/asns"],
|
38
|
+
"core/data-files": ["core/data-sources"],
|
39
|
+
"core/data-sources": ["extras/tags"],
|
40
|
+
"core/jobs": ["extras/content-types"],
|
41
|
+
"dcim/cable-terminations": [
|
42
|
+
"dcim/cables",
|
43
|
+
"dcim/devices",
|
44
|
+
"dcim/locations",
|
45
|
+
"dcim/racks",
|
46
|
+
"dcim/sites",
|
47
|
+
],
|
48
|
+
"dcim/cables": ["extras/tags", "tenancy/tenants"],
|
49
|
+
"dcim/console-port-templates": ["dcim/device-types", "dcim/module-types"],
|
50
|
+
"dcim/console-ports": [
|
51
|
+
"dcim/cable-terminations",
|
52
|
+
"dcim/devices",
|
53
|
+
"dcim/modules",
|
54
|
+
"extras/tags",
|
55
|
+
],
|
56
|
+
"dcim/console-server-port-templates": ["dcim/device-types", "dcim/module-types"],
|
57
|
+
"dcim/console-server-ports": [
|
58
|
+
"dcim/cable-terminations",
|
59
|
+
"dcim/devices",
|
60
|
+
"dcim/modules",
|
61
|
+
"extras/tags",
|
62
|
+
],
|
63
|
+
"dcim/device-bay-templates": ["dcim/device-types"],
|
64
|
+
"dcim/device-bays": ["dcim/devices", "extras/tags"],
|
65
|
+
"dcim/device-roles": ["extras/config-templates", "extras/tags"],
|
66
|
+
"dcim/device-types": ["dcim/manufacturers", "extras/tags"],
|
67
|
+
"dcim/devices": [
|
68
|
+
"dcim/device-roles",
|
69
|
+
"dcim/device-types",
|
70
|
+
"dcim/locations",
|
71
|
+
"dcim/platforms",
|
72
|
+
"dcim/racks",
|
73
|
+
"dcim/sites",
|
74
|
+
"dcim/virtual-chassis",
|
75
|
+
"extras/config-templates",
|
76
|
+
"extras/tags",
|
77
|
+
"tenancy/tenants",
|
78
|
+
"virtualization/clusters",
|
79
|
+
],
|
80
|
+
"dcim/front-port-templates": [
|
81
|
+
"dcim/device-types",
|
82
|
+
"dcim/module-types",
|
83
|
+
"dcim/rear-port-templates",
|
84
|
+
],
|
85
|
+
"dcim/front-ports": [
|
86
|
+
"dcim/cable-terminations",
|
87
|
+
"dcim/devices",
|
88
|
+
"dcim/modules",
|
89
|
+
"dcim/rear-ports",
|
90
|
+
"extras/tags",
|
91
|
+
],
|
92
|
+
"dcim/interface-templates": ["dcim/device-types", "dcim/module-types"],
|
93
|
+
"dcim/interfaces": [
|
94
|
+
"dcim/cable-terminations",
|
95
|
+
"dcim/devices",
|
96
|
+
"dcim/modules",
|
97
|
+
"dcim/virtual-device-contexts",
|
98
|
+
"extras/tags",
|
99
|
+
"ipam/ip-addresses",
|
100
|
+
"ipam/l2vpn-terminations",
|
101
|
+
"ipam/vlans",
|
102
|
+
"ipam/vrfs",
|
103
|
+
"virtualization/interfaces",
|
104
|
+
"wireless/wireless-lans",
|
105
|
+
],
|
106
|
+
"dcim/inventory-item-roles": ["extras/tags"],
|
107
|
+
"dcim/inventory-item-templates": [
|
108
|
+
"dcim/device-types",
|
109
|
+
"dcim/inventory-item-roles",
|
110
|
+
"dcim/manufacturers",
|
111
|
+
],
|
112
|
+
"dcim/inventory-items": [
|
113
|
+
"dcim/devices",
|
114
|
+
"dcim/inventory-item-roles",
|
115
|
+
"dcim/manufacturers",
|
116
|
+
"extras/tags",
|
117
|
+
],
|
118
|
+
"dcim/locations": ["dcim/sites", "extras/tags", "ipam/vlan-groups", "tenancy/tenants"],
|
119
|
+
"dcim/manufacturers": ["extras/tags"],
|
120
|
+
"dcim/module-bay-templates": ["dcim/device-types"],
|
121
|
+
"dcim/module-bays": ["dcim/devices", "extras/tags"],
|
122
|
+
"dcim/module-types": ["dcim/manufacturers", "extras/tags"],
|
123
|
+
"dcim/modules": ["dcim/devices", "dcim/module-bays", "dcim/module-types", "extras/tags"],
|
124
|
+
"dcim/platforms": ["dcim/manufacturers", "extras/config-templates", "extras/tags"],
|
125
|
+
"dcim/power-feeds": [
|
126
|
+
"dcim/cable-terminations",
|
127
|
+
"dcim/power-panels",
|
128
|
+
"dcim/racks",
|
129
|
+
"extras/tags",
|
130
|
+
],
|
131
|
+
"dcim/power-outlet-templates": [
|
132
|
+
"dcim/device-types",
|
133
|
+
"dcim/module-types",
|
134
|
+
"dcim/power-port-templates",
|
135
|
+
],
|
136
|
+
"dcim/power-outlets": [
|
137
|
+
"dcim/cable-terminations",
|
138
|
+
"dcim/devices",
|
139
|
+
"dcim/modules",
|
140
|
+
"dcim/power-ports",
|
141
|
+
"extras/tags",
|
142
|
+
],
|
143
|
+
"dcim/power-panels": ["dcim/locations", "dcim/sites", "extras/tags"],
|
144
|
+
"dcim/power-port-templates": ["dcim/device-types", "dcim/module-types"],
|
145
|
+
"dcim/power-ports": ["dcim/cable-terminations", "dcim/devices", "dcim/modules", "extras/tags"],
|
146
|
+
"dcim/rack-reservations": ["dcim/racks", "extras/tags", "tenancy/tenants", "users/users"],
|
147
|
+
"dcim/rack-roles": ["extras/tags"],
|
148
|
+
"dcim/racks": [
|
149
|
+
"dcim/locations",
|
150
|
+
"dcim/rack-roles",
|
151
|
+
"dcim/sites",
|
152
|
+
"extras/tags",
|
153
|
+
"ipam/vlan-groups",
|
154
|
+
"tenancy/tenants",
|
155
|
+
],
|
156
|
+
"dcim/rear-port-templates": ["dcim/device-types", "dcim/module-types"],
|
157
|
+
"dcim/rear-ports": ["dcim/cable-terminations", "dcim/devices", "dcim/modules", "extras/tags"],
|
158
|
+
"dcim/regions": ["extras/tags", "ipam/vlan-groups"],
|
159
|
+
"dcim/site-groups": ["extras/tags", "ipam/vlan-groups"],
|
160
|
+
"dcim/sites": [
|
161
|
+
"dcim/regions",
|
162
|
+
"dcim/site-groups",
|
163
|
+
"extras/tags",
|
164
|
+
"ipam/asns",
|
165
|
+
"ipam/vlan-groups",
|
166
|
+
"tenancy/tenants",
|
167
|
+
],
|
168
|
+
"dcim/virtual-chassis": ["dcim/devices", "extras/tags"],
|
169
|
+
"dcim/virtual-device-contexts": ["dcim/devices", "extras/tags", "tenancy/tenants"],
|
170
|
+
"extras/config-contexts": [
|
171
|
+
"dcim/device-roles",
|
172
|
+
"dcim/device-types",
|
173
|
+
"dcim/locations",
|
174
|
+
"dcim/platforms",
|
175
|
+
"dcim/regions",
|
176
|
+
"dcim/site-groups",
|
177
|
+
"dcim/sites",
|
178
|
+
"extras/tags",
|
179
|
+
"tenancy/tenant-groups",
|
180
|
+
"tenancy/tenants",
|
181
|
+
"virtualization/cluster-groups",
|
182
|
+
"virtualization/cluster-types",
|
183
|
+
"virtualization/clusters",
|
184
|
+
],
|
185
|
+
"extras/config-templates": ["extras/tags"],
|
186
|
+
"extras/content-types": [],
|
187
|
+
"extras/custom-fields": ["extras/content-types"],
|
188
|
+
"extras/custom-links": ["extras/content-types"],
|
189
|
+
"extras/export-templates": ["extras/content-types"],
|
190
|
+
"extras/image-attachments": ["extras/content-types"],
|
191
|
+
"extras/journal-entries": ["extras/content-types", "extras/tags", "users/users"],
|
192
|
+
"extras/object-changes": ["users/users"],
|
193
|
+
"extras/saved-filters": ["extras/content-types", "users/users"],
|
194
|
+
"extras/tags": [],
|
195
|
+
"extras/webhooks": ["extras/content-types"],
|
196
|
+
"ipam/aggregates": ["extras/tags", "ipam/rirs", "tenancy/tenants"],
|
197
|
+
"ipam/asn-ranges": ["extras/tags", "ipam/rirs", "tenancy/tenants"],
|
198
|
+
"ipam/asns": ["extras/tags", "ipam/rirs", "tenancy/tenants"],
|
199
|
+
"ipam/fhrp-group-assignments": ["extras/content-types", "ipam/fhrp-groups"],
|
200
|
+
"ipam/fhrp-groups": ["extras/tags", "ipam/ip-addresses"],
|
201
|
+
"ipam/ip-addresses": ["extras/tags", "ipam/vrfs", "tenancy/tenants"],
|
202
|
+
"ipam/ip-ranges": ["extras/tags", "ipam/roles", "ipam/vrfs", "tenancy/tenants"],
|
203
|
+
"ipam/l2vpn-terminations": ["extras/tags", "ipam/l2vpns"],
|
204
|
+
"ipam/l2vpns": ["extras/tags", "ipam/route-targets", "tenancy/tenants"],
|
205
|
+
"ipam/prefixes": [
|
206
|
+
"dcim/sites",
|
207
|
+
"extras/tags",
|
208
|
+
"ipam/roles",
|
209
|
+
"ipam/vlans",
|
210
|
+
"ipam/vrfs",
|
211
|
+
"tenancy/tenants",
|
212
|
+
],
|
213
|
+
"ipam/rirs": ["extras/tags"],
|
214
|
+
"ipam/roles": ["extras/tags"],
|
215
|
+
"ipam/route-targets": ["extras/tags", "tenancy/tenants"],
|
216
|
+
"ipam/service-templates": ["extras/tags"],
|
217
|
+
"ipam/services": [
|
218
|
+
"dcim/devices",
|
219
|
+
"extras/tags",
|
220
|
+
"ipam/ip-addresses",
|
221
|
+
"virtualization/virtual-machines",
|
222
|
+
],
|
223
|
+
"ipam/vlan-groups": ["extras/content-types", "extras/tags"],
|
224
|
+
"ipam/vlans": [
|
225
|
+
"dcim/sites",
|
226
|
+
"extras/tags",
|
227
|
+
"ipam/l2vpn-terminations",
|
228
|
+
"ipam/roles",
|
229
|
+
"ipam/vlan-groups",
|
230
|
+
"tenancy/tenants",
|
231
|
+
],
|
232
|
+
"ipam/vrfs": ["extras/tags", "ipam/route-targets", "tenancy/tenants"],
|
233
|
+
"tenancy/contact-assignments": [
|
234
|
+
"extras/content-types",
|
235
|
+
"tenancy/contact-roles",
|
236
|
+
"tenancy/contacts",
|
237
|
+
],
|
238
|
+
"tenancy/contact-groups": ["extras/tags"],
|
239
|
+
"tenancy/contact-roles": ["extras/tags"],
|
240
|
+
"tenancy/contacts": ["extras/tags", "tenancy/contact-groups"],
|
241
|
+
"tenancy/tenant-groups": ["extras/tags"],
|
242
|
+
"tenancy/tenants": ["extras/tags", "tenancy/tenant-groups"],
|
243
|
+
"users/groups": [],
|
244
|
+
"users/permissions": ["extras/content-types", "users/groups", "users/users"],
|
245
|
+
"users/tokens": ["users/users"],
|
246
|
+
"users/users": [],
|
247
|
+
"virtualization/cluster-groups": ["extras/tags", "ipam/vlan-groups"],
|
248
|
+
"virtualization/cluster-types": ["extras/tags"],
|
249
|
+
"virtualization/clusters": [
|
250
|
+
"dcim/sites",
|
251
|
+
"extras/tags",
|
252
|
+
"ipam/vlan-groups",
|
253
|
+
"tenancy/tenants",
|
254
|
+
"virtualization/cluster-groups",
|
255
|
+
"virtualization/cluster-types",
|
256
|
+
],
|
257
|
+
"virtualization/interfaces": [
|
258
|
+
"extras/tags",
|
259
|
+
"ipam/ip-addresses",
|
260
|
+
"ipam/l2vpn-terminations",
|
261
|
+
"ipam/vlans",
|
262
|
+
"ipam/vrfs",
|
263
|
+
"virtualization/virtual-machines",
|
264
|
+
],
|
265
|
+
"virtualization/virtual-machines": [
|
266
|
+
"dcim/device-roles",
|
267
|
+
"dcim/devices",
|
268
|
+
"dcim/platforms",
|
269
|
+
"dcim/sites",
|
270
|
+
"extras/tags",
|
271
|
+
"tenancy/tenants",
|
272
|
+
"virtualization/clusters",
|
273
|
+
],
|
274
|
+
"wireless/wireless-lan-groups": ["extras/tags"],
|
275
|
+
"wireless/wireless-lans": [
|
276
|
+
"extras/tags",
|
277
|
+
"ipam/vlans",
|
278
|
+
"tenancy/tenants",
|
279
|
+
"wireless/wireless-lan-groups",
|
280
|
+
],
|
281
|
+
"wireless/wireless-links": ["extras/tags", "tenancy/tenants"],
|
282
|
+
}
|
283
|
+
"""Models dependency for Netbox v3.5."""
|
@@ -9,286 +9,13 @@ from urllib.parse import ParseResult, urlencode, urlparse, parse_qs
|
|
9
9
|
from vhelpers import vlist, vparam, vint
|
10
10
|
|
11
11
|
from nbforager.exceptions import NbApiError
|
12
|
+
from nbforager.constants import DEPENDENT_MODELS
|
12
13
|
from nbforager.types_ import LStr, LDAny, DDDLInt, LValue, LParam, LDList, DList, DLStr, ODLStr
|
13
14
|
from nbforager.types_ import LTInt2, DAny, SeqStr, SStr, TValues, TLists, T2Str, T3Str, T3StrInt
|
14
15
|
|
15
|
-
# Netbox v3.5
|
16
|
-
DEPENDENT_MODELS: DLStr = {
|
17
|
-
"circuits/circuit-terminations": [
|
18
|
-
"circuits/circuits",
|
19
|
-
"circuits/provider-networks",
|
20
|
-
"dcim/cable-terminations",
|
21
|
-
"dcim/sites",
|
22
|
-
"extras/tags",
|
23
|
-
],
|
24
|
-
"circuits/circuit-types": ["extras/tags"],
|
25
|
-
"circuits/circuits": [
|
26
|
-
"circuits/circuit-types",
|
27
|
-
"circuits/provider-accounts",
|
28
|
-
"circuits/providers",
|
29
|
-
"extras/tags",
|
30
|
-
"tenancy/tenants",
|
31
|
-
],
|
32
|
-
"circuits/provider-accounts": ["circuits/providers", "extras/tags"],
|
33
|
-
"circuits/provider-networks": ["circuits/providers", "extras/tags"],
|
34
|
-
"circuits/providers": ["extras/tags", "ipam/asns"],
|
35
|
-
"core/data-files": ["core/data-sources"],
|
36
|
-
"core/data-sources": ["extras/tags"],
|
37
|
-
"core/jobs": ["extras/content-types"],
|
38
|
-
"dcim/cable-terminations": [
|
39
|
-
"dcim/cables",
|
40
|
-
"dcim/devices",
|
41
|
-
"dcim/locations",
|
42
|
-
"dcim/racks",
|
43
|
-
"dcim/sites",
|
44
|
-
],
|
45
|
-
"dcim/cables": ["extras/tags", "tenancy/tenants"],
|
46
|
-
"dcim/console-port-templates": ["dcim/device-types", "dcim/module-types"],
|
47
|
-
"dcim/console-ports": [
|
48
|
-
"dcim/cable-terminations",
|
49
|
-
"dcim/devices",
|
50
|
-
"dcim/modules",
|
51
|
-
"extras/tags",
|
52
|
-
],
|
53
|
-
"dcim/console-server-port-templates": ["dcim/device-types", "dcim/module-types"],
|
54
|
-
"dcim/console-server-ports": [
|
55
|
-
"dcim/cable-terminations",
|
56
|
-
"dcim/devices",
|
57
|
-
"dcim/modules",
|
58
|
-
"extras/tags",
|
59
|
-
],
|
60
|
-
"dcim/device-bay-templates": ["dcim/device-types"],
|
61
|
-
"dcim/device-bays": ["dcim/devices", "extras/tags"],
|
62
|
-
"dcim/device-roles": ["extras/config-templates", "extras/tags"],
|
63
|
-
"dcim/device-types": ["dcim/manufacturers", "extras/tags"],
|
64
|
-
"dcim/devices": [
|
65
|
-
"dcim/device-roles",
|
66
|
-
"dcim/device-types",
|
67
|
-
"dcim/locations",
|
68
|
-
"dcim/platforms",
|
69
|
-
"dcim/racks",
|
70
|
-
"dcim/sites",
|
71
|
-
"dcim/virtual-chassis",
|
72
|
-
"extras/config-templates",
|
73
|
-
"extras/tags",
|
74
|
-
"tenancy/tenants",
|
75
|
-
"virtualization/clusters",
|
76
|
-
],
|
77
|
-
"dcim/front-port-templates": [
|
78
|
-
"dcim/device-types",
|
79
|
-
"dcim/module-types",
|
80
|
-
"dcim/rear-port-templates",
|
81
|
-
],
|
82
|
-
"dcim/front-ports": [
|
83
|
-
"dcim/cable-terminations",
|
84
|
-
"dcim/devices",
|
85
|
-
"dcim/modules",
|
86
|
-
"dcim/rear-ports",
|
87
|
-
"extras/tags",
|
88
|
-
],
|
89
|
-
"dcim/interface-templates": ["dcim/device-types", "dcim/module-types"],
|
90
|
-
"dcim/interfaces": [
|
91
|
-
"dcim/cable-terminations",
|
92
|
-
"dcim/devices",
|
93
|
-
"dcim/modules",
|
94
|
-
"dcim/virtual-device-contexts",
|
95
|
-
"extras/tags",
|
96
|
-
"ipam/ip-addresses",
|
97
|
-
"ipam/l2vpn-terminations",
|
98
|
-
"ipam/vlans",
|
99
|
-
"ipam/vrfs",
|
100
|
-
"virtualization/interfaces",
|
101
|
-
"wireless/wireless-lans",
|
102
|
-
],
|
103
|
-
"dcim/inventory-item-roles": ["extras/tags"],
|
104
|
-
"dcim/inventory-item-templates": [
|
105
|
-
"dcim/device-types",
|
106
|
-
"dcim/inventory-item-roles",
|
107
|
-
"dcim/manufacturers",
|
108
|
-
],
|
109
|
-
"dcim/inventory-items": [
|
110
|
-
"dcim/devices",
|
111
|
-
"dcim/inventory-item-roles",
|
112
|
-
"dcim/manufacturers",
|
113
|
-
"extras/tags",
|
114
|
-
],
|
115
|
-
"dcim/locations": ["dcim/sites", "extras/tags", "ipam/vlan-groups", "tenancy/tenants"],
|
116
|
-
"dcim/manufacturers": ["extras/tags"],
|
117
|
-
"dcim/module-bay-templates": ["dcim/device-types"],
|
118
|
-
"dcim/module-bays": ["dcim/devices", "extras/tags"],
|
119
|
-
"dcim/module-types": ["dcim/manufacturers", "extras/tags"],
|
120
|
-
"dcim/modules": ["dcim/devices", "dcim/module-bays", "dcim/module-types", "extras/tags"],
|
121
|
-
"dcim/platforms": ["dcim/manufacturers", "extras/config-templates", "extras/tags"],
|
122
|
-
"dcim/power-feeds": [
|
123
|
-
"dcim/cable-terminations",
|
124
|
-
"dcim/power-panels",
|
125
|
-
"dcim/racks",
|
126
|
-
"extras/tags",
|
127
|
-
],
|
128
|
-
"dcim/power-outlet-templates": [
|
129
|
-
"dcim/device-types",
|
130
|
-
"dcim/module-types",
|
131
|
-
"dcim/power-port-templates",
|
132
|
-
],
|
133
|
-
"dcim/power-outlets": [
|
134
|
-
"dcim/cable-terminations",
|
135
|
-
"dcim/devices",
|
136
|
-
"dcim/modules",
|
137
|
-
"dcim/power-ports",
|
138
|
-
"extras/tags",
|
139
|
-
],
|
140
|
-
"dcim/power-panels": ["dcim/locations", "dcim/sites", "extras/tags"],
|
141
|
-
"dcim/power-port-templates": ["dcim/device-types", "dcim/module-types"],
|
142
|
-
"dcim/power-ports": ["dcim/cable-terminations", "dcim/devices", "dcim/modules", "extras/tags"],
|
143
|
-
"dcim/rack-reservations": ["dcim/racks", "extras/tags", "tenancy/tenants", "users/users"],
|
144
|
-
"dcim/rack-roles": ["extras/tags"],
|
145
|
-
"dcim/racks": [
|
146
|
-
"dcim/locations",
|
147
|
-
"dcim/rack-roles",
|
148
|
-
"dcim/sites",
|
149
|
-
"extras/tags",
|
150
|
-
"ipam/vlan-groups",
|
151
|
-
"tenancy/tenants",
|
152
|
-
],
|
153
|
-
"dcim/rear-port-templates": ["dcim/device-types", "dcim/module-types"],
|
154
|
-
"dcim/rear-ports": ["dcim/cable-terminations", "dcim/devices", "dcim/modules", "extras/tags"],
|
155
|
-
"dcim/regions": ["extras/tags", "ipam/vlan-groups"],
|
156
|
-
"dcim/site-groups": ["extras/tags", "ipam/vlan-groups"],
|
157
|
-
"dcim/sites": [
|
158
|
-
"dcim/regions",
|
159
|
-
"dcim/site-groups",
|
160
|
-
"extras/tags",
|
161
|
-
"ipam/asns",
|
162
|
-
"ipam/vlan-groups",
|
163
|
-
"tenancy/tenants",
|
164
|
-
],
|
165
|
-
"dcim/virtual-chassis": ["dcim/devices", "extras/tags"],
|
166
|
-
"dcim/virtual-device-contexts": ["dcim/devices", "extras/tags", "tenancy/tenants"],
|
167
|
-
"extras/branchs": ["users/users"],
|
168
|
-
"extras/config-contexts": [
|
169
|
-
"dcim/device-roles",
|
170
|
-
"dcim/device-types",
|
171
|
-
"dcim/locations",
|
172
|
-
"dcim/platforms",
|
173
|
-
"dcim/regions",
|
174
|
-
"dcim/site-groups",
|
175
|
-
"dcim/sites",
|
176
|
-
"extras/tags",
|
177
|
-
"tenancy/tenant-groups",
|
178
|
-
"tenancy/tenants",
|
179
|
-
"virtualization/cluster-groups",
|
180
|
-
"virtualization/cluster-types",
|
181
|
-
"virtualization/clusters",
|
182
|
-
],
|
183
|
-
"extras/config-templates": ["extras/tags"],
|
184
|
-
"extras/content-types": [],
|
185
|
-
"extras/custom-fields": ["extras/content-types"],
|
186
|
-
"extras/custom-links": ["extras/content-types"],
|
187
|
-
"extras/dashboards": ["users/users"],
|
188
|
-
"extras/export-templates": ["extras/content-types"],
|
189
|
-
"extras/image-attachments": ["extras/content-types"],
|
190
|
-
"extras/journal-entries": ["extras/content-types", "extras/tags", "users/users"],
|
191
|
-
"extras/object-changes": ["users/users"],
|
192
|
-
"extras/saved-filters": ["extras/content-types", "users/users"],
|
193
|
-
"extras/tagged-items": ["extras/content-types", "extras/tags"],
|
194
|
-
"extras/tags": [],
|
195
|
-
"extras/webhooks": ["extras/content-types"],
|
196
|
-
"ipam/aggregates": ["extras/tags", "ipam/rirs", "tenancy/tenants"],
|
197
|
-
"ipam/asn-ranges": ["extras/tags", "ipam/rirs", "tenancy/tenants"],
|
198
|
-
"ipam/asns": ["extras/tags", "ipam/rirs", "tenancy/tenants"],
|
199
|
-
"ipam/fhrp-group-assignments": ["extras/content-types", "ipam/fhrp-groups"],
|
200
|
-
"ipam/fhrp-groups": ["extras/tags", "ipam/ip-addresses"],
|
201
|
-
"ipam/ip-addresses": ["extras/tags", "ipam/vrfs", "tenancy/tenants"],
|
202
|
-
"ipam/ip-ranges": ["extras/tags", "ipam/roles", "ipam/vrfs", "tenancy/tenants"],
|
203
|
-
"ipam/l2vpn-terminations": ["extras/tags", "ipam/l2vpns"],
|
204
|
-
"ipam/l2vpns": ["extras/tags", "ipam/route-targets", "tenancy/tenants"],
|
205
|
-
"ipam/prefixes": [
|
206
|
-
"dcim/sites",
|
207
|
-
"extras/tags",
|
208
|
-
"ipam/roles",
|
209
|
-
"ipam/vlans",
|
210
|
-
"ipam/vrfs",
|
211
|
-
"tenancy/tenants",
|
212
|
-
],
|
213
|
-
"ipam/rirs": ["extras/tags"],
|
214
|
-
"ipam/roles": ["extras/tags"],
|
215
|
-
"ipam/route-targets": ["extras/tags", "tenancy/tenants"],
|
216
|
-
"ipam/service-templates": ["extras/tags"],
|
217
|
-
"ipam/services": [
|
218
|
-
"dcim/devices",
|
219
|
-
"extras/tags",
|
220
|
-
"ipam/ip-addresses",
|
221
|
-
"virtualization/virtual-machines",
|
222
|
-
],
|
223
|
-
"ipam/vlan-groups": ["extras/content-types", "extras/tags"],
|
224
|
-
"ipam/vlans": [
|
225
|
-
"dcim/sites",
|
226
|
-
"extras/tags",
|
227
|
-
"ipam/l2vpn-terminations",
|
228
|
-
"ipam/roles",
|
229
|
-
"ipam/vlan-groups",
|
230
|
-
"tenancy/tenants",
|
231
|
-
],
|
232
|
-
"ipam/vrfs": ["extras/tags", "ipam/route-targets", "tenancy/tenants"],
|
233
|
-
"nb_config_checker/tasks": ["extras/tags", "users/users"],
|
234
|
-
"social_django/user-social-auths": ["users/users"],
|
235
|
-
"taggit/tagged-items": ["extras/content-types"],
|
236
|
-
"tenancy/contact-assignments": [
|
237
|
-
"extras/content-types",
|
238
|
-
"tenancy/contact-roles",
|
239
|
-
"tenancy/contacts",
|
240
|
-
],
|
241
|
-
"tenancy/contact-groups": ["extras/tags"],
|
242
|
-
"tenancy/contact-roles": ["extras/tags"],
|
243
|
-
"tenancy/contacts": ["extras/tags", "tenancy/contact-groups"],
|
244
|
-
"tenancy/tenant-groups": ["extras/tags"],
|
245
|
-
"tenancy/tenants": ["extras/tags", "tenancy/tenant-groups"],
|
246
|
-
"users/groups": [],
|
247
|
-
"users/permissions": ["extras/content-types", "users/groups", "users/users"],
|
248
|
-
"users/tokens": ["users/users"],
|
249
|
-
"users/user-preferences": ["users/users"],
|
250
|
-
"users/users": [],
|
251
|
-
"virtualization/cluster-groups": ["extras/tags", "ipam/vlan-groups"],
|
252
|
-
"virtualization/cluster-types": ["extras/tags"],
|
253
|
-
"virtualization/clusters": [
|
254
|
-
"dcim/sites",
|
255
|
-
"extras/tags",
|
256
|
-
"ipam/vlan-groups",
|
257
|
-
"tenancy/tenants",
|
258
|
-
"virtualization/cluster-groups",
|
259
|
-
"virtualization/cluster-types",
|
260
|
-
],
|
261
|
-
"virtualization/interfaces": [
|
262
|
-
"extras/tags",
|
263
|
-
"ipam/ip-addresses",
|
264
|
-
"ipam/l2vpn-terminations",
|
265
|
-
"ipam/vlans",
|
266
|
-
"ipam/vrfs",
|
267
|
-
"virtualization/virtual-machines",
|
268
|
-
],
|
269
|
-
"virtualization/virtual-machines": [
|
270
|
-
"dcim/device-roles",
|
271
|
-
"dcim/devices",
|
272
|
-
"dcim/platforms",
|
273
|
-
"dcim/sites",
|
274
|
-
"extras/tags",
|
275
|
-
"tenancy/tenants",
|
276
|
-
"virtualization/clusters",
|
277
|
-
],
|
278
|
-
"wireless/wireless-lan-groups": ["extras/tags"],
|
279
|
-
"wireless/wireless-lans": [
|
280
|
-
"extras/tags",
|
281
|
-
"ipam/vlans",
|
282
|
-
"tenancy/tenants",
|
283
|
-
"wireless/wireless-lan-groups",
|
284
|
-
],
|
285
|
-
"wireless/wireless-links": ["extras/tags", "tenancy/tenants"],
|
286
|
-
}
|
287
|
-
"""Models dependency for Netbox v3.5"""
|
288
|
-
|
289
16
|
|
290
17
|
def dependency_ordered_paths(dependency: ODLStr = None) -> LStr:
|
291
|
-
"""Order paths based on dependencies. Models with the lowes count dependencies will be first.
|
18
|
+
"""Order paths based on dependencies. Models with the lowes count of dependencies will be first.
|
292
19
|
|
293
20
|
:param dependency: Dictionary representing dependencies,
|
294
21
|
where key is the parent model and value is a list of child models.
|
@@ -10,6 +10,7 @@ from requests import Response
|
|
10
10
|
|
11
11
|
from nbforager import helpers as h
|
12
12
|
from nbforager.api.circuits import CircuitsAC
|
13
|
+
from nbforager.api.connector import Connector, GConnector
|
13
14
|
from nbforager.api.core import CoreAC
|
14
15
|
from nbforager.api.dcim import DcimAC
|
15
16
|
from nbforager.api.extras import ExtrasAC
|
@@ -20,22 +21,10 @@ from nbforager.api.tenancy import TenancyAC
|
|
20
21
|
from nbforager.api.users import UsersAC
|
21
22
|
from nbforager.api.virtualization import VirtualizationAC
|
22
23
|
from nbforager.api.wireless import WirelessAC
|
24
|
+
from nbforager.constants import APPS
|
23
25
|
from nbforager.parser.nb_parser import NbParser
|
24
26
|
from nbforager.types_ import ODLStr, ODDAny, DAny, LDAny, LStr, LT2Str
|
25
27
|
|
26
|
-
APPS = (
|
27
|
-
"circuits",
|
28
|
-
"core",
|
29
|
-
"dcim",
|
30
|
-
"extras",
|
31
|
-
"ipam",
|
32
|
-
"plugins",
|
33
|
-
"tenancy",
|
34
|
-
"users",
|
35
|
-
"virtualization",
|
36
|
-
"wireless",
|
37
|
-
)
|
38
|
-
|
39
28
|
|
40
29
|
class NbApi:
|
41
30
|
"""NbApi, Python wrapper of Netbox REST API.
|
@@ -282,8 +271,17 @@ class NbApi:
|
|
282
271
|
app_paths.append(path)
|
283
272
|
return app_paths
|
284
273
|
|
285
|
-
def connectors(self) ->
|
286
|
-
"""Return
|
274
|
+
def connectors(self) -> GConnector:
|
275
|
+
"""Return generator of Connector instances ordered based on dependencies.
|
276
|
+
Connectors to models with the lowes count of dependencies will be first.
|
277
|
+
|
278
|
+
:return: Generator of Connector instances.
|
279
|
+
"""
|
280
|
+
paths: LStr = h.dependency_ordered_paths()
|
281
|
+
for path in paths:
|
282
|
+
app, model = h.path_to_attrs(path)
|
283
|
+
connector: Connector = getattr(getattr(self, app), model)
|
284
|
+
yield connector
|
287
285
|
|
288
286
|
def copy(self, **kwargs) -> NbApi:
|
289
287
|
"""Create a duplicate of the object.
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
from datetime import datetime
|
4
4
|
from pathlib import Path
|
5
|
-
from typing import Any, Dict, List, Optional,
|
5
|
+
from typing import Any, Dict, List, Optional, Sequence, Set, TypeVar, Tuple, Union
|
6
6
|
|
7
7
|
# 1 level
|
8
8
|
DAny = Dict[str, Any]
|
@@ -10,6 +10,7 @@ DInt = Dict[str, int]
|
|
10
10
|
DObj = Dict[str, object]
|
11
11
|
DStr = Dict[str, str]
|
12
12
|
Int = int
|
13
|
+
IntStr = Union[int, str]
|
13
14
|
LBool = List[bool]
|
14
15
|
LInt = List[int]
|
15
16
|
LPath = List[Path]
|
@@ -22,11 +23,10 @@ SInt = Set[int]
|
|
22
23
|
SStr = Set[str]
|
23
24
|
SeqStr = Sequence[str]
|
24
25
|
Str = str
|
25
|
-
IntStr = Union[int, str]
|
26
26
|
T = TypeVar("T")
|
27
27
|
T2Str = Tuple[str, str]
|
28
|
-
T3StrInt = Tuple[str, str, int]
|
29
28
|
T3Str = Tuple[str, str, str]
|
29
|
+
T3StrInt = Tuple[str, str, int]
|
30
30
|
TLists = (list, set, tuple)
|
31
31
|
TStr = Tuple[str, ...]
|
32
32
|
TValues = (str, int, float)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
[tool.poetry]
|
2
2
|
name = "nbforager"
|
3
|
-
version = "0.8.
|
3
|
+
version = "0.8.1"
|
4
4
|
description = "Python package designed to assist in working with the Netbox REST API. The filter parameters are identical to those in the Web UI filter form. It replaces brief data with full information, and Netbox objects are represented as a recursive multidimensional dictionary."
|
5
5
|
authors = ["Vladimirs Prusakovs <vladimir.prusakovs@gmail.com>"]
|
6
6
|
readme = "README.rst"
|
@@ -19,7 +19,7 @@ classifiers = [
|
|
19
19
|
homepage = "https://github.com/vladimirs-git/nbforager"
|
20
20
|
repository = "https://github.com/vladimirs-git/nbforager"
|
21
21
|
"Bug Tracker" = "https://github.com/vladimirs-git/nbforager/issues"
|
22
|
-
"Download URL" = "https://github.com/vladimirs-git/nbforager/archive/refs/tags/0.8.
|
22
|
+
"Download URL" = "https://github.com/vladimirs-git/nbforager/archive/refs/tags/0.8.1.tar.gz"
|
23
23
|
|
24
24
|
[tool.poetry.dependencies]
|
25
25
|
python = "^3.11"
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|