Diode SDK Python is a Python library for interacting with the Diode ingestion service utilizing gRPC.
Diode is a new NetBox ingestion service that greatly simplifies and enhances the process to add and update network data in NetBox, ensuring your network source of truth is always accurate and can be trusted to power your network automation pipelines.
More information about Diode can be found at https://netboxlabs.com/blog/introducing-diode-streamlining-data-ingestion-in-netbox/.
pip install netboxlabs-diode-sdk
DIODE_API_KEY
- API key for the Diode serviceDIODE_SDK_LOG_LEVEL
- Log level for the SDK (default:INFO
)DIODE_SENTRY_DSN
- Optional Sentry DSN for error reporting
target
should be the address of the Diode service, e.g.grpc://localhost:8080/diode
for insecure connection orgrpcs://example.com
for secure connection.
from netboxlabs.diode.sdk import DiodeClient
from netboxlabs.diode.sdk.ingester import (
Device,
Entity,
)
def main():
with DiodeClient(
target="grpc://localhost:8080/diode",
app_name="my-test-app",
app_version="0.0.1",
) as client:
entities = []
"""
Ingest device with device type, platform, manufacturer, site, role, and tags.
"""
device = Device(
name="Device A",
device_type="Device Type A",
platform="Platform A",
manufacturer="Manufacturer A",
site="Site ABC",
role="Role ABC",
serial="123456",
asset_tag="123456",
status="active",
tags=["tag 1", "tag 2"],
)
entities.append(Entity(device=device))
response = client.ingest(entities=entities)
if response.errors:
print(f"Errors: {response.errors}")
if __name__ == "__main__":
main()
- Device
- Interface
- Device Type
- Platform
- Manufacturer
- Site
- Role
- IP Address
- Prefix
- Cluster Group
- Cluster Type
- Cluster
- Virtual Machine
- Virtual Disk
- VM Interface
Code in netboxlabs/diode/sdk/diode/*
is generated from Protocol Buffers definitions (will be published and referred
here soon).
ruff netboxlabs/
black netboxlabs/
pytest tests/
Distributed under the Apache 2.0 License. See LICENSE.txt for more information.