nbforager 0.1.15__tar.gz → 0.2.2__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.
Files changed (55) hide show
  1. nbforager-0.2.2/LICENCE.txt +177 -0
  2. {nbforager-0.1.15 → nbforager-0.2.2}/PKG-INFO +10 -7
  3. {nbforager-0.1.15 → nbforager-0.2.2}/README.rst +5 -5
  4. {nbforager-0.1.15 → nbforager-0.2.2}/nbforager/__init__.py +4 -4
  5. {nbforager-0.1.15 → nbforager-0.2.2}/nbforager/api/base_c.py +55 -20
  6. {nbforager-0.1.15 → nbforager-0.2.2}/nbforager/exceptions.py +1 -1
  7. {nbforager-0.1.15 → nbforager-0.2.2}/nbforager/foragers/base_fa.py +3 -1
  8. {nbforager-0.1.15 → nbforager-0.2.2}/nbforager/foragers/circuits.py +3 -2
  9. {nbforager-0.1.15 → nbforager-0.2.2}/nbforager/foragers/core.py +3 -2
  10. {nbforager-0.1.15 → nbforager-0.2.2}/nbforager/foragers/dcim.py +3 -2
  11. {nbforager-0.1.15 → nbforager-0.2.2}/nbforager/foragers/extras.py +3 -2
  12. {nbforager-0.1.15 → nbforager-0.2.2}/nbforager/foragers/forager.py +16 -3
  13. {nbforager-0.1.15 → nbforager-0.2.2}/nbforager/foragers/ipam.py +3 -2
  14. nbforager-0.2.2/nbforager/foragers/joiner.py +293 -0
  15. {nbforager-0.1.15 → nbforager-0.2.2}/nbforager/foragers/tenancy.py +3 -2
  16. {nbforager-0.1.15 → nbforager-0.2.2}/nbforager/foragers/users.py +3 -2
  17. {nbforager-0.1.15 → nbforager-0.2.2}/nbforager/foragers/virtualization.py +3 -2
  18. {nbforager-0.1.15 → nbforager-0.2.2}/nbforager/foragers/wireless.py +3 -2
  19. {nbforager-0.1.15 → nbforager-0.2.2}/nbforager/nb_api.py +3 -3
  20. {nbforager-0.1.15 → nbforager-0.2.2}/nbforager/nb_cache.py +3 -3
  21. {nbforager-0.1.15 → nbforager-0.2.2}/nbforager/nb_forager.py +86 -33
  22. {nbforager-0.1.15 → nbforager-0.2.2}/nbforager/nb_tree.py +9 -1
  23. nbforager-0.2.2/nbforager/parser/__init__.py +1 -0
  24. {nbforager-0.1.15/nbforager/branch → nbforager-0.2.2/nbforager/parser}/nb_custom.py +60 -35
  25. nbforager-0.1.15/nbforager/branch/nb_branch.py → nbforager-0.2.2/nbforager/parser/nb_parser.py +90 -48
  26. nbforager-0.2.2/nbforager/parser/nb_value.py +862 -0
  27. nbforager-0.2.2/nbforager/py_tree.py +265 -0
  28. {nbforager-0.1.15 → nbforager-0.2.2}/nbforager/types_.py +1 -0
  29. {nbforager-0.1.15 → nbforager-0.2.2}/pyproject.toml +30 -3
  30. nbforager-0.1.15/nbforager/branch/__init__.py +0 -1
  31. nbforager-0.1.15/nbforager/branch/nb_value.py +0 -299
  32. nbforager-0.1.15/nbforager/foragers/joiner.py +0 -219
  33. nbforager-0.1.15/nbforager/wrappers.py +0 -31
  34. {nbforager-0.1.15 → nbforager-0.2.2}/nbforager/api/__init__.py +0 -0
  35. {nbforager-0.1.15 → nbforager-0.2.2}/nbforager/api/base_ca.py +0 -0
  36. {nbforager-0.1.15 → nbforager-0.2.2}/nbforager/api/circuits.py +0 -0
  37. {nbforager-0.1.15 → nbforager-0.2.2}/nbforager/api/connector.py +0 -0
  38. {nbforager-0.1.15 → nbforager-0.2.2}/nbforager/api/core.py +0 -0
  39. {nbforager-0.1.15 → nbforager-0.2.2}/nbforager/api/dcim.py +0 -0
  40. {nbforager-0.1.15 → nbforager-0.2.2}/nbforager/api/extended_get.py +0 -0
  41. {nbforager-0.1.15 → nbforager-0.2.2}/nbforager/api/extras.py +0 -0
  42. {nbforager-0.1.15 → nbforager-0.2.2}/nbforager/api/ip_addresses.py +0 -0
  43. {nbforager-0.1.15 → nbforager-0.2.2}/nbforager/api/ipam.py +0 -0
  44. {nbforager-0.1.15 → nbforager-0.2.2}/nbforager/api/plugins_ca.py +0 -0
  45. {nbforager-0.1.15 → nbforager-0.2.2}/nbforager/api/status.py +0 -0
  46. {nbforager-0.1.15 → nbforager-0.2.2}/nbforager/api/tenancy.py +0 -0
  47. {nbforager-0.1.15 → nbforager-0.2.2}/nbforager/api/users.py +0 -0
  48. {nbforager-0.1.15 → nbforager-0.2.2}/nbforager/api/virtualization.py +0 -0
  49. {nbforager-0.1.15 → nbforager-0.2.2}/nbforager/api/wireless.py +0 -0
  50. {nbforager-0.1.15 → nbforager-0.2.2}/nbforager/foragers/__init__.py +0 -0
  51. {nbforager-0.1.15 → nbforager-0.2.2}/nbforager/foragers/ipv4.py +0 -0
  52. {nbforager-0.1.15 → nbforager-0.2.2}/nbforager/helpers.py +0 -0
  53. {nbforager-0.1.15 → nbforager-0.2.2}/nbforager/log.py +0 -0
  54. {nbforager-0.1.15 → nbforager-0.2.2}/nbforager/messages.py +0 -0
  55. {nbforager-0.1.15 → nbforager-0.2.2}/nbforager/py.typed +0 -0
