Git Product home page Git Product logo

diode-sdk-python's Introduction

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.

diode-sdk-python's People

Contributors

mfiedorowicz avatar weyrick avatar dependabot[bot] avatar

Stargazers

 avatar Amanda Rodrigues avatar Rich Bibby avatar Kris Beevers avatar Richard Boucher avatar Mark Robert Coleman avatar  avatar Leonardo Parente avatar  avatar

Watchers

Damien Garros avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.