netbox-explorer 0.1.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.
- netbox_explorer-0.1.2/LICENSE +21 -0
- netbox_explorer-0.1.2/PKG-INFO +588 -0
- netbox_explorer-0.1.2/README.md +534 -0
- netbox_explorer-0.1.2/netbox_cli/__init__.py +6 -0
- netbox_explorer-0.1.2/netbox_cli/app.py +468 -0
- netbox_explorer-0.1.2/netbox_cli/cache.py +112 -0
- netbox_explorer-0.1.2/netbox_cli/client.py +429 -0
- netbox_explorer-0.1.2/netbox_cli/config.py +266 -0
- netbox_explorer-0.1.2/netbox_cli/discovery.py +300 -0
- netbox_explorer-0.1.2/netbox_cli/errors.py +57 -0
- netbox_explorer-0.1.2/netbox_cli/parsing.py +102 -0
- netbox_explorer-0.1.2/netbox_cli/profiles.py +77 -0
- netbox_explorer-0.1.2/netbox_cli/query.py +205 -0
- netbox_explorer-0.1.2/netbox_cli/render.py +493 -0
- netbox_explorer-0.1.2/netbox_cli/repl/__init__.py +7 -0
- netbox_explorer-0.1.2/netbox_cli/repl/commands.py +486 -0
- netbox_explorer-0.1.2/netbox_cli/repl/completer.py +336 -0
- netbox_explorer-0.1.2/netbox_cli/repl/help.py +41 -0
- netbox_explorer-0.1.2/netbox_cli/repl/metadata.py +469 -0
- netbox_explorer-0.1.2/netbox_cli/repl/shell.py +248 -0
- netbox_explorer-0.1.2/netbox_cli/repl/state.py +167 -0
- netbox_explorer-0.1.2/netbox_cli/search.py +302 -0
- netbox_explorer-0.1.2/netbox_cli/settings.py +51 -0
- netbox_explorer-0.1.2/netbox_explorer.egg-info/PKG-INFO +588 -0
- netbox_explorer-0.1.2/netbox_explorer.egg-info/SOURCES.txt +43 -0
- netbox_explorer-0.1.2/netbox_explorer.egg-info/dependency_links.txt +1 -0
- netbox_explorer-0.1.2/netbox_explorer.egg-info/entry_points.txt +2 -0
- netbox_explorer-0.1.2/netbox_explorer.egg-info/requires.txt +8 -0
- netbox_explorer-0.1.2/netbox_explorer.egg-info/top_level.txt +1 -0
- netbox_explorer-0.1.2/pyproject.toml +53 -0
- netbox_explorer-0.1.2/setup.cfg +4 -0
- netbox_explorer-0.1.2/tests/test_app.py +929 -0
- netbox_explorer-0.1.2/tests/test_cache.py +63 -0
- netbox_explorer-0.1.2/tests/test_client.py +202 -0
- netbox_explorer-0.1.2/tests/test_config.py +122 -0
- netbox_explorer-0.1.2/tests/test_discovery.py +262 -0
- netbox_explorer-0.1.2/tests/test_parsing.py +82 -0
- netbox_explorer-0.1.2/tests/test_query.py +296 -0
- netbox_explorer-0.1.2/tests/test_render.py +315 -0
- netbox_explorer-0.1.2/tests/test_repl_commands.py +852 -0
- netbox_explorer-0.1.2/tests/test_repl_completer.py +278 -0
- netbox_explorer-0.1.2/tests/test_repl_metadata.py +316 -0
- netbox_explorer-0.1.2/tests/test_repl_shell.py +295 -0
- netbox_explorer-0.1.2/tests/test_repl_state.py +59 -0
- netbox_explorer-0.1.2/tests/test_search.py +192 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 netbox-cli contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,588 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: netbox-explorer
|
|
3
|
+
Version: 0.1.2
|
|
4
|
+
Summary: Read-only NetBox CLI with a classic command surface and an interactive shell.
|
|
5
|
+
License: MIT License
|
|
6
|
+
|
|
7
|
+
Copyright (c) 2026 netbox-cli contributors
|
|
8
|
+
|
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
in the Software without restriction, including without limitation the rights
|
|
12
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
furnished to do so, subject to the following conditions:
|
|
15
|
+
|
|
16
|
+
The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
copies or substantial portions of the Software.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
+
SOFTWARE.
|
|
26
|
+
|
|
27
|
+
Project-URL: Homepage, https://github.com/fciarfella/netbox-cli
|
|
28
|
+
Project-URL: Issues, https://github.com/fciarfella/netbox-cli/issues
|
|
29
|
+
Project-URL: Repository, https://github.com/fciarfella/netbox-cli
|
|
30
|
+
Keywords: netbox,cli,network-automation,inventory
|
|
31
|
+
Classifier: Development Status :: 4 - Beta
|
|
32
|
+
Classifier: Environment :: Console
|
|
33
|
+
Classifier: Intended Audience :: System Administrators
|
|
34
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
35
|
+
Classifier: Operating System :: OS Independent
|
|
36
|
+
Classifier: Programming Language :: Python
|
|
37
|
+
Classifier: Programming Language :: Python :: 3
|
|
38
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
39
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
40
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
41
|
+
Classifier: Topic :: System :: Networking
|
|
42
|
+
Classifier: Topic :: Utilities
|
|
43
|
+
Requires-Python: >=3.11
|
|
44
|
+
Description-Content-Type: text/markdown
|
|
45
|
+
License-File: LICENSE
|
|
46
|
+
Requires-Dist: httpx<1.0,>=0.27
|
|
47
|
+
Requires-Dist: prompt-toolkit<4.0,>=3.0
|
|
48
|
+
Requires-Dist: rich<14.0,>=13.7
|
|
49
|
+
Requires-Dist: typer<1.0,>=0.12
|
|
50
|
+
Provides-Extra: dev
|
|
51
|
+
Requires-Dist: pytest<9.0,>=8.0; extra == "dev"
|
|
52
|
+
Requires-Dist: respx<1.0,>=0.21; extra == "dev"
|
|
53
|
+
Dynamic: license-file
|
|
54
|
+
|
|
55
|
+
# NetBox CLI
|
|
56
|
+
|
|
57
|
+
## What It Is
|
|
58
|
+
|
|
59
|
+
`netbox-cli` is a read-only Python CLI for NetBox.
|
|
60
|
+
|
|
61
|
+
The package is published on PyPI as `netbox-explorer`, while the installed command remains `netbox`.
|
|
62
|
+
|
|
63
|
+
It provides two aligned interfaces:
|
|
64
|
+
|
|
65
|
+
- a standard command line for automation, documentation, and copy/paste use
|
|
66
|
+
- an interactive shell for faster exploration, using the same service layer and command semantics
|
|
67
|
+
|
|
68
|
+
The CLI is the primary interface.
|
|
69
|
+
|
|
70
|
+