@@ -0,0 +1,177 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+ Copyright 2023 Vladimirs Prusakovs
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nbforager
3
- Version: 0.1.15
3
+ Version: 0.2.2
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
  Home-page: https://github.com/vladimirs-git/nbforager
6
6
  License: Apache-2.0
@@ -17,15 +17,18 @@ Classifier: Programming Language :: Python :: 3.8
17
17
  Classifier: Programming Language :: Python :: 3.9
18
18
  Classifier: Programming Language :: Python :: 3.10
19
19
  Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
20
21
  Provides-Extra: test
21
22
  Requires-Dist: ciscoconfparse (>=1.9,<2.0)
22
23
  Requires-Dist: netports (>=0.12.1,<0.13.0)
23
24
  Requires-Dist: pydantic (>=2,<3)
25
+ Requires-Dist: pynetbox (>=7.3.3,<8.0.0)
24
26
  Requires-Dist: requests (>=2,<3)
27
+ Requires-Dist: tabulate (>=0.9.0,<0.10.0)
25
28
  Requires-Dist: tomli (==2.0.1)
26
29
  Requires-Dist: vhelpers (>=0.1,<0.2)
27
30
  Project-URL: Bug Tracker, https://github.com/vladimirs-git/nbforager/issues
28
- Project-URL: Download URL, https://github.com/vladimirs-git/nbforager/archive/refs/tags/0.1.15.tar.gz
31
+ Project-URL: Download URL, https://github.com/vladimirs-git/nbforager/archive/refs/tags/0.2.2.tar.gz
29
32
  Project-URL: Repository, https://github.com/vladimirs-git/nbforager
30
33
  Description-Content-Type: text/x-rst
31
34
 
@@ -40,7 +43,7 @@ Python package designed to help work with the `Netbox`_ REST API.
40
43
 
41
44
  - `NbApi`_ Request data from Netbox using filter parameters identical to those in the Web UI filter form. Filter parameters use the ``OR`` operator.
