nbforager 0.7.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.7.0 → nbforager-0.8.1}/PKG-INFO +2 -2
- {nbforager-0.7.0 → nbforager-0.8.1}/nbforager/api/connector.py +4 -0
- nbforager-0.8.1/nbforager/constants.py +283 -0
- {nbforager-0.7.0 → nbforager-0.8.1}/nbforager/helpers.py +38 -1
- {nbforager-0.7.0 → nbforager-0.8.1}/nbforager/nb_api.py +14 -13
- {nbforager-0.7.0 → nbforager-0.8.1}/nbforager/parser/nb_parser.py +1 -1
- {nbforager-0.7.0 → nbforager-0.8.1}/nbforager/types_.py +3 -4
- {nbforager-0.7.0 → nbforager-0.8.1}/pyproject.toml +3 -2
- {nbforager-0.7.0 → nbforager-0.8.1}/LICENSE.txt +0 -0
- {nbforager-0.7.0 → nbforager-0.8.1}/README.rst +0 -0
- {nbforager-0.7.0 → nbforager-0.8.1}/nbforager/__init__.py +0 -0
- {nbforager-0.7.0 → nbforager-0.8.1}/nbforager/api/__init__.py +0 -0
- {nbforager-0.7.0 → nbforager-0.8.1}/nbforager/api/base_ac.py +0 -0
- {nbforager-0.7.0 → nbforager-0.8.1}/nbforager/api/base_c.py +0 -0
- {nbforager-0.7.0 → nbforager-0.8.1}/nbforager/api/circuits.py +0 -0
- {nbforager-0.7.0 → nbforager-0.8.1}/nbforager/api/core.py +0 -0
- {nbforager-0.7.0 → nbforager-0.8.1}/nbforager/api/dcim.py +0 -0
- {nbforager-0.7.0 → nbforager-0.8.1}/nbforager/api/extended_get.py +0 -0
- {nbforager-0.7.0 → nbforager-0.8.1}/nbforager/api/extras.py +0 -0
- {nbforager-0.7.0 → nbforager-0.8.1}/nbforager/api/ip_addresses.py +0 -0
- {nbforager-0.7.0 → nbforager-0.8.1}/nbforager/api/ipam.py +0 -0
- {nbforager-0.7.0 → nbforager-0.8.1}/nbforager/api/plugins_ca.py +0 -0
- {nbforager-0.7.0 → nbforager-0.8.1}/nbforager/api/status.py +0 -0
- {nbforager-0.7.0 → nbforager-0.8.1}/nbforager/api/tenancy.py +0 -0
- {nbforager-0.7.0 → nbforager-0.8.1}/nbforager/api/users.py +0 -0
- {nbforager-0.7.0 → nbforager-0.8.1}/nbforager/api/virtualization.py +0 -0
- {nbforager-0.7.0 → nbforager-0.8.1}/nbforager/api/wireless.py +0 -0
- {nbforager-0.7.0 → nbforager-0.8.1}/nbforager/exceptions.py +0 -0
- {nbforager-0.7.0 → nbforager-0.8.1}/nbforager/foragers/__init__.py +0 -0
- {nbforager-0.7.0 → nbforager-0.8.1}/nbforager/foragers/base_fa.py +0 -0
- {nbforager-0.7.0 → nbforager-0.8.1}/nbforager/foragers/circuits.py +0 -0
- {nbforager-0.7.0 → nbforager-0.8.1}/nbforager/foragers/core.py +0 -0
- {nbforager-0.7.0 → nbforager-0.8.1}/nbforager/foragers/dcim.py +0 -0
- {nbforager-0.7.0 → nbforager-0.8.1}/nbforager/foragers/extras.py +0 -0
- {nbforager-0.7.0 → nbforager-0.8.1}/nbforager/foragers/forager.py +0 -0
- {nbforager-0.7.0 → nbforager-0.8.1}/nbforager/foragers/ipam.py +0 -0
- {nbforager-0.7.0 → nbforager-0.8.1}/nbforager/foragers/ipv4.py +0 -0
- {nbforager-0.7.0 → nbforager-0.8.1}/nbforager/foragers/joiner.py +0 -0
- {nbforager-0.7.0 → nbforager-0.8.1}/nbforager/foragers/tenancy.py +0 -0
- {nbforager-0.7.0 → nbforager-0.8.1}/nbforager/foragers/users.py +0 -0
- {nbforager-0.7.0 → nbforager-0.8.1}/nbforager/foragers/virtualization.py +0 -0
- {nbforager-0.7.0 → nbforager-0.8.1}/nbforager/foragers/wireless.py +0 -0
- {nbforager-0.7.0 → nbforager-0.8.1}/nbforager/log.py +0 -0
- {nbforager-0.7.0 → nbforager-0.8.1}/nbforager/messages.py +0 -0
- {nbforager-0.7.0 → nbforager-0.8.1}/nbforager/nb_cache.py +0 -0
- {nbforager-0.7.0 → nbforager-0.8.1}/nbforager/nb_forager.py +0 -0
- {nbforager-0.7.0 → nbforager-0.8.1}/nbforager/nb_tree.py +0 -0
- {nbforager-0.7.0 → nbforager-0.8.1}/nbforager/parser/__init__.py +0 -0
- {nbforager-0.7.0 → nbforager-0.8.1}/nbforager/parser/nb_custom.py +0 -0
- {nbforager-0.7.0 → nbforager-0.8.1}/nbforager/parser/nb_value.py +0 -0
- {nbforager-0.7.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.
|
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.
|
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."""
|
@@ -2,16 +2,53 @@
|
|
2
2
|
|
3
3
|
import itertools
|
4
4
|
import urllib
|
5
|
+
from copy import deepcopy
|
5
6
|
from typing import Any
|
6
7
|
from urllib.parse import ParseResult, urlencode, urlparse, parse_qs
|
7
8
|
|
8
9
|
from vhelpers import vlist, vparam, vint
|
9
10
|
|
10
11
|
from nbforager.exceptions import NbApiError
|
11
|
-
from nbforager.
|
12
|
+
from nbforager.constants import DEPENDENT_MODELS
|
13
|
+
from nbforager.types_ import LStr, LDAny, DDDLInt, LValue, LParam, LDList, DList, DLStr, ODLStr
|
12
14
|
from nbforager.types_ import LTInt2, DAny, SeqStr, SStr, TValues, TLists, T2Str, T3Str, T3StrInt
|
13
15
|
|
14
16
|
|
17
|
+
def dependency_ordered_paths(dependency: ODLStr = None) -> LStr:
|
18
|
+
"""Order paths based on dependencies. Models with the lowes count of dependencies will be first.
|
19
|
+
|
20
|
+
:param dependency: Dictionary representing dependencies,
|
21
|
+
where key is the parent model and value is a list of child models.
|
22
|
+
:return: Ordered paths based on dependencies.
|
23
|
+
:raises ValueError: If circular dependency, too many iterations.
|
24
|
+
"""
|
25
|
+
paths: LStr = []
|
26
|
+
|
27
|
+
idx = 0
|
28
|
+
dependency_: DLStr = dependency if dependency else DEPENDENT_MODELS
|
29
|
+
dependency_ = deepcopy(dependency_)
|
30
|
+
|
31
|
+
while dependency_:
|
32
|
+
for parent, children in dependency_.items():
|
33
|
+
if parent in paths:
|
34
|
+
continue
|
35
|
+
diff = set(children).difference(set(paths))
|
36
|
+
if parent == "dcim/devices":
|
37
|
+
diff.discard("dcim/virtual-chassis")
|
38
|
+
if not diff:
|
39
|
+
paths.append(parent)
|
40
|
+
|
41
|
+
dependency_ = {k: v for k, v in dependency_.items() if k not in paths}
|
42
|
+
if not dependency_:
|
43
|
+
break
|
44
|
+
|
45
|
+
idx += 1
|
46
|
+
if idx >= 100:
|
47
|
+
raise ValueError("Circular dependency, too many iterations")
|
48
|
+
|
49
|
+
return paths
|
50
|
+
|
51
|
+
|
15
52
|
# =========================== app model id ===========================
|
16
53
|
|
17
54
|
|
@@ -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,6 +271,18 @@ class NbApi:
|
|
282
271
|
app_paths.append(path)
|
283
272
|
return app_paths
|
284
273
|
|
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
|
285
|
+
|
285
286
|
def copy(self, **kwargs) -> NbApi:
|
286
287
|
"""Create a duplicate of the object.
|
287
288
|
|
@@ -117,7 +117,7 @@ class NbParser:
|
|
117
117
|
|
118
118
|
:param keys: Chaining dictionary keys to retrieve the desired value.
|
119
119
|
|
120
|
-
:return: Boolean value or
|
120
|
+
:return: Boolean value or False if the value is absent.
|
121
121
|
:rtype: bool
|
122
122
|
"""
|
123
123
|
return self._get_keys(type_=bool, keys=keys, data=self.data)
|
@@ -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)
|
@@ -77,4 +77,3 @@ UParam = Union[LParam, SParam, TParam]
|
|
77
77
|
|
78
78
|
# 5 level
|
79
79
|
OUParam = Optional[UParam]
|
80
|
-
|
@@ -1,6 +1,6 @@
|
|
1
1
|
[tool.poetry]
|
2
2
|
name = "nbforager"
|
3
|
-
version = "0.
|
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.
|
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"
|
@@ -82,6 +82,7 @@ disable = [
|
|
82
82
|
"protected-access",
|
83
83
|
"redefined-builtin",
|
84
84
|
"redefined-outer-name",
|
85
|
+
"too-many-positional-arguments",
|
85
86
|
"too-many-statements",
|
86
87
|
"unused-import",
|
87
88
|
"use-dict-literal",
|
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
|