Skip to content

Commit 812887c

Browse files
authored
chore: entity docs (#62)
Code examples include all known entities as generated directly from NetBox
1 parent f8eace7 commit 812887c

195 files changed

Lines changed: 12441 additions & 501 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 1 addition & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func main() {
117117
}
118118
```
119119

120-
See all [examples](./examples/main.go) for reference.
120+
See all [entities examples](./docs/README.md).
121121

122122
### Using Metadata
123123

@@ -665,95 +665,6 @@ repeat `-file` to specify multiple files. OAuth2
665665
credentials can be supplied using `-client-id` and `-client-secret` or the
666666
`DIODE_CLIENT_ID` and `DIODE_CLIENT_SECRET` environment variables.
667667

668-
## Supported entities (object types)
669-
670-
* ASN
671-
* ASN Range
672-
* Aggregate
673-
* Circuit
674-
* Circuit Group
675-
* Circuit Group Assignment
676-
* Circuit Termination
677-
* Circuit Type
678-
* Cluster
679-
* Cluster Group
680-
* Cluster Type
681-
* Console Port
682-
* Console Server Port
683-
* Contact
684-
* Contact Assignment
685-
* Contact Group
686-
* Contact Role
687-
* Device
688-
* Device Bay
689-
* Device Role
690-
* Device Type
691-
* FHRP Group
692-
* FHRP Group Assignment
693-
* Front Port
694-
* IKE Policy
695-
* IKE Proposal
696-
* IP Address
697-
* IP Range
698-
* IP Sec Policy
699-
* IP Sec Profile
700-
* IP Sec Proposal
701-
* Interface
702-
* Inventory Item
703-
* Inventory Item Role
704-
* L2VPN
705-
* L2VPN Termination
706-
* Location
707-
* MAC Address
708-
* Manufacturer
709-
* Module
710-
* Module Bay
711-
* Module Type
712-
* Owner
713-
* Owner Group
714-
* Platform
715-
* Power Feed
716-
* Power Outlet
717-
* Power Panel
718-
* Power Port
719-
* Prefix
720-
* Provider
721-
* Provider Account
722-
* Provider Network
723-
* RIR
724-
* Rack
725-
* Rack Role
726-
* Rack Type
727-
* Rear Port
728-
* Region
729-
* Role
730-
* Route Target
731-
* Service
732-
* Site
733-
* Site Group
734-
* Tag
735-
* Tenant
736-
* Tenant Group
737-
* Tunnel
738-
* Tunnel Group
739-
* Tunnel Termination
740-
* VLAN
741-
* VLAN Group
742-
* VLAN Translation Policy
743-
* VLAN Translation Rule
744-
* VM Interface
745-
* VRF
746-
* Virtual Chassis
747-
* Virtual Circuit
748-
* Virtual Circuit Termination
749-
* Virtual Circuit Type
750-
* Virtual Device Context
751-
* Virtual Disk
752-
* Virtual Machine
753-
* Wireless Lan
754-
* Wireless Lan Group
755-
* Wireless Link
756-
757668
#### Linting
758669

759670
```shell

docs/README.md

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
# Diode Go SDK - Entity Examples
2+
3+
Source: NetBox v4.5.0
4+
Generated: 2026-02-13 17:55:35Z
5+
6+
## Prerequisites
7+
8+
- Go 1.25 or later
9+
- Diode SDK for Go
10+
11+
## Installation
12+
13+
```bash
14+
go get github.com/netboxlabs/diode-sdk-go@latest
15+
```
16+
17+
## Configuration
18+
19+
Each example uses constants for configuration. You can modify these in the example code:
20+
21+
```go
22+
target = "grpc://localhost:8080/diode"
23+
appName = "example-app"
24+
appVersion = "1.0.0"
25+
```
26+
27+
## Quick Start
28+
29+
Each entity example is in its own directory with a complete Go module. To run an example:
30+
31+
```bash
32+
cd examples/device
33+
go run main.go
34+
```
35+
36+
## Example Patterns
37+
38+
Each example includes three patterns:
39+
40+
- **Minimal**: Only required fields
41+
- **Extended**: Required fields plus common optional fields
42+
- **Explicit**: Fully nested objects with all common fields
43+
44+
Switch between patterns by uncommenting the desired function call in `main()`.
45+
46+
## Available Entity Examples
47+
48+
### Circuits
49+
50+
- [Circuit](examples/circuit/)
51+
- [CircuitGroup](examples/circuit_group/)
52+
- [CircuitGroupAssignment](examples/circuit_group_assignment/)
53+
- [CircuitTermination](examples/circuit_termination/)
54+
- [CircuitType](examples/circuit_type/)
55+
- [Provider](examples/provider/)
56+
- [ProviderAccount](examples/provider_account/)
57+
- [ProviderNetwork](examples/provider_network/)
58+
- [VirtualCircuit](examples/virtual_circuit/)
59+
- [VirtualCircuitTermination](examples/virtual_circuit_termination/)
60+
- [VirtualCircuitType](examples/virtual_circuit_type/)
61+
62+
### DCIM
63+
64+
- [Cable](examples/cable/)
65+
- [CablePath](examples/cable_path/)
66+
- [CableTermination](examples/cable_termination/)
67+
- [ConsolePort](examples/console_port/)
68+
- [ConsoleServerPort](examples/console_server_port/)
69+
- [Device](examples/device/)
70+
- [DeviceBay](examples/device_bay/)
71+
- [DeviceRole](examples/device_role/)
72+
- [DeviceType](examples/device_type/)
73+
- [FrontPort](examples/front_port/)
74+
- [Interface](examples/interface_entity/)
75+
- [InventoryItem](examples/inventory_item/)
76+
- [InventoryItemRole](examples/inventory_item_role/)
77+
- [Location](examples/location/)
78+
- [Manufacturer](examples/manufacturer/)
79+
- [Module](examples/module/)
80+
- [ModuleBay](examples/module_bay/)
81+
- [ModuleType](examples/module_type/)
82+
- [ModuleTypeProfile](examples/module_type_profile/)
83+
- [Platform](examples/platform/)
84+
- [PowerFeed](examples/power_feed/)
85+
- [PowerOutlet](examples/power_outlet/)
86+
- [PowerPanel](examples/power_panel/)
87+
- [PowerPort](examples/power_port/)
88+
- [Rack](examples/rack/)
89+
- [RackReservation](examples/rack_reservation/)
90+
- [RackRole](examples/rack_role/)
91+
- [RackType](examples/rack_type/)
92+
- [RearPort](examples/rear_port/)
93+
- [Region](examples/region/)
94+
- [Site](examples/site/)
95+
- [SiteGroup](examples/site_group/)
96+
- [VirtualChassis](examples/virtual_chassis/)
97+
- [VirtualDeviceContext](examples/virtual_device_context/)
98+
99+
### Extras
100+
101+
- [CustomField](examples/custom_field/)
102+
- [CustomFieldChoiceSet](examples/custom_field_choice_set/)
103+
- [CustomLink](examples/custom_link/)
104+
- [JournalEntry](examples/journal_entry/)
105+
- [Tag](examples/tag/)
106+
107+
### IPAM
108+
109+
- [ASN](examples/asn/)
110+
- [ASNRange](examples/asn_range/)
111+
- [Aggregate](examples/aggregate/)
112+
- [FHRPGroup](examples/fhrp_group/)
113+
- [FHRPGroupAssignment](examples/fhrp_group_assignment/)
114+
- [IPAddress](examples/ip_address/)
115+
- [IPRange](examples/ip_range/)
116+
- [MACAddress](examples/mac_address/)
117+
- [Prefix](examples/prefix/)
118+
- [RIR](examples/rir/)
119+
- [Role](examples/role/)
120+
- [RouteTarget](examples/route_target/)
121+
- [Service](examples/service/)
122+
- [VLAN](examples/vlan/)
123+
- [VLANGroup](examples/vlan_group/)
124+
- [VLANTranslationPolicy](examples/vlan_translation_policy/)
125+
- [VLANTranslationRule](examples/vlan_translation_rule/)
126+
- [VRF](examples/vrf/)
127+
128+
### Other
129+
130+
- [DeviceConfig](examples/device_config/)
131+
132+
### Tenancy
133+
134+
- [Contact](examples/contact/)
135+
- [ContactAssignment](examples/contact_assignment/)
136+
- [ContactGroup](examples/contact_group/)
137+
- [ContactRole](examples/contact_role/)
138+
- [Owner](examples/owner/)
139+
- [OwnerGroup](examples/owner_group/)
140+
- [Tenant](examples/tenant/)
141+
- [TenantGroup](examples/tenant_group/)
142+
143+
### VPN
144+
145+
- [IKEPolicy](examples/ike_policy/)
146+
- [IKEProposal](examples/ike_proposal/)
147+
- [IPSecPolicy](examples/ip_sec_policy/)
148+
- [IPSecProfile](examples/ip_sec_profile/)
149+
- [IPSecProposal](examples/ip_sec_proposal/)
150+
- [L2VPN](examples/l2vpn/)
151+
- [L2VPNTermination](examples/l2vpn_termination/)
152+
- [Tunnel](examples/tunnel/)
153+
- [TunnelGroup](examples/tunnel_group/)
154+
- [TunnelTermination](examples/tunnel_termination/)
155+
156+
### Virtualization
157+
158+
- [Cluster](examples/cluster/)
159+
- [ClusterGroup](examples/cluster_group/)
160+
- [ClusterType](examples/cluster_type/)
161+
- [VMInterface](examples/vm_interface/)
162+
- [VirtualDisk](examples/virtual_disk/)
163+
- [VirtualMachine](examples/virtual_machine/)
164+
165+
### Wireless
166+
167+
- [WirelessLAN](examples/wireless_lan/)
168+
- [WirelessLANGroup](examples/wireless_lan_group/)
169+
- [WirelessLink](examples/wireless_link/)

docs/examples/aggregate/go.mod

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module aggregate
2+
3+
go 1.25
4+
5+
require github.com/netboxlabs/diode-sdk-go
6+
7+
// Use local SDK for development and validation
8+
// When copying this example, remove the replace directive and update the require version above
9+
replace github.com/netboxlabs/diode-sdk-go => ../../..

docs/examples/aggregate/main.go

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
// Package main demonstrates ingesting Aggregate entities using the Diode SDK.
2+
// This example includes three patterns: Minimal, Extended, and Explicit.
3+
package main
4+
5+
import (
6+
"context"
7+
"log"
8+
9+
"github.com/netboxlabs/diode-sdk-go/diode"
10+
)
11+
12+
const (
13+
target = "grpc://localhost:8080/diode"
14+
appName = "aggregate-example"
15+
appVersion = "1.0.0"
16+
)
17+
18+
func main() {
19+
client, err := diode.NewClient(
20+
target,
21+
appName,
22+
appVersion,
23+
)
24+
if err != nil {
25+
log.Fatalf("Failed to create client: %v", err)
26+
}
27+
28+
// Choose one of the three patterns by uncommenting:
29+
aggregate := AggregateMinimal()
30+
// aggregate := AggregateExtended()
31+
// aggregate := AggregateExplicit()
32+
33+
resp, err := client.Ingest(context.Background(), []diode.Entity{aggregate})
34+
if err != nil {
35+
log.Fatalf("Ingestion failed: %v", err)
36+
}
37+
if resp.Errors != nil {
38+
log.Printf("Errors: %v", resp.Errors)
39+
} else {
40+
log.Println("Aggregate ingested successfully")
41+
}
42+
}
43+
44+
// AggregateMinimal Creates a Aggregate with only required fields.
45+
func AggregateMinimal() *diode.Aggregate {
46+
return &diode.Aggregate{
47+
Prefix: diode.String("192.0.2.0/24"),
48+
Rir: &diode.RIR{
49+
Name: diode.String("Example Name"),
50+
Slug: diode.String("example-slug"),
51+
Metadata: diode.Metadata{"source": "example"},
52+
},
53+
Metadata: diode.Metadata{"source": "example"},
54+
}
55+
}
56+
57+
// AggregateExtended Creates a Aggregate with common optional fields.
58+
func AggregateExtended() *diode.Aggregate {
59+
return &diode.Aggregate{
60+
Prefix: diode.String("192.0.2.0/24"),
61+
Rir: &diode.RIR{
62+
Name: diode.String("Example Name"),
63+
Slug: diode.String("example-slug"),
64+
Metadata: diode.Metadata{"source": "example"},
65+
},
66+
Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"},
67+
Description: diode.String("Example description"),
68+
Comments: diode.String("Example comments"),
69+
}
70+
}
71+
72+
// AggregateExplicit Creates a Aggregate with fully nested objects and all common fields.
73+
func AggregateExplicit() *diode.Aggregate {
74+
return &diode.Aggregate{
75+
Prefix: diode.String("192.0.2.0/24"),
76+
Rir: &diode.RIR{
77+
Name: diode.String("Example Name"),
78+
Slug: diode.String("example-slug"),
79+
Metadata: diode.Metadata{"source": "example"},
80+
},
81+
Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"},
82+
Description: diode.String("Example description"),
83+
Comments: diode.String("Example comments"),
84+
Tenant: &diode.Tenant{
85+
Name: diode.String("Example Name"),
86+
Slug: diode.String("example-slug"),
87+
Metadata: diode.Metadata{"source": "example"},
88+
},
89+
Owner: &diode.Owner{
90+
Name: diode.String("Example Name"),
91+
Group: &diode.OwnerGroup{
92+
Name: diode.String("Example Name"),
93+
Metadata: diode.Metadata{"source": "example"},
94+
},
95+
Metadata: diode.Metadata{"source": "example"},
96+
},
97+
Tags: []*diode.Tag{{Name: diode.String("production")}},
98+
}
99+
}

docs/examples/asn/go.mod

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module asn
2+
3+
go 1.25
4+
5+
require github.com/netboxlabs/diode-sdk-go
6+
7+
// Use local SDK for development and validation
8+
// When copying this example, remove the replace directive and update the require version above
9+
replace github.com/netboxlabs/diode-sdk-go => ../../..

0 commit comments

Comments
 (0)