Skip to main content

NetBox Labs, Diode SDK

Project description

Diode SDK Python

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/.

Installation

pip install netboxlabs-diode-sdk

Usage

Environment variables

  • DIODE_API_KEY - API key for the Diode service
  • DIODE_SDK_LOG_LEVEL - Log level for the SDK (default: INFO)
  • DIODE_SENTRY_DSN - Optional Sentry DSN for error reporting

Example

  • target should be the address of the Diode service, e.g. grpc://localhost:8081 for insecure connection or grpcs://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:8081",
        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()

Supported entities (object types)

Development notes

Code in netboxlabs/diode/sdk/diode/* is generated from Protocol Buffers definitions (will be published and referred here soon).

Linting

ruff netboxlabs/
black netboxlabs/

Testing

pytest tests/

License

Distributed under the Apache 2.0 License. See LICENSE.txt for more information.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

netboxlabs-diode-sdk-0.1.0.tar.gz (36.2 kB view details)

Uploaded Source

File details

Details for the file netboxlabs-diode-sdk-0.1.0.tar.gz.

File metadata

  • Download URL: netboxlabs-diode-sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 36.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for netboxlabs-diode-sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 807ebbaee2820c14e5757a01266dbfb84d1e3387206b749497f14acfec92c5fd
MD5 8e6af866c840c9ae1e10d3b19ba850af
BLAKE2b-256 c9d60a12217d0be4c31c73ae92e6398b62df5a143e7f54acf063f6e8e32e8d60

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page