Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Diode Python SDK - Entity Examples

Source: NetBox v4.5.0
Generated: 2026-02-17 23:39:38Z
Source: NetBox v4.6.0
Generated: 2026-05-14 20:30:15Z

## Prerequisites

Expand Down Expand Up @@ -126,7 +126,11 @@ Switch between patterns by uncommenting the desired function call in `main()`.

### Other

- [CableBundle](examples/cable_bundle.py)
- [DeviceConfig](examples/device_config.py)
- [RackGroup](examples/rack_group.py)
- [ScriptModule](examples/script_module.py)
- [VirtualMachineType](examples/virtual_machine_type.py)

### Tenancy

Expand Down
5 changes: 5 additions & 0 deletions docs/examples/asn.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
Owner,
OwnerGroup,
RIR,
Role,
Tag,
Tenant,
)
Expand Down Expand Up @@ -63,6 +64,7 @@ def asn_extended() -> ASN:
rir="Example RIR",
tenant="Example Tenant",
comments="Example comments",
role="Example Role",
)


Expand All @@ -88,6 +90,9 @@ def asn_explicit() -> ASN:
group=OwnerGroup(name="Example Name", metadata={"source": "example"}),
metadata={"source": "example"},
),
role=Role(
name="Example Name", slug="example-slug", metadata={"source": "example"}
),
tags=[Tag(name="production")],
)

Expand Down
6 changes: 4 additions & 2 deletions docs/examples/cable.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from netboxlabs.diode.sdk import DiodeClient
from netboxlabs.diode.sdk.ingester import (
Cable,
CableBundle,
Entity,
Owner,
OwnerGroup,
Expand Down Expand Up @@ -65,7 +66,7 @@ def cable_extended() -> Cable:
length=1.0,
length_unit="cm",
comments="Example comments",
profile="breakout-1c4p-4c1p",
profile="breakout-1c2p-2c1p",
)


Expand All @@ -85,7 +86,7 @@ def cable_explicit() -> Cable:
label="Example Label",
length=1.0,
length_unit="cm",
profile="breakout-1c4p-4c1p",
profile="breakout-1c2p-2c1p",
tenant=Tenant(
name="Example Name", slug="example-slug", metadata={"source": "example"}
),
Expand All @@ -94,6 +95,7 @@ def cable_explicit() -> Cable:
group=OwnerGroup(name="Example Name", metadata={"source": "example"}),
metadata={"source": "example"},
),
bundle=CableBundle(name="Example Name", metadata={"source": "example"}),
tags=[Tag(name="production")],
)

Expand Down
86 changes: 86 additions & 0 deletions docs/examples/cable_bundle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
"""
CableBundle entity examples for the Diode Python SDK.

This module demonstrates three patterns for ingesting CableBundle entities:
- cable_bundle_minimal: Required fields only
- cable_bundle_extended: Common optional fields
- cable_bundle_explicit: Fully nested objects with all fields
"""

from netboxlabs.diode.sdk import DiodeClient
from netboxlabs.diode.sdk.ingester import (
CableBundle,
Entity,
Owner,
OwnerGroup,
Tag,
)

TARGET = "grpc://localhost:8080/diode"
APP_NAME = "cable_bundle-example"
APP_VERSION = "1.0.0"
CLIENT_ID = "diode"
CLIENT_SECRET = "changeme"


def main():
"""Main execution - demonstrates ingesting a CableBundle entity."""
with DiodeClient(
target=TARGET,
app_name=APP_NAME,
app_version=APP_VERSION,
client_id=CLIENT_ID,
client_secret=CLIENT_SECRET,
) as client:
# Choose one of the three patterns:
cable_bundle = cable_bundle_minimal()
# cable_bundle = cable_bundle_extended()
# cable_bundle = cable_bundle_explicit()

response = client.ingest(entities=[Entity(cable_bundle=cable_bundle)])
if response.errors:
print(f"Errors: {response.errors}")
else:
print("CableBundle ingested successfully")


def cable_bundle_minimal() -> CableBundle:
"""Create a CableBundle with only required fields using flat strings."""
return CableBundle(
name="Example Name",
metadata={"source": "example"},
)


def cable_bundle_extended() -> CableBundle:
"""Create a CableBundle with common optional fields."""
return CableBundle(
name="Example Name",
metadata={"source": "example", "custom_key": "custom_value"},
description="Example description",
comments="Example comments",
)


def cable_bundle_explicit() -> CableBundle:
"""Create a CableBundle with fully nested objects and all common fields."""
return CableBundle(
name="Example Name",
metadata={
"source": "example",
"custom_key": "custom_value",
"collected_at": "2024-01-15T10:30:00Z",
},
description="Example description",
comments="Example comments",
owner=Owner(
name="Example Name",
group=OwnerGroup(name="Example Name", metadata={"source": "example"}),
metadata={"source": "example"},
),
tags=[Tag(name="production")],
)


