netbox.rs
rust client for the netbox 4.x rest api. it was co-evolved using ai. pre-release, but stable and improving.
features
- ergonomic, typed api
- automatic pagination
- query builder for filters
- token auth
- configurable timeouts, retries, ssl
- graphql (read-only) helper
- documented examples
- unit tests and smoke tests
install
add to Cargo.toml:
[]
= "0.2.1"
= { = "1.0", = ["full"] }
version compatibility
current releases are pre-1.0.0 and do not track netbox versions. this client targets netbox 4.x. patch releases include fixes and client improvements.
quick start
use ;
async
examples
for a fuller client guide, see crates/netbox/docs/client.md.
for a docs index, see docs/index.md.
for runnable examples, see crates/netbox/examples/README.md.
auth
use ClientConfig;
let config = new
.with_timeout
.with_max_retries
.with_ssl_verification;
let client = new?;
list with filters
use QueryBuilder;
let query = new
.filter
.filter
.limit
.order_by;
let devices = client.dcim.devices.list.await?;
println!;
pagination
let mut paginator = client.dcim.devices.paginate?;
while let Some = paginator.next_page.await?
let all_devices = client
.dcim
.devices
.paginate?
.collect_all
.await?;
bulk operations
use ;
let updates = vec!;
client.dcim.devices.bulk_patch.await?;
let deletes = vec!;
client.dcim.devices.bulk_delete.await?;
status and schema
let status = client.status.status.await?;
println!;
let schema = client.schema.schema.await?;
println!;
graphql (read-only)
let data = client
.graphql
.query
.await?;
println!;
connected device lookup
let devices = client
.dcim
.connected_device
.await?;
println!;
branching plugin
let branches = client.plugins.branches.list.await?;
println!;
error handling
use Error;
match client.dcim.devices.get.await
cli
netbox-cli is a full-featured cli for the netbox api. it covers standard crud resources and exposes a raw mode for any endpoint.
see crates/netbox-cli/docs/cli.md for a complete guide.
install:
quickstart:
common commands:
create or update with json:
raw requests:
output formats and selection:
dry run for writes:
graphql:
run netbox-cli --help for all subcommands.
api coverage
all core netbox modules are covered via typed Resource<T> wrappers. additional endpoints include status, schema, connected-device, and netbox-branching plugin resources.
note: paginate returns Result<Paginator<T>>; handle errors before calling next_page.
for endpoints not wrapped yet, use the generated openapi client:
use ;
use dcim_api;
# async
development
prerequisites
- rust 1.85+
- a netbox instance for schema generation and smoke tests
setup
docs
RUSTDOCFLAGS="--cfg docsrs"
open target/doc/netbox/index.html for the library docs.
regenerate api bindings
see scripts/README.md for details.
basic flow:
for container setup, follow the netbox-docker instructions: https://github.com/netbox-community/netbox-docker
contributing
see CONTRIBUTING.md.
license
mit. see LICENSE.