42
45
  - `NbForager`_ The REST API returns objects that contain a brief representation of related objects. NbForager replaces brief data with full and objects look like a recursive multidimensional dictionary.
43
- - `NbBranch`_ Extract typed values from a Netbox object dictionary by using a chain of keys.
46
+ - `NbParser`_ Extract typed values from a Netbox object dictionary by using a chain of keys.
44
47
 
45
48
  Checked with Python >= 3.8, Netbox >= v3.6.
46
49
  Fully documented on `Read the Docs`_.
@@ -115,7 +118,7 @@ Request objects using filtering parameters. Assemble multidimensional dictionary
115
118
 
116
119
  from pprint import pprint
117
120
 
118
- from nbforager import NbForager, NbBranch
121
+ from nbforager import NbForager, NbParser
119
122
 
120
123
  HOST = "demo.netbox.dev"
121
124
  TOKEN = "1234567890123456789012345678901234567890"
@@ -167,8 +170,8 @@ Request objects using filtering parameters. Assemble multidimensional dictionary
167
170
  region = device["site"]["region"]["name"]
168
171
  print(f"{region=}") # region="North Carolina"
169
172
 
170
- # Use NbBranch to ensure the data type if any dictionary in the chain is missing.
171
- region = NbBranch(device).str("site", "region", "name")
173
+ # Use NbParser to ensure the data type if any dictionary in the chain is missing.
174
+ region = NbParser(device).str("site", "region", "name")
172
175
  print(f"{region=}") # region="North Carolina"
173
176
 
174
177
 
@@ -227,5 +230,5 @@ Create, get, update and delete ip-addresses.
227
230
  .. _`Read the Docs`: https://nbforager.readthedocs.io/en/latest/
228
231
  .. _`NbApi`: https://nbforager.readthedocs.io/en/latest/api/nb_api.html#nbapi
229
232
  .. _`NbForager`: https://nbforager.readthedocs.io/en/latest/foragers/nb_forager.html#nbforager
230
- .. _`NbBranch`: https://nbforager.readthedocs.io/en/latest/branch/nb_branch.html#nbbranch
233
+ .. _`NbParser`: https://nbforager.readthedocs.io/en/latest/parser/nb_parser.html#nbparser
231
234
 
@@ -9,7 +9,7 @@ Python package designed to help work with the `Netbox`_ REST API.
9
9
 
10
10
  - `NbApi`_ Request data from Netbox using filter parameters identical to those in the Web UI filter form. Filter parameters use the ``OR`` operator.
11
11
  - `NbForager`_ The REST API returns objects that contain a brief representation of related objects. NbForager replaces brief data with full and objects look like a recursive multidimensional dictionary.
12
- - `NbBranch`_ Extract typed values from a Netbox object dictionary by using a chain of keys.
12
+ - `NbParser`_ Extract typed values from a Netbox object dictionary by using a chain of keys.
13
13
 
14
14
  Checked with Python >= 3.8, Netbox >= v3.6.
15
15
  Fully documented on `Read the Docs`_.
@@ -84,7 +84,7 @@ Request objects using filtering parameters. Assemble multidimensional dictionary
84
84
 
85
85
  from pprint import pprint
86
86
 
87
- from nbforager import NbForager, NbBranch
87
+ from nbforager import NbForager, NbParser
88
88
 
89
89
  HOST = "demo.netbox.dev"
90
90
  TOKEN = "1234567890123456789012345678901234567890"
@@ -136,8 +136,8 @@ Request objects using filtering parameters. Assemble multidimensional dictionary
136
136
  region = device["site"]["region"]["name"]
137
137
  print(f"{region=}") # region="North Carolina"
138
138
 
139
- # Use NbBranch to ensure the data type if any dictionary in the chain is missing.
140
- region = NbBranch(device).str("site", "region", "name")
139
+ # Use NbParser to ensure the data type if any dictionary in the chain is missing.
140
+ region = NbParser(device).str("site", "region", "name")
141
141
  print(f"{region=}") # region="North Carolina"
142
142
 
143
143
 
@@ -196,4 +196,4 @@ Create, get, update and delete ip-addresses.
196
196
  .. _`Read the Docs`: https://nbforager.readthedocs.io/en/latest/