|
|
71
|
+
|
|
72
|
+
The shell is a convenience layer on top of it.
|
|
73
|
+
|
|
74
|
+

|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
## Features
|
|
78
|
+
|
|
79
|
+
- explicit configuration with `netbox init`
|
|
80
|
+
- config validation and connectivity checks with `netbox config test`
|
|
81
|
+
- discovery of apps, endpoints, filters, and known choices from the NetBox API
|
|
82
|
+
- read-only `list`, `get`, and grouped global `search`
|
|
83
|
+
- Rich tables for interactive terminal output
|
|
84
|
+
- JSON and CSV output for automation and piping
|
|
85
|
+
- interactive shell with history, contextual navigation, and autocomplete
|
|
86
|
+
- local metadata caching for API root, schema, and endpoint `OPTIONS`
|
|
87
|
+
|
|
88
|
+
## Install
|
|
89
|
+
|
|
90
|
+
Using a virtual environment is the recommended install path.
|
|
91
|
+
|
|
92
|
+
### Install from PyPI
|
|
93
|
+
|
|
94
|
+
Use this for the normal published package install.
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
python3 -m venv .venv
|
|
98
|
+
source .venv/bin/activate
|
|
99
|
+
python3 -m pip install --upgrade pip
|
|
100
|
+
python3 -m pip install netbox-explorer
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Install from GitHub
|
|
104
|
+
|
|
105
|
+
Use this when you want to try the tool quickly without cloning the repository.
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
python3 -m venv .venv
|
|
109
|
+
source .venv/bin/activate
|
|
110
|
+
python3 -m pip install --upgrade pip
|
|
111
|
+
python3 -m pip install "git+https://github.com/fciarfella/netbox-cli.git"
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Install a tagged release from GitHub
|
|
115
|
+
|
|
116
|
+
Use a tagged release when you want a specific published version from GitHub.
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
python3 -m pip install "git+https://github.com/fciarfella/netbox-cli.git@v0.1.0"
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Install from a local clone
|
|
123
|
+
|
|
124
|
+
Use a local clone when you want to develop the project or make local changes.
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
git clone https://github.com/fciarfella/netbox-cli.git
|
|
128
|
+
cd netbox-cli
|
|
129
|
+
python3 -m venv .venv
|
|
130
|
+
source .venv/bin/activate
|
|
131
|
+
python3 -m pip install --upgrade pip
|
|
132
|
+
python3 -m pip install -e .
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Install development dependencies
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
python3 -m pip install -e ".[dev]"
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Verify the install
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
netbox --help
|
|
145
|
+
netbox --version
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Reactivate the environment
|
|
149
|
+
|
|
150
|
+
If you open a new shell later, reactivate the environment first:
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
source .venv/bin/activate
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## Configuration
|
|
157
|
+
|
|
158
|
+
`config.toml` is the primary configuration source for the tool. Environment variables are supported as optional overrides, but normal usage should start with an explicit config file.
|
|
159
|
+
|
|
160
|
+
Examples in this README assume you have access to a reachable NetBox instance and a valid API token. DNS plugin examples apply only when that plugin is installed and exposed by your NetBox API.
|
|
161
|
+
|
|
162
|
+
Create config:
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
netbox init
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Example:
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
netbox init \
|
|
172
|
+
--url https://netbox.example.com \
|
|
173
|
+
--token YOUR_TOKEN \
|
|
174
|
+
--default-format table \
|
|
175
|
+
--default-limit 25
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Validate config, token, and connectivity:
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
netbox config test
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
Show config, cache, and history paths:
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
netbox config paths
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
Clear cached metadata:
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
netbox cache clear
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
Typical paths:
|
|
197
|
+
|
|
198
|
+
```text
|
|
199
|
+
~/.config/netbox-cli/config.toml
|
|
200
|
+
~/.cache/netbox-cli/
|
|
201
|
+
~/.local/state/netbox-cli/shell-history
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
Optional environment variable overrides:
|
|
205
|
+
|
|
206
|
+
```text
|
|
207
|
+
NETBOX_URL
|
|
208
|
+
NETBOX_TOKEN
|
|
209
|
+
NETBOX_CLI_DEFAULT_FORMAT
|
|
210
|
+
NETBOX_CLI_DEFAULT_LIMIT
|
|
211
|
+
NETBOX_CLI_TIMEOUT
|
|
212
|
+
NETBOX_CLI_VERIFY_TLS
|
|
213
|
+
NETBOX_CLI_CONFIG
|
|
214
|
+
NETBOX_CLI_CONFIG_DIR
|
|
215
|
+
NETBOX_CLI_CACHE_DIR
|
|
216
|
+
NETBOX_CLI_HISTORY_DIR
|
|
217
|
+
NETBOX_CLI_HISTORY_PATH
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
## CLI Quick Start
|
|
221
|
+
|
|
222
|
+
Common first commands:
|
|
223
|
+
|
|
224
|
+
```bash
|
|
225
|
+
netbox config test
|
|
226
|
+
netbox list
|
|
227
|
+
netbox list dcim
|
|
228
|
+
netbox filters dcim/devices
|
|
229
|
+
netbox list dcim/devices status=active
|
|
230
|
+
netbox list dcim/devices q=router01 --cols name,site,status
|
|
231
|
+
netbox get dcim/devices id=1490
|
|
232
|
+
netbox search router01 --cols id,name,site,status
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
## CLI Examples
|
|
236
|
+
|
|
237
|
+
Discover apps and endpoints:
|
|
238
|
+
|
|
239
|
+
```bash
|
|
240
|
+
netbox list
|
|
241
|
+
netbox list dcim
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
Compatibility commands remain available:
|
|
245
|
+
|
|
246
|
+
```bash
|
|
247
|
+
netbox apps
|
|
248
|
+
netbox endpoints dcim
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
Inspect endpoint filters and known choices:
|
|
252
|
+
|
|
253
|
+
```bash
|
|
254
|
+
netbox filters dcim/devices
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
List rows from an endpoint:
|
|
258
|
+
|
|
259
|
+
```bash
|
|
260
|
+
netbox list
|
|
261
|
+
netbox list dcim
|
|
262
|
+
netbox list dcim/devices status=active
|
|
263
|
+
netbox list dcim/devices router01
|
|
264
|
+
netbox list dcim/devices router 01
|
|
265
|
+
netbox list dcim/devices router01 status=active
|
|
266
|
+
netbox list dcim/devices site=dc1 site=lab
|
|
267
|
+
netbox list dcim/devices status=active status=offline
|
|
268
|
+
netbox list dcim/devices q=router01
|
|
269
|
+
netbox list dcim/devices name__ic=router
|
|
270
|
+
netbox list dcim/devices q=router01 --cols name,site,status
|
|
271
|
+
netbox list plugins/netbox-dns/records q=198.51.100.10 --cols zone,name,type,value,status
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
The CLI `list` command follows the same exploration flow and shorthand as the shell:
|
|
275
|
+
|
|
276
|
+
```bash
|
|
277
|
+
netbox list
|
|
278
|
+
netbox list dcim
|
|
279
|
+
netbox list dcim/devices
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
Inside an endpoint path, bare terms are treated as `q=...`:
|
|
283
|
+
|
|
284
|
+
```bash
|
|
285
|
+
netbox list dcim/devices router01
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
This behaves like:
|
|
289
|
+
|
|
290
|
+
```bash
|
|
291
|
+
netbox list dcim/devices q=router01
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
Fetch exactly one object:
|
|
295
|
+
|
|
296
|
+
```bash
|
|
297
|
+
netbox get dcim/devices id=1490
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
Run global search across curated endpoints:
|
|
301
|
+
|
|
302
|
+
```bash
|
|
303
|
+
netbox search router01
|
|
304
|
+
netbox search router01 --cols id,name,site,status
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
`--cols` takes a comma-separated list of fields and overrides the default profile columns for `list` and `search`.
|
|
308
|
+
|
|
309
|
+
Use `netbox search <term>` when you want a broad search across multiple object types.
|
|
310
|
+
|
|
311
|
+
Use `netbox list` to explore progressively:
|
|
312
|
+
|
|
313
|
+
- `netbox list` shows top-level apps
|
|
314
|
+
- `netbox list <app>` shows endpoints for that app
|
|
315
|
+
- `netbox list <app>/<endpoint>` lists records from that endpoint
|
|
316
|
+
|
|
317
|
+
Use `netbox list <endpoint> q=<term>` when you already know the endpoint you want to search inside.
|
|
318
|
+
|
|
319
|
+
Examples:
|
|
320
|
+
|
|
321
|
+
```bash
|
|
322
|
+
netbox search router01
|
|
323
|
+
netbox list dcim/devices q=router01
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
Actual supported filters depend on the target endpoint and the schema exposed by your NetBox instance. For endpoint-specific lookups, `netbox filters <app>/<endpoint>` shows what the tool has discovered.
|
|
327
|
+
|
|
328
|
+
For multi-value filters, repeat the parameter instead of using a comma-separated value:
|
|
329
|
+
|
|
330
|
+
```bash
|
|
331
|
+
netbox list dcim/devices site=dc1 site=lab
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
This is separate from NetBox options like `ordering`, where comma-separated values are still the normal form:
|
|
335
|
+
|
|
336
|
+
```bash
|
|
337
|
+
netbox list dcim/devices ordering=name,-serial
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
## Search Behavior
|
|
341
|
+
|
|
342
|
+
`netbox search <term>` searches a curated set of endpoints and groups results by object type.
|
|
343
|
+
|
|
344
|
+
The v1 search set includes:
|
|
345
|
+
|
|
346
|
+
- `dcim/devices`
|
|
347
|
+
- `virtualization/virtual-machines`
|
|
348
|
+
- `ipam/ip-addresses`
|
|
349
|
+
- `ipam/prefixes`
|
|
350
|
+
- `ipam/vlans`
|
|
351
|
+
- `dcim/sites`
|
|
352
|
+
- `dcim/racks`
|
|
353
|
+
- `plugins/netbox_dns/records` when available
|
|
354
|
+
|
|
355
|
+
Ranking prefers:
|
|
356
|
+
|
|
357
|
+
1. exact matches
|
|
358
|
+
2. prefix matches
|
|
359
|
+
3. substring matches
|
|
360
|
+
|
|
361
|
+
Search output is grouped by endpoint and shows the endpoint path, match count, and a useful default column set for each group.
|
|
362
|
+
|
|
363
|
+
## Interactive Shell
|
|
364
|
+
|
|
365
|
+
Launch the shell:
|
|
366
|
+
|
|
367
|
+
```bash
|
|
368
|
+
netbox shell
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
The prompt always shows the current path, output format, and row limit:
|
|
372
|
+
|
|
373
|
+
```text
|
|
374
|
+
netbox:/ [table|15]>
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
Typical session:
|
|
378
|
+
|
|
379
|
+
```text
|
|
380
|
+
netbox:/ [table|15]> list
|
|
381
|
+
netbox:/ [table|15]> cd dcim
|
|
382
|
+
netbox:/dcim [table|15]> list
|
|
383
|
+
netbox:/dcim [table|15]> cd devices
|
|
384
|
+
netbox:/dcim/devices [table|15]> filters
|
|
385
|
+
netbox:/dcim/devices [table|15]> list status=active
|
|
386
|
+
netbox:/dcim/devices [table|15]> open 1
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
Change output format and row limit:
|
|
390
|
+
|
|
391
|
+
```text
|
|
392
|
+
netbox:/dcim/devices [table|15]> format json
|
|
393
|
+
netbox:/dcim/devices [json|15]> limit 5
|
|
394
|
+
netbox:/dcim/devices [json|5]> get name=router01
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
Search and open:
|
|
398
|
+
|
|
399
|
+
```text
|
|
400
|
+
netbox:/ [table|15]> search router01
|
|
401
|
+
netbox:/ [table|15]> open 2
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
Inside an endpoint context, `list` supports a shorthand search term:
|
|
405
|
+
|
|
406
|
+
```text
|
|
407
|
+
netbox:/dcim/devices [table|15]> list web01
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
This behaves like:
|
|
411
|
+
|
|
412
|
+
```text
|
|
413
|
+
netbox:/dcim/devices [table|15]> list q=web01
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
Quoted values work the same way:
|
|
417
|
+
|
|
418
|
+
```text
|
|
419
|
+
netbox:/dcim/devices [table|15]> list "router 01"
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
This behaves like:
|
|
423
|
+
|
|
424
|
+
```text
|
|
425
|
+
netbox:/dcim/devices [table|15]> list q="router 01"
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
Mixed shorthand and explicit filters also work:
|
|
429
|
+
|
|
430
|
+
```text
|
|
431
|
+
netbox:/dcim/devices [table|15]> list web01 status=active
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
This behaves like:
|
|
435
|
+
|
|
436
|
+
```text
|
|
437
|
+
netbox:/dcim/devices [table|15]> list q=web01 status=active
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
If `q=...` is already present explicitly, the shell does not add a second `q`.
|
|
441
|
+
|
|
442
|
+
Repeated filters are supported in the shell the same way they are in the CLI:
|
|
443
|
+
|
|
444
|
+
```text
|
|
445
|
+
netbox:/dcim/devices [table|15]> list site=dc1 site=lab
|
|
446
|
+
netbox:/dcim/devices [table|15]> list web01 site=dc1 site=lab
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
Shell commands:
|
|
450
|
+
|
|
451
|
+
Navigation:
|
|
452
|
+
|
|
453
|
+
```text
|
|
454
|
+
cd [path]
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
Inspection:
|
|
458
|
+
|
|
459
|
+
```text
|
|
460
|
+
filters
|
|
461
|
+
list [term] [k=v ...]
|
|
462
|
+
get [k=v ...]
|
|
463
|
+
search <term>
|
|
464
|
+
open <index>
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
Session controls:
|
|
468
|
+
|
|
469
|
+
```text
|
|
470
|
+
cols
|
|
471
|
+
cols a,b,c
|
|
472
|
+
cols reset
|
|
473
|
+
format <table|json|csv>
|
|
474
|
+
limit <n>
|
|
475
|
+
exit
|
|
476
|
+
help
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
## Autocomplete
|
|
480
|
+
|
|
481
|
+
Shell completion is contextual.
|
|
482
|
+
|
|
483
|
+
It uses the current shell state plus cached metadata to suggest:
|
|
484
|
+
|
|
485
|
+
- shell commands
|
|
486
|
+
- app names
|
|
487
|
+
- endpoint path segments
|
|
488
|
+
- filter names for the current endpoint
|
|
489
|
+
- known choice values for filters
|
|
490
|
+
- known and default columns
|
|
491
|
+
- simple enum values such as output formats
|
|
492
|
+
|
|
493
|
+
Examples:
|
|
494
|
+
|
|
495
|
+
```text
|
|
496
|
+
cd d<TAB> -> dcim
|
|
497
|
+
cd /plugins/ne<TAB> -> /plugins/netbox_dns
|
|
498
|
+
cd net<TAB> -> netbox_dns
|
|
499
|
+
list st<TAB> -> status=
|
|
500
|
+
list status=<TAB> -> active offline planned
|
|
501
|
+
cols na<TAB> -> name
|
|
502
|
+
format j<TAB> -> json
|
|
503
|
+
```
|
|
504
|
+
|
|
505
|
+
Completion is driven by shell state and cached metadata. If metadata for the current context is missing, the shell may fetch it lazily once and then reuse it for later completions.
|
|
506
|
+
|
|
507
|
+
## Output Formats
|
|
508
|
+
|
|
509
|
+
CLI and shell share the same renderers.
|
|
510
|
+
|
|
511
|
+
Available formats:
|
|
512
|
+
|
|
513
|
+
- `table`
|
|
514
|
+
- `json`
|
|
515
|
+
- `csv`
|
|
516
|
+
|
|
517
|
+
Use table output for interactive work:
|
|
518
|
+
|
|
519
|
+
```bash
|
|
520
|
+
netbox list dcim/devices status=active
|
|
521
|
+
```
|
|
522
|
+
|
|
523
|
+
Use JSON when you want machine-readable output:
|
|
524
|
+
|
|
525
|
+
```bash
|
|
526
|
+
netbox get dcim/devices id=1490 --format json
|
|
527
|
+
netbox list dcim/devices q=router01 --cols name,site,status --format json
|
|
528
|
+
```
|
|
529
|
+
|
|
530
|
+
Use CSV when you want simple pipe-friendly rows:
|
|
531
|
+
|
|
532
|
+
```bash
|
|
533
|
+
netbox list dcim/devices status=active --format csv
|
|
534
|
+
netbox search router01 --cols id,name,site,status --format csv
|
|
535
|
+
```
|
|
536
|
+
|
|
537
|
+
In the shell, numbered results are mainly meant for table-mode exploration with `open <index>`. JSON and CSV still include the index for consistency, but the primary workflow is interactive table output plus `open`.
|
|
538
|
+
|
|
539
|
+
## Cache
|
|
540
|
+
|
|
541
|
+
The tool caches a small amount of discovery metadata locally:
|
|
542
|
+
|
|
543
|
+
- API root
|
|
544
|
+
- schema
|
|
545
|
+
- endpoint `OPTIONS` metadata
|
|
546
|
+
|
|
547
|
+
This cache improves discovery, filter help, choice lookups, and autocomplete responsiveness.
|
|
548
|
+
|
|
549
|
+
Use this command to clear it:
|
|
550
|
+
|
|
551
|
+
```bash
|
|
552
|
+
netbox cache clear
|
|
553
|
+
```
|
|
554
|
+
|
|
555
|
+
`netbox cache clear` is the supported reset path. There is no `--no-cache` flag.
|
|
556
|
+
|
|
557
|
+
## Project Layout
|
|
558
|
+
|
|
559
|
+
The codebase is split by responsibility:
|
|
560
|
+
|
|
561
|
+
```text
|
|
562
|
+
netbox_cli/
|
|
563
|
+
app.py
|
|
564
|
+
client.py
|
|
565
|
+
config.py
|
|
566
|
+
discovery.py
|
|
567
|
+
query.py
|
|
568
|
+
search.py
|
|
569
|
+
render.py
|
|
570
|
+
cache.py
|
|
571
|
+
profiles.py
|
|
572
|
+
repl/
|
|
573
|
+
shell.py
|
|
574
|
+
state.py
|
|
575
|
+
commands.py
|
|
576
|
+
completer.py
|
|
577
|
+
metadata.py
|
|
578
|
+
tests/
|
|
579
|
+
...
|
|
580
|
+
```
|
|
581
|
+
|
|
582
|
+
## Known Limitations
|
|
583
|
+
|
|
584
|
+
- v1 is read-only
|
|
585
|
+
- the shell is line-oriented, not a full-screen TUI
|
|
586
|
+
- autocomplete is best-effort when metadata is incomplete or unavailable
|
|
587
|
+
- plugin endpoints are handled gracefully, but depend on what your NetBox instance exposes
|
|
588
|
+
- endpoint-specific filter support depends on the schema and metadata provided by your NetBox instance
|