NetBox Labs, Diode SDK
项目描述
Diode SDK Python
Diode SDK Python是一个用于利用gRPC与Diode摄入服务交互的Python库。
Diode是一个新的NetBox摄入服务,极大地简化并增强了在NetBox中添加和更新网络数据的过程,确保您的网络真相源始终准确且值得信赖,可用于驱动您的网络自动化流程。
有关Diode的更多信息,请参阅https://netboxlabs.com/blog/introducing-diode-streamlining-data-ingestion-in-netbox/。
安装
pip install netboxlabs-diode-sdk
用法
环境变量
DIODE_API_KEY
- Diode服务的API密钥DIODE_SDK_LOG_LEVEL
- SDK的日志级别(默认:INFO
)DIODE_SENTRY_DSN
- 可选的Sentry DSN用于错误报告
示例
target
应为Diode服务的地址,例如不安全连接的grpc://localhost:8081
或安全连接的grpcs://example.com
。
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()
支持实体(对象类型)
开发笔记
netboxlabs/diode/sdk/diode/*
中的代码由Protocol Buffers定义生成(将很快发布并在此引用)。
代码检查
ruff netboxlabs/
black netboxlabs/
测试
pytest tests/
许可证
在Apache 2.0许可证下分发。更多信息请见LICENSE.txt。
项目详情
关闭
netboxlabs-diode-sdk-0.4.0.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 09649fcf84989e1bebe583c42239103ff0b3f3c4974ff36a96d0828b639396ab |
|
MD5 | 5980a56b915ea131839b3867ce67a83f |
|
BLAKE2b-256 | dd22d458a0faa7b2ad3998eceb4e05ac28827e7680913f4a8ff072f7467db3e3 |