197
197
  .. _`NbApi`: https://nbforager.readthedocs.io/en/latest/api/nb_api.html#nbapi
198
198
  .. _`NbForager`: https://nbforager.readthedocs.io/en/latest/foragers/nb_forager.html#nbforager
199
- .. _`NbBranch`: https://nbforager.readthedocs.io/en/latest/branch/nb_branch.html#nbbranch
199
+ .. _`NbParser`: https://nbforager.readthedocs.io/en/latest/parser/nb_parser.html#nbparser
@@ -1,15 +1,15 @@
1
1
  """nbforager."""
2
2
 
3
- from nbforager.branch.nb_branch import NbBranch
4
- from nbforager.branch.nb_custom import NbCustom
5
- from nbforager.branch.nb_value import NbValue
6
3
  from nbforager.nb_api import NbApi
7
4
  from nbforager.nb_forager import NbForager
8
5
  from nbforager.nb_tree import NbTree
6
+ from nbforager.parser.nb_custom import NbCustom
7
+ from nbforager.parser.nb_parser import NbParser
8
+ from nbforager.parser.nb_value import NbValue
9
9
 
10
10
  __all__ = [
11
11
  "NbApi",
12
- "NbBranch",
12
+ "NbParser",
13
13
  "NbCustom",
14
14
  "NbForager",
15
15
  "NbTree",
@@ -33,6 +33,7 @@ LONERS: DLStr = {
33
33
  "dcim/devices/": ["airflow"],
34
34
  "ipam/aggregates/": ["prefix"],
35
35
  "ipam/prefixes/": ["within_include"],
36
+ "ipam/vlan-groups/": ["site"],
36
37
  "extras/content-types/": ["id", "app_label", "model"],
37
38
  }
38
39
 
@@ -51,6 +52,7 @@ class BaseC:
51
52
  "cid",
52
53
  "vid",
53
54
  "asn",
55
+ "device_id",
54
56
  ]
