nbforager 0.8.2__tar.gz → 0.8.4__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.2 → nbforager-0.8.4}/PKG-INFO +2 -3
- {nbforager-0.8.2 → nbforager-0.8.4}/nbforager/api/base_c.py +15 -6
- {nbforager-0.8.2 → nbforager-0.8.4}/nbforager/api/connector.py +0 -7
- {nbforager-0.8.2 → nbforager-0.8.4}/nbforager/api/ip_addresses.py +0 -6
- nbforager-0.8.4/nbforager/foragers/ipv4.py +79 -0
- {nbforager-0.8.2 → nbforager-0.8.4}/nbforager/foragers/joiner.py +1 -1
- {nbforager-0.8.2 → nbforager-0.8.4}/nbforager/nb_forager.py +1 -1
- {nbforager-0.8.2 → nbforager-0.8.4}/pyproject.toml +2 -3
- nbforager-0.8.2/nbforager/foragers/ipv4.py +0 -22
- {nbforager-0.8.2 → nbforager-0.8.4}/LICENSE.txt +0 -0
- {nbforager-0.8.2 → nbforager-0.8.4}/README.rst +0 -0
- {nbforager-0.8.2 → nbforager-0.8.4}/nbforager/__init__.py +0 -0
- {nbforager-0.8.2 → nbforager-0.8.4}/nbforager/api/__init__.py +0 -0
- {nbforager-0.8.2 → nbforager-0.8.4}/nbforager/api/base_ac.py +0 -0
- {nbforager-0.8.2 → nbforager-0.8.4}/nbforager/api/circuits.py +0 -0
- {nbforager-0.8.2 → nbforager-0.8.4}/nbforager/api/core.py +0 -0
- {nbforager-0.8.2 → nbforager-0.8.4}/nbforager/api/dcim.py +0 -0
- {nbforager-0.8.2 → nbforager-0.8.4}/nbforager/api/extended_get.py +0 -0
- {nbforager-0.8.2 → nbforager-0.8.4}/nbforager/api/extras.py +0 -0
- {nbforager-0.8.2 → nbforager-0.8.4}/nbforager/api/ipam.py +0 -0
- {nbforager-0.8.2 → nbforager-0.8.4}/nbforager/api/plugins_ca.py +0 -0
- {nbforager-0.8.2 → nbforager-0.8.4}/nbforager/api/status.py +0 -0
- {nbforager-0.8.2 → nbforager-0.8.4}/nbforager/api/tenancy.py +0 -0
- {nbforager-0.8.2 → nbforager-0.8.4}/nbforager/api/users.py +0 -0
- {nbforager-0.8.2 → nbforager-0.8.4}/nbforager/api/virtualization.py +0 -0
- {nbforager-0.8.2 → nbforager-0.8.4}/nbforager/api/wireless.py +0 -0
- {nbforager-0.8.2 → nbforager-0.8.4}/nbforager/constants.py +0 -0
- {nbforager-0.8.2 → nbforager-0.8.4}/nbforager/exceptions.py +0 -0
- {nbforager-0.8.2 → nbforager-0.8.4}/nbforager/foragers/__init__.py +0 -0
- {nbforager-0.8.2 → nbforager-0.8.4}/nbforager/foragers/base_fa.py +0 -0
- {nbforager-0.8.2 → nbforager-0.8.4}/nbforager/foragers/circuits.py +0 -0
- {nbforager-0.8.2 → nbforager-0.8.4}/nbforager/foragers/core.py +0 -0
- {nbforager-0.8.2 → nbforager-0.8.4}/nbforager/foragers/dcim.py +0 -0
- {nbforager-0.8.2 → nbforager-0.8.4}/nbforager/foragers/extras.py +0 -0
- {nbforager-0.8.2 → nbforager-0.8.4}/nbforager/foragers/forager.py +0 -0
- {nbforager-0.8.2 → nbforager-0.8.4}/nbforager/foragers/ipam.py +0 -0
- {nbforager-0.8.2 → nbforager-0.8.4}/nbforager/foragers/tenancy.py +0 -0
- {nbforager-0.8.2 → nbforager-0.8.4}/nbforager/foragers/users.py +0 -0
- {nbforager-0.8.2 → nbforager-0.8.4}/nbforager/foragers/virtualization.py +0 -0
- {nbforager-0.8.2 → nbforager-0.8.4}/nbforager/foragers/wireless.py +0 -0
- {nbforager-0.8.2 → nbforager-0.8.4}/nbforager/helpers.py +0 -0
- {nbforager-0.8.2 → nbforager-0.8.4}/nbforager/log.py +0 -0
- {nbforager-0.8.2 → nbforager-0.8.4}/nbforager/messages.py +0 -0
- {nbforager-0.8.2 → nbforager-0.8.4}/nbforager/nb_api.py +0 -0
- {nbforager-0.8.2 → nbforager-0.8.4}/nbforager/nb_cache.py +0 -0
- {nbforager-0.8.2 → nbforager-0.8.4}/nbforager/nb_tree.py +0 -0
- {nbforager-0.8.2 → nbforager-0.8.4}/nbforager/parser/__init__.py +0 -0
- {nbforager-0.8.2 → nbforager-0.8.4}/nbforager/parser/nb_custom.py +0 -0
- {nbforager-0.8.2 → nbforager-0.8.4}/nbforager/parser/nb_parser.py +0 -0
- {nbforager-0.8.2 → nbforager-0.8.4}/nbforager/parser/nb_value.py +0 -0
- {nbforager-0.8.2 → nbforager-0.8.4}/nbforager/py.typed +0 -0
- {nbforager-0.8.2 → nbforager-0.8.4}/nbforager/types_.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: nbforager
|
3
|
-
Version: 0.8.
|
3
|
+
Version: 0.8.4
|
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
|
@@ -16,14 +16,13 @@ Classifier: Programming Language :: Python :: 3.11
|
|
16
16
|
Classifier: Programming Language :: Python :: 3.12
|
17
17
|
Classifier: Programming Language :: Python :: 3.13
|
18
18
|
Provides-Extra: test
|
19
|
-
Requires-Dist: ciscoconfparse (>=1.9,<2.0)
|
20
19
|
Requires-Dist: netports (>=0.17)
|
21
20
|
Requires-Dist: pydantic (>=2,<3)
|
22
21
|
Requires-Dist: requests (>=2,<3)
|
23
22
|
Requires-Dist: tabulate (>=0.9,<0.10)
|
24
23
|
Requires-Dist: vhelpers (>=0.3)
|
25
24
|
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.
|
25
|
+
Project-URL: Download URL, https://github.com/vladimirs-git/nbforager/archive/refs/tags/0.8.4.tar.gz
|
27
26
|
Project-URL: homepage, https://github.com/vladimirs-git/nbforager
|
28
27
|
Project-URL: repository, https://github.com/vladimirs-git/nbforager
|
29
28
|
Description-Content-Type: text/x-rst
|
@@ -316,12 +316,7 @@ class BaseC:
|
|
316
316
|
|
317
317
|
:return: Netbox objects. Update self _results.
|
318
318
|
"""
|
319
|
-
params_d =
|
320
|
-
if "limit" not in params_d:
|
321
|
-
params_d["limit"] = [self.limit]
|
322
|
-
if "offset" not in params_d:
|
323
|
-
params_d["offset"] = [0]
|
324
|
-
|
319
|
+
params_d = self._add_params_limit_offset(params_d)
|
325
320
|
params_l: LParam = vparam.from_dict(params_d)
|
326
321
|
url = f"{self.url_base}{path}?{urllib.parse.urlencode(params_l)}"
|
327
322
|
|
@@ -359,6 +354,7 @@ class BaseC:
|
|
359
354
|
|
360
355
|
:return: Netbox objects. Update self _results.
|
361
356
|
"""
|
357
|
+
params_d = self._add_params_limit_offset(params_d)
|
362
358
|
params_l: LParam = vparam.from_dict(params_d)
|
363
359
|
url = f"{self.url_base}{path}?{urllib.parse.urlencode(params_l)}"
|
364
360
|
|
@@ -431,6 +427,19 @@ class BaseC:
|
|
431
427
|
|
432
428
|
# ============================== helper ==============================
|
433
429
|
|
430
|
+
def _add_params_limit_offset(self, params_d: DList) -> DList:
|
431
|
+
"""Add `limit` and `offset` default values to the params_d if they are not already present.
|
432
|
+
|
433
|
+
:param params_d: Parameters that need to update.
|
434
|
+
:return: Updated parameters.
|
435
|
+
"""
|
436
|
+
params_d = params_d.copy()
|
437
|
+
if "limit" not in params_d:
|
438
|
+
params_d["limit"] = [self.limit]
|
439
|
+
if "offset" not in params_d:
|
440
|
+
params_d["offset"] = [0]
|
441
|
+
return params_d
|
442
|
+
|
434
443
|
def _get_d(self) -> DAny:
|
435
444
|
"""Get dictionary from the Netbox.
|
436
445
|
|
@@ -102,13 +102,6 @@ class Connector(BaseC):
|
|
102
102
|
- Examples https://github.com/vladimirs-git/nbforager/tree/main/examples,
|
103
103
|
- Official documentation (if you're lucky).
|
104
104
|
|
105
|
-
|
106
|
-
:param max_limit: Maximum count of objects that need to be requested.
|
107
|
-
This is useful in development to prevent script blocking when
|
108
|
-
receiving only part of the requested data is acceptable.
|
109
|
-
Default is `0` no limit.
|
110
|
-
:type max_limit: int
|
111
|
-
|
112
105
|
:param or_{parameter}: List of parameters that need to be requested
|
113
106
|
in an ``OR`` manner, where ``{parameter}`` is the name of the
|
114
107
|
Netbox REST API `Schema ip_addresses`_.
|
@@ -21,12 +21,6 @@ class IpAddressesC(Connector):
|
|
21
21
|
|
22
22
|
NbApi parameters:
|
23
23
|
|
24
|
-
:param max_limit: Maximum count of objects that need to be requested.
|
25
|
-
This is useful in development to prevent script blocking when
|
26
|
-
receiving only part of the requested data is acceptable.
|
27
|
-
Default is `0` no limit.
|
28
|
-
:type max_limit: int
|
29
|
-
|
30
24
|
:param or_{parameter}: List of parameters that need to be requested
|
31
25
|
in an ``OR`` manner, where ``{parameter}`` is the name of the
|
32
26
|
Netbox REST API `Schema ip_addresses`_.
|
@@ -0,0 +1,79 @@
|
|
1
|
+
"""IPv4 address representation in CIDR notation."""
|
2
|
+
|
3
|
+
from __future__ import annotations
|
4
|
+
|
5
|
+
from functools import total_ordering
|
6
|
+
from ipaddress import IPv4Interface, IPv4Network
|
7
|
+
|
8
|
+
|
9
|
+
@total_ordering
|
10
|
+
class IPv4:
|
11
|
+
"""IPv4 address representation in CIDR notation."""
|
12
|
+
|
13
|
+
def __init__(self, cidr: str, strict: bool = False):
|
14
|
+
"""Initialize IPv4 object with the given CIDR notation.
|
15
|
+
|
16
|
+
:param cidr: A string like '192.168.1.1/24'
|
17
|
+
:param strict: If True, IP must be valid network address (not host address).
|
18
|
+
:raises ValueError: If strict is True and a network address is not supplied.
|
19
|
+
"""
|
20
|
+
_ = IPv4Network(cidr, strict=strict) # Validate network with strictness
|
21
|
+
self._interface = IPv4Interface(cidr)
|
22
|
+
|
23
|
+
def __repr__(self):
|
24
|
+
"""Representation of the object."""
|
25
|
+
return f"IPv4('{self.ipv4}')"
|
26
|
+
|
27
|
+
def __str__(self):
|
28
|
+
"""String representation
|
29
|
+
|
30
|
+
:return: IPv4 address with prefixlen, A.B.C.D/LEN.
|
31
|
+
"""
|
32
|
+
return self.ipv4
|
33
|
+
|
34
|
+
def __hash__(self) -> int:
|
35
|
+
"""Hash value of the object."""
|
36
|
+
return hash(self._interface.network)
|
37
|
+
|
38
|
+
def __eq__(self, other: IPv4, /) -> bool:
|
39
|
+
"""Check if two objects are equal.
|
40
|
+
|
41
|
+
:param other: Another object to compare.
|
42
|
+
:return: True if objects are equal, False otherwise.
|
43
|
+
"""
|
44
|
+
if not isinstance(other, IPv4):
|
45
|
+
return False
|
46
|
+
return self._interface == other._interface
|
47
|
+
|
48
|
+
def __lt__(self, other: IPv4, /) -> bool:
|
49
|
+
"""Compare two objects.
|
50
|
+
|
51
|
+
:param other: Another object to compare with.
|
52
|
+
"""
|
53
|
+
if not isinstance(other, IPv4):
|
54
|
+
return False
|
55
|
+
return self._interface < other._interface
|
56
|
+
|
57
|
+
def __contains__(self, other: IPv4, /) -> bool:
|
58
|
+
"""Check if all IPs in the other subnet are part of this network."""
|
59
|
+
return other._interface.network.subnet_of(self._interface.network)
|
60
|
+
|
61
|
+
@property
|
62
|
+
def ip(self) -> str:
|
63
|
+
"""IPv4 address without prefixlen, A.B.C.D."""
|
64
|
+
return str(self._interface.ip)
|
65
|
+
|
66
|
+
@property
|
67
|
+
def ipv4(self) -> str:
|
68
|
+
"""IPv4 address with prefixlen, A.B.C.D/LEN."""
|
69
|
+
return str(self._interface.with_prefixlen)
|
70
|
+
|
71
|
+
@property
|
72
|
+
def net(self) -> str:
|
73
|
+
"""IPv4 network with prefixlen, A.B.C.D/LEN."""
|
74
|
+
return str(self._interface.network)
|
75
|
+
|
76
|
+
@property
|
77
|
+
def prefixlen(self) -> int:
|
78
|
+
"""IPv4 network with prefixlen, A.B.C.D/LEN."""
|
79
|
+
return self._interface.network.prefixlen
|
@@ -189,7 +189,7 @@ class Joiner:
|
|
189
189
|
|
190
190
|
Add new attributes in ipam.aggregate, ipam.prefixes, ipam.ip_addresses:
|
191
191
|
|
192
|
-
- ``_ipv4`` IPv4 object
|
192
|
+
- ``_ipv4`` IPv4 object
|
193
193
|
- ``_aggregate`` Aggregate data for ipam.prefixes and ipam.ip_addresses
|
194
194
|
- ``_super_prefix`` Related parent prefix data for ipam.prefixes and ipam.ip_addresses
|
195
195
|
- ``_sub_prefixes`` Related child prefixes data for ipam.prefixes and ipam.ip_addresses
|
@@ -304,7 +304,7 @@ class NbForager:
|
|
304
304
|
|
305
305
|
In ipam.aggregate, ipam.prefixes, ipam.ip_addresses:
|
306
306
|
|
307
|
-
- ``_ipv4`` IPv4 object
|
307
|
+
- ``_ipv4`` IPv4 object
|
308
308
|
- ``_aggregate`` Aggregate data for ipam.prefixes and ipam.ip_addresses
|
309
309
|
- ``_super_prefix`` Related parent prefix data for ipam.prefixes and ipam.ip_addresses
|
310
310
|
- ``_sub_prefixes`` Related child prefixes data for ipam.prefixes and ipam.ip_addresses
|
@@ -1,6 +1,6 @@
|
|
1
1
|
[tool.poetry]
|
2
2
|
name = "nbforager"
|
3
|
-
version = "0.8.
|
3
|
+
version = "0.8.4"
|
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,12 +19,11 @@ 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.4.tar.gz"
|
23
23
|
|
24
24
|
[tool.poetry.dependencies]
|
25
25
|
python = "^3.11"
|
26
26
|
#
|
27
|
-
ciscoconfparse = "^1.9"
|
28
27
|
netports = ">=0.17"
|
29
28
|
pydantic = "^2"
|
30
29
|
requests = "^2"
|
@@ -1,22 +0,0 @@
|
|
1
|
-
"""IPv4"""
|
2
|
-
|
3
|
-
from ciscoconfparse import IPv4Obj # type: ignore
|
4
|
-
|
5
|
-
|
6
|
-
class IPv4(IPv4Obj):
|
7
|
-
"""IPv4, support prefixlen for ip-address."""
|
8
|
-
|
9
|
-
@property
|
10
|
-
def ip(self) -> str:
|
11
|
-
"""IPv4 address without prefixlen, A.B.C.D."""
|
12
|
-
return self.exploded
|
13
|
-
|
14
|
-
@property
|
15
|
-
def ipv4(self) -> str:
|
16
|
-
"""IPv4 address with prefixlen, A.B.C.D/LEN."""
|
17
|
-
return self.as_cidr_addr
|
18
|
-
|
19
|
-
@property
|
20
|
-
def net(self) -> str:
|
21
|
-
"""IPv4 network with prefixlen, A.B.C.D/LEN."""
|
22
|
-
return self.as_cidr_net
|
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
|