if __name__ == "__main__":
main()
4 changes: 4 additions & 0 deletions docs/examples/cable_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
"""

from netboxlabs.diode.sdk import DiodeClient
from netboxlabs.diode.sdk.ingester import (
CablePath,
Entity,
)

TARGET = "grpc://localhost:8080/diode"
APP_NAME = "cable_path-example"
Expand Down
2 changes: 2 additions & 0 deletions docs/examples/custom_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def custom_field_extended() -> CustomField:
validation_maximum=1.0,
validation_regex="Example Validation Regex",
comments="Example comments",
validation_schema="Example Validation Schema",
)


Expand Down Expand Up @@ -108,6 +109,7 @@ def custom_field_explicit() -> CustomField:
validation_minimum=1.0,
validation_maximum=1.0,
validation_regex="Example Validation Regex",
validation_schema="Example Validation Schema",
choice_set=CustomFieldChoiceSet(
name="Example Name", metadata={"source": "example"}
),
Expand Down
2 changes: 2 additions & 0 deletions docs/examples/custom_field_choice_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def custom_field_choice_set_extended() -> CustomFieldChoiceSet:
description="Example description",
base_choices="IATA",
order_alphabetically=True,
choice_colors="Example Choice Colors",
)


Expand All @@ -76,6 +77,7 @@ def custom_field_choice_set_explicit() -> CustomFieldChoiceSet:
description="Example description",
base_choices="IATA",
order_alphabetically=True,
choice_colors="Example Choice Colors",
owner=Owner(
name="Example Name",
group=OwnerGroup(name="Example Name", metadata={"source": "example"}),
Expand Down
2 changes: 2 additions & 0 deletions docs/examples/device_bay.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def device_bay_extended() -> DeviceBay:
metadata={"source": "example", "custom_key": "custom_value"},
description="Example description",
label="Example Label",
enabled=True,
)


Expand Down Expand Up @@ -106,6 +107,7 @@ def device_bay_explicit() -> DeviceBay:
},
description="Example description",
label="Example Label",
enabled=True,
installed_device=Device(
device_type=DeviceType(
manufacturer=Manufacturer(
Expand Down
4 changes: 4 additions & 0 deletions docs/examples/device_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
"""

from netboxlabs.diode.sdk import DiodeClient
from netboxlabs.diode.sdk.ingester import (
DeviceConfig,
Entity,
)

TARGET = "grpc://localhost:8080/diode"
APP_NAME = "device_config-example"
Expand Down
6 changes: 3 additions & 3 deletions docs/examples/interface_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def interface_example_minimal() -> Interface:
return Interface(
device="Example Device", # flat string -> Device
name="Example Name",
type="1000base-bx10-d",
type="1.6tbase-cr8",
metadata={"source": "example"},
)

Expand All @@ -71,7 +71,7 @@ def interface_example_extended() -> Interface:
return Interface(
device="Example Device",
name="Example Name",
type="1000base-bx10-d",
type="1.6tbase-cr8",
metadata={"source": "example", "custom_key": "custom_value"},
description="Example description",
label="Example Label",
Expand Down Expand Up @@ -123,7 +123,7 @@ def interface_example_explicit() -> Interface:
metadata={"source": "example"},
),
name="Example Name",
type="1000base-bx10-d",
type="1.6tbase-cr8",
metadata={
"source": "example",
"custom_key": "custom_value",
Expand Down
4 changes: 4 additions & 0 deletions docs/examples/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ def module_extended() -> Module:
description="Example description",
asset_tag="ASSET-001",
comments="Example comments",
replicate_components=True,
adopt_components=True,
)


Expand Down Expand Up @@ -152,6 +154,8 @@ def module_explicit() -> Module:
description="Example description",
comments="Example comments",
asset_tag="ASSET-001",
replicate_components=True,
adopt_components=True,
owner=Owner(
name="Example Name",
group=OwnerGroup(name="Example Name", metadata={"source": "example"}),
Expand Down
2 changes: 2 additions & 0 deletions docs/examples/module_bay.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def module_bay_extended() -> ModuleBay:
description="Example description",
label="Example Label",
position="Example Position",
enabled=True,
)


Expand Down Expand Up @@ -110,6 +111,7 @@ def module_bay_explicit() -> ModuleBay:
description="Example description",
label="Example Label",
position="Example Position",
enabled=True,
module=Module(
device=Device(
device_type=DeviceType(
Expand Down
4 changes: 4 additions & 0 deletions docs/examples/owner_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
"""

from netboxlabs.diode.sdk import DiodeClient
from netboxlabs.diode.sdk.ingester import (
Entity,
OwnerGroup,
)

TARGET = "grpc://localhost:8080/diode"
APP_NAME = "owner_group-example"
Expand Down
4 changes: 4 additions & 0 deletions docs/examples/rack.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
Owner,
OwnerGroup,
Rack,
RackGroup,
RackRole,
RackType,
Site,
Expand Down Expand Up @@ -160,6 +161,9 @@ def rack_explicit() -> Rack:
group=OwnerGroup(name="Example Name", metadata={"source": "example"}),
metadata={"source": "example"},
),
group=RackGroup(
name="Example Name", slug="example-slug", metadata={"source": "example"}
),
tags=[Tag(name="production")],
)

Expand Down
Loading
Loading