55
57
  _init_params = [
56
58
  "host",
@@ -71,11 +73,11 @@ class BaseC:
71
73
  _reserved_keys: DLStr = {
72
74
  "ipam/": [
73
75
  # ipam aggregates, prefixes, ip_addresses
74
- "ipv4",
75
- "aggregate",
76
- "super_prefix",
77
- "sub_prefixes",
78
- "ip_addresses",
76
+ "_ipv4",
77
+ "_aggregate",
78
+ "_super_prefix",
79
+ "_sub_prefixes",
80
+ "_ip_addresses",
79
81
  # evonetbox
80
82
  "overlapped",
81
83
  "warnings",
@@ -83,19 +85,25 @@ class BaseC:
83
85
  "nbnets__subnets",
84
86
  ],
85
87
  "dcim/devices/": [
86
- "interfaces",
87
- "front_ports",
88
- "rear_ports",
89
- "console_ports",
90
- "console_server_ports",
91
- "power_ports",
92
- "power_outlets",
93
- "module_bays",
94
- "device_bays",
95
- "inventory_items",
88
+ "_interfaces",
89
+ "_front_ports",
90
+ "_rear_ports",
91
+ "_console_ports",
92
+ "_console_server_ports",
93
+ "_power_ports",
94
+ "_power_outlets",
95
+ "_module_bays",
96
+ "_device_bays",
97
+ "_inventory_items",
98
+ ],
99
+ "dcim/interfaces/": [
100
+ "_ip_addresses",
96
101
  ],
97
102
  "virtualization/virtual-machines/": [
98
- "interfaces",
103
+ "_interfaces",
104
+ ],
105
+ "virtualization/interfaces/": [
106
+ "_ip_addresses",
99
107
  ],
100
108
  }
101
109
 
@@ -187,9 +195,14 @@ class BaseC:
187
195
 
188
196
  @property
189
197
  def url(self) -> str:
190
- """Base URL with the application and model path."""
198
+ """URL to the API endpoint of the Netbox object."""
191
199
  return f"{self.url_base}{self.path}"
192
200
 
201
+ @property
202
+ def url_ui(self) -> str:
203
+ """URL to the UI endpoint to the Netbox object."""
204
+ return self.url.replace("/api/", "/", 1)
205
+
193
206
  @property
194
207
  def url_base(self) -> str:
195
208
  """Base URL without the application and model path."""
@@ -509,6 +522,7 @@ class BaseC:
509
522
  """
510
523
  params_d: DList = _lists_wo_dupl(kwargs)
511
524
  params_d = self._change_params_name_to_id(params_d)
525
+ params_d = self._change_params_exceptions(params_d)
512
526
  params_ld: LDList = h.make_combinations(self._loners, params_d)
513
527
  params_ld = h.change_params_or(params_ld)
514
528
  params_ld = h.join_params(params_ld, self._default_get)
@@ -552,9 +566,6 @@ class BaseC:
552
566
  params_d = result["params_d"]
553
567
  if not result["count"]:
554
568
  continue
555
- if count <= self.limit:
556
- params.append(params_d)
557
- continue
558
569
  params_: LDAny = h.generate_offsets(count, self.limit, params_d)
559
570
  params.extend(params_)
560
571
  return params
@@ -614,6 +625,9 @@ class BaseC:
614
625
  """Change parameter with name to parameter with id.
615
626
 
616
627
  Request all related objects from the Netbox, find the name, and replace it with the ID.
628
+
629
+ Described in: nb_api.rst Extended filtering parameters
630
+
617
631
  :param params_d: Parameters that need to update.
618
632
  :return: Updated parameters.
619
633
  """
@@ -640,6 +654,27 @@ class BaseC:
640
654
  params_d_.update(need_add)
641
655
  return params_d_
642
656
 
657
+ def _change_params_exceptions(self, params_d: DList) -> DList:
658
+ """Process exceptions that work differently than
659
+
660
+ Described in: nb_api.rst Extended filtering parameters
661
+
662
+ ipam/vlan-groups/ need site=1 instead of site_id=1.
663
+
664
+ :param params_d: Parameters that need to update.
665
+ :return: Updated parameters.
666
+ """
667
+ if self.extended_get is False:
668
+ return params_d
669
+
670
+ params_d_: DList = {}
671
+ for key, params in params_d.items():
672
+ if self.path == "ipam/vlan-groups/":
673
+ if key == "site_id":
674
+ key = "site"
675
+ params_d_[key] = params
676
+ return params_d_
677
+
643
678
  @staticmethod
644
679
  def _msg_status_code(response: Response) -> str:
645
680
  """Return message ready for logging ConnectionError."""
@@ -5,5 +5,5 @@ class NbApiError(Exception):
5
5
  """Invalid dict key in Netbox data."""
6
6
 
7
7
 
8
- class NbBranchError(Exception):
8
+ class NbParserError(Exception):
9
9
  """Parsing error in Netbox data."""
@@ -4,13 +4,14 @@ from nbforager import helpers as h
4
4
  from nbforager.api import ConnectorA
5
5
  from nbforager.nb_api import NbApi
6
6
  from nbforager.nb_tree import NbTree
7
+ from nbforager.py_tree import PyTree
7
8
  from nbforager.types_ import LStr
8
9
 
9
10
 
10
11
  class BaseAF:
11
12
  """Base for Application Foragers."""
12
13
 
13
- def __init__(self, api: NbApi, root: NbTree, tree: NbTree):
14
+ def __init__(self, api: NbApi, root: NbTree, tree: NbTree, pynb: PyTree):
14
15
  """Init BaseAF.
15
16
 
16
17
  :param root: Dictionary where data from Netbox needs to be saved.
@@ -18,6 +19,7 @@ class BaseAF:
18
19
  self.api = api
19
20
  self.root: NbTree = root
20
21
  self.tree: NbTree = tree
22
+ self.pynb: PyTree = pynb
21
23
  self.app: str = h.attr_name(self)
22
24
  self.connector: ConnectorA = getattr(api, self.app) # connector to application
23
25
 
@@ -5,19 +5,20 @@ from nbforager.foragers.base_fa import BaseAF
5
5
  from nbforager.foragers.forager import Forager
6
6
  from nbforager.nb_api import NbApi
7
7
  from nbforager.nb_tree import NbTree
8
+ from nbforager.py_tree import PyTree
8
9
 
9
10
 
10
11
  class CircuitsAF(BaseAF):
11
12
  """Circuits Forager."""
12
13
 
13
- def __init__(self, api: NbApi, root: NbTree, tree: NbTree):
14
+ def __init__(self, api: NbApi, root: NbTree, tree: NbTree, pynb: PyTree):
14
15
  """Init CircuitsAF.
15
16
 
16
17
  :param api: NbApi object, connector to Netbox API.
17
18
  :param root: NbTree object where raw data from Netbox needs to be saved.
18
19
  :param tree: NbTree object where transformed data from Netbox needs to be saved.
19
20
  """
20
- super().__init__(api, root, tree)
21
+ super().__init__(api, root, tree, pynb)
21
22
  self.circuit_terminations = self.CircuitTerminationsF(self)
22
23
  self.circuit_types = self.CircuitTypesF(self)
23
24
  self.circuits = self.CircuitsF(self)
@@ -5,19 +5,20 @@ from nbforager.foragers.base_fa import BaseAF
5
5
  from nbforager.foragers.forager import Forager
6
6
  from nbforager.nb_api import NbApi
7
7
  from nbforager.nb_tree import NbTree
8
+ from nbforager.py_tree import PyTree
8
9
 
9
10
 
10
11
  class CoreAF(BaseAF):
11
12
  """Core Forager."""
12
13
 
13
- def __init__(self, api: NbApi, root: NbTree, tree: NbTree):
14
+ def __init__(self, api: NbApi, root: NbTree, tree: NbTree, pynb: PyTree):
14
15
  """Init CoreAF.
15
16
 
16
17
  :param api: NbApi object, connector to Netbox API.
17
18
  :param root: NbTree object where raw data from Netbox needs to be saved.
18
19
  :param tree: NbTree object where transformed data from Netbox needs to be saved.
19
20
  """
20
- super().__init__(api, root, tree)
21
+ super().__init__(api, root, tree, pynb)
21
22
  self.data_files = self.DataFilesF(self)
22
23
  self.data_sources = self.DataSourcesF(self)
23
24
  self.jobs = self.JobsF(self)
@@ -5,19 +5,20 @@ from nbforager.foragers.base_fa import BaseAF
5
5
  from nbforager.foragers.forager import Forager
6
6
  from nbforager.nb_api import NbApi
7
7
  from nbforager.nb_tree import NbTree
8
+ from nbforager.py_tree import PyTree
8
9
 
9
10
 
10
11
  class DcimAF(BaseAF):
11
12
  """DCIM Forager."""
12
13
 
13
- def __init__(self, api: NbApi, root: NbTree, tree: NbTree):
14
+ def __init__(self, api: NbApi, root: NbTree, tree: NbTree, pynb: PyTree):
14
15
  """Init DcimAF.
15
16
 
16
17
  :param api: NbApi object, connector to Netbox API.
17
18
  :param root: NbTree object where raw data from Netbox needs to be saved.
18
19
  :param tree: NbTree object where transformed data from Netbox needs to be saved.
19
20
  """
20
- super().__init__(api, root, tree)
21
+ super().__init__(api, root, tree, pynb)
21
22
  self.cable_terminations = self.CableTerminationsF(self)
22
23
  self.cables = self.CablesF(self)
23
24
  # connected_device, is not model
@@ -5,19 +5,20 @@ from nbforager.foragers.base_fa import BaseAF
5
5
  from nbforager.foragers.forager import Forager
6
6
  from nbforager.nb_api import NbApi
7
7
  from nbforager.nb_tree import NbTree
8
+ from nbforager.py_tree import PyTree
8
9
 
9
10
 
10
11
  class ExtrasAF(BaseAF):
11
12
  """Extras Forager."""
12
13
 
13
- def __init__(self, api: NbApi, root: NbTree, tree: NbTree):
14
+ def __init__(self, api: NbApi, root: NbTree, tree: NbTree, pynb: PyTree):
14
15
  """Init ExtrasAF.
15
16
 
16
17
  :param api: NbApi object, connector to Netbox API.
17
18
  :param root: NbTree object where raw data from Netbox needs to be saved.
18
19
  :param tree: NbTree object where transformed data from Netbox needs to be saved.
19
20
  """
20
- super().__init__(api, root, tree)
21
+ super().__init__(api, root, tree, pynb)
21
22
  self.bookmarks = self.BookmarksF(self)
22
23
  self.config_contexts = self.ConfigContextsF(self)
23
24
  self.config_templates = self.ConfigTemplatesF(self)
@@ -13,10 +13,11 @@ from urllib.parse import urlparse, parse_qs
13
13
  from vhelpers import vlist, vstr
14
14
 
15
15
  from nbforager import helpers as h
16
- from nbforager.branch.nb_branch import NbBranch
17
16
  from nbforager.nb_api import NbApi
18
17
  from nbforager.nb_tree import NbTree, missed_urls
19
- from nbforager.types_ import LDAny, DiDAny, LStr, LT2StrDAny, DList, LDList, TLists
18
+ from nbforager.parser.nb_parser import NbParser
19
+ from nbforager.py_tree import PyTree
20
+ from nbforager.types_ import LDAny, DiDAny, LStr, LT2StrDAny, DList, LDList, TLists, DiAny
20
21
 
21
22
 
22
23
  class Forager:
@@ -39,6 +40,7 @@ class Forager:
39
40
  self.root_d: DiDAny = getattr(getattr(self.root, app), model)
40
41
  self.tree: NbTree = forager_a.tree
41
42
  self.tree_d: DiDAny = getattr(getattr(self.tree, app), model)
43
+ self.pynb: PyTree = forager_a.pynb
42
44
 
43
45
  def __repr__(self) -> str:
44
46
  """__repr__."""
@@ -316,6 +318,17 @@ class Forager:
316
318
  model_d: DiDAny = self._get_root_data(path)
317
319
  model_d[int(digit)] = data
318
320
 
321
+ def _get_pynb_data(self, path: str) -> DiAny:
322
+ """Get data in self pynb by app/model path.
323
+
324
+ :param path: The app/model path.
325
+
326
+ :return: The model data.
327
+ """
328
+ app, model = h.path_to_attrs(path)
329
+ data = getattr(getattr(self.pynb, app), model)
330
+ return data
331
+
319
332
  def _get_root_data(self, path: str) -> DiDAny:
320
333
  """Get data in self root by app/model path.
321
334
 
@@ -353,7 +366,7 @@ def _find(objects: LDAny, **kwargs) -> LDAny:
353
366
  if vlist.is_in(values_, values):
354
367
  objects_.append(data)
355
368
  else:
356
- value_ = NbBranch(data).any(*keys)
369
+ value_ = NbParser(data).any(*keys)
357
370
  if value_ in values:
358
371
  objects_.append(data)
359
372
 
@@ -5,19 +5,20 @@ from nbforager.foragers.base_fa import BaseAF
5
5
  from nbforager.foragers.forager import Forager
6
6
  from nbforager.nb_api import NbApi
7
7
  from nbforager.nb_tree import NbTree
8
+ from nbforager.py_tree import PyTree
8
9
 
9
10
 
10
11
  class IpamAF(BaseAF):
11
12
  """IPAM Forager."""
12
13
 
13
- def __init__(self, api: NbApi, root: NbTree, tree: NbTree):
14
+ def __init__(self, api: NbApi, root: NbTree, tree: NbTree, pynb: PyTree):
14
15
  """Init IpamAF.
15
16
 
16
17
  :param api: NbApi object, connector to Netbox API.
17
18
  :param root: NbTree object where raw data from Netbox needs to be saved.
18
19
  :param tree: NbTree object where transformed data from Netbox needs to be saved.
19
20
  """
20
- super().__init__(api, root, tree)
21
+ super().__init__(api, root, tree, pynb)
21
22
  self.aggregates = self.AggregatesF(self)
22
23
  self.asn_ranges = self.AsnRangesF(self)
23
24
  self.asns = self.AsnsF(self)