diff --git a/README.md b/README.md index 2e1b2e9..b35bc37 100644 --- a/README.md +++ b/README.md @@ -117,7 +117,7 @@ func main() { } ``` -See all [examples](./examples/main.go) for reference. +See all [entities examples](./docs/README.md). ### Using Metadata @@ -665,95 +665,6 @@ repeat `-file` to specify multiple files. OAuth2 credentials can be supplied using `-client-id` and `-client-secret` or the `DIODE_CLIENT_ID` and `DIODE_CLIENT_SECRET` environment variables. -## Supported entities (object types) - -* ASN -* ASN Range -* Aggregate -* Circuit -* Circuit Group -* Circuit Group Assignment -* Circuit Termination -* Circuit Type -* Cluster -* Cluster Group -* Cluster Type -* Console Port -* Console Server Port -* Contact -* Contact Assignment -* Contact Group -* Contact Role -* Device -* Device Bay -* Device Role -* Device Type -* FHRP Group -* FHRP Group Assignment -* Front Port -* IKE Policy -* IKE Proposal -* IP Address -* IP Range -* IP Sec Policy -* IP Sec Profile -* IP Sec Proposal -* Interface -* Inventory Item -* Inventory Item Role -* L2VPN -* L2VPN Termination -* Location -* MAC Address -* Manufacturer -* Module -* Module Bay -* Module Type -* Owner -* Owner Group -* Platform -* Power Feed -* Power Outlet -* Power Panel -* Power Port -* Prefix -* Provider -* Provider Account -* Provider Network -* RIR -* Rack -* Rack Role -* Rack Type -* Rear Port -* Region -* Role -* Route Target -* Service -* Site -* Site Group -* Tag -* Tenant -* Tenant Group -* Tunnel -* Tunnel Group -* Tunnel Termination -* VLAN -* VLAN Group -* VLAN Translation Policy -* VLAN Translation Rule -* VM Interface -* VRF -* Virtual Chassis -* Virtual Circuit -* Virtual Circuit Termination -* Virtual Circuit Type -* Virtual Device Context -* Virtual Disk -* Virtual Machine -* Wireless Lan -* Wireless Lan Group -* Wireless Link - #### Linting ```shell diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000..6dd99a8 --- /dev/null +++ b/docs/README.md @@ -0,0 +1,169 @@ +# Diode Go SDK - Entity Examples + +Source: NetBox v4.5.0 +Generated: 2026-02-13 17:55:35Z + +## Prerequisites + +- Go 1.25 or later +- Diode SDK for Go + +## Installation + +```bash +go get github.com/netboxlabs/diode-sdk-go@latest +``` + +## Configuration + +Each example uses constants for configuration. You can modify these in the example code: + +```go +target = "grpc://localhost:8080/diode" +appName = "example-app" +appVersion = "1.0.0" +``` + +## Quick Start + +Each entity example is in its own directory with a complete Go module. To run an example: + +```bash +cd examples/device +go run main.go +``` + +## Example Patterns + +Each example includes three patterns: + +- **Minimal**: Only required fields +- **Extended**: Required fields plus common optional fields +- **Explicit**: Fully nested objects with all common fields + +Switch between patterns by uncommenting the desired function call in `main()`. + +## Available Entity Examples + +### Circuits + +- [Circuit](examples/circuit/) +- [CircuitGroup](examples/circuit_group/) +- [CircuitGroupAssignment](examples/circuit_group_assignment/) +- [CircuitTermination](examples/circuit_termination/) +- [CircuitType](examples/circuit_type/) +- [Provider](examples/provider/) +- [ProviderAccount](examples/provider_account/) +- [ProviderNetwork](examples/provider_network/) +- [VirtualCircuit](examples/virtual_circuit/) +- [VirtualCircuitTermination](examples/virtual_circuit_termination/) +- [VirtualCircuitType](examples/virtual_circuit_type/) + +### DCIM + +- [Cable](examples/cable/) +- [CablePath](examples/cable_path/) +- [CableTermination](examples/cable_termination/) +- [ConsolePort](examples/console_port/) +- [ConsoleServerPort](examples/console_server_port/) +- [Device](examples/device/) +- [DeviceBay](examples/device_bay/) +- [DeviceRole](examples/device_role/) +- [DeviceType](examples/device_type/) +- [FrontPort](examples/front_port/) +- [Interface](examples/interface_entity/) +- [InventoryItem](examples/inventory_item/) +- [InventoryItemRole](examples/inventory_item_role/) +- [Location](examples/location/) +- [Manufacturer](examples/manufacturer/) +- [Module](examples/module/) +- [ModuleBay](examples/module_bay/) +- [ModuleType](examples/module_type/) +- [ModuleTypeProfile](examples/module_type_profile/) +- [Platform](examples/platform/) +- [PowerFeed](examples/power_feed/) +- [PowerOutlet](examples/power_outlet/) +- [PowerPanel](examples/power_panel/) +- [PowerPort](examples/power_port/) +- [Rack](examples/rack/) +- [RackReservation](examples/rack_reservation/) +- [RackRole](examples/rack_role/) +- [RackType](examples/rack_type/) +- [RearPort](examples/rear_port/) +- [Region](examples/region/) +- [Site](examples/site/) +- [SiteGroup](examples/site_group/) +- [VirtualChassis](examples/virtual_chassis/) +- [VirtualDeviceContext](examples/virtual_device_context/) + +### Extras + +- [CustomField](examples/custom_field/) +- [CustomFieldChoiceSet](examples/custom_field_choice_set/) +- [CustomLink](examples/custom_link/) +- [JournalEntry](examples/journal_entry/) +- [Tag](examples/tag/) + +### IPAM + +- [ASN](examples/asn/) +- [ASNRange](examples/asn_range/) +- [Aggregate](examples/aggregate/) +- [FHRPGroup](examples/fhrp_group/) +- [FHRPGroupAssignment](examples/fhrp_group_assignment/) +- [IPAddress](examples/ip_address/) +- [IPRange](examples/ip_range/) +- [MACAddress](examples/mac_address/) +- [Prefix](examples/prefix/) +- [RIR](examples/rir/) +- [Role](examples/role/) +- [RouteTarget](examples/route_target/) +- [Service](examples/service/) +- [VLAN](examples/vlan/) +- [VLANGroup](examples/vlan_group/) +- [VLANTranslationPolicy](examples/vlan_translation_policy/) +- [VLANTranslationRule](examples/vlan_translation_rule/) +- [VRF](examples/vrf/) + +### Other + +- [DeviceConfig](examples/device_config/) + +### Tenancy + +- [Contact](examples/contact/) +- [ContactAssignment](examples/contact_assignment/) +- [ContactGroup](examples/contact_group/) +- [ContactRole](examples/contact_role/) +- [Owner](examples/owner/) +- [OwnerGroup](examples/owner_group/) +- [Tenant](examples/tenant/) +- [TenantGroup](examples/tenant_group/) + +### VPN + +- [IKEPolicy](examples/ike_policy/) +- [IKEProposal](examples/ike_proposal/) +- [IPSecPolicy](examples/ip_sec_policy/) +- [IPSecProfile](examples/ip_sec_profile/) +- [IPSecProposal](examples/ip_sec_proposal/) +- [L2VPN](examples/l2vpn/) +- [L2VPNTermination](examples/l2vpn_termination/) +- [Tunnel](examples/tunnel/) +- [TunnelGroup](examples/tunnel_group/) +- [TunnelTermination](examples/tunnel_termination/) + +### Virtualization + +- [Cluster](examples/cluster/) +- [ClusterGroup](examples/cluster_group/) +- [ClusterType](examples/cluster_type/) +- [VMInterface](examples/vm_interface/) +- [VirtualDisk](examples/virtual_disk/) +- [VirtualMachine](examples/virtual_machine/) + +### Wireless + +- [WirelessLAN](examples/wireless_lan/) +- [WirelessLANGroup](examples/wireless_lan_group/) +- [WirelessLink](examples/wireless_link/) diff --git a/docs/examples/aggregate/go.mod b/docs/examples/aggregate/go.mod new file mode 100644 index 0000000..8d82770 --- /dev/null +++ b/docs/examples/aggregate/go.mod @@ -0,0 +1,9 @@ +module aggregate + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/aggregate/main.go b/docs/examples/aggregate/main.go new file mode 100644 index 0000000..c1173be --- /dev/null +++ b/docs/examples/aggregate/main.go @@ -0,0 +1,99 @@ +// Package main demonstrates ingesting Aggregate entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "aggregate-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + aggregate := AggregateMinimal() + // aggregate := AggregateExtended() + // aggregate := AggregateExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{aggregate}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("Aggregate ingested successfully") + } +} + +// AggregateMinimal Creates a Aggregate with only required fields. +func AggregateMinimal() *diode.Aggregate { + return &diode.Aggregate{ + Prefix: diode.String("192.0.2.0/24"), + Rir: &diode.RIR{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + } +} + +// AggregateExtended Creates a Aggregate with common optional fields. +func AggregateExtended() *diode.Aggregate { + return &diode.Aggregate{ + Prefix: diode.String("192.0.2.0/24"), + Rir: &diode.RIR{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + } +} + +// AggregateExplicit Creates a Aggregate with fully nested objects and all common fields. +func AggregateExplicit() *diode.Aggregate { + return &diode.Aggregate{ + Prefix: diode.String("192.0.2.0/24"), + Rir: &diode.RIR{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + Tenant: &diode.Tenant{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/asn/go.mod b/docs/examples/asn/go.mod new file mode 100644 index 0000000..698e31a --- /dev/null +++ b/docs/examples/asn/go.mod @@ -0,0 +1,9 @@ +module asn + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/asn/main.go b/docs/examples/asn/main.go new file mode 100644 index 0000000..f0e349b --- /dev/null +++ b/docs/examples/asn/main.go @@ -0,0 +1,89 @@ +// Package main demonstrates ingesting ASN entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "asn-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + asn := ASNMinimal() + // asn := ASNExtended() + // asn := ASNExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{asn}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("ASN ingested successfully") + } +} + +// ASNMinimal Creates a ASN with only required fields. +func ASNMinimal() *diode.ASN { + return &diode.ASN{ + Asn: diode.Int64(64512), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// ASNExtended Creates a ASN with common optional fields. +func ASNExtended() *diode.ASN { + return &diode.ASN{ + Asn: diode.Int64(64512), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + } +} + +// ASNExplicit Creates a ASN with fully nested objects and all common fields. +func ASNExplicit() *diode.ASN { + return &diode.ASN{ + Asn: diode.Int64(64512), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + Rir: &diode.RIR{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Tenant: &diode.Tenant{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/asn_range/go.mod b/docs/examples/asn_range/go.mod new file mode 100644 index 0000000..093aa52 --- /dev/null +++ b/docs/examples/asn_range/go.mod @@ -0,0 +1,9 @@ +module asn_range + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/asn_range/main.go b/docs/examples/asn_range/main.go new file mode 100644 index 0000000..1e56b61 --- /dev/null +++ b/docs/examples/asn_range/main.go @@ -0,0 +1,108 @@ +// Package main demonstrates ingesting ASNRange entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "asn_range-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + asnRange := ASNRangeMinimal() + // asnRange := ASNRangeExtended() + // asnRange := ASNRangeExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{asnRange}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("ASNRange ingested successfully") + } +} + +// ASNRangeMinimal Creates a ASNRange with only required fields. +func ASNRangeMinimal() *diode.ASNRange { + return &diode.ASNRange{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Rir: &diode.RIR{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Start: diode.Int64(1), + End: diode.Int64(1), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// ASNRangeExtended Creates a ASNRange with common optional fields. +func ASNRangeExtended() *diode.ASNRange { + return &diode.ASNRange{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Rir: &diode.RIR{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Start: diode.Int64(1), + End: diode.Int64(1), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + } +} + +// ASNRangeExplicit Creates a ASNRange with fully nested objects and all common fields. +func ASNRangeExplicit() *diode.ASNRange { + return &diode.ASNRange{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Rir: &diode.RIR{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Start: diode.Int64(1), + End: diode.Int64(1), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + Tenant: &diode.Tenant{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/cable/go.mod b/docs/examples/cable/go.mod new file mode 100644 index 0000000..f4d67b3 --- /dev/null +++ b/docs/examples/cable/go.mod @@ -0,0 +1,9 @@ +module cable + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/cable/main.go b/docs/examples/cable/main.go new file mode 100644 index 0000000..ce130b4 --- /dev/null +++ b/docs/examples/cable/main.go @@ -0,0 +1,95 @@ +// Package main demonstrates ingesting Cable entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "cable-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + cable := CableMinimal() + // cable := CableExtended() + // cable := CableExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{cable}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("Cable ingested successfully") + } +} + +// CableMinimal Creates a Cable with only required fields. +func CableMinimal() *diode.Cable { + return &diode.Cable{ + Metadata: diode.Metadata{"source": "example"}, + } +} + +// CableExtended Creates a Cable with common optional fields. +func CableExtended() *diode.Cable { + return &diode.Cable{ + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Status: diode.String("connected"), + Description: diode.String("Example description"), + Color: diode.String("0000ff"), + Type: diode.String("aoc"), + Label: diode.String("Example Label"), + Length: diode.Float64(1.0), + LengthUnit: diode.String("cm"), + Comments: diode.String("Example comments"), + Profile: diode.String("breakout-1c4p-4c1p"), + } +} + +// CableExplicit Creates a Cable with fully nested objects and all common fields. +func CableExplicit() *diode.Cable { + return &diode.Cable{ + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Status: diode.String("connected"), + Description: diode.String("Example description"), + Color: diode.String("0000ff"), + Comments: diode.String("Example comments"), + Type: diode.String("aoc"), + Label: diode.String("Example Label"), + Length: diode.Float64(1.0), + LengthUnit: diode.String("cm"), + Profile: diode.String("breakout-1c4p-4c1p"), + Tenant: &diode.Tenant{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/cable_path/go.mod b/docs/examples/cable_path/go.mod new file mode 100644 index 0000000..6621563 --- /dev/null +++ b/docs/examples/cable_path/go.mod @@ -0,0 +1,9 @@ +module cable_path + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/cable_path/main.go b/docs/examples/cable_path/main.go new file mode 100644 index 0000000..436e5e3 --- /dev/null +++ b/docs/examples/cable_path/main.go @@ -0,0 +1,69 @@ +// Package main demonstrates ingesting CablePath entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "cable_path-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + cablePath := CablePathMinimal() + // cablePath := CablePathExtended() + // cablePath := CablePathExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{cablePath}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("CablePath ingested successfully") + } +} + +// CablePathMinimal Creates a CablePath with only required fields. +func CablePathMinimal() *diode.CablePath { + return &diode.CablePath{ + Metadata: diode.Metadata{"source": "example"}, + } +} + +// CablePathExtended Creates a CablePath with common optional fields. +func CablePathExtended() *diode.CablePath { + return &diode.CablePath{ + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + IsActive: diode.Bool(true), + IsComplete: diode.Bool(true), + IsSplit: diode.Bool(true), + } +} + +// CablePathExplicit Creates a CablePath with fully nested objects and all common fields. +func CablePathExplicit() *diode.CablePath { + return &diode.CablePath{ + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + IsActive: diode.Bool(true), + IsComplete: diode.Bool(true), + IsSplit: diode.Bool(true), + } +} diff --git a/docs/examples/cable_termination/go.mod b/docs/examples/cable_termination/go.mod new file mode 100644 index 0000000..e0c32b0 --- /dev/null +++ b/docs/examples/cable_termination/go.mod @@ -0,0 +1,9 @@ +module cable_termination + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/cable_termination/main.go b/docs/examples/cable_termination/main.go new file mode 100644 index 0000000..08ea507 --- /dev/null +++ b/docs/examples/cable_termination/main.go @@ -0,0 +1,77 @@ +// Package main demonstrates ingesting CableTermination entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "cable_termination-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + cableTermination := CableTerminationMinimal() + // cableTermination := CableTerminationExtended() + // cableTermination := CableTerminationExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{cableTermination}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("CableTermination ingested successfully") + } +} + +// CableTerminationMinimal Creates a CableTermination with only required fields. +func CableTerminationMinimal() *diode.CableTermination { + return &diode.CableTermination{ + Cable: &diode.Cable{ + Metadata: diode.Metadata{"source": "example"}, + }, + CableEnd: diode.String("A"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// CableTerminationExtended Creates a CableTermination with common optional fields. +func CableTerminationExtended() *diode.CableTermination { + return &diode.CableTermination{ + Cable: &diode.Cable{ + Metadata: diode.Metadata{"source": "example"}, + }, + CableEnd: diode.String("A"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + } +} + +// CableTerminationExplicit Creates a CableTermination with fully nested objects and all common fields. +func CableTerminationExplicit() *diode.CableTermination { + return &diode.CableTermination{ + Cable: &diode.Cable{ + Status: diode.String("active"), + Color: diode.String("0000ff"), + Metadata: diode.Metadata{"source": "example"}, + }, + CableEnd: diode.String("A"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + } +} diff --git a/docs/examples/circuit/go.mod b/docs/examples/circuit/go.mod new file mode 100644 index 0000000..ce29978 --- /dev/null +++ b/docs/examples/circuit/go.mod @@ -0,0 +1,9 @@ +module circuit + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/circuit/main.go b/docs/examples/circuit/main.go new file mode 100644 index 0000000..bae407c --- /dev/null +++ b/docs/examples/circuit/main.go @@ -0,0 +1,132 @@ +// Package main demonstrates ingesting Circuit entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "circuit-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + circuit := CircuitMinimal() + // circuit := CircuitExtended() + // circuit := CircuitExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{circuit}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("Circuit ingested successfully") + } +} + +// CircuitMinimal Creates a Circuit with only required fields. +func CircuitMinimal() *diode.Circuit { + return &diode.Circuit{ + Cid: diode.String("CID-001"), + Provider: &diode.Provider{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Type: &diode.CircuitType{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + } +} + +// CircuitExtended Creates a Circuit with common optional fields. +func CircuitExtended() *diode.Circuit { + return &diode.Circuit{ + Cid: diode.String("CID-001"), + Provider: &diode.Provider{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Type: &diode.CircuitType{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Status: diode.String("active"), + Description: diode.String("Example description"), + CommitRate: diode.Int64(1), + Distance: diode.Float64(1.0), + DistanceUnit: diode.String("ft"), + Comments: diode.String("Example comments"), + } +} + +// CircuitExplicit Creates a Circuit with fully nested objects and all common fields. +func CircuitExplicit() *diode.Circuit { + return &diode.Circuit{ + Cid: diode.String("CID-001"), + Provider: &diode.Provider{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Type: &diode.CircuitType{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Color: diode.String("0000ff"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Status: diode.String("active"), + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + CommitRate: diode.Int64(1), + Distance: diode.Float64(1.0), + DistanceUnit: diode.String("ft"), + ProviderAccount: &diode.ProviderAccount{ + Provider: &diode.Provider{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Account: diode.String("Example Account"), + Metadata: diode.Metadata{"source": "example"}, + }, + Tenant: &diode.Tenant{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/circuit_group/go.mod b/docs/examples/circuit_group/go.mod new file mode 100644 index 0000000..c9faa51 --- /dev/null +++ b/docs/examples/circuit_group/go.mod @@ -0,0 +1,9 @@ +module circuit_group + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/circuit_group/main.go b/docs/examples/circuit_group/main.go new file mode 100644 index 0000000..1df206d --- /dev/null +++ b/docs/examples/circuit_group/main.go @@ -0,0 +1,87 @@ +// Package main demonstrates ingesting CircuitGroup entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "circuit_group-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + circuitGroup := CircuitGroupMinimal() + // circuitGroup := CircuitGroupExtended() + // circuitGroup := CircuitGroupExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{circuitGroup}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("CircuitGroup ingested successfully") + } +} + +// CircuitGroupMinimal Creates a CircuitGroup with only required fields. +func CircuitGroupMinimal() *diode.CircuitGroup { + return &diode.CircuitGroup{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// CircuitGroupExtended Creates a CircuitGroup with common optional fields. +func CircuitGroupExtended() *diode.CircuitGroup { + return &diode.CircuitGroup{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + } +} + +// CircuitGroupExplicit Creates a CircuitGroup with fully nested objects and all common fields. +func CircuitGroupExplicit() *diode.CircuitGroup { + return &diode.CircuitGroup{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + Tenant: &diode.Tenant{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/circuit_group_assignment/go.mod b/docs/examples/circuit_group_assignment/go.mod new file mode 100644 index 0000000..80625c2 --- /dev/null +++ b/docs/examples/circuit_group_assignment/go.mod @@ -0,0 +1,9 @@ +module circuit_group_assignment + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/circuit_group_assignment/main.go b/docs/examples/circuit_group_assignment/main.go new file mode 100644 index 0000000..a1d5bf0 --- /dev/null +++ b/docs/examples/circuit_group_assignment/main.go @@ -0,0 +1,81 @@ +// Package main demonstrates ingesting CircuitGroupAssignment entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "circuit_group_assignment-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + circuitGroupAssignment := CircuitGroupAssignmentMinimal() + // circuitGroupAssignment := CircuitGroupAssignmentExtended() + // circuitGroupAssignment := CircuitGroupAssignmentExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{circuitGroupAssignment}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("CircuitGroupAssignment ingested successfully") + } +} + +// CircuitGroupAssignmentMinimal Creates a CircuitGroupAssignment with only required fields. +func CircuitGroupAssignmentMinimal() *diode.CircuitGroupAssignment { + return &diode.CircuitGroupAssignment{ + Group: &diode.CircuitGroup{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + } +} + +// CircuitGroupAssignmentExtended Creates a CircuitGroupAssignment with common optional fields. +func CircuitGroupAssignmentExtended() *diode.CircuitGroupAssignment { + return &diode.CircuitGroupAssignment{ + Group: &diode.CircuitGroup{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Priority: diode.String("inactive"), + } +} + +// CircuitGroupAssignmentExplicit Creates a CircuitGroupAssignment with fully nested objects and all common fields. +func CircuitGroupAssignmentExplicit() *diode.CircuitGroupAssignment { + return &diode.CircuitGroupAssignment{ + Group: &diode.CircuitGroup{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Priority: diode.String("inactive"), + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/circuit_termination/go.mod b/docs/examples/circuit_termination/go.mod new file mode 100644 index 0000000..34b4ebd --- /dev/null +++ b/docs/examples/circuit_termination/go.mod @@ -0,0 +1,9 @@ +module circuit_termination + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/circuit_termination/main.go b/docs/examples/circuit_termination/main.go new file mode 100644 index 0000000..365db57 --- /dev/null +++ b/docs/examples/circuit_termination/main.go @@ -0,0 +1,123 @@ +// Package main demonstrates ingesting CircuitTermination entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "circuit_termination-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + circuitTermination := CircuitTerminationMinimal() + // circuitTermination := CircuitTerminationExtended() + // circuitTermination := CircuitTerminationExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{circuitTermination}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("CircuitTermination ingested successfully") + } +} + +// CircuitTerminationMinimal Creates a CircuitTermination with only required fields. +func CircuitTerminationMinimal() *diode.CircuitTermination { + return &diode.CircuitTermination{ + Circuit: &diode.Circuit{ + Cid: diode.String("CID-001"), + Provider: &diode.Provider{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Type: &diode.CircuitType{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + TermSide: diode.String("A"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// CircuitTerminationExtended Creates a CircuitTermination with common optional fields. +func CircuitTerminationExtended() *diode.CircuitTermination { + return &diode.CircuitTermination{ + Circuit: &diode.Circuit{ + Cid: diode.String("CID-001"), + Provider: &diode.Provider{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Type: &diode.CircuitType{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + TermSide: diode.String("A"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + PortSpeed: diode.Int64(1), + UpstreamSpeed: diode.Int64(1), + XconnectId: diode.String("Example XconnectId"), + PpInfo: diode.String("Example PpInfo"), + MarkConnected: diode.Bool(true), + } +} + +// CircuitTerminationExplicit Creates a CircuitTermination with fully nested objects and all common fields. +func CircuitTerminationExplicit() *diode.CircuitTermination { + return &diode.CircuitTermination{ + Circuit: &diode.Circuit{ + Cid: diode.String("CID-001"), + Provider: &diode.Provider{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Type: &diode.CircuitType{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Color: diode.String("0000ff"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + TermSide: diode.String("A"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + PortSpeed: diode.Int64(1), + UpstreamSpeed: diode.Int64(1), + XconnectId: diode.String("Example XconnectId"), + PpInfo: diode.String("Example PpInfo"), + MarkConnected: diode.Bool(true), + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/circuit_type/go.mod b/docs/examples/circuit_type/go.mod new file mode 100644 index 0000000..fa15495 --- /dev/null +++ b/docs/examples/circuit_type/go.mod @@ -0,0 +1,9 @@ +module circuit_type + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/circuit_type/main.go b/docs/examples/circuit_type/main.go new file mode 100644 index 0000000..5c6d1ed --- /dev/null +++ b/docs/examples/circuit_type/main.go @@ -0,0 +1,84 @@ +// Package main demonstrates ingesting CircuitType entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "circuit_type-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + circuitType := CircuitTypeMinimal() + // circuitType := CircuitTypeExtended() + // circuitType := CircuitTypeExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{circuitType}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("CircuitType ingested successfully") + } +} + +// CircuitTypeMinimal Creates a CircuitType with only required fields. +func CircuitTypeMinimal() *diode.CircuitType { + return &diode.CircuitType{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// CircuitTypeExtended Creates a CircuitType with common optional fields. +func CircuitTypeExtended() *diode.CircuitType { + return &diode.CircuitType{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + Color: diode.String("0000ff"), + Comments: diode.String("Example comments"), + } +} + +// CircuitTypeExplicit Creates a CircuitType with fully nested objects and all common fields. +func CircuitTypeExplicit() *diode.CircuitType { + return &diode.CircuitType{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Color: diode.String("0000ff"), + Comments: diode.String("Example comments"), + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/cluster/go.mod b/docs/examples/cluster/go.mod new file mode 100644 index 0000000..62b9385 --- /dev/null +++ b/docs/examples/cluster/go.mod @@ -0,0 +1,9 @@ +module cluster + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/cluster/main.go b/docs/examples/cluster/main.go new file mode 100644 index 0000000..b8a2880 --- /dev/null +++ b/docs/examples/cluster/main.go @@ -0,0 +1,106 @@ +// Package main demonstrates ingesting Cluster entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "cluster-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + cluster := ClusterMinimal() + // cluster := ClusterExtended() + // cluster := ClusterExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{cluster}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("Cluster ingested successfully") + } +} + +// ClusterMinimal Creates a Cluster with only required fields. +func ClusterMinimal() *diode.Cluster { + return &diode.Cluster{ + Name: diode.String("Example Name"), + Type: &diode.ClusterType{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + } +} + +// ClusterExtended Creates a Cluster with common optional fields. +func ClusterExtended() *diode.Cluster { + return &diode.Cluster{ + Name: diode.String("Example Name"), + Type: &diode.ClusterType{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Status: diode.String("active"), + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + } +} + +// ClusterExplicit Creates a Cluster with fully nested objects and all common fields. +func ClusterExplicit() *diode.Cluster { + return &diode.Cluster{ + Name: diode.String("Example Name"), + Type: &diode.ClusterType{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Status: diode.String("active"), + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + Group: &diode.ClusterGroup{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Tenant: &diode.Tenant{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/cluster_group/go.mod b/docs/examples/cluster_group/go.mod new file mode 100644 index 0000000..6a7de4e --- /dev/null +++ b/docs/examples/cluster_group/go.mod @@ -0,0 +1,9 @@ +module cluster_group + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/cluster_group/main.go b/docs/examples/cluster_group/main.go new file mode 100644 index 0000000..87c4120 --- /dev/null +++ b/docs/examples/cluster_group/main.go @@ -0,0 +1,82 @@ +// Package main demonstrates ingesting ClusterGroup entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "cluster_group-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + clusterGroup := ClusterGroupMinimal() + // clusterGroup := ClusterGroupExtended() + // clusterGroup := ClusterGroupExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{clusterGroup}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("ClusterGroup ingested successfully") + } +} + +// ClusterGroupMinimal Creates a ClusterGroup with only required fields. +func ClusterGroupMinimal() *diode.ClusterGroup { + return &diode.ClusterGroup{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// ClusterGroupExtended Creates a ClusterGroup with common optional fields. +func ClusterGroupExtended() *diode.ClusterGroup { + return &diode.ClusterGroup{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + } +} + +// ClusterGroupExplicit Creates a ClusterGroup with fully nested objects and all common fields. +func ClusterGroupExplicit() *diode.ClusterGroup { + return &diode.ClusterGroup{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/cluster_type/go.mod b/docs/examples/cluster_type/go.mod new file mode 100644 index 0000000..82a4dfc --- /dev/null +++ b/docs/examples/cluster_type/go.mod @@ -0,0 +1,9 @@ +module cluster_type + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/cluster_type/main.go b/docs/examples/cluster_type/main.go new file mode 100644 index 0000000..bb21377 --- /dev/null +++ b/docs/examples/cluster_type/main.go @@ -0,0 +1,82 @@ +// Package main demonstrates ingesting ClusterType entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "cluster_type-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + clusterType := ClusterTypeMinimal() + // clusterType := ClusterTypeExtended() + // clusterType := ClusterTypeExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{clusterType}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("ClusterType ingested successfully") + } +} + +// ClusterTypeMinimal Creates a ClusterType with only required fields. +func ClusterTypeMinimal() *diode.ClusterType { + return &diode.ClusterType{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// ClusterTypeExtended Creates a ClusterType with common optional fields. +func ClusterTypeExtended() *diode.ClusterType { + return &diode.ClusterType{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + } +} + +// ClusterTypeExplicit Creates a ClusterType with fully nested objects and all common fields. +func ClusterTypeExplicit() *diode.ClusterType { + return &diode.ClusterType{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/console_port/go.mod b/docs/examples/console_port/go.mod new file mode 100644 index 0000000..d625737 --- /dev/null +++ b/docs/examples/console_port/go.mod @@ -0,0 +1,9 @@ +module console_port + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/console_port/main.go b/docs/examples/console_port/main.go new file mode 100644 index 0000000..792d7c8 --- /dev/null +++ b/docs/examples/console_port/main.go @@ -0,0 +1,226 @@ +// Package main demonstrates ingesting ConsolePort entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "console_port-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + consolePort := ConsolePortMinimal() + // consolePort := ConsolePortExtended() + // consolePort := ConsolePortExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{consolePort}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("ConsolePort ingested successfully") + } +} + +// ConsolePortMinimal Creates a ConsolePort with only required fields. +func ConsolePortMinimal() *diode.ConsolePort { + return &diode.ConsolePort{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// ConsolePortExtended Creates a ConsolePort with common optional fields. +func ConsolePortExtended() *diode.ConsolePort { + return &diode.ConsolePort{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + Label: diode.String("Example Label"), + Type: diode.String("db-25"), + Speed: diode.Int64(1), + MarkConnected: diode.Bool(true), + } +} + +// ConsolePortExplicit Creates a ConsolePort with fully nested objects and all common fields. +func ConsolePortExplicit() *diode.ConsolePort { + return &diode.ConsolePort{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Color: diode.String("0000ff"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Label: diode.String("Example Label"), + Type: diode.String("db-25"), + Speed: diode.Int64(1), + MarkConnected: diode.Bool(true), + Module: &diode.Module{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Color: diode.String("0000ff"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + ModuleBay: &diode.ModuleBay{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Color: diode.String("0000ff"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + ModuleType: &diode.ModuleType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/console_server_port/go.mod b/docs/examples/console_server_port/go.mod new file mode 100644 index 0000000..758ffc0 --- /dev/null +++ b/docs/examples/console_server_port/go.mod @@ -0,0 +1,9 @@ +module console_server_port + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/console_server_port/main.go b/docs/examples/console_server_port/main.go new file mode 100644 index 0000000..2a08db0 --- /dev/null +++ b/docs/examples/console_server_port/main.go @@ -0,0 +1,226 @@ +// Package main demonstrates ingesting ConsoleServerPort entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "console_server_port-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + consoleServerPort := ConsoleServerPortMinimal() + // consoleServerPort := ConsoleServerPortExtended() + // consoleServerPort := ConsoleServerPortExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{consoleServerPort}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("ConsoleServerPort ingested successfully") + } +} + +// ConsoleServerPortMinimal Creates a ConsoleServerPort with only required fields. +func ConsoleServerPortMinimal() *diode.ConsoleServerPort { + return &diode.ConsoleServerPort{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// ConsoleServerPortExtended Creates a ConsoleServerPort with common optional fields. +func ConsoleServerPortExtended() *diode.ConsoleServerPort { + return &diode.ConsoleServerPort{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + Label: diode.String("Example Label"), + Type: diode.String("db-25"), + Speed: diode.Int64(1), + MarkConnected: diode.Bool(true), + } +} + +// ConsoleServerPortExplicit Creates a ConsoleServerPort with fully nested objects and all common fields. +func ConsoleServerPortExplicit() *diode.ConsoleServerPort { + return &diode.ConsoleServerPort{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Color: diode.String("0000ff"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Label: diode.String("Example Label"), + Type: diode.String("db-25"), + Speed: diode.Int64(1), + MarkConnected: diode.Bool(true), + Module: &diode.Module{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Color: diode.String("0000ff"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + ModuleBay: &diode.ModuleBay{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Color: diode.String("0000ff"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + ModuleType: &diode.ModuleType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/contact/go.mod b/docs/examples/contact/go.mod new file mode 100644 index 0000000..2767270 --- /dev/null +++ b/docs/examples/contact/go.mod @@ -0,0 +1,9 @@ +module contact + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/contact/main.go b/docs/examples/contact/main.go new file mode 100644 index 0000000..3e30ec6 --- /dev/null +++ b/docs/examples/contact/main.go @@ -0,0 +1,94 @@ +// Package main demonstrates ingesting Contact entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "contact-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + contact := ContactMinimal() + // contact := ContactExtended() + // contact := ContactExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{contact}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("Contact ingested successfully") + } +} + +// ContactMinimal Creates a Contact with only required fields. +func ContactMinimal() *diode.Contact { + return &diode.Contact{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// ContactExtended Creates a Contact with common optional fields. +func ContactExtended() *diode.Contact { + return &diode.Contact{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + Title: diode.String("Example Title"), + Phone: diode.String("Example Phone"), + Email: diode.String("Example Email"), + Address: diode.String("192.0.2.1/32"), + Link: diode.String("Example Link"), + Comments: diode.String("Example comments"), + } +} + +// ContactExplicit Creates a Contact with fully nested objects and all common fields. +func ContactExplicit() *diode.Contact { + return &diode.Contact{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + Title: diode.String("Example Title"), + Phone: diode.String("Example Phone"), + Email: diode.String("Example Email"), + Address: diode.String("192.0.2.1/32"), + Link: diode.String("Example Link"), + Group: &diode.ContactGroup{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/contact_assignment/go.mod b/docs/examples/contact_assignment/go.mod new file mode 100644 index 0000000..f4cec01 --- /dev/null +++ b/docs/examples/contact_assignment/go.mod @@ -0,0 +1,9 @@ +module contact_assignment + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/contact_assignment/main.go b/docs/examples/contact_assignment/main.go new file mode 100644 index 0000000..ad76d32 --- /dev/null +++ b/docs/examples/contact_assignment/main.go @@ -0,0 +1,83 @@ +// Package main demonstrates ingesting ContactAssignment entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "contact_assignment-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + contactAssignment := ContactAssignmentMinimal() + // contactAssignment := ContactAssignmentExtended() + // contactAssignment := ContactAssignmentExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{contactAssignment}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("ContactAssignment ingested successfully") + } +} + +// ContactAssignmentMinimal Creates a ContactAssignment with only required fields. +func ContactAssignmentMinimal() *diode.ContactAssignment { + return &diode.ContactAssignment{ + Contact: &diode.Contact{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + } +} + +// ContactAssignmentExtended Creates a ContactAssignment with common optional fields. +func ContactAssignmentExtended() *diode.ContactAssignment { + return &diode.ContactAssignment{ + Contact: &diode.Contact{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Priority: diode.String("inactive"), + } +} + +// ContactAssignmentExplicit Creates a ContactAssignment with fully nested objects and all common fields. +func ContactAssignmentExplicit() *diode.ContactAssignment { + return &diode.ContactAssignment{ + Contact: &diode.Contact{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Priority: diode.String("inactive"), + Role: &diode.ContactRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/contact_group/go.mod b/docs/examples/contact_group/go.mod new file mode 100644 index 0000000..bb8b0df --- /dev/null +++ b/docs/examples/contact_group/go.mod @@ -0,0 +1,9 @@ +module contact_group + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/contact_group/main.go b/docs/examples/contact_group/main.go new file mode 100644 index 0000000..93786e4 --- /dev/null +++ b/docs/examples/contact_group/main.go @@ -0,0 +1,87 @@ +// Package main demonstrates ingesting ContactGroup entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "contact_group-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + contactGroup := ContactGroupMinimal() + // contactGroup := ContactGroupExtended() + // contactGroup := ContactGroupExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{contactGroup}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("ContactGroup ingested successfully") + } +} + +// ContactGroupMinimal Creates a ContactGroup with only required fields. +func ContactGroupMinimal() *diode.ContactGroup { + return &diode.ContactGroup{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// ContactGroupExtended Creates a ContactGroup with common optional fields. +func ContactGroupExtended() *diode.ContactGroup { + return &diode.ContactGroup{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + } +} + +// ContactGroupExplicit Creates a ContactGroup with fully nested objects and all common fields. +func ContactGroupExplicit() *diode.ContactGroup { + return &diode.ContactGroup{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + Parent: &diode.ContactGroup{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/contact_role/go.mod b/docs/examples/contact_role/go.mod new file mode 100644 index 0000000..532bb3a --- /dev/null +++ b/docs/examples/contact_role/go.mod @@ -0,0 +1,9 @@ +module contact_role + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/contact_role/main.go b/docs/examples/contact_role/main.go new file mode 100644 index 0000000..722a37c --- /dev/null +++ b/docs/examples/contact_role/main.go @@ -0,0 +1,82 @@ +// Package main demonstrates ingesting ContactRole entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "contact_role-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + contactRole := ContactRoleMinimal() + // contactRole := ContactRoleExtended() + // contactRole := ContactRoleExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{contactRole}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("ContactRole ingested successfully") + } +} + +// ContactRoleMinimal Creates a ContactRole with only required fields. +func ContactRoleMinimal() *diode.ContactRole { + return &diode.ContactRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// ContactRoleExtended Creates a ContactRole with common optional fields. +func ContactRoleExtended() *diode.ContactRole { + return &diode.ContactRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + } +} + +// ContactRoleExplicit Creates a ContactRole with fully nested objects and all common fields. +func ContactRoleExplicit() *diode.ContactRole { + return &diode.ContactRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/custom_field/go.mod b/docs/examples/custom_field/go.mod new file mode 100644 index 0000000..6564274 --- /dev/null +++ b/docs/examples/custom_field/go.mod @@ -0,0 +1,9 @@ +module custom_field + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/custom_field/main.go b/docs/examples/custom_field/main.go new file mode 100644 index 0000000..37be04a --- /dev/null +++ b/docs/examples/custom_field/main.go @@ -0,0 +1,117 @@ +// Package main demonstrates ingesting CustomField entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "custom_field-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + customField := CustomFieldMinimal() + // customField := CustomFieldExtended() + // customField := CustomFieldExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{customField}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("CustomField ingested successfully") + } +} + +// CustomFieldMinimal Creates a CustomField with only required fields. +func CustomFieldMinimal() *diode.CustomField { + return &diode.CustomField{ + Type: diode.String("boolean"), + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// CustomFieldExtended Creates a CustomField with common optional fields. +func CustomFieldExtended() *diode.CustomField { + return &diode.CustomField{ + Type: diode.String("boolean"), + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + RelatedObjectType: diode.String("circuits.circuit"), + Label: diode.String("Example Label"), + GroupName: diode.String("Example GroupName"), + Required: diode.Bool(true), + Unique: diode.Bool(true), + SearchWeight: diode.Int64(1), + FilterLogic: diode.String("disabled"), + UiVisible: diode.String("always"), + UiEditable: diode.String("hidden"), + IsCloneable: diode.Bool(true), + Default: diode.String("Example Default"), + RelatedObjectFilter: diode.String("Example RelatedObjectFilter"), + Weight: diode.Int64(1), + ValidationMinimum: diode.Float64(1.0), + ValidationMaximum: diode.Float64(1.0), + ValidationRegex: diode.String("Example ValidationRegex"), + Comments: diode.String("Example comments"), + } +} + +// CustomFieldExplicit Creates a CustomField with fully nested objects and all common fields. +func CustomFieldExplicit() *diode.CustomField { + return &diode.CustomField{ + Type: diode.String("boolean"), + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + RelatedObjectType: diode.String("circuits.circuit"), + Label: diode.String("Example Label"), + GroupName: diode.String("Example GroupName"), + Required: diode.Bool(true), + Unique: diode.Bool(true), + SearchWeight: diode.Int64(1), + FilterLogic: diode.String("disabled"), + UiVisible: diode.String("always"), + UiEditable: diode.String("hidden"), + IsCloneable: diode.Bool(true), + Default: diode.String("Example Default"), + RelatedObjectFilter: diode.String("Example RelatedObjectFilter"), + Weight: diode.Int64(1), + ValidationMinimum: diode.Float64(1.0), + ValidationMaximum: diode.Float64(1.0), + ValidationRegex: diode.String("Example ValidationRegex"), + ChoiceSet: &diode.CustomFieldChoiceSet{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + } +} diff --git a/docs/examples/custom_field_choice_set/go.mod b/docs/examples/custom_field_choice_set/go.mod new file mode 100644 index 0000000..42ab2a3 --- /dev/null +++ b/docs/examples/custom_field_choice_set/go.mod @@ -0,0 +1,9 @@ +module custom_field_choice_set + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/custom_field_choice_set/main.go b/docs/examples/custom_field_choice_set/main.go new file mode 100644 index 0000000..d343a0c --- /dev/null +++ b/docs/examples/custom_field_choice_set/main.go @@ -0,0 +1,80 @@ +// Package main demonstrates ingesting CustomFieldChoiceSet entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "custom_field_choice_set-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + customFieldChoiceSet := CustomFieldChoiceSetMinimal() + // customFieldChoiceSet := CustomFieldChoiceSetExtended() + // customFieldChoiceSet := CustomFieldChoiceSetExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{customFieldChoiceSet}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("CustomFieldChoiceSet ingested successfully") + } +} + +// CustomFieldChoiceSetMinimal Creates a CustomFieldChoiceSet with only required fields. +func CustomFieldChoiceSetMinimal() *diode.CustomFieldChoiceSet { + return &diode.CustomFieldChoiceSet{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// CustomFieldChoiceSetExtended Creates a CustomFieldChoiceSet with common optional fields. +func CustomFieldChoiceSetExtended() *diode.CustomFieldChoiceSet { + return &diode.CustomFieldChoiceSet{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + BaseChoices: diode.String("IATA"), + OrderAlphabetically: diode.Bool(true), + } +} + +// CustomFieldChoiceSetExplicit Creates a CustomFieldChoiceSet with fully nested objects and all common fields. +func CustomFieldChoiceSetExplicit() *diode.CustomFieldChoiceSet { + return &diode.CustomFieldChoiceSet{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + BaseChoices: diode.String("IATA"), + OrderAlphabetically: diode.Bool(true), + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + } +} diff --git a/docs/examples/custom_link/go.mod b/docs/examples/custom_link/go.mod new file mode 100644 index 0000000..368c501 --- /dev/null +++ b/docs/examples/custom_link/go.mod @@ -0,0 +1,9 @@ +module custom_link + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/custom_link/main.go b/docs/examples/custom_link/main.go new file mode 100644 index 0000000..924edec --- /dev/null +++ b/docs/examples/custom_link/main.go @@ -0,0 +1,90 @@ +// Package main demonstrates ingesting CustomLink entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "custom_link-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + customLink := CustomLinkMinimal() + // customLink := CustomLinkExtended() + // customLink := CustomLinkExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{customLink}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("CustomLink ingested successfully") + } +} + +// CustomLinkMinimal Creates a CustomLink with only required fields. +func CustomLinkMinimal() *diode.CustomLink { + return &diode.CustomLink{ + Name: diode.String("Example Name"), + LinkText: diode.String("Example LinkText"), + LinkUrl: diode.String("Example LinkUrl"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// CustomLinkExtended Creates a CustomLink with common optional fields. +func CustomLinkExtended() *diode.CustomLink { + return &diode.CustomLink{ + Name: diode.String("Example Name"), + LinkText: diode.String("Example LinkText"), + LinkUrl: diode.String("Example LinkUrl"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Enabled: diode.Bool(true), + Weight: diode.Int64(1), + GroupName: diode.String("Example GroupName"), + ButtonClass: diode.String("black"), + NewWindow: diode.Bool(true), + } +} + +// CustomLinkExplicit Creates a CustomLink with fully nested objects and all common fields. +func CustomLinkExplicit() *diode.CustomLink { + return &diode.CustomLink{ + Name: diode.String("Example Name"), + LinkText: diode.String("Example LinkText"), + LinkUrl: diode.String("Example LinkUrl"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Enabled: diode.Bool(true), + Weight: diode.Int64(1), + GroupName: diode.String("Example GroupName"), + ButtonClass: diode.String("black"), + NewWindow: diode.Bool(true), + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + } +} diff --git a/docs/examples/device/go.mod b/docs/examples/device/go.mod new file mode 100644 index 0000000..73417fd --- /dev/null +++ b/docs/examples/device/go.mod @@ -0,0 +1,9 @@ +module device + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/device/main.go b/docs/examples/device/main.go new file mode 100644 index 0000000..a59726c --- /dev/null +++ b/docs/examples/device/main.go @@ -0,0 +1,228 @@ +// Package main demonstrates ingesting Device entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "device-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + device := DeviceMinimal() + // device := DeviceExtended() + // device := DeviceExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{device}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("Device ingested successfully") + } +} + +// DeviceMinimal Creates a Device with only required fields. +func DeviceMinimal() *diode.Device { + return &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + } +} + +// DeviceExtended Creates a Device with common optional fields. +func DeviceExtended() *diode.Device { + return &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Status: diode.String("active"), + Serial: diode.String("SN-001234"), + Description: diode.String("Example description"), + Name: diode.String("Example Name"), + AssetTag: diode.String("ASSET-001"), + Position: diode.Float64(1.0), + Face: diode.String("front"), + Latitude: diode.Float64(1.0), + Longitude: diode.Float64(1.0), + Airflow: diode.String("bottom-to-top"), + VcPosition: diode.Int64(1), + VcPriority: diode.Int64(1), + Comments: diode.String("Example comments"), + } +} + +// DeviceExplicit Creates a Device with fully nested objects and all common fields. +func DeviceExplicit() *diode.Device { + return &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Color: diode.String("0000ff"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Status: diode.String("active"), + Serial: diode.String("SN-001234"), + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + AssetTag: diode.String("ASSET-001"), + Name: diode.String("Example Name"), + Position: diode.Float64(1.0), + Face: diode.String("front"), + Latitude: diode.Float64(1.0), + Longitude: diode.Float64(1.0), + Airflow: diode.String("bottom-to-top"), + VcPosition: diode.Int64(1), + VcPriority: diode.Int64(1), + Tenant: &diode.Tenant{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Platform: &diode.Platform{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Location: &diode.Location{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Rack: &diode.Rack{ + Name: diode.String("Example Name"), + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + PrimaryIp4: &diode.IPAddress{ + Address: diode.String("192.0.2.1/32"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + PrimaryIp6: &diode.IPAddress{ + Address: diode.String("192.0.2.1/32"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + OobIp: &diode.IPAddress{ + Address: diode.String("192.0.2.1/32"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Cluster: &diode.Cluster{ + Name: diode.String("Example Name"), + Type: &diode.ClusterType{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + VirtualChassis: &diode.VirtualChassis{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Config: &diode.DeviceConfig{ + Startup: []byte("example data"), + Running: []byte("example data"), + Candidate: []byte("example data"), + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/device_bay/go.mod b/docs/examples/device_bay/go.mod new file mode 100644 index 0000000..ee2d9ac --- /dev/null +++ b/docs/examples/device_bay/go.mod @@ -0,0 +1,9 @@ +module device_bay + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/device_bay/main.go b/docs/examples/device_bay/main.go new file mode 100644 index 0000000..44f4b73 --- /dev/null +++ b/docs/examples/device_bay/main.go @@ -0,0 +1,177 @@ +// Package main demonstrates ingesting DeviceBay entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "device_bay-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + deviceBay := DeviceBayMinimal() + // deviceBay := DeviceBayExtended() + // deviceBay := DeviceBayExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{deviceBay}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("DeviceBay ingested successfully") + } +} + +// DeviceBayMinimal Creates a DeviceBay with only required fields. +func DeviceBayMinimal() *diode.DeviceBay { + return &diode.DeviceBay{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// DeviceBayExtended Creates a DeviceBay with common optional fields. +func DeviceBayExtended() *diode.DeviceBay { + return &diode.DeviceBay{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + Label: diode.String("Example Label"), + } +} + +// DeviceBayExplicit Creates a DeviceBay with fully nested objects and all common fields. +func DeviceBayExplicit() *diode.DeviceBay { + return &diode.DeviceBay{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Color: diode.String("0000ff"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Label: diode.String("Example Label"), + InstalledDevice: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Color: diode.String("0000ff"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/device_config/go.mod b/docs/examples/device_config/go.mod new file mode 100644 index 0000000..66c4d87 --- /dev/null +++ b/docs/examples/device_config/go.mod @@ -0,0 +1,9 @@ +module device_config + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/device_config/main.go b/docs/examples/device_config/main.go new file mode 100644 index 0000000..7ffb65f --- /dev/null +++ b/docs/examples/device_config/main.go @@ -0,0 +1,69 @@ +// Package main demonstrates ingesting DeviceConfig entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "device_config-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + deviceConfig := DeviceConfigMinimal() + // deviceConfig := DeviceConfigExtended() + // deviceConfig := DeviceConfigExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{deviceConfig}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("DeviceConfig ingested successfully") + } +} + +// DeviceConfigMinimal Creates a DeviceConfig with only required fields. +func DeviceConfigMinimal() *diode.DeviceConfig { + return &diode.DeviceConfig{ + Startup: []byte("example data"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// DeviceConfigExtended Creates a DeviceConfig with common optional fields. +func DeviceConfigExtended() *diode.DeviceConfig { + return &diode.DeviceConfig{ + Startup: []byte("example data"), + Running: []byte("example data"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + } +} + +// DeviceConfigExplicit Creates a DeviceConfig with fully nested objects and all common fields. +func DeviceConfigExplicit() *diode.DeviceConfig { + return &diode.DeviceConfig{ + Startup: []byte("example data"), + Running: []byte("example data"), + Candidate: []byte("example data"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + } +} diff --git a/docs/examples/device_role/go.mod b/docs/examples/device_role/go.mod new file mode 100644 index 0000000..5c61f09 --- /dev/null +++ b/docs/examples/device_role/go.mod @@ -0,0 +1,9 @@ +module device_role + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/device_role/main.go b/docs/examples/device_role/main.go new file mode 100644 index 0000000..cf033e6 --- /dev/null +++ b/docs/examples/device_role/main.go @@ -0,0 +1,92 @@ +// Package main demonstrates ingesting DeviceRole entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "device_role-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + deviceRole := DeviceRoleMinimal() + // deviceRole := DeviceRoleExtended() + // deviceRole := DeviceRoleExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{deviceRole}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("DeviceRole ingested successfully") + } +} + +// DeviceRoleMinimal Creates a DeviceRole with only required fields. +func DeviceRoleMinimal() *diode.DeviceRole { + return &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// DeviceRoleExtended Creates a DeviceRole with common optional fields. +func DeviceRoleExtended() *diode.DeviceRole { + return &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + Color: diode.String("0000ff"), + VmRole: diode.Bool(true), + Comments: diode.String("Example comments"), + } +} + +// DeviceRoleExplicit Creates a DeviceRole with fully nested objects and all common fields. +func DeviceRoleExplicit() *diode.DeviceRole { + return &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Color: diode.String("0000ff"), + Comments: diode.String("Example comments"), + VmRole: diode.Bool(true), + Parent: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Color: diode.String("0000ff"), + Metadata: diode.Metadata{"source": "example"}, + }, + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/device_type/go.mod b/docs/examples/device_type/go.mod new file mode 100644 index 0000000..12b64a4 --- /dev/null +++ b/docs/examples/device_type/go.mod @@ -0,0 +1,9 @@ +module device_type + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/device_type/main.go b/docs/examples/device_type/main.go new file mode 100644 index 0000000..0362240 --- /dev/null +++ b/docs/examples/device_type/main.go @@ -0,0 +1,118 @@ +// Package main demonstrates ingesting DeviceType entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "device_type-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + deviceType := DeviceTypeMinimal() + // deviceType := DeviceTypeExtended() + // deviceType := DeviceTypeExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{deviceType}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("DeviceType ingested successfully") + } +} + +// DeviceTypeMinimal Creates a DeviceType with only required fields. +func DeviceTypeMinimal() *diode.DeviceType { + return &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// DeviceTypeExtended Creates a DeviceType with common optional fields. +func DeviceTypeExtended() *diode.DeviceType { + return &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + PartNumber: diode.String("Example PartNumber"), + UHeight: diode.Float64(1.0), + ExcludeFromUtilization: diode.Bool(true), + IsFullDepth: diode.Bool(true), + SubdeviceRole: diode.String("child"), + Airflow: diode.String("bottom-to-top"), + Weight: diode.Float64(1.0), + WeightUnit: diode.String("g"), + Comments: diode.String("Example comments"), + } +} + +// DeviceTypeExplicit Creates a DeviceType with fully nested objects and all common fields. +func DeviceTypeExplicit() *diode.DeviceType { + return &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + PartNumber: diode.String("Example PartNumber"), + UHeight: diode.Float64(1.0), + ExcludeFromUtilization: diode.Bool(true), + IsFullDepth: diode.Bool(true), + SubdeviceRole: diode.String("child"), + Airflow: diode.String("bottom-to-top"), + Weight: diode.Float64(1.0), + WeightUnit: diode.String("g"), + DefaultPlatform: &diode.Platform{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/fhrp_group/go.mod b/docs/examples/fhrp_group/go.mod new file mode 100644 index 0000000..9a3bc9f --- /dev/null +++ b/docs/examples/fhrp_group/go.mod @@ -0,0 +1,9 @@ +module fhrp_group + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/fhrp_group/main.go b/docs/examples/fhrp_group/main.go new file mode 100644 index 0000000..c749888 --- /dev/null +++ b/docs/examples/fhrp_group/main.go @@ -0,0 +1,88 @@ +// Package main demonstrates ingesting FHRPGroup entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "fhrp_group-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + fhrpGroup := FHRPGroupMinimal() + // fhrpGroup := FHRPGroupExtended() + // fhrpGroup := FHRPGroupExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{fhrpGroup}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("FHRPGroup ingested successfully") + } +} + +// FHRPGroupMinimal Creates a FHRPGroup with only required fields. +func FHRPGroupMinimal() *diode.FHRPGroup { + return &diode.FHRPGroup{ + Protocol: diode.String("carp"), + GroupId: diode.Int64(1), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// FHRPGroupExtended Creates a FHRPGroup with common optional fields. +func FHRPGroupExtended() *diode.FHRPGroup { + return &diode.FHRPGroup{ + Protocol: diode.String("carp"), + GroupId: diode.Int64(1), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + Name: diode.String("Example Name"), + AuthType: diode.String("md5"), + AuthKey: diode.String("Example AuthKey"), + Comments: diode.String("Example comments"), + } +} + +// FHRPGroupExplicit Creates a FHRPGroup with fully nested objects and all common fields. +func FHRPGroupExplicit() *diode.FHRPGroup { + return &diode.FHRPGroup{ + Protocol: diode.String("carp"), + GroupId: diode.Int64(1), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + Name: diode.String("Example Name"), + AuthType: diode.String("md5"), + AuthKey: diode.String("Example AuthKey"), + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/fhrp_group_assignment/go.mod b/docs/examples/fhrp_group_assignment/go.mod new file mode 100644 index 0000000..2bef423 --- /dev/null +++ b/docs/examples/fhrp_group_assignment/go.mod @@ -0,0 +1,9 @@ +module fhrp_group_assignment + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/fhrp_group_assignment/main.go b/docs/examples/fhrp_group_assignment/main.go new file mode 100644 index 0000000..e80efc4 --- /dev/null +++ b/docs/examples/fhrp_group_assignment/main.go @@ -0,0 +1,81 @@ +// Package main demonstrates ingesting FHRPGroupAssignment entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "fhrp_group_assignment-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + fhrpGroupAssignment := FHRPGroupAssignmentMinimal() + // fhrpGroupAssignment := FHRPGroupAssignmentExtended() + // fhrpGroupAssignment := FHRPGroupAssignmentExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{fhrpGroupAssignment}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("FHRPGroupAssignment ingested successfully") + } +} + +// FHRPGroupAssignmentMinimal Creates a FHRPGroupAssignment with only required fields. +func FHRPGroupAssignmentMinimal() *diode.FHRPGroupAssignment { + return &diode.FHRPGroupAssignment{ + Group: &diode.FHRPGroup{ + Protocol: diode.String("Example Protocol"), + GroupId: diode.Int64(1), + Metadata: diode.Metadata{"source": "example"}, + }, + Priority: diode.Int64(1), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// FHRPGroupAssignmentExtended Creates a FHRPGroupAssignment with common optional fields. +func FHRPGroupAssignmentExtended() *diode.FHRPGroupAssignment { + return &diode.FHRPGroupAssignment{ + Group: &diode.FHRPGroup{ + Protocol: diode.String("Example Protocol"), + GroupId: diode.Int64(1), + Metadata: diode.Metadata{"source": "example"}, + }, + Priority: diode.Int64(1), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + } +} + +// FHRPGroupAssignmentExplicit Creates a FHRPGroupAssignment with fully nested objects and all common fields. +func FHRPGroupAssignmentExplicit() *diode.FHRPGroupAssignment { + return &diode.FHRPGroupAssignment{ + Group: &diode.FHRPGroup{ + Protocol: diode.String("Example Protocol"), + GroupId: diode.Int64(1), + Metadata: diode.Metadata{"source": "example"}, + }, + Priority: diode.Int64(1), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + } +} diff --git a/docs/examples/front_port/go.mod b/docs/examples/front_port/go.mod new file mode 100644 index 0000000..fac0857 --- /dev/null +++ b/docs/examples/front_port/go.mod @@ -0,0 +1,9 @@ +module front_port + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/front_port/main.go b/docs/examples/front_port/main.go new file mode 100644 index 0000000..91d6edc --- /dev/null +++ b/docs/examples/front_port/main.go @@ -0,0 +1,319 @@ +// Package main demonstrates ingesting FrontPort entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "front_port-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + frontPort := FrontPortMinimal() + // frontPort := FrontPortExtended() + // frontPort := FrontPortExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{frontPort}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("FrontPort ingested successfully") + } +} + +// FrontPortMinimal Creates a FrontPort with only required fields. +func FrontPortMinimal() *diode.FrontPort { + return &diode.FrontPort{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Type: diode.String("110-punch"), + RearPort: &diode.RearPort{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Type: diode.String("Example Type"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + } +} + +// FrontPortExtended Creates a FrontPort with common optional fields. +func FrontPortExtended() *diode.FrontPort { + return &diode.FrontPort{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Type: diode.String("110-punch"), + RearPort: &diode.RearPort{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Type: diode.String("Example Type"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + Color: diode.String("0000ff"), + Label: diode.String("Example Label"), + RearPortPosition: diode.Int64(1), + MarkConnected: diode.Bool(true), + Positions: diode.Int64(1), + } +} + +// FrontPortExplicit Creates a FrontPort with fully nested objects and all common fields. +func FrontPortExplicit() *diode.FrontPort { + return &diode.FrontPort{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Color: diode.String("0000ff"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Type: diode.String("110-punch"), + RearPort: &diode.RearPort{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Color: diode.String("0000ff"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Type: diode.String("Example Type"), + Color: diode.String("0000ff"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Color: diode.String("0000ff"), + Label: diode.String("Example Label"), + RearPortPosition: diode.Int64(1), + MarkConnected: diode.Bool(true), + Positions: diode.Int64(1), + Module: &diode.Module{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Color: diode.String("0000ff"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + ModuleBay: &diode.ModuleBay{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Color: diode.String("0000ff"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + ModuleType: &diode.ModuleType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/ike_policy/go.mod b/docs/examples/ike_policy/go.mod new file mode 100644 index 0000000..b276f61 --- /dev/null +++ b/docs/examples/ike_policy/go.mod @@ -0,0 +1,9 @@ +module ike_policy + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/ike_policy/main.go b/docs/examples/ike_policy/main.go new file mode 100644 index 0000000..4f0bf43 --- /dev/null +++ b/docs/examples/ike_policy/main.go @@ -0,0 +1,86 @@ +// Package main demonstrates ingesting IKEPolicy entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "ike_policy-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + ikePolicy := IKEPolicyMinimal() + // ikePolicy := IKEPolicyExtended() + // ikePolicy := IKEPolicyExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{ikePolicy}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("IKEPolicy ingested successfully") + } +} + +// IKEPolicyMinimal Creates a IKEPolicy with only required fields. +func IKEPolicyMinimal() *diode.IKEPolicy { + return &diode.IKEPolicy{ + Name: diode.String("Example Name"), + Version: diode.Int64(1), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// IKEPolicyExtended Creates a IKEPolicy with common optional fields. +func IKEPolicyExtended() *diode.IKEPolicy { + return &diode.IKEPolicy{ + Name: diode.String("Example Name"), + Version: diode.Int64(1), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + Mode: diode.String("aggressive"), + PresharedKey: diode.String("Example PresharedKey"), + Comments: diode.String("Example comments"), + } +} + +// IKEPolicyExplicit Creates a IKEPolicy with fully nested objects and all common fields. +func IKEPolicyExplicit() *diode.IKEPolicy { + return &diode.IKEPolicy{ + Name: diode.String("Example Name"), + Version: diode.Int64(1), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + Mode: diode.String("aggressive"), + PresharedKey: diode.String("Example PresharedKey"), + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/ike_proposal/go.mod b/docs/examples/ike_proposal/go.mod new file mode 100644 index 0000000..532e5f7 --- /dev/null +++ b/docs/examples/ike_proposal/go.mod @@ -0,0 +1,9 @@ +module ike_proposal + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/ike_proposal/main.go b/docs/examples/ike_proposal/main.go new file mode 100644 index 0000000..c5cfcce --- /dev/null +++ b/docs/examples/ike_proposal/main.go @@ -0,0 +1,92 @@ +// Package main demonstrates ingesting IKEProposal entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "ike_proposal-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + ikeProposal := IKEProposalMinimal() + // ikeProposal := IKEProposalExtended() + // ikeProposal := IKEProposalExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{ikeProposal}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("IKEProposal ingested successfully") + } +} + +// IKEProposalMinimal Creates a IKEProposal with only required fields. +func IKEProposalMinimal() *diode.IKEProposal { + return &diode.IKEProposal{ + Name: diode.String("Example Name"), + AuthenticationMethod: diode.String("certificates"), + EncryptionAlgorithm: diode.String("3des-cbc"), + Group: diode.Int64(1), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// IKEProposalExtended Creates a IKEProposal with common optional fields. +func IKEProposalExtended() *diode.IKEProposal { + return &diode.IKEProposal{ + Name: diode.String("Example Name"), + AuthenticationMethod: diode.String("certificates"), + EncryptionAlgorithm: diode.String("3des-cbc"), + Group: diode.Int64(1), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + AuthenticationAlgorithm: diode.String("hmac-md5"), + SaLifetime: diode.Int64(1), + Comments: diode.String("Example comments"), + } +} + +// IKEProposalExplicit Creates a IKEProposal with fully nested objects and all common fields. +func IKEProposalExplicit() *diode.IKEProposal { + return &diode.IKEProposal{ + Name: diode.String("Example Name"), + AuthenticationMethod: diode.String("certificates"), + EncryptionAlgorithm: diode.String("3des-cbc"), + Group: diode.Int64(1), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + AuthenticationAlgorithm: diode.String("hmac-md5"), + SaLifetime: diode.Int64(1), + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/interface_entity/go.mod b/docs/examples/interface_entity/go.mod new file mode 100644 index 0000000..efb8841 --- /dev/null +++ b/docs/examples/interface_entity/go.mod @@ -0,0 +1,9 @@ +module interface_entity + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/interface_entity/main.go b/docs/examples/interface_entity/main.go new file mode 100644 index 0000000..14714f9 --- /dev/null +++ b/docs/examples/interface_entity/main.go @@ -0,0 +1,370 @@ +// Package main demonstrates ingesting Interface entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "interface-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + interfaceEntity := InterfaceMinimal() + // interfaceEntity := InterfaceExtended() + // interfaceEntity := InterfaceExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{interfaceEntity}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("Interface ingested successfully") + } +} + +// InterfaceMinimal Creates a Interface with only required fields. +func InterfaceMinimal() *diode.Interface { + return &diode.Interface{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Type: diode.String("1000base-bx10-d"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// InterfaceExtended Creates a Interface with common optional fields. +func InterfaceExtended() *diode.Interface { + return &diode.Interface{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Type: diode.String("1000base-bx10-d"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + Label: diode.String("Example Label"), + Enabled: diode.Bool(true), + Mtu: diode.Int64(1), + Speed: diode.Int64(1), + Duplex: diode.String("auto"), + Wwn: diode.String("Example Wwn"), + MgmtOnly: diode.Bool(true), + Mode: diode.String("access"), + RfRole: diode.String("ap"), + RfChannel: diode.String("2.4g-1-2412-22"), + PoeMode: diode.String("pd"), + PoeType: diode.String("passive-24v-2pair"), + RfChannelFrequency: diode.Float64(1.0), + RfChannelWidth: diode.Float64(1.0), + TxPower: diode.Int64(1), + MarkConnected: diode.Bool(true), + } +} + +// InterfaceExplicit Creates a Interface with fully nested objects and all common fields. +func InterfaceExplicit() *diode.Interface { + return &diode.Interface{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Color: diode.String("0000ff"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Type: diode.String("1000base-bx10-d"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Label: diode.String("Example Label"), + Enabled: diode.Bool(true), + Mtu: diode.Int64(1), + Speed: diode.Int64(1), + Duplex: diode.String("auto"), + Wwn: diode.String("Example Wwn"), + MgmtOnly: diode.Bool(true), + Mode: diode.String("access"), + RfRole: diode.String("ap"), + RfChannel: diode.String("2.4g-1-2412-22"), + PoeMode: diode.String("pd"), + PoeType: diode.String("passive-24v-2pair"), + RfChannelFrequency: diode.Float64(1.0), + RfChannelWidth: diode.Float64(1.0), + TxPower: diode.Int64(1), + MarkConnected: diode.Bool(true), + Module: &diode.Module{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Color: diode.String("0000ff"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + ModuleBay: &diode.ModuleBay{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Color: diode.String("0000ff"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + ModuleType: &diode.ModuleType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Parent: &diode.Interface{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Color: diode.String("0000ff"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Type: diode.String("Example Type"), + Metadata: diode.Metadata{"source": "example"}, + }, + Bridge: &diode.Interface{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Color: diode.String("0000ff"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Type: diode.String("Example Type"), + Metadata: diode.Metadata{"source": "example"}, + }, + Lag: &diode.Interface{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Color: diode.String("0000ff"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Type: diode.String("Example Type"), + Metadata: diode.Metadata{"source": "example"}, + }, + PrimaryMacAddress: &diode.MACAddress{ + MacAddress: diode.String("00:11:22:33:44:55"), + Metadata: diode.Metadata{"source": "example"}, + }, + UntaggedVlan: &diode.VLAN{ + Vid: diode.Int64(1), + Name: diode.String("Example Name"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + QinqSvlan: &diode.VLAN{ + Vid: diode.Int64(1), + Name: diode.String("Example Name"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + VlanTranslationPolicy: &diode.VLANTranslationPolicy{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Vrf: &diode.VRF{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/inventory_item/go.mod b/docs/examples/inventory_item/go.mod new file mode 100644 index 0000000..4d0c665 --- /dev/null +++ b/docs/examples/inventory_item/go.mod @@ -0,0 +1,9 @@ +module inventory_item + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/inventory_item/main.go b/docs/examples/inventory_item/main.go new file mode 100644 index 0000000..20f120b --- /dev/null +++ b/docs/examples/inventory_item/main.go @@ -0,0 +1,203 @@ +// Package main demonstrates ingesting InventoryItem entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "inventory_item-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + inventoryItem := InventoryItemMinimal() + // inventoryItem := InventoryItemExtended() + // inventoryItem := InventoryItemExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{inventoryItem}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("InventoryItem ingested successfully") + } +} + +// InventoryItemMinimal Creates a InventoryItem with only required fields. +func InventoryItemMinimal() *diode.InventoryItem { + return &diode.InventoryItem{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// InventoryItemExtended Creates a InventoryItem with common optional fields. +func InventoryItemExtended() *diode.InventoryItem { + return &diode.InventoryItem{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Status: diode.String("active"), + Serial: diode.String("SN-001234"), + Description: diode.String("Example description"), + Label: diode.String("Example Label"), + PartId: diode.String("Example PartId"), + AssetTag: diode.String("ASSET-001"), + Discovered: diode.Bool(true), + } +} + +// InventoryItemExplicit Creates a InventoryItem with fully nested objects and all common fields. +func InventoryItemExplicit() *diode.InventoryItem { + return &diode.InventoryItem{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Color: diode.String("0000ff"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Status: diode.String("active"), + Serial: diode.String("SN-001234"), + Description: diode.String("Example description"), + AssetTag: diode.String("ASSET-001"), + Label: diode.String("Example Label"), + PartId: diode.String("Example PartId"), + Discovered: diode.Bool(true), + Parent: &diode.InventoryItem{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Color: diode.String("0000ff"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.InventoryItemRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Color: diode.String("0000ff"), + Metadata: diode.Metadata{"source": "example"}, + }, + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/inventory_item_role/go.mod b/docs/examples/inventory_item_role/go.mod new file mode 100644 index 0000000..515587a --- /dev/null +++ b/docs/examples/inventory_item_role/go.mod @@ -0,0 +1,9 @@ +module inventory_item_role + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/inventory_item_role/main.go b/docs/examples/inventory_item_role/main.go new file mode 100644 index 0000000..2ae430b --- /dev/null +++ b/docs/examples/inventory_item_role/main.go @@ -0,0 +1,84 @@ +// Package main demonstrates ingesting InventoryItemRole entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "inventory_item_role-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + inventoryItemRole := InventoryItemRoleMinimal() + // inventoryItemRole := InventoryItemRoleExtended() + // inventoryItemRole := InventoryItemRoleExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{inventoryItemRole}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("InventoryItemRole ingested successfully") + } +} + +// InventoryItemRoleMinimal Creates a InventoryItemRole with only required fields. +func InventoryItemRoleMinimal() *diode.InventoryItemRole { + return &diode.InventoryItemRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// InventoryItemRoleExtended Creates a InventoryItemRole with common optional fields. +func InventoryItemRoleExtended() *diode.InventoryItemRole { + return &diode.InventoryItemRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + Color: diode.String("0000ff"), + Comments: diode.String("Example comments"), + } +} + +// InventoryItemRoleExplicit Creates a InventoryItemRole with fully nested objects and all common fields. +func InventoryItemRoleExplicit() *diode.InventoryItemRole { + return &diode.InventoryItemRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Color: diode.String("0000ff"), + Comments: diode.String("Example comments"), + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/ip_address/go.mod b/docs/examples/ip_address/go.mod new file mode 100644 index 0000000..5b10984 --- /dev/null +++ b/docs/examples/ip_address/go.mod @@ -0,0 +1,9 @@ +module ip_address + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/ip_address/main.go b/docs/examples/ip_address/main.go new file mode 100644 index 0000000..230e8f4 --- /dev/null +++ b/docs/examples/ip_address/main.go @@ -0,0 +1,99 @@ +// Package main demonstrates ingesting IPAddress entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "ip_address-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + ipAddress := IPAddressMinimal() + // ipAddress := IPAddressExtended() + // ipAddress := IPAddressExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{ipAddress}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("IPAddress ingested successfully") + } +} + +// IPAddressMinimal Creates a IPAddress with only required fields. +func IPAddressMinimal() *diode.IPAddress { + return &diode.IPAddress{ + Address: diode.String("192.0.2.1/32"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// IPAddressExtended Creates a IPAddress with common optional fields. +func IPAddressExtended() *diode.IPAddress { + return &diode.IPAddress{ + Address: diode.String("192.0.2.1/32"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Status: diode.String("active"), + Description: diode.String("Example description"), + Role: diode.String("anycast"), + DnsName: diode.String("Example DnsName"), + Comments: diode.String("Example comments"), + } +} + +// IPAddressExplicit Creates a IPAddress with fully nested objects and all common fields. +func IPAddressExplicit() *diode.IPAddress { + return &diode.IPAddress{ + Address: diode.String("192.0.2.1/32"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Status: diode.String("active"), + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + Role: diode.String("anycast"), + DnsName: diode.String("Example DnsName"), + Vrf: &diode.VRF{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Tenant: &diode.Tenant{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + NatInside: &diode.IPAddress{ + Address: diode.String("192.0.2.1/32"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/ip_range/go.mod b/docs/examples/ip_range/go.mod new file mode 100644 index 0000000..74d145a --- /dev/null +++ b/docs/examples/ip_range/go.mod @@ -0,0 +1,9 @@ +module ip_range + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/ip_range/main.go b/docs/examples/ip_range/main.go new file mode 100644 index 0000000..9b2917c --- /dev/null +++ b/docs/examples/ip_range/main.go @@ -0,0 +1,102 @@ +// Package main demonstrates ingesting IPRange entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "ip_range-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + ipRange := IPRangeMinimal() + // ipRange := IPRangeExtended() + // ipRange := IPRangeExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{ipRange}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("IPRange ingested successfully") + } +} + +// IPRangeMinimal Creates a IPRange with only required fields. +func IPRangeMinimal() *diode.IPRange { + return &diode.IPRange{ + StartAddress: diode.String("Example StartAddress"), + EndAddress: diode.String("Example EndAddress"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// IPRangeExtended Creates a IPRange with common optional fields. +func IPRangeExtended() *diode.IPRange { + return &diode.IPRange{ + StartAddress: diode.String("Example StartAddress"), + EndAddress: diode.String("Example EndAddress"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Status: diode.String("active"), + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + MarkUtilized: diode.Bool(true), + MarkPopulated: diode.Bool(true), + } +} + +// IPRangeExplicit Creates a IPRange with fully nested objects and all common fields. +func IPRangeExplicit() *diode.IPRange { + return &diode.IPRange{ + StartAddress: diode.String("Example StartAddress"), + EndAddress: diode.String("Example EndAddress"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Status: diode.String("active"), + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + MarkUtilized: diode.Bool(true), + MarkPopulated: diode.Bool(true), + Vrf: &diode.VRF{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Tenant: &diode.Tenant{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.Role{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/ip_sec_policy/go.mod b/docs/examples/ip_sec_policy/go.mod new file mode 100644 index 0000000..1c4571c --- /dev/null +++ b/docs/examples/ip_sec_policy/go.mod @@ -0,0 +1,9 @@ +module ip_sec_policy + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/ip_sec_policy/main.go b/docs/examples/ip_sec_policy/main.go new file mode 100644 index 0000000..de6756e --- /dev/null +++ b/docs/examples/ip_sec_policy/main.go @@ -0,0 +1,81 @@ +// Package main demonstrates ingesting IPSecPolicy entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "ip_sec_policy-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + ipSecPolicy := IPSecPolicyMinimal() + // ipSecPolicy := IPSecPolicyExtended() + // ipSecPolicy := IPSecPolicyExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{ipSecPolicy}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("IPSecPolicy ingested successfully") + } +} + +// IPSecPolicyMinimal Creates a IPSecPolicy with only required fields. +func IPSecPolicyMinimal() *diode.IPSecPolicy { + return &diode.IPSecPolicy{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// IPSecPolicyExtended Creates a IPSecPolicy with common optional fields. +func IPSecPolicyExtended() *diode.IPSecPolicy { + return &diode.IPSecPolicy{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + PfsGroup: diode.Int64(1), + Comments: diode.String("Example comments"), + } +} + +// IPSecPolicyExplicit Creates a IPSecPolicy with fully nested objects and all common fields. +func IPSecPolicyExplicit() *diode.IPSecPolicy { + return &diode.IPSecPolicy{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + PfsGroup: diode.Int64(1), + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/ip_sec_profile/go.mod b/docs/examples/ip_sec_profile/go.mod new file mode 100644 index 0000000..dcfe1aa --- /dev/null +++ b/docs/examples/ip_sec_profile/go.mod @@ -0,0 +1,9 @@ +module ip_sec_profile + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/ip_sec_profile/main.go b/docs/examples/ip_sec_profile/main.go new file mode 100644 index 0000000..cfcf46b --- /dev/null +++ b/docs/examples/ip_sec_profile/main.go @@ -0,0 +1,109 @@ +// Package main demonstrates ingesting IPSecProfile entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "ip_sec_profile-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + ipSecProfile := IPSecProfileMinimal() + // ipSecProfile := IPSecProfileExtended() + // ipSecProfile := IPSecProfileExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{ipSecProfile}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("IPSecProfile ingested successfully") + } +} + +// IPSecProfileMinimal Creates a IPSecProfile with only required fields. +func IPSecProfileMinimal() *diode.IPSecProfile { + return &diode.IPSecProfile{ + Name: diode.String("Example Name"), + Mode: diode.String("ah"), + IkePolicy: &diode.IKEPolicy{ + Name: diode.String("Example Name"), + Version: diode.Int64(1), + Metadata: diode.Metadata{"source": "example"}, + }, + IpsecPolicy: &diode.IPSecPolicy{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + } +} + +// IPSecProfileExtended Creates a IPSecProfile with common optional fields. +func IPSecProfileExtended() *diode.IPSecProfile { + return &diode.IPSecProfile{ + Name: diode.String("Example Name"), + Mode: diode.String("ah"), + IkePolicy: &diode.IKEPolicy{ + Name: diode.String("Example Name"), + Version: diode.Int64(1), + Metadata: diode.Metadata{"source": "example"}, + }, + IpsecPolicy: &diode.IPSecPolicy{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + } +} + +// IPSecProfileExplicit Creates a IPSecProfile with fully nested objects and all common fields. +func IPSecProfileExplicit() *diode.IPSecProfile { + return &diode.IPSecProfile{ + Name: diode.String("Example Name"), + Mode: diode.String("ah"), + IkePolicy: &diode.IKEPolicy{ + Name: diode.String("Example Name"), + Version: diode.Int64(1), + Metadata: diode.Metadata{"source": "example"}, + }, + IpsecPolicy: &diode.IPSecPolicy{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/ip_sec_proposal/go.mod b/docs/examples/ip_sec_proposal/go.mod new file mode 100644 index 0000000..298eda4 --- /dev/null +++ b/docs/examples/ip_sec_proposal/go.mod @@ -0,0 +1,9 @@ +module ip_sec_proposal + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/ip_sec_proposal/main.go b/docs/examples/ip_sec_proposal/main.go new file mode 100644 index 0000000..337f0c1 --- /dev/null +++ b/docs/examples/ip_sec_proposal/main.go @@ -0,0 +1,87 @@ +// Package main demonstrates ingesting IPSecProposal entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "ip_sec_proposal-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + ipSecProposal := IPSecProposalMinimal() + // ipSecProposal := IPSecProposalExtended() + // ipSecProposal := IPSecProposalExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{ipSecProposal}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("IPSecProposal ingested successfully") + } +} + +// IPSecProposalMinimal Creates a IPSecProposal with only required fields. +func IPSecProposalMinimal() *diode.IPSecProposal { + return &diode.IPSecProposal{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// IPSecProposalExtended Creates a IPSecProposal with common optional fields. +func IPSecProposalExtended() *diode.IPSecProposal { + return &diode.IPSecProposal{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + EncryptionAlgorithm: diode.String("3des-cbc"), + AuthenticationAlgorithm: diode.String("hmac-md5"), + SaLifetimeSeconds: diode.Int64(1), + SaLifetimeData: diode.Int64(1), + Comments: diode.String("Example comments"), + } +} + +// IPSecProposalExplicit Creates a IPSecProposal with fully nested objects and all common fields. +func IPSecProposalExplicit() *diode.IPSecProposal { + return &diode.IPSecProposal{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + EncryptionAlgorithm: diode.String("3des-cbc"), + AuthenticationAlgorithm: diode.String("hmac-md5"), + SaLifetimeSeconds: diode.Int64(1), + SaLifetimeData: diode.Int64(1), + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/journal_entry/go.mod b/docs/examples/journal_entry/go.mod new file mode 100644 index 0000000..7f244c2 --- /dev/null +++ b/docs/examples/journal_entry/go.mod @@ -0,0 +1,9 @@ +module journal_entry + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/journal_entry/main.go b/docs/examples/journal_entry/main.go new file mode 100644 index 0000000..54cdf9f --- /dev/null +++ b/docs/examples/journal_entry/main.go @@ -0,0 +1,69 @@ +// Package main demonstrates ingesting JournalEntry entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "journal_entry-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + journalEntry := JournalEntryMinimal() + // journalEntry := JournalEntryExtended() + // journalEntry := JournalEntryExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{journalEntry}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("JournalEntry ingested successfully") + } +} + +// JournalEntryMinimal Creates a JournalEntry with only required fields. +func JournalEntryMinimal() *diode.JournalEntry { + return &diode.JournalEntry{ + Comments: diode.String("Example comments"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// JournalEntryExtended Creates a JournalEntry with common optional fields. +func JournalEntryExtended() *diode.JournalEntry { + return &diode.JournalEntry{ + Comments: diode.String("Example comments"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Kind: diode.String("danger"), + } +} + +// JournalEntryExplicit Creates a JournalEntry with fully nested objects and all common fields. +func JournalEntryExplicit() *diode.JournalEntry { + return &diode.JournalEntry{ + Comments: diode.String("Example comments"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Kind: diode.String("danger"), + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/l2vpn/go.mod b/docs/examples/l2vpn/go.mod new file mode 100644 index 0000000..5777ddb --- /dev/null +++ b/docs/examples/l2vpn/go.mod @@ -0,0 +1,9 @@ +module l2vpn + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/l2vpn/main.go b/docs/examples/l2vpn/main.go new file mode 100644 index 0000000..97cddda --- /dev/null +++ b/docs/examples/l2vpn/main.go @@ -0,0 +1,93 @@ +// Package main demonstrates ingesting L2VPN entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "l2vpn-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + l2vpn := L2VPNMinimal() + // l2vpn := L2VPNExtended() + // l2vpn := L2VPNExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{l2vpn}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("L2VPN ingested successfully") + } +} + +// L2VPNMinimal Creates a L2VPN with only required fields. +func L2VPNMinimal() *diode.L2VPN { + return &diode.L2VPN{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// L2VPNExtended Creates a L2VPN with common optional fields. +func L2VPNExtended() *diode.L2VPN { + return &diode.L2VPN{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Status: diode.String("active"), + Description: diode.String("Example description"), + Identifier: diode.Int64(1), + Type: diode.String("ep-lan"), + Comments: diode.String("Example comments"), + } +} + +// L2VPNExplicit Creates a L2VPN with fully nested objects and all common fields. +func L2VPNExplicit() *diode.L2VPN { + return &diode.L2VPN{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Status: diode.String("active"), + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + Identifier: diode.Int64(1), + Type: diode.String("ep-lan"), + Tenant: &diode.Tenant{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/l2vpn_termination/go.mod b/docs/examples/l2vpn_termination/go.mod new file mode 100644 index 0000000..61433ce --- /dev/null +++ b/docs/examples/l2vpn_termination/go.mod @@ -0,0 +1,9 @@ +module l2vpn_termination + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/l2vpn_termination/main.go b/docs/examples/l2vpn_termination/main.go new file mode 100644 index 0000000..fec34a5 --- /dev/null +++ b/docs/examples/l2vpn_termination/main.go @@ -0,0 +1,80 @@ +// Package main demonstrates ingesting L2VPNTermination entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "l2vpn_termination-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + l2vpnTermination := L2VPNTerminationMinimal() + // l2vpnTermination := L2VPNTerminationExtended() + // l2vpnTermination := L2VPNTerminationExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{l2vpnTermination}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("L2VPNTermination ingested successfully") + } +} + +// L2VPNTerminationMinimal Creates a L2VPNTermination with only required fields. +func L2VPNTerminationMinimal() *diode.L2VPNTermination { + return &diode.L2VPNTermination{ + L2Vpn: &diode.L2VPN{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + } +} + +// L2VPNTerminationExtended Creates a L2VPNTermination with common optional fields. +func L2VPNTerminationExtended() *diode.L2VPNTermination { + return &diode.L2VPNTermination{ + L2Vpn: &diode.L2VPN{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + } +} + +// L2VPNTerminationExplicit Creates a L2VPNTermination with fully nested objects and all common fields. +func L2VPNTerminationExplicit() *diode.L2VPNTermination { + return &diode.L2VPNTermination{ + L2Vpn: &diode.L2VPN{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/location/go.mod b/docs/examples/location/go.mod new file mode 100644 index 0000000..54e2b91 --- /dev/null +++ b/docs/examples/location/go.mod @@ -0,0 +1,9 @@ +module location + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/location/main.go b/docs/examples/location/main.go new file mode 100644 index 0000000..5631ceb --- /dev/null +++ b/docs/examples/location/main.go @@ -0,0 +1,119 @@ +// Package main demonstrates ingesting Location entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "location-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + location := LocationMinimal() + // location := LocationExtended() + // location := LocationExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{location}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("Location ingested successfully") + } +} + +// LocationMinimal Creates a Location with only required fields. +func LocationMinimal() *diode.Location { + return &diode.Location{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + } +} + +// LocationExtended Creates a Location with common optional fields. +func LocationExtended() *diode.Location { + return &diode.Location{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Status: diode.String("active"), + Description: diode.String("Example description"), + Facility: diode.String("Example Facility"), + Comments: diode.String("Example comments"), + } +} + +// LocationExplicit Creates a Location with fully nested objects and all common fields. +func LocationExplicit() *diode.Location { + return &diode.Location{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Status: diode.String("active"), + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + Facility: diode.String("Example Facility"), + Parent: &diode.Location{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Tenant: &diode.Tenant{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/mac_address/go.mod b/docs/examples/mac_address/go.mod new file mode 100644 index 0000000..cd150a9 --- /dev/null +++ b/docs/examples/mac_address/go.mod @@ -0,0 +1,9 @@ +module mac_address + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/mac_address/main.go b/docs/examples/mac_address/main.go new file mode 100644 index 0000000..98e24c5 --- /dev/null +++ b/docs/examples/mac_address/main.go @@ -0,0 +1,79 @@ +// Package main demonstrates ingesting MACAddress entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "mac_address-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + macAddress := MACAddressMinimal() + // macAddress := MACAddressExtended() + // macAddress := MACAddressExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{macAddress}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("MACAddress ingested successfully") + } +} + +// MACAddressMinimal Creates a MACAddress with only required fields. +func MACAddressMinimal() *diode.MACAddress { + return &diode.MACAddress{ + MacAddress: diode.String("00:11:22:33:44:55"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// MACAddressExtended Creates a MACAddress with common optional fields. +func MACAddressExtended() *diode.MACAddress { + return &diode.MACAddress{ + MacAddress: diode.String("00:11:22:33:44:55"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + } +} + +// MACAddressExplicit Creates a MACAddress with fully nested objects and all common fields. +func MACAddressExplicit() *diode.MACAddress { + return &diode.MACAddress{ + MacAddress: diode.String("00:11:22:33:44:55"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/manufacturer/go.mod b/docs/examples/manufacturer/go.mod new file mode 100644 index 0000000..bebdd25 --- /dev/null +++ b/docs/examples/manufacturer/go.mod @@ -0,0 +1,9 @@ +module manufacturer + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/manufacturer/main.go b/docs/examples/manufacturer/main.go new file mode 100644 index 0000000..97a0a16 --- /dev/null +++ b/docs/examples/manufacturer/main.go @@ -0,0 +1,82 @@ +// Package main demonstrates ingesting Manufacturer entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "manufacturer-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + manufacturer := ManufacturerMinimal() + // manufacturer := ManufacturerExtended() + // manufacturer := ManufacturerExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{manufacturer}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("Manufacturer ingested successfully") + } +} + +// ManufacturerMinimal Creates a Manufacturer with only required fields. +func ManufacturerMinimal() *diode.Manufacturer { + return &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// ManufacturerExtended Creates a Manufacturer with common optional fields. +func ManufacturerExtended() *diode.Manufacturer { + return &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + } +} + +// ManufacturerExplicit Creates a Manufacturer with fully nested objects and all common fields. +func ManufacturerExplicit() *diode.Manufacturer { + return &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/module/go.mod b/docs/examples/module/go.mod new file mode 100644 index 0000000..9ec7ccc --- /dev/null +++ b/docs/examples/module/go.mod @@ -0,0 +1,9 @@ +module module + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/module/main.go b/docs/examples/module/main.go new file mode 100644 index 0000000..70fcc9f --- /dev/null +++ b/docs/examples/module/main.go @@ -0,0 +1,265 @@ +// Package main demonstrates ingesting Module entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "module-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + module := ModuleMinimal() + // module := ModuleExtended() + // module := ModuleExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{module}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("Module ingested successfully") + } +} + +// ModuleMinimal Creates a Module with only required fields. +func ModuleMinimal() *diode.Module { + return &diode.Module{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + ModuleBay: &diode.ModuleBay{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + ModuleType: &diode.ModuleType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + } +} + +// ModuleExtended Creates a Module with common optional fields. +func ModuleExtended() *diode.Module { + return &diode.Module{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + ModuleBay: &diode.ModuleBay{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + ModuleType: &diode.ModuleType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Status: diode.String("active"), + Serial: diode.String("SN-001234"), + Description: diode.String("Example description"), + AssetTag: diode.String("ASSET-001"), + Comments: diode.String("Example comments"), + } +} + +// ModuleExplicit Creates a Module with fully nested objects and all common fields. +func ModuleExplicit() *diode.Module { + return &diode.Module{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Color: diode.String("0000ff"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + ModuleBay: &diode.ModuleBay{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Color: diode.String("0000ff"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + ModuleType: &diode.ModuleType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Status: diode.String("active"), + Serial: diode.String("SN-001234"), + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + AssetTag: diode.String("ASSET-001"), + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/module_bay/go.mod b/docs/examples/module_bay/go.mod new file mode 100644 index 0000000..17c3aef --- /dev/null +++ b/docs/examples/module_bay/go.mod @@ -0,0 +1,9 @@ +module module_bay + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/module_bay/main.go b/docs/examples/module_bay/main.go new file mode 100644 index 0000000..0c25610 --- /dev/null +++ b/docs/examples/module_bay/main.go @@ -0,0 +1,291 @@ +// Package main demonstrates ingesting ModuleBay entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "module_bay-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + moduleBay := ModuleBayMinimal() + // moduleBay := ModuleBayExtended() + // moduleBay := ModuleBayExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{moduleBay}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("ModuleBay ingested successfully") + } +} + +// ModuleBayMinimal Creates a ModuleBay with only required fields. +func ModuleBayMinimal() *diode.ModuleBay { + return &diode.ModuleBay{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// ModuleBayExtended Creates a ModuleBay with common optional fields. +func ModuleBayExtended() *diode.ModuleBay { + return &diode.ModuleBay{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + Label: diode.String("Example Label"), + Position: diode.String("Example Position"), + } +} + +// ModuleBayExplicit Creates a ModuleBay with fully nested objects and all common fields. +func ModuleBayExplicit() *diode.ModuleBay { + return &diode.ModuleBay{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Color: diode.String("0000ff"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Label: diode.String("Example Label"), + Position: diode.String("Example Position"), + Module: &diode.Module{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Color: diode.String("0000ff"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + ModuleBay: &diode.ModuleBay{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Color: diode.String("0000ff"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + ModuleType: &diode.ModuleType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + InstalledModule: &diode.Module{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Color: diode.String("0000ff"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + ModuleBay: &diode.ModuleBay{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Color: diode.String("0000ff"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + ModuleType: &diode.ModuleType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/module_type/go.mod b/docs/examples/module_type/go.mod new file mode 100644 index 0000000..2337a48 --- /dev/null +++ b/docs/examples/module_type/go.mod @@ -0,0 +1,9 @@ +module module_type + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/module_type/main.go b/docs/examples/module_type/main.go new file mode 100644 index 0000000..ba68d57 --- /dev/null +++ b/docs/examples/module_type/main.go @@ -0,0 +1,108 @@ +// Package main demonstrates ingesting ModuleType entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "module_type-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + moduleType := ModuleTypeMinimal() + // moduleType := ModuleTypeExtended() + // moduleType := ModuleTypeExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{moduleType}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("ModuleType ingested successfully") + } +} + +// ModuleTypeMinimal Creates a ModuleType with only required fields. +func ModuleTypeMinimal() *diode.ModuleType { + return &diode.ModuleType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// ModuleTypeExtended Creates a ModuleType with common optional fields. +func ModuleTypeExtended() *diode.ModuleType { + return &diode.ModuleType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + PartNumber: diode.String("Example PartNumber"), + Airflow: diode.String("front-to-rear"), + Weight: diode.Float64(1.0), + WeightUnit: diode.String("g"), + Comments: diode.String("Example comments"), + Attributes: diode.String("Example Attributes"), + } +} + +// ModuleTypeExplicit Creates a ModuleType with fully nested objects and all common fields. +func ModuleTypeExplicit() *diode.ModuleType { + return &diode.ModuleType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + PartNumber: diode.String("Example PartNumber"), + Airflow: diode.String("front-to-rear"), + Weight: diode.Float64(1.0), + WeightUnit: diode.String("g"), + Attributes: diode.String("Example Attributes"), + Profile: &diode.ModuleTypeProfile{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/module_type_profile/go.mod b/docs/examples/module_type_profile/go.mod new file mode 100644 index 0000000..51781de --- /dev/null +++ b/docs/examples/module_type_profile/go.mod @@ -0,0 +1,9 @@ +module module_type_profile + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/module_type_profile/main.go b/docs/examples/module_type_profile/main.go new file mode 100644 index 0000000..bf0b6d9 --- /dev/null +++ b/docs/examples/module_type_profile/main.go @@ -0,0 +1,81 @@ +// Package main demonstrates ingesting ModuleTypeProfile entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "module_type_profile-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + moduleTypeProfile := ModuleTypeProfileMinimal() + // moduleTypeProfile := ModuleTypeProfileExtended() + // moduleTypeProfile := ModuleTypeProfileExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{moduleTypeProfile}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("ModuleTypeProfile ingested successfully") + } +} + +// ModuleTypeProfileMinimal Creates a ModuleTypeProfile with only required fields. +func ModuleTypeProfileMinimal() *diode.ModuleTypeProfile { + return &diode.ModuleTypeProfile{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// ModuleTypeProfileExtended Creates a ModuleTypeProfile with common optional fields. +func ModuleTypeProfileExtended() *diode.ModuleTypeProfile { + return &diode.ModuleTypeProfile{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + Schema: diode.String("Example Schema"), + Comments: diode.String("Example comments"), + } +} + +// ModuleTypeProfileExplicit Creates a ModuleTypeProfile with fully nested objects and all common fields. +func ModuleTypeProfileExplicit() *diode.ModuleTypeProfile { + return &diode.ModuleTypeProfile{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + Schema: diode.String("Example Schema"), + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/owner/go.mod b/docs/examples/owner/go.mod new file mode 100644 index 0000000..bb9dc74 --- /dev/null +++ b/docs/examples/owner/go.mod @@ -0,0 +1,9 @@ +module owner + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/owner/main.go b/docs/examples/owner/main.go new file mode 100644 index 0000000..225a71f --- /dev/null +++ b/docs/examples/owner/main.go @@ -0,0 +1,80 @@ +// Package main demonstrates ingesting Owner entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "owner-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + owner := OwnerMinimal() + // owner := OwnerExtended() + // owner := OwnerExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{owner}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("Owner ingested successfully") + } +} + +// OwnerMinimal Creates a Owner with only required fields. +func OwnerMinimal() *diode.Owner { + return &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + } +} + +// OwnerExtended Creates a Owner with common optional fields. +func OwnerExtended() *diode.Owner { + return &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + } +} + +// OwnerExplicit Creates a Owner with fully nested objects and all common fields. +func OwnerExplicit() *diode.Owner { + return &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + } +} diff --git a/docs/examples/owner_group/go.mod b/docs/examples/owner_group/go.mod new file mode 100644 index 0000000..73b0fec --- /dev/null +++ b/docs/examples/owner_group/go.mod @@ -0,0 +1,9 @@ +module owner_group + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/owner_group/main.go b/docs/examples/owner_group/main.go new file mode 100644 index 0000000..b9353b9 --- /dev/null +++ b/docs/examples/owner_group/main.go @@ -0,0 +1,68 @@ +// Package main demonstrates ingesting OwnerGroup entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "owner_group-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + ownerGroup := OwnerGroupMinimal() + // ownerGroup := OwnerGroupExtended() + // ownerGroup := OwnerGroupExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{ownerGroup}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("OwnerGroup ingested successfully") + } +} + +// OwnerGroupMinimal Creates a OwnerGroup with only required fields. +func OwnerGroupMinimal() *diode.OwnerGroup { + return &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// OwnerGroupExtended Creates a OwnerGroup with common optional fields. +func OwnerGroupExtended() *diode.OwnerGroup { + return &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + } +} + +// OwnerGroupExplicit Creates a OwnerGroup with fully nested objects and all common fields. +func OwnerGroupExplicit() *diode.OwnerGroup { + return &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + } +} diff --git a/docs/examples/platform/go.mod b/docs/examples/platform/go.mod new file mode 100644 index 0000000..9c9007a --- /dev/null +++ b/docs/examples/platform/go.mod @@ -0,0 +1,9 @@ +module platform + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/platform/main.go b/docs/examples/platform/main.go new file mode 100644 index 0000000..c6272b4 --- /dev/null +++ b/docs/examples/platform/main.go @@ -0,0 +1,92 @@ +// Package main demonstrates ingesting Platform entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "platform-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + platform := PlatformMinimal() + // platform := PlatformExtended() + // platform := PlatformExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{platform}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("Platform ingested successfully") + } +} + +// PlatformMinimal Creates a Platform with only required fields. +func PlatformMinimal() *diode.Platform { + return &diode.Platform{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// PlatformExtended Creates a Platform with common optional fields. +func PlatformExtended() *diode.Platform { + return &diode.Platform{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + } +} + +// PlatformExplicit Creates a Platform with fully nested objects and all common fields. +func PlatformExplicit() *diode.Platform { + return &diode.Platform{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Parent: &diode.Platform{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/power_feed/go.mod b/docs/examples/power_feed/go.mod new file mode 100644 index 0000000..7ee6eb2 --- /dev/null +++ b/docs/examples/power_feed/go.mod @@ -0,0 +1,9 @@ +module power_feed + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/power_feed/main.go b/docs/examples/power_feed/main.go new file mode 100644 index 0000000..45b411a --- /dev/null +++ b/docs/examples/power_feed/main.go @@ -0,0 +1,139 @@ +// Package main demonstrates ingesting PowerFeed entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "power_feed-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + powerFeed := PowerFeedMinimal() + // powerFeed := PowerFeedExtended() + // powerFeed := PowerFeedExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{powerFeed}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("PowerFeed ingested successfully") + } +} + +// PowerFeedMinimal Creates a PowerFeed with only required fields. +func PowerFeedMinimal() *diode.PowerFeed { + return &diode.PowerFeed{ + PowerPanel: &diode.PowerPanel{ + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// PowerFeedExtended Creates a PowerFeed with common optional fields. +func PowerFeedExtended() *diode.PowerFeed { + return &diode.PowerFeed{ + PowerPanel: &diode.PowerPanel{ + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Status: diode.String("active"), + Description: diode.String("Example description"), + Type: diode.String("primary"), + Supply: diode.String("ac"), + Phase: diode.String("single-phase"), + Voltage: diode.Int64(1), + Amperage: diode.Int64(1), + MaxUtilization: diode.Int64(1), + MarkConnected: diode.Bool(true), + Comments: diode.String("Example comments"), + } +} + +// PowerFeedExplicit Creates a PowerFeed with fully nested objects and all common fields. +func PowerFeedExplicit() *diode.PowerFeed { + return &diode.PowerFeed{ + PowerPanel: &diode.PowerPanel{ + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Status: diode.String("active"), + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + Type: diode.String("primary"), + Supply: diode.String("ac"), + Phase: diode.String("single-phase"), + Voltage: diode.Int64(1), + Amperage: diode.Int64(1), + MaxUtilization: diode.Int64(1), + MarkConnected: diode.Bool(true), + Rack: &diode.Rack{ + Name: diode.String("Example Name"), + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Tenant: &diode.Tenant{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/power_outlet/go.mod b/docs/examples/power_outlet/go.mod new file mode 100644 index 0000000..9fd9082 --- /dev/null +++ b/docs/examples/power_outlet/go.mod @@ -0,0 +1,9 @@ +module power_outlet + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/power_outlet/main.go b/docs/examples/power_outlet/main.go new file mode 100644 index 0000000..704610b --- /dev/null +++ b/docs/examples/power_outlet/main.go @@ -0,0 +1,260 @@ +// Package main demonstrates ingesting PowerOutlet entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "power_outlet-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + powerOutlet := PowerOutletMinimal() + // powerOutlet := PowerOutletExtended() + // powerOutlet := PowerOutletExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{powerOutlet}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("PowerOutlet ingested successfully") + } +} + +// PowerOutletMinimal Creates a PowerOutlet with only required fields. +func PowerOutletMinimal() *diode.PowerOutlet { + return &diode.PowerOutlet{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// PowerOutletExtended Creates a PowerOutlet with common optional fields. +func PowerOutletExtended() *diode.PowerOutlet { + return &diode.PowerOutlet{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Status: diode.String("disabled"), + Description: diode.String("Example description"), + Color: diode.String("0000ff"), + Label: diode.String("Example Label"), + Type: diode.String("CS6360C"), + FeedLeg: diode.String("A"), + MarkConnected: diode.Bool(true), + } +} + +// PowerOutletExplicit Creates a PowerOutlet with fully nested objects and all common fields. +func PowerOutletExplicit() *diode.PowerOutlet { + return &diode.PowerOutlet{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Color: diode.String("0000ff"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Status: diode.String("disabled"), + Description: diode.String("Example description"), + Color: diode.String("0000ff"), + Label: diode.String("Example Label"), + Type: diode.String("CS6360C"), + FeedLeg: diode.String("A"), + MarkConnected: diode.Bool(true), + Module: &diode.Module{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Color: diode.String("0000ff"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + ModuleBay: &diode.ModuleBay{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Color: diode.String("0000ff"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + ModuleType: &diode.ModuleType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + PowerPort: &diode.PowerPort{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Color: diode.String("0000ff"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/power_panel/go.mod b/docs/examples/power_panel/go.mod new file mode 100644 index 0000000..7db81b2 --- /dev/null +++ b/docs/examples/power_panel/go.mod @@ -0,0 +1,9 @@ +module power_panel + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/power_panel/main.go b/docs/examples/power_panel/main.go new file mode 100644 index 0000000..373f433 --- /dev/null +++ b/docs/examples/power_panel/main.go @@ -0,0 +1,107 @@ +// Package main demonstrates ingesting PowerPanel entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "power_panel-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + powerPanel := PowerPanelMinimal() + // powerPanel := PowerPanelExtended() + // powerPanel := PowerPanelExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{powerPanel}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("PowerPanel ingested successfully") + } +} + +// PowerPanelMinimal Creates a PowerPanel with only required fields. +func PowerPanelMinimal() *diode.PowerPanel { + return &diode.PowerPanel{ + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// PowerPanelExtended Creates a PowerPanel with common optional fields. +func PowerPanelExtended() *diode.PowerPanel { + return &diode.PowerPanel{ + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + } +} + +// PowerPanelExplicit Creates a PowerPanel with fully nested objects and all common fields. +func PowerPanelExplicit() *diode.PowerPanel { + return &diode.PowerPanel{ + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + Location: &diode.Location{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/power_port/go.mod b/docs/examples/power_port/go.mod new file mode 100644 index 0000000..068c2a0 --- /dev/null +++ b/docs/examples/power_port/go.mod @@ -0,0 +1,9 @@ +module power_port + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/power_port/main.go b/docs/examples/power_port/main.go new file mode 100644 index 0000000..6b07f8e --- /dev/null +++ b/docs/examples/power_port/main.go @@ -0,0 +1,228 @@ +// Package main demonstrates ingesting PowerPort entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "power_port-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + powerPort := PowerPortMinimal() + // powerPort := PowerPortExtended() + // powerPort := PowerPortExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{powerPort}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("PowerPort ingested successfully") + } +} + +// PowerPortMinimal Creates a PowerPort with only required fields. +func PowerPortMinimal() *diode.PowerPort { + return &diode.PowerPort{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// PowerPortExtended Creates a PowerPort with common optional fields. +func PowerPortExtended() *diode.PowerPort { + return &diode.PowerPort{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + Label: diode.String("Example Label"), + Type: diode.String("cs6361c"), + MaximumDraw: diode.Int64(1), + AllocatedDraw: diode.Int64(1), + MarkConnected: diode.Bool(true), + } +} + +// PowerPortExplicit Creates a PowerPort with fully nested objects and all common fields. +func PowerPortExplicit() *diode.PowerPort { + return &diode.PowerPort{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Color: diode.String("0000ff"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Label: diode.String("Example Label"), + Type: diode.String("cs6361c"), + MaximumDraw: diode.Int64(1), + AllocatedDraw: diode.Int64(1), + MarkConnected: diode.Bool(true), + Module: &diode.Module{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Color: diode.String("0000ff"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + ModuleBay: &diode.ModuleBay{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Color: diode.String("0000ff"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + ModuleType: &diode.ModuleType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/prefix/go.mod b/docs/examples/prefix/go.mod new file mode 100644 index 0000000..a8cd137 --- /dev/null +++ b/docs/examples/prefix/go.mod @@ -0,0 +1,9 @@ +module prefix + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/prefix/main.go b/docs/examples/prefix/main.go new file mode 100644 index 0000000..049cf3a --- /dev/null +++ b/docs/examples/prefix/main.go @@ -0,0 +1,105 @@ +// Package main demonstrates ingesting Prefix entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "prefix-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + prefix := PrefixMinimal() + // prefix := PrefixExtended() + // prefix := PrefixExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{prefix}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("Prefix ingested successfully") + } +} + +// PrefixMinimal Creates a Prefix with only required fields. +func PrefixMinimal() *diode.Prefix { + return &diode.Prefix{ + Prefix: diode.String("192.0.2.0/24"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// PrefixExtended Creates a Prefix with common optional fields. +func PrefixExtended() *diode.Prefix { + return &diode.Prefix{ + Prefix: diode.String("192.0.2.0/24"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Status: diode.String("active"), + Description: diode.String("Example description"), + IsPool: diode.Bool(true), + MarkUtilized: diode.Bool(true), + Comments: diode.String("Example comments"), + } +} + +// PrefixExplicit Creates a Prefix with fully nested objects and all common fields. +func PrefixExplicit() *diode.Prefix { + return &diode.Prefix{ + Prefix: diode.String("192.0.2.0/24"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Status: diode.String("active"), + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + IsPool: diode.Bool(true), + MarkUtilized: diode.Bool(true), + Vrf: &diode.VRF{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Tenant: &diode.Tenant{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Vlan: &diode.VLAN{ + Vid: diode.Int64(1), + Name: diode.String("Example Name"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.Role{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/provider/go.mod b/docs/examples/provider/go.mod new file mode 100644 index 0000000..2f72e66 --- /dev/null +++ b/docs/examples/provider/go.mod @@ -0,0 +1,9 @@ +module provider + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/provider/main.go b/docs/examples/provider/main.go new file mode 100644 index 0000000..21ebdcb --- /dev/null +++ b/docs/examples/provider/main.go @@ -0,0 +1,82 @@ +// Package main demonstrates ingesting Provider entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "provider-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + provider := ProviderMinimal() + // provider := ProviderExtended() + // provider := ProviderExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{provider}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("Provider ingested successfully") + } +} + +// ProviderMinimal Creates a Provider with only required fields. +func ProviderMinimal() *diode.Provider { + return &diode.Provider{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// ProviderExtended Creates a Provider with common optional fields. +func ProviderExtended() *diode.Provider { + return &diode.Provider{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + } +} + +// ProviderExplicit Creates a Provider with fully nested objects and all common fields. +func ProviderExplicit() *diode.Provider { + return &diode.Provider{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/provider_account/go.mod b/docs/examples/provider_account/go.mod new file mode 100644 index 0000000..fc9f339 --- /dev/null +++ b/docs/examples/provider_account/go.mod @@ -0,0 +1,9 @@ +module provider_account + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/provider_account/main.go b/docs/examples/provider_account/main.go new file mode 100644 index 0000000..8f137e2 --- /dev/null +++ b/docs/examples/provider_account/main.go @@ -0,0 +1,96 @@ +// Package main demonstrates ingesting ProviderAccount entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "provider_account-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + providerAccount := ProviderAccountMinimal() + // providerAccount := ProviderAccountExtended() + // providerAccount := ProviderAccountExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{providerAccount}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("ProviderAccount ingested successfully") + } +} + +// ProviderAccountMinimal Creates a ProviderAccount with only required fields. +func ProviderAccountMinimal() *diode.ProviderAccount { + return &diode.ProviderAccount{ + Provider: &diode.Provider{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Account: diode.String("Example Account"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// ProviderAccountExtended Creates a ProviderAccount with common optional fields. +func ProviderAccountExtended() *diode.ProviderAccount { + return &diode.ProviderAccount{ + Provider: &diode.Provider{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Account: diode.String("Example Account"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + Name: diode.String("Example Name"), + Comments: diode.String("Example comments"), + } +} + +// ProviderAccountExplicit Creates a ProviderAccount with fully nested objects and all common fields. +func ProviderAccountExplicit() *diode.ProviderAccount { + return &diode.ProviderAccount{ + Provider: &diode.Provider{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Account: diode.String("Example Account"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + Name: diode.String("Example Name"), + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/provider_network/go.mod b/docs/examples/provider_network/go.mod new file mode 100644 index 0000000..b83d580 --- /dev/null +++ b/docs/examples/provider_network/go.mod @@ -0,0 +1,9 @@ +module provider_network + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/provider_network/main.go b/docs/examples/provider_network/main.go new file mode 100644 index 0000000..5643ee2 --- /dev/null +++ b/docs/examples/provider_network/main.go @@ -0,0 +1,96 @@ +// Package main demonstrates ingesting ProviderNetwork entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "provider_network-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + providerNetwork := ProviderNetworkMinimal() + // providerNetwork := ProviderNetworkExtended() + // providerNetwork := ProviderNetworkExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{providerNetwork}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("ProviderNetwork ingested successfully") + } +} + +// ProviderNetworkMinimal Creates a ProviderNetwork with only required fields. +func ProviderNetworkMinimal() *diode.ProviderNetwork { + return &diode.ProviderNetwork{ + Provider: &diode.Provider{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// ProviderNetworkExtended Creates a ProviderNetwork with common optional fields. +func ProviderNetworkExtended() *diode.ProviderNetwork { + return &diode.ProviderNetwork{ + Provider: &diode.Provider{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + ServiceId: diode.String("Example ServiceId"), + Comments: diode.String("Example comments"), + } +} + +// ProviderNetworkExplicit Creates a ProviderNetwork with fully nested objects and all common fields. +func ProviderNetworkExplicit() *diode.ProviderNetwork { + return &diode.ProviderNetwork{ + Provider: &diode.Provider{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + ServiceId: diode.String("Example ServiceId"), + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/rack/go.mod b/docs/examples/rack/go.mod new file mode 100644 index 0000000..0cd1d55 --- /dev/null +++ b/docs/examples/rack/go.mod @@ -0,0 +1,9 @@ +module rack + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/rack/main.go b/docs/examples/rack/main.go new file mode 100644 index 0000000..4abbbdc --- /dev/null +++ b/docs/examples/rack/main.go @@ -0,0 +1,164 @@ +// Package main demonstrates ingesting Rack entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "rack-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + rack := RackMinimal() + // rack := RackExtended() + // rack := RackExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{rack}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("Rack ingested successfully") + } +} + +// RackMinimal Creates a Rack with only required fields. +func RackMinimal() *diode.Rack { + return &diode.Rack{ + Name: diode.String("Example Name"), + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + } +} + +// RackExtended Creates a Rack with common optional fields. +func RackExtended() *diode.Rack { + return &diode.Rack{ + Name: diode.String("Example Name"), + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Status: diode.String("active"), + Serial: diode.String("SN-001234"), + Description: diode.String("Example description"), + FacilityId: diode.String("Example FacilityId"), + AssetTag: diode.String("ASSET-001"), + FormFactor: diode.String("2-post-frame"), + Width: diode.Int64(1), + UHeight: diode.Int64(1), + StartingUnit: diode.Int64(1), + Weight: diode.Float64(1.0), + MaxWeight: diode.Int64(1), + WeightUnit: diode.String("g"), + DescUnits: diode.Bool(true), + OuterWidth: diode.Int64(1), + OuterDepth: diode.Int64(1), + OuterUnit: diode.String("in"), + MountingDepth: diode.Int64(1), + Airflow: diode.String("front-to-rear"), + Comments: diode.String("Example comments"), + OuterHeight: diode.Int64(1), + } +} + +// RackExplicit Creates a Rack with fully nested objects and all common fields. +func RackExplicit() *diode.Rack { + return &diode.Rack{ + Name: diode.String("Example Name"), + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Status: diode.String("active"), + Serial: diode.String("SN-001234"), + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + AssetTag: diode.String("ASSET-001"), + FacilityId: diode.String("Example FacilityId"), + FormFactor: diode.String("2-post-frame"), + Width: diode.Int64(1), + UHeight: diode.Int64(1), + StartingUnit: diode.Int64(1), + Weight: diode.Float64(1.0), + MaxWeight: diode.Int64(1), + WeightUnit: diode.String("g"), + DescUnits: diode.Bool(true), + OuterWidth: diode.Int64(1), + OuterDepth: diode.Int64(1), + OuterUnit: diode.String("in"), + MountingDepth: diode.Int64(1), + Airflow: diode.String("front-to-rear"), + OuterHeight: diode.Int64(1), + Location: &diode.Location{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Tenant: &diode.Tenant{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.RackRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Color: diode.String("0000ff"), + Metadata: diode.Metadata{"source": "example"}, + }, + RackType: &diode.RackType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/rack_reservation/go.mod b/docs/examples/rack_reservation/go.mod new file mode 100644 index 0000000..a6636e9 --- /dev/null +++ b/docs/examples/rack_reservation/go.mod @@ -0,0 +1,9 @@ +module rack_reservation + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/rack_reservation/main.go b/docs/examples/rack_reservation/main.go new file mode 100644 index 0000000..2ca0388 --- /dev/null +++ b/docs/examples/rack_reservation/main.go @@ -0,0 +1,113 @@ +// Package main demonstrates ingesting RackReservation entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "rack_reservation-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + rackReservation := RackReservationMinimal() + // rackReservation := RackReservationExtended() + // rackReservation := RackReservationExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{rackReservation}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("RackReservation ingested successfully") + } +} + +// RackReservationMinimal Creates a RackReservation with only required fields. +func RackReservationMinimal() *diode.RackReservation { + return &diode.RackReservation{ + Rack: &diode.Rack{ + Name: diode.String("Example Name"), + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Description: diode.String("Example description"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// RackReservationExtended Creates a RackReservation with common optional fields. +func RackReservationExtended() *diode.RackReservation { + return &diode.RackReservation{ + Rack: &diode.Rack{ + Name: diode.String("Example Name"), + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Description: diode.String("Example description"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Status: diode.String("active"), + Comments: diode.String("Example comments"), + } +} + +// RackReservationExplicit Creates a RackReservation with fully nested objects and all common fields. +func RackReservationExplicit() *diode.RackReservation { + return &diode.RackReservation{ + Rack: &diode.Rack{ + Name: diode.String("Example Name"), + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Description: diode.String("Example description"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Status: diode.String("active"), + Comments: diode.String("Example comments"), + Tenant: &diode.Tenant{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/rack_role/go.mod b/docs/examples/rack_role/go.mod new file mode 100644 index 0000000..8f77fc3 --- /dev/null +++ b/docs/examples/rack_role/go.mod @@ -0,0 +1,9 @@ +module rack_role + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/rack_role/main.go b/docs/examples/rack_role/main.go new file mode 100644 index 0000000..655b887 --- /dev/null +++ b/docs/examples/rack_role/main.go @@ -0,0 +1,84 @@ +// Package main demonstrates ingesting RackRole entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "rack_role-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + rackRole := RackRoleMinimal() + // rackRole := RackRoleExtended() + // rackRole := RackRoleExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{rackRole}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("RackRole ingested successfully") + } +} + +// RackRoleMinimal Creates a RackRole with only required fields. +func RackRoleMinimal() *diode.RackRole { + return &diode.RackRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// RackRoleExtended Creates a RackRole with common optional fields. +func RackRoleExtended() *diode.RackRole { + return &diode.RackRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + Color: diode.String("0000ff"), + Comments: diode.String("Example comments"), + } +} + +// RackRoleExplicit Creates a RackRole with fully nested objects and all common fields. +func RackRoleExplicit() *diode.RackRole { + return &diode.RackRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Color: diode.String("0000ff"), + Comments: diode.String("Example comments"), + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/rack_type/go.mod b/docs/examples/rack_type/go.mod new file mode 100644 index 0000000..6ee165c --- /dev/null +++ b/docs/examples/rack_type/go.mod @@ -0,0 +1,9 @@ +module rack_type + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/rack_type/main.go b/docs/examples/rack_type/main.go new file mode 100644 index 0000000..04e6cad --- /dev/null +++ b/docs/examples/rack_type/main.go @@ -0,0 +1,123 @@ +// Package main demonstrates ingesting RackType entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "rack_type-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + rackType := RackTypeMinimal() + // rackType := RackTypeExtended() + // rackType := RackTypeExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{rackType}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("RackType ingested successfully") + } +} + +// RackTypeMinimal Creates a RackType with only required fields. +func RackTypeMinimal() *diode.RackType { + return &diode.RackType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// RackTypeExtended Creates a RackType with common optional fields. +func RackTypeExtended() *diode.RackType { + return &diode.RackType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + FormFactor: diode.String("2-post-frame"), + Width: diode.Int64(1), + UHeight: diode.Int64(1), + StartingUnit: diode.Int64(1), + DescUnits: diode.Bool(true), + OuterWidth: diode.Int64(1), + OuterDepth: diode.Int64(1), + OuterUnit: diode.String("in"), + Weight: diode.Float64(1.0), + MaxWeight: diode.Int64(1), + WeightUnit: diode.String("g"), + MountingDepth: diode.Int64(1), + Comments: diode.String("Example comments"), + OuterHeight: diode.Int64(1), + } +} + +// RackTypeExplicit Creates a RackType with fully nested objects and all common fields. +func RackTypeExplicit() *diode.RackType { + return &diode.RackType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + FormFactor: diode.String("2-post-frame"), + Width: diode.Int64(1), + UHeight: diode.Int64(1), + StartingUnit: diode.Int64(1), + DescUnits: diode.Bool(true), + OuterWidth: diode.Int64(1), + OuterDepth: diode.Int64(1), + OuterUnit: diode.String("in"), + Weight: diode.Float64(1.0), + MaxWeight: diode.Int64(1), + WeightUnit: diode.String("g"), + MountingDepth: diode.Int64(1), + OuterHeight: diode.Int64(1), + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/rear_port/go.mod b/docs/examples/rear_port/go.mod new file mode 100644 index 0000000..114eaf1 --- /dev/null +++ b/docs/examples/rear_port/go.mod @@ -0,0 +1,9 @@ +module rear_port + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/rear_port/main.go b/docs/examples/rear_port/main.go new file mode 100644 index 0000000..dd62e79 --- /dev/null +++ b/docs/examples/rear_port/main.go @@ -0,0 +1,229 @@ +// Package main demonstrates ingesting RearPort entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "rear_port-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + rearPort := RearPortMinimal() + // rearPort := RearPortExtended() + // rearPort := RearPortExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{rearPort}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("RearPort ingested successfully") + } +} + +// RearPortMinimal Creates a RearPort with only required fields. +func RearPortMinimal() *diode.RearPort { + return &diode.RearPort{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Type: diode.String("110-punch"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// RearPortExtended Creates a RearPort with common optional fields. +func RearPortExtended() *diode.RearPort { + return &diode.RearPort{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Type: diode.String("110-punch"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + Color: diode.String("0000ff"), + Label: diode.String("Example Label"), + Positions: diode.Int64(1), + MarkConnected: diode.Bool(true), + } +} + +// RearPortExplicit Creates a RearPort with fully nested objects and all common fields. +func RearPortExplicit() *diode.RearPort { + return &diode.RearPort{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Color: diode.String("0000ff"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Type: diode.String("110-punch"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Color: diode.String("0000ff"), + Label: diode.String("Example Label"), + Positions: diode.Int64(1), + MarkConnected: diode.Bool(true), + Module: &diode.Module{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Color: diode.String("0000ff"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + ModuleBay: &diode.ModuleBay{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Color: diode.String("0000ff"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + ModuleType: &diode.ModuleType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/region/go.mod b/docs/examples/region/go.mod new file mode 100644 index 0000000..dd16904 --- /dev/null +++ b/docs/examples/region/go.mod @@ -0,0 +1,9 @@ +module region + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/region/main.go b/docs/examples/region/main.go new file mode 100644 index 0000000..6ad2b5e --- /dev/null +++ b/docs/examples/region/main.go @@ -0,0 +1,87 @@ +// Package main demonstrates ingesting Region entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "region-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + region := RegionMinimal() + // region := RegionExtended() + // region := RegionExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{region}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("Region ingested successfully") + } +} + +// RegionMinimal Creates a Region with only required fields. +func RegionMinimal() *diode.Region { + return &diode.Region{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// RegionExtended Creates a Region with common optional fields. +func RegionExtended() *diode.Region { + return &diode.Region{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + } +} + +// RegionExplicit Creates a Region with fully nested objects and all common fields. +func RegionExplicit() *diode.Region { + return &diode.Region{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + Parent: &diode.Region{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/rir/go.mod b/docs/examples/rir/go.mod new file mode 100644 index 0000000..f28a5af --- /dev/null +++ b/docs/examples/rir/go.mod @@ -0,0 +1,9 @@ +module rir + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/rir/main.go b/docs/examples/rir/main.go new file mode 100644 index 0000000..6d961f0 --- /dev/null +++ b/docs/examples/rir/main.go @@ -0,0 +1,84 @@ +// Package main demonstrates ingesting RIR entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "rir-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + rir := RIRMinimal() + // rir := RIRExtended() + // rir := RIRExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{rir}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("RIR ingested successfully") + } +} + +// RIRMinimal Creates a RIR with only required fields. +func RIRMinimal() *diode.RIR { + return &diode.RIR{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// RIRExtended Creates a RIR with common optional fields. +func RIRExtended() *diode.RIR { + return &diode.RIR{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + IsPrivate: diode.Bool(true), + Comments: diode.String("Example comments"), + } +} + +// RIRExplicit Creates a RIR with fully nested objects and all common fields. +func RIRExplicit() *diode.RIR { + return &diode.RIR{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + IsPrivate: diode.Bool(true), + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/role/go.mod b/docs/examples/role/go.mod new file mode 100644 index 0000000..92f7366 --- /dev/null +++ b/docs/examples/role/go.mod @@ -0,0 +1,9 @@ +module role + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/role/main.go b/docs/examples/role/main.go new file mode 100644 index 0000000..087efc0 --- /dev/null +++ b/docs/examples/role/main.go @@ -0,0 +1,84 @@ +// Package main demonstrates ingesting Role entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "role-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + role := RoleMinimal() + // role := RoleExtended() + // role := RoleExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{role}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("Role ingested successfully") + } +} + +// RoleMinimal Creates a Role with only required fields. +func RoleMinimal() *diode.Role { + return &diode.Role{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// RoleExtended Creates a Role with common optional fields. +func RoleExtended() *diode.Role { + return &diode.Role{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + Weight: diode.Int64(1), + Comments: diode.String("Example comments"), + } +} + +// RoleExplicit Creates a Role with fully nested objects and all common fields. +func RoleExplicit() *diode.Role { + return &diode.Role{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + Weight: diode.Int64(1), + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/route_target/go.mod b/docs/examples/route_target/go.mod new file mode 100644 index 0000000..f5d7b84 --- /dev/null +++ b/docs/examples/route_target/go.mod @@ -0,0 +1,9 @@ +module route_target + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/route_target/main.go b/docs/examples/route_target/main.go new file mode 100644 index 0000000..7e3ae9e --- /dev/null +++ b/docs/examples/route_target/main.go @@ -0,0 +1,84 @@ +// Package main demonstrates ingesting RouteTarget entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "route_target-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + routeTarget := RouteTargetMinimal() + // routeTarget := RouteTargetExtended() + // routeTarget := RouteTargetExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{routeTarget}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("RouteTarget ingested successfully") + } +} + +// RouteTargetMinimal Creates a RouteTarget with only required fields. +func RouteTargetMinimal() *diode.RouteTarget { + return &diode.RouteTarget{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// RouteTargetExtended Creates a RouteTarget with common optional fields. +func RouteTargetExtended() *diode.RouteTarget { + return &diode.RouteTarget{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + } +} + +// RouteTargetExplicit Creates a RouteTarget with fully nested objects and all common fields. +func RouteTargetExplicit() *diode.RouteTarget { + return &diode.RouteTarget{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + Tenant: &diode.Tenant{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/service/go.mod b/docs/examples/service/go.mod new file mode 100644 index 0000000..1264f01 --- /dev/null +++ b/docs/examples/service/go.mod @@ -0,0 +1,9 @@ +module service + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/service/main.go b/docs/examples/service/main.go new file mode 100644 index 0000000..9fe4ac1 --- /dev/null +++ b/docs/examples/service/main.go @@ -0,0 +1,112 @@ +// Package main demonstrates ingesting Service entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "service-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + service := ServiceMinimal() + // service := ServiceExtended() + // service := ServiceExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{service}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("Service ingested successfully") + } +} + +// ServiceMinimal Creates a Service with only required fields. +func ServiceMinimal() *diode.Service { + return &diode.Service{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// ServiceExtended Creates a Service with common optional fields. +func ServiceExtended() *diode.Service { + return &diode.Service{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + Protocol: diode.String("sctp"), + Comments: diode.String("Example comments"), + } +} + +// ServiceExplicit Creates a Service with fully nested objects and all common fields. +func ServiceExplicit() *diode.Service { + return &diode.Service{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + Protocol: diode.String("sctp"), + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Color: diode.String("0000ff"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + VirtualMachine: &diode.VirtualMachine{ + Name: diode.String("Example Name"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/site/go.mod b/docs/examples/site/go.mod new file mode 100644 index 0000000..9b86744 --- /dev/null +++ b/docs/examples/site/go.mod @@ -0,0 +1,9 @@ +module site + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/site/main.go b/docs/examples/site/main.go new file mode 100644 index 0000000..84213d7 --- /dev/null +++ b/docs/examples/site/main.go @@ -0,0 +1,111 @@ +// Package main demonstrates ingesting Site entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "site-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + site := SiteMinimal() + // site := SiteExtended() + // site := SiteExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{site}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("Site ingested successfully") + } +} + +// SiteMinimal Creates a Site with only required fields. +func SiteMinimal() *diode.Site { + return &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// SiteExtended Creates a Site with common optional fields. +func SiteExtended() *diode.Site { + return &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Status: diode.String("active"), + Description: diode.String("Example description"), + Facility: diode.String("Example Facility"), + TimeZone: diode.String("Example TimeZone"), + PhysicalAddress: diode.String("Example PhysicalAddress"), + ShippingAddress: diode.String("Example ShippingAddress"), + Latitude: diode.Float64(1.0), + Longitude: diode.Float64(1.0), + Comments: diode.String("Example comments"), + } +} + +// SiteExplicit Creates a Site with fully nested objects and all common fields. +func SiteExplicit() *diode.Site { + return &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Status: diode.String("active"), + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + Facility: diode.String("Example Facility"), + TimeZone: diode.String("Example TimeZone"), + PhysicalAddress: diode.String("Example PhysicalAddress"), + ShippingAddress: diode.String("Example ShippingAddress"), + Latitude: diode.Float64(1.0), + Longitude: diode.Float64(1.0), + Region: &diode.Region{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Group: &diode.SiteGroup{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Tenant: &diode.Tenant{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/site_group/go.mod b/docs/examples/site_group/go.mod new file mode 100644 index 0000000..66a19c7 --- /dev/null +++ b/docs/examples/site_group/go.mod @@ -0,0 +1,9 @@ +module site_group + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/site_group/main.go b/docs/examples/site_group/main.go new file mode 100644 index 0000000..147b994 --- /dev/null +++ b/docs/examples/site_group/main.go @@ -0,0 +1,87 @@ +// Package main demonstrates ingesting SiteGroup entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "site_group-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + siteGroup := SiteGroupMinimal() + // siteGroup := SiteGroupExtended() + // siteGroup := SiteGroupExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{siteGroup}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("SiteGroup ingested successfully") + } +} + +// SiteGroupMinimal Creates a SiteGroup with only required fields. +func SiteGroupMinimal() *diode.SiteGroup { + return &diode.SiteGroup{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// SiteGroupExtended Creates a SiteGroup with common optional fields. +func SiteGroupExtended() *diode.SiteGroup { + return &diode.SiteGroup{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + } +} + +// SiteGroupExplicit Creates a SiteGroup with fully nested objects and all common fields. +func SiteGroupExplicit() *diode.SiteGroup { + return &diode.SiteGroup{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + Parent: &diode.SiteGroup{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/tag/go.mod b/docs/examples/tag/go.mod new file mode 100644 index 0000000..74328ae --- /dev/null +++ b/docs/examples/tag/go.mod @@ -0,0 +1,9 @@ +module tag + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/tag/main.go b/docs/examples/tag/main.go new file mode 100644 index 0000000..6e33853 --- /dev/null +++ b/docs/examples/tag/main.go @@ -0,0 +1,75 @@ +// Package main demonstrates ingesting Tag entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "tag-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + tag := TagMinimal() + // tag := TagExtended() + // tag := TagExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{tag}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("Tag ingested successfully") + } +} + +// TagMinimal Creates a Tag with only required fields. +func TagMinimal() *diode.Tag { + return &diode.Tag{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// TagExtended Creates a Tag with common optional fields. +func TagExtended() *diode.Tag { + return &diode.Tag{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + Color: diode.String("0000ff"), + Weight: diode.Int64(1), + } +} + +// TagExplicit Creates a Tag with fully nested objects and all common fields. +func TagExplicit() *diode.Tag { + return &diode.Tag{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Color: diode.String("0000ff"), + Weight: diode.Int64(1), + } +} diff --git a/docs/examples/tenant/go.mod b/docs/examples/tenant/go.mod new file mode 100644 index 0000000..c8261e7 --- /dev/null +++ b/docs/examples/tenant/go.mod @@ -0,0 +1,9 @@ +module tenant + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/tenant/main.go b/docs/examples/tenant/main.go new file mode 100644 index 0000000..bf20446 --- /dev/null +++ b/docs/examples/tenant/main.go @@ -0,0 +1,87 @@ +// Package main demonstrates ingesting Tenant entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "tenant-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + tenant := TenantMinimal() + // tenant := TenantExtended() + // tenant := TenantExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{tenant}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("Tenant ingested successfully") + } +} + +// TenantMinimal Creates a Tenant with only required fields. +func TenantMinimal() *diode.Tenant { + return &diode.Tenant{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// TenantExtended Creates a Tenant with common optional fields. +func TenantExtended() *diode.Tenant { + return &diode.Tenant{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + } +} + +// TenantExplicit Creates a Tenant with fully nested objects and all common fields. +func TenantExplicit() *diode.Tenant { + return &diode.Tenant{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + Group: &diode.TenantGroup{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/tenant_group/go.mod b/docs/examples/tenant_group/go.mod new file mode 100644 index 0000000..b8be8b6 --- /dev/null +++ b/docs/examples/tenant_group/go.mod @@ -0,0 +1,9 @@ +module tenant_group + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/tenant_group/main.go b/docs/examples/tenant_group/main.go new file mode 100644 index 0000000..8b3a85c --- /dev/null +++ b/docs/examples/tenant_group/main.go @@ -0,0 +1,87 @@ +// Package main demonstrates ingesting TenantGroup entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "tenant_group-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + tenantGroup := TenantGroupMinimal() + // tenantGroup := TenantGroupExtended() + // tenantGroup := TenantGroupExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{tenantGroup}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("TenantGroup ingested successfully") + } +} + +// TenantGroupMinimal Creates a TenantGroup with only required fields. +func TenantGroupMinimal() *diode.TenantGroup { + return &diode.TenantGroup{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// TenantGroupExtended Creates a TenantGroup with common optional fields. +func TenantGroupExtended() *diode.TenantGroup { + return &diode.TenantGroup{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + } +} + +// TenantGroupExplicit Creates a TenantGroup with fully nested objects and all common fields. +func TenantGroupExplicit() *diode.TenantGroup { + return &diode.TenantGroup{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + Parent: &diode.TenantGroup{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/tunnel/go.mod b/docs/examples/tunnel/go.mod new file mode 100644 index 0000000..fcc8321 --- /dev/null +++ b/docs/examples/tunnel/go.mod @@ -0,0 +1,9 @@ +module tunnel + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/tunnel/main.go b/docs/examples/tunnel/main.go new file mode 100644 index 0000000..7b7d2e3 --- /dev/null +++ b/docs/examples/tunnel/main.go @@ -0,0 +1,111 @@ +// Package main demonstrates ingesting Tunnel entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "tunnel-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + tunnel := TunnelMinimal() + // tunnel := TunnelExtended() + // tunnel := TunnelExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{tunnel}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("Tunnel ingested successfully") + } +} + +// TunnelMinimal Creates a Tunnel with only required fields. +func TunnelMinimal() *diode.Tunnel { + return &diode.Tunnel{ + Name: diode.String("Example Name"), + Status: diode.String("active"), + Encapsulation: diode.String("gre"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// TunnelExtended Creates a Tunnel with common optional fields. +func TunnelExtended() *diode.Tunnel { + return &diode.Tunnel{ + Name: diode.String("Example Name"), + Status: diode.String("active"), + Encapsulation: diode.String("gre"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + TunnelId: diode.Int64(1), + Comments: diode.String("Example comments"), + } +} + +// TunnelExplicit Creates a Tunnel with fully nested objects and all common fields. +func TunnelExplicit() *diode.Tunnel { + return &diode.Tunnel{ + Name: diode.String("Example Name"), + Status: diode.String("active"), + Encapsulation: diode.String("gre"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + TunnelId: diode.Int64(1), + Group: &diode.TunnelGroup{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + IpsecProfile: &diode.IPSecProfile{ + Name: diode.String("Example Name"), + Mode: diode.String("Example Mode"), + IkePolicy: &diode.IKEPolicy{ + Name: diode.String("Example Name"), + Version: diode.Int64(1), + Metadata: diode.Metadata{"source": "example"}, + }, + IpsecPolicy: &diode.IPSecPolicy{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tenant: &diode.Tenant{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/tunnel_group/go.mod b/docs/examples/tunnel_group/go.mod new file mode 100644 index 0000000..7e9761a --- /dev/null +++ b/docs/examples/tunnel_group/go.mod @@ -0,0 +1,9 @@ +module tunnel_group + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/tunnel_group/main.go b/docs/examples/tunnel_group/main.go new file mode 100644 index 0000000..7388f00 --- /dev/null +++ b/docs/examples/tunnel_group/main.go @@ -0,0 +1,82 @@ +// Package main demonstrates ingesting TunnelGroup entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "tunnel_group-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + tunnelGroup := TunnelGroupMinimal() + // tunnelGroup := TunnelGroupExtended() + // tunnelGroup := TunnelGroupExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{tunnelGroup}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("TunnelGroup ingested successfully") + } +} + +// TunnelGroupMinimal Creates a TunnelGroup with only required fields. +func TunnelGroupMinimal() *diode.TunnelGroup { + return &diode.TunnelGroup{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// TunnelGroupExtended Creates a TunnelGroup with common optional fields. +func TunnelGroupExtended() *diode.TunnelGroup { + return &diode.TunnelGroup{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + } +} + +// TunnelGroupExplicit Creates a TunnelGroup with fully nested objects and all common fields. +func TunnelGroupExplicit() *diode.TunnelGroup { + return &diode.TunnelGroup{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/tunnel_termination/go.mod b/docs/examples/tunnel_termination/go.mod new file mode 100644 index 0000000..8cea9a3 --- /dev/null +++ b/docs/examples/tunnel_termination/go.mod @@ -0,0 +1,9 @@ +module tunnel_termination + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/tunnel_termination/main.go b/docs/examples/tunnel_termination/main.go new file mode 100644 index 0000000..206a820 --- /dev/null +++ b/docs/examples/tunnel_termination/main.go @@ -0,0 +1,90 @@ +// Package main demonstrates ingesting TunnelTermination entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "tunnel_termination-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + tunnelTermination := TunnelTerminationMinimal() + // tunnelTermination := TunnelTerminationExtended() + // tunnelTermination := TunnelTerminationExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{tunnelTermination}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("TunnelTermination ingested successfully") + } +} + +// TunnelTerminationMinimal Creates a TunnelTermination with only required fields. +func TunnelTerminationMinimal() *diode.TunnelTermination { + return &diode.TunnelTermination{ + Tunnel: &diode.Tunnel{ + Name: diode.String("Example Name"), + Status: diode.String("active"), + Encapsulation: diode.String("Example Encapsulation"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: diode.String("hub"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// TunnelTerminationExtended Creates a TunnelTermination with common optional fields. +func TunnelTerminationExtended() *diode.TunnelTermination { + return &diode.TunnelTermination{ + Tunnel: &diode.Tunnel{ + Name: diode.String("Example Name"), + Status: diode.String("active"), + Encapsulation: diode.String("Example Encapsulation"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: diode.String("hub"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + } +} + +// TunnelTerminationExplicit Creates a TunnelTermination with fully nested objects and all common fields. +func TunnelTerminationExplicit() *diode.TunnelTermination { + return &diode.TunnelTermination{ + Tunnel: &diode.Tunnel{ + Name: diode.String("Example Name"), + Status: diode.String("active"), + Encapsulation: diode.String("Example Encapsulation"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: diode.String("hub"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + OutsideIp: &diode.IPAddress{ + Address: diode.String("192.0.2.1/32"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/virtual_chassis/go.mod b/docs/examples/virtual_chassis/go.mod new file mode 100644 index 0000000..0493333 --- /dev/null +++ b/docs/examples/virtual_chassis/go.mod @@ -0,0 +1,9 @@ +module virtual_chassis + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/virtual_chassis/main.go b/docs/examples/virtual_chassis/main.go new file mode 100644 index 0000000..98d57d2 --- /dev/null +++ b/docs/examples/virtual_chassis/main.go @@ -0,0 +1,107 @@ +// Package main demonstrates ingesting VirtualChassis entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "virtual_chassis-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + virtualChassis := VirtualChassisMinimal() + // virtualChassis := VirtualChassisExtended() + // virtualChassis := VirtualChassisExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{virtualChassis}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("VirtualChassis ingested successfully") + } +} + +// VirtualChassisMinimal Creates a VirtualChassis with only required fields. +func VirtualChassisMinimal() *diode.VirtualChassis { + return &diode.VirtualChassis{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// VirtualChassisExtended Creates a VirtualChassis with common optional fields. +func VirtualChassisExtended() *diode.VirtualChassis { + return &diode.VirtualChassis{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + Domain: diode.String("Example Domain"), + Comments: diode.String("Example comments"), + } +} + +// VirtualChassisExplicit Creates a VirtualChassis with fully nested objects and all common fields. +func VirtualChassisExplicit() *diode.VirtualChassis { + return &diode.VirtualChassis{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + Domain: diode.String("Example Domain"), + Master: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Color: diode.String("0000ff"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/virtual_circuit/go.mod b/docs/examples/virtual_circuit/go.mod new file mode 100644 index 0000000..c44c279 --- /dev/null +++ b/docs/examples/virtual_circuit/go.mod @@ -0,0 +1,9 @@ +module virtual_circuit + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/virtual_circuit/main.go b/docs/examples/virtual_circuit/main.go new file mode 100644 index 0000000..2f6876b --- /dev/null +++ b/docs/examples/virtual_circuit/main.go @@ -0,0 +1,138 @@ +// Package main demonstrates ingesting VirtualCircuit entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "virtual_circuit-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + virtualCircuit := VirtualCircuitMinimal() + // virtualCircuit := VirtualCircuitExtended() + // virtualCircuit := VirtualCircuitExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{virtualCircuit}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("VirtualCircuit ingested successfully") + } +} + +// VirtualCircuitMinimal Creates a VirtualCircuit with only required fields. +func VirtualCircuitMinimal() *diode.VirtualCircuit { + return &diode.VirtualCircuit{ + Cid: diode.String("CID-001"), + ProviderNetwork: &diode.ProviderNetwork{ + Provider: &diode.Provider{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Type: &diode.VirtualCircuitType{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + } +} + +// VirtualCircuitExtended Creates a VirtualCircuit with common optional fields. +func VirtualCircuitExtended() *diode.VirtualCircuit { + return &diode.VirtualCircuit{ + Cid: diode.String("CID-001"), + ProviderNetwork: &diode.ProviderNetwork{ + Provider: &diode.Provider{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Type: &diode.VirtualCircuitType{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Status: diode.String("active"), + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + } +} + +// VirtualCircuitExplicit Creates a VirtualCircuit with fully nested objects and all common fields. +func VirtualCircuitExplicit() *diode.VirtualCircuit { + return &diode.VirtualCircuit{ + Cid: diode.String("CID-001"), + ProviderNetwork: &diode.ProviderNetwork{ + Provider: &diode.Provider{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Type: &diode.VirtualCircuitType{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Color: diode.String("0000ff"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Status: diode.String("active"), + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + ProviderAccount: &diode.ProviderAccount{ + Provider: &diode.Provider{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Account: diode.String("Example Account"), + Metadata: diode.Metadata{"source": "example"}, + }, + Tenant: &diode.Tenant{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/virtual_circuit_termination/go.mod b/docs/examples/virtual_circuit_termination/go.mod new file mode 100644 index 0000000..0626f62 --- /dev/null +++ b/docs/examples/virtual_circuit_termination/go.mod @@ -0,0 +1,9 @@ +module virtual_circuit_termination + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/virtual_circuit_termination/main.go b/docs/examples/virtual_circuit_termination/main.go new file mode 100644 index 0000000..04936d4 --- /dev/null +++ b/docs/examples/virtual_circuit_termination/main.go @@ -0,0 +1,211 @@ +// Package main demonstrates ingesting VirtualCircuitTermination entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "virtual_circuit_termination-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + virtualCircuitTermination := VirtualCircuitTerminationMinimal() + // virtualCircuitTermination := VirtualCircuitTerminationExtended() + // virtualCircuitTermination := VirtualCircuitTerminationExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{virtualCircuitTermination}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("VirtualCircuitTermination ingested successfully") + } +} + +// VirtualCircuitTerminationMinimal Creates a VirtualCircuitTermination with only required fields. +func VirtualCircuitTerminationMinimal() *diode.VirtualCircuitTermination { + return &diode.VirtualCircuitTermination{ + VirtualCircuit: &diode.VirtualCircuit{ + Cid: diode.String("CID-001"), + ProviderNetwork: &diode.ProviderNetwork{ + Provider: &diode.Provider{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Type: &diode.VirtualCircuitType{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Interface: &diode.Interface{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Type: diode.String("Example Type"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + } +} + +// VirtualCircuitTerminationExtended Creates a VirtualCircuitTermination with common optional fields. +func VirtualCircuitTerminationExtended() *diode.VirtualCircuitTermination { + return &diode.VirtualCircuitTermination{ + VirtualCircuit: &diode.VirtualCircuit{ + Cid: diode.String("CID-001"), + ProviderNetwork: &diode.ProviderNetwork{ + Provider: &diode.Provider{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Type: &diode.VirtualCircuitType{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Interface: &diode.Interface{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Type: diode.String("Example Type"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + Role: diode.String("hub"), + } +} + +// VirtualCircuitTerminationExplicit Creates a VirtualCircuitTermination with fully nested objects and all common fields. +func VirtualCircuitTerminationExplicit() *diode.VirtualCircuitTermination { + return &diode.VirtualCircuitTermination{ + VirtualCircuit: &diode.VirtualCircuit{ + Cid: diode.String("CID-001"), + ProviderNetwork: &diode.ProviderNetwork{ + Provider: &diode.Provider{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Type: &diode.VirtualCircuitType{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Color: diode.String("0000ff"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Interface: &diode.Interface{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Color: diode.String("0000ff"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Type: diode.String("Example Type"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Role: diode.String("hub"), + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/virtual_circuit_type/go.mod b/docs/examples/virtual_circuit_type/go.mod new file mode 100644 index 0000000..4ed7e2c --- /dev/null +++ b/docs/examples/virtual_circuit_type/go.mod @@ -0,0 +1,9 @@ +module virtual_circuit_type + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/virtual_circuit_type/main.go b/docs/examples/virtual_circuit_type/main.go new file mode 100644 index 0000000..0bfa4fe --- /dev/null +++ b/docs/examples/virtual_circuit_type/main.go @@ -0,0 +1,84 @@ +// Package main demonstrates ingesting VirtualCircuitType entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "virtual_circuit_type-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + virtualCircuitType := VirtualCircuitTypeMinimal() + // virtualCircuitType := VirtualCircuitTypeExtended() + // virtualCircuitType := VirtualCircuitTypeExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{virtualCircuitType}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("VirtualCircuitType ingested successfully") + } +} + +// VirtualCircuitTypeMinimal Creates a VirtualCircuitType with only required fields. +func VirtualCircuitTypeMinimal() *diode.VirtualCircuitType { + return &diode.VirtualCircuitType{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// VirtualCircuitTypeExtended Creates a VirtualCircuitType with common optional fields. +func VirtualCircuitTypeExtended() *diode.VirtualCircuitType { + return &diode.VirtualCircuitType{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + Color: diode.String("0000ff"), + Comments: diode.String("Example comments"), + } +} + +// VirtualCircuitTypeExplicit Creates a VirtualCircuitType with fully nested objects and all common fields. +func VirtualCircuitTypeExplicit() *diode.VirtualCircuitType { + return &diode.VirtualCircuitType{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Color: diode.String("0000ff"), + Comments: diode.String("Example comments"), + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/virtual_device_context/go.mod b/docs/examples/virtual_device_context/go.mod new file mode 100644 index 0000000..41296dc --- /dev/null +++ b/docs/examples/virtual_device_context/go.mod @@ -0,0 +1,9 @@ +module virtual_device_context + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/virtual_device_context/main.go b/docs/examples/virtual_device_context/main.go new file mode 100644 index 0000000..dc4cd4f --- /dev/null +++ b/docs/examples/virtual_device_context/main.go @@ -0,0 +1,171 @@ +// Package main demonstrates ingesting VirtualDeviceContext entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "virtual_device_context-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + virtualDeviceContext := VirtualDeviceContextMinimal() + // virtualDeviceContext := VirtualDeviceContextExtended() + // virtualDeviceContext := VirtualDeviceContextExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{virtualDeviceContext}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("VirtualDeviceContext ingested successfully") + } +} + +// VirtualDeviceContextMinimal Creates a VirtualDeviceContext with only required fields. +func VirtualDeviceContextMinimal() *diode.VirtualDeviceContext { + return &diode.VirtualDeviceContext{ + Name: diode.String("Example Name"), + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// VirtualDeviceContextExtended Creates a VirtualDeviceContext with common optional fields. +func VirtualDeviceContextExtended() *diode.VirtualDeviceContext { + return &diode.VirtualDeviceContext{ + Name: diode.String("Example Name"), + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + Identifier: diode.Int64(1), + Comments: diode.String("Example comments"), + } +} + +// VirtualDeviceContextExplicit Creates a VirtualDeviceContext with fully nested objects and all common fields. +func VirtualDeviceContextExplicit() *diode.VirtualDeviceContext { + return &diode.VirtualDeviceContext{ + Name: diode.String("Example Name"), + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Color: diode.String("0000ff"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + Identifier: diode.Int64(1), + Tenant: &diode.Tenant{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + PrimaryIp4: &diode.IPAddress{ + Address: diode.String("192.0.2.1/32"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + PrimaryIp6: &diode.IPAddress{ + Address: diode.String("192.0.2.1/32"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/virtual_disk/go.mod b/docs/examples/virtual_disk/go.mod new file mode 100644 index 0000000..68d582a --- /dev/null +++ b/docs/examples/virtual_disk/go.mod @@ -0,0 +1,9 @@ +module virtual_disk + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/virtual_disk/main.go b/docs/examples/virtual_disk/main.go new file mode 100644 index 0000000..fdc1cf7 --- /dev/null +++ b/docs/examples/virtual_disk/main.go @@ -0,0 +1,93 @@ +// Package main demonstrates ingesting VirtualDisk entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "virtual_disk-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + virtualDisk := VirtualDiskMinimal() + // virtualDisk := VirtualDiskExtended() + // virtualDisk := VirtualDiskExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{virtualDisk}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("VirtualDisk ingested successfully") + } +} + +// VirtualDiskMinimal Creates a VirtualDisk with only required fields. +func VirtualDiskMinimal() *diode.VirtualDisk { + return &diode.VirtualDisk{ + VirtualMachine: &diode.VirtualMachine{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Size: diode.Int64(1), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// VirtualDiskExtended Creates a VirtualDisk with common optional fields. +func VirtualDiskExtended() *diode.VirtualDisk { + return &diode.VirtualDisk{ + VirtualMachine: &diode.VirtualMachine{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Size: diode.Int64(1), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + } +} + +// VirtualDiskExplicit Creates a VirtualDisk with fully nested objects and all common fields. +func VirtualDiskExplicit() *diode.VirtualDisk { + return &diode.VirtualDisk{ + VirtualMachine: &diode.VirtualMachine{ + Name: diode.String("Example Name"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Size: diode.Int64(1), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/virtual_machine/go.mod b/docs/examples/virtual_machine/go.mod new file mode 100644 index 0000000..2d737d6 --- /dev/null +++ b/docs/examples/virtual_machine/go.mod @@ -0,0 +1,9 @@ +module virtual_machine + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/virtual_machine/main.go b/docs/examples/virtual_machine/main.go new file mode 100644 index 0000000..25a343b --- /dev/null +++ b/docs/examples/virtual_machine/main.go @@ -0,0 +1,159 @@ +// Package main demonstrates ingesting VirtualMachine entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "virtual_machine-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + virtualMachine := VirtualMachineMinimal() + // virtualMachine := VirtualMachineExtended() + // virtualMachine := VirtualMachineExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{virtualMachine}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("VirtualMachine ingested successfully") + } +} + +// VirtualMachineMinimal Creates a VirtualMachine with only required fields. +func VirtualMachineMinimal() *diode.VirtualMachine { + return &diode.VirtualMachine{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// VirtualMachineExtended Creates a VirtualMachine with common optional fields. +func VirtualMachineExtended() *diode.VirtualMachine { + return &diode.VirtualMachine{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Status: diode.String("active"), + Serial: diode.String("SN-001234"), + Description: diode.String("Example description"), + Vcpus: diode.Float64(1.0), + Memory: diode.Int64(1), + Disk: diode.Int64(1), + Comments: diode.String("Example comments"), + StartOnBoot: diode.String("laststate"), + } +} + +// VirtualMachineExplicit Creates a VirtualMachine with fully nested objects and all common fields. +func VirtualMachineExplicit() *diode.VirtualMachine { + return &diode.VirtualMachine{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Status: diode.String("active"), + Serial: diode.String("SN-001234"), + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + Vcpus: diode.Float64(1.0), + Memory: diode.Int64(1), + Disk: diode.Int64(1), + StartOnBoot: diode.String("laststate"), + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Cluster: &diode.Cluster{ + Name: diode.String("Example Name"), + Type: &diode.ClusterType{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Color: diode.String("0000ff"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Color: diode.String("0000ff"), + Metadata: diode.Metadata{"source": "example"}, + }, + Tenant: &diode.Tenant{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Platform: &diode.Platform{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + PrimaryIp4: &diode.IPAddress{ + Address: diode.String("192.0.2.1/32"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + PrimaryIp6: &diode.IPAddress{ + Address: diode.String("192.0.2.1/32"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/vlan/go.mod b/docs/examples/vlan/go.mod new file mode 100644 index 0000000..0a59203 --- /dev/null +++ b/docs/examples/vlan/go.mod @@ -0,0 +1,9 @@ +module vlan + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/vlan/main.go b/docs/examples/vlan/main.go new file mode 100644 index 0000000..763db9a --- /dev/null +++ b/docs/examples/vlan/main.go @@ -0,0 +1,113 @@ +// Package main demonstrates ingesting VLAN entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "vlan-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + vlan := VLANMinimal() + // vlan := VLANExtended() + // vlan := VLANExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{vlan}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("VLAN ingested successfully") + } +} + +// VLANMinimal Creates a VLAN with only required fields. +func VLANMinimal() *diode.VLAN { + return &diode.VLAN{ + Vid: diode.Int64(1), + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// VLANExtended Creates a VLAN with common optional fields. +func VLANExtended() *diode.VLAN { + return &diode.VLAN{ + Vid: diode.Int64(1), + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Status: diode.String("active"), + Description: diode.String("Example description"), + QinqRole: diode.String("cvlan"), + Comments: diode.String("Example comments"), + } +} + +// VLANExplicit Creates a VLAN with fully nested objects and all common fields. +func VLANExplicit() *diode.VLAN { + return &diode.VLAN{ + Vid: diode.Int64(1), + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Status: diode.String("active"), + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + QinqRole: diode.String("cvlan"), + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Group: &diode.VLANGroup{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Tenant: &diode.Tenant{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.Role{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + QinqSvlan: &diode.VLAN{ + Vid: diode.Int64(1), + Name: diode.String("Example Name"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/vlan_group/go.mod b/docs/examples/vlan_group/go.mod new file mode 100644 index 0000000..d3d5d35 --- /dev/null +++ b/docs/examples/vlan_group/go.mod @@ -0,0 +1,9 @@ +module vlan_group + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/vlan_group/main.go b/docs/examples/vlan_group/main.go new file mode 100644 index 0000000..9c787ab --- /dev/null +++ b/docs/examples/vlan_group/main.go @@ -0,0 +1,87 @@ +// Package main demonstrates ingesting VLANGroup entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "vlan_group-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + vlanGroup := VLANGroupMinimal() + // vlanGroup := VLANGroupExtended() + // vlanGroup := VLANGroupExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{vlanGroup}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("VLANGroup ingested successfully") + } +} + +// VLANGroupMinimal Creates a VLANGroup with only required fields. +func VLANGroupMinimal() *diode.VLANGroup { + return &diode.VLANGroup{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// VLANGroupExtended Creates a VLANGroup with common optional fields. +func VLANGroupExtended() *diode.VLANGroup { + return &diode.VLANGroup{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + } +} + +// VLANGroupExplicit Creates a VLANGroup with fully nested objects and all common fields. +func VLANGroupExplicit() *diode.VLANGroup { + return &diode.VLANGroup{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + Tenant: &diode.Tenant{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/vlan_translation_policy/go.mod b/docs/examples/vlan_translation_policy/go.mod new file mode 100644 index 0000000..e6a39fe --- /dev/null +++ b/docs/examples/vlan_translation_policy/go.mod @@ -0,0 +1,9 @@ +module vlan_translation_policy + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/vlan_translation_policy/main.go b/docs/examples/vlan_translation_policy/main.go new file mode 100644 index 0000000..43e1321 --- /dev/null +++ b/docs/examples/vlan_translation_policy/main.go @@ -0,0 +1,78 @@ +// Package main demonstrates ingesting VLANTranslationPolicy entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "vlan_translation_policy-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + vlanTranslationPolicy := VLANTranslationPolicyMinimal() + // vlanTranslationPolicy := VLANTranslationPolicyExtended() + // vlanTranslationPolicy := VLANTranslationPolicyExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{vlanTranslationPolicy}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("VLANTranslationPolicy ingested successfully") + } +} + +// VLANTranslationPolicyMinimal Creates a VLANTranslationPolicy with only required fields. +func VLANTranslationPolicyMinimal() *diode.VLANTranslationPolicy { + return &diode.VLANTranslationPolicy{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// VLANTranslationPolicyExtended Creates a VLANTranslationPolicy with common optional fields. +func VLANTranslationPolicyExtended() *diode.VLANTranslationPolicy { + return &diode.VLANTranslationPolicy{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + } +} + +// VLANTranslationPolicyExplicit Creates a VLANTranslationPolicy with fully nested objects and all common fields. +func VLANTranslationPolicyExplicit() *diode.VLANTranslationPolicy { + return &diode.VLANTranslationPolicy{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + } +} diff --git a/docs/examples/vlan_translation_rule/go.mod b/docs/examples/vlan_translation_rule/go.mod new file mode 100644 index 0000000..abe78a6 --- /dev/null +++ b/docs/examples/vlan_translation_rule/go.mod @@ -0,0 +1,9 @@ +module vlan_translation_rule + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/vlan_translation_rule/main.go b/docs/examples/vlan_translation_rule/main.go new file mode 100644 index 0000000..e67dd96 --- /dev/null +++ b/docs/examples/vlan_translation_rule/main.go @@ -0,0 +1,83 @@ +// Package main demonstrates ingesting VLANTranslationRule entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "vlan_translation_rule-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + vlanTranslationRule := VLANTranslationRuleMinimal() + // vlanTranslationRule := VLANTranslationRuleExtended() + // vlanTranslationRule := VLANTranslationRuleExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{vlanTranslationRule}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("VLANTranslationRule ingested successfully") + } +} + +// VLANTranslationRuleMinimal Creates a VLANTranslationRule with only required fields. +func VLANTranslationRuleMinimal() *diode.VLANTranslationRule { + return &diode.VLANTranslationRule{ + Policy: &diode.VLANTranslationPolicy{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + LocalVid: diode.Int64(1), + RemoteVid: diode.Int64(1), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// VLANTranslationRuleExtended Creates a VLANTranslationRule with common optional fields. +func VLANTranslationRuleExtended() *diode.VLANTranslationRule { + return &diode.VLANTranslationRule{ + Policy: &diode.VLANTranslationPolicy{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + LocalVid: diode.Int64(1), + RemoteVid: diode.Int64(1), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + } +} + +// VLANTranslationRuleExplicit Creates a VLANTranslationRule with fully nested objects and all common fields. +func VLANTranslationRuleExplicit() *diode.VLANTranslationRule { + return &diode.VLANTranslationRule{ + Policy: &diode.VLANTranslationPolicy{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + LocalVid: diode.Int64(1), + RemoteVid: diode.Int64(1), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + } +} diff --git a/docs/examples/vm_interface/go.mod b/docs/examples/vm_interface/go.mod new file mode 100644 index 0000000..1106cad --- /dev/null +++ b/docs/examples/vm_interface/go.mod @@ -0,0 +1,9 @@ +module vm_interface + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/vm_interface/main.go b/docs/examples/vm_interface/main.go new file mode 100644 index 0000000..ecb94df --- /dev/null +++ b/docs/examples/vm_interface/main.go @@ -0,0 +1,138 @@ +// Package main demonstrates ingesting VMInterface entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "vm_interface-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + vmInterface := VMInterfaceMinimal() + // vmInterface := VMInterfaceExtended() + // vmInterface := VMInterfaceExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{vmInterface}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("VMInterface ingested successfully") + } +} + +// VMInterfaceMinimal Creates a VMInterface with only required fields. +func VMInterfaceMinimal() *diode.VMInterface { + return &diode.VMInterface{ + VirtualMachine: &diode.VirtualMachine{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// VMInterfaceExtended Creates a VMInterface with common optional fields. +func VMInterfaceExtended() *diode.VMInterface { + return &diode.VMInterface{ + VirtualMachine: &diode.VirtualMachine{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + Enabled: diode.Bool(true), + Mtu: diode.Int64(1), + Mode: diode.String("access"), + } +} + +// VMInterfaceExplicit Creates a VMInterface with fully nested objects and all common fields. +func VMInterfaceExplicit() *diode.VMInterface { + return &diode.VMInterface{ + VirtualMachine: &diode.VirtualMachine{ + Name: diode.String("Example Name"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Enabled: diode.Bool(true), + Mtu: diode.Int64(1), + Mode: diode.String("access"), + Parent: &diode.VMInterface{ + VirtualMachine: &diode.VirtualMachine{ + Name: diode.String("Example Name"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Bridge: &diode.VMInterface{ + VirtualMachine: &diode.VirtualMachine{ + Name: diode.String("Example Name"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + PrimaryMacAddress: &diode.MACAddress{ + MacAddress: diode.String("00:11:22:33:44:55"), + Metadata: diode.Metadata{"source": "example"}, + }, + UntaggedVlan: &diode.VLAN{ + Vid: diode.Int64(1), + Name: diode.String("Example Name"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + QinqSvlan: &diode.VLAN{ + Vid: diode.Int64(1), + Name: diode.String("Example Name"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + VlanTranslationPolicy: &diode.VLANTranslationPolicy{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Vrf: &diode.VRF{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/vrf/go.mod b/docs/examples/vrf/go.mod new file mode 100644 index 0000000..1f69dc6 --- /dev/null +++ b/docs/examples/vrf/go.mod @@ -0,0 +1,9 @@ +module vrf + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/vrf/main.go b/docs/examples/vrf/main.go new file mode 100644 index 0000000..1d23a94 --- /dev/null +++ b/docs/examples/vrf/main.go @@ -0,0 +1,88 @@ +// Package main demonstrates ingesting VRF entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "vrf-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + vrf := VRFMinimal() + // vrf := VRFExtended() + // vrf := VRFExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{vrf}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("VRF ingested successfully") + } +} + +// VRFMinimal Creates a VRF with only required fields. +func VRFMinimal() *diode.VRF { + return &diode.VRF{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// VRFExtended Creates a VRF with common optional fields. +func VRFExtended() *diode.VRF { + return &diode.VRF{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + Rd: diode.String("Example Rd"), + EnforceUnique: diode.Bool(true), + Comments: diode.String("Example comments"), + } +} + +// VRFExplicit Creates a VRF with fully nested objects and all common fields. +func VRFExplicit() *diode.VRF { + return &diode.VRF{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + Rd: diode.String("Example Rd"), + EnforceUnique: diode.Bool(true), + Tenant: &diode.Tenant{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/wireless_lan/go.mod b/docs/examples/wireless_lan/go.mod new file mode 100644 index 0000000..cc2ff17 --- /dev/null +++ b/docs/examples/wireless_lan/go.mod @@ -0,0 +1,9 @@ +module wireless_lan + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/wireless_lan/main.go b/docs/examples/wireless_lan/main.go new file mode 100644 index 0000000..8177127 --- /dev/null +++ b/docs/examples/wireless_lan/main.go @@ -0,0 +1,103 @@ +// Package main demonstrates ingesting WirelessLAN entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "wireless_lan-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + wirelessLan := WirelessLANMinimal() + // wirelessLan := WirelessLANExtended() + // wirelessLan := WirelessLANExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{wirelessLan}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("WirelessLAN ingested successfully") + } +} + +// WirelessLANMinimal Creates a WirelessLAN with only required fields. +func WirelessLANMinimal() *diode.WirelessLAN { + return &diode.WirelessLAN{ + Ssid: diode.String("ExampleSSID"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// WirelessLANExtended Creates a WirelessLAN with common optional fields. +func WirelessLANExtended() *diode.WirelessLAN { + return &diode.WirelessLAN{ + Ssid: diode.String("ExampleSSID"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Status: diode.String("active"), + Description: diode.String("Example description"), + AuthType: diode.String("open"), + AuthCipher: diode.String("aes"), + AuthPsk: diode.String("Example AuthPsk"), + Comments: diode.String("Example comments"), + } +} + +// WirelessLANExplicit Creates a WirelessLAN with fully nested objects and all common fields. +func WirelessLANExplicit() *diode.WirelessLAN { + return &diode.WirelessLAN{ + Ssid: diode.String("ExampleSSID"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Status: diode.String("active"), + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + AuthType: diode.String("open"), + AuthCipher: diode.String("aes"), + AuthPsk: diode.String("Example AuthPsk"), + Group: &diode.WirelessLANGroup{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Vlan: &diode.VLAN{ + Vid: diode.Int64(1), + Name: diode.String("Example Name"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Tenant: &diode.Tenant{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/wireless_lan_group/go.mod b/docs/examples/wireless_lan_group/go.mod new file mode 100644 index 0000000..040a0e2 --- /dev/null +++ b/docs/examples/wireless_lan_group/go.mod @@ -0,0 +1,9 @@ +module wireless_lan_group + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/wireless_lan_group/main.go b/docs/examples/wireless_lan_group/main.go new file mode 100644 index 0000000..3fa1337 --- /dev/null +++ b/docs/examples/wireless_lan_group/main.go @@ -0,0 +1,87 @@ +// Package main demonstrates ingesting WirelessLANGroup entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "wireless_lan_group-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + wirelessLanGroup := WirelessLANGroupMinimal() + // wirelessLanGroup := WirelessLANGroupExtended() + // wirelessLanGroup := WirelessLANGroupExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{wirelessLanGroup}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("WirelessLANGroup ingested successfully") + } +} + +// WirelessLANGroupMinimal Creates a WirelessLANGroup with only required fields. +func WirelessLANGroupMinimal() *diode.WirelessLANGroup { + return &diode.WirelessLANGroup{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + } +} + +// WirelessLANGroupExtended Creates a WirelessLANGroup with common optional fields. +func WirelessLANGroupExtended() *diode.WirelessLANGroup { + return &diode.WirelessLANGroup{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + } +} + +// WirelessLANGroupExplicit Creates a WirelessLANGroup with fully nested objects and all common fields. +func WirelessLANGroupExplicit() *diode.WirelessLANGroup { + return &diode.WirelessLANGroup{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + Parent: &diode.WirelessLANGroup{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/docs/examples/wireless_link/go.mod b/docs/examples/wireless_link/go.mod new file mode 100644 index 0000000..6f6d25c --- /dev/null +++ b/docs/examples/wireless_link/go.mod @@ -0,0 +1,9 @@ +module wireless_link + +go 1.25 + +require github.com/netboxlabs/diode-sdk-go + +// Use local SDK for development and validation +// When copying this example, remove the replace directive and update the require version above +replace github.com/netboxlabs/diode-sdk-go => ../../.. diff --git a/docs/examples/wireless_link/main.go b/docs/examples/wireless_link/main.go new file mode 100644 index 0000000..42e48eb --- /dev/null +++ b/docs/examples/wireless_link/main.go @@ -0,0 +1,269 @@ +// Package main demonstrates ingesting WirelessLink entities using the Diode SDK. +// This example includes three patterns: Minimal, Extended, and Explicit. +package main + +import ( + "context" + "log" + + "github.com/netboxlabs/diode-sdk-go/diode" +) + +const ( + target = "grpc://localhost:8080/diode" + appName = "wireless_link-example" + appVersion = "1.0.0" +) + +func main() { + client, err := diode.NewClient( + target, + appName, + appVersion, + ) + if err != nil { + log.Fatalf("Failed to create client: %v", err) + } + + // Choose one of the three patterns by uncommenting: + wirelessLink := WirelessLinkMinimal() + // wirelessLink := WirelessLinkExtended() + // wirelessLink := WirelessLinkExplicit() + + resp, err := client.Ingest(context.Background(), []diode.Entity{wirelessLink}) + if err != nil { + log.Fatalf("Ingestion failed: %v", err) + } + if resp.Errors != nil { + log.Printf("Errors: %v", resp.Errors) + } else { + log.Println("WirelessLink ingested successfully") + } +} + +// WirelessLinkMinimal Creates a WirelessLink with only required fields. +func WirelessLinkMinimal() *diode.WirelessLink { + return &diode.WirelessLink{ + InterfaceA: &diode.Interface{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Type: diode.String("Example Type"), + Metadata: diode.Metadata{"source": "example"}, + }, + InterfaceB: &diode.Interface{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Type: diode.String("Example Type"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + } +} + +// WirelessLinkExtended Creates a WirelessLink with common optional fields. +func WirelessLinkExtended() *diode.WirelessLink { + return &diode.WirelessLink{ + InterfaceA: &diode.Interface{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Type: diode.String("Example Type"), + Metadata: diode.Metadata{"source": "example"}, + }, + InterfaceB: &diode.Interface{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Type: diode.String("Example Type"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value"}, + Status: diode.String("connected"), + Description: diode.String("Example description"), + Ssid: diode.String("ExampleSSID"), + AuthType: diode.String("open"), + AuthCipher: diode.String("aes"), + AuthPsk: diode.String("Example AuthPsk"), + Distance: diode.Float64(1.0), + DistanceUnit: diode.String("ft"), + Comments: diode.String("Example comments"), + } +} + +// WirelessLinkExplicit Creates a WirelessLink with fully nested objects and all common fields. +func WirelessLinkExplicit() *diode.WirelessLink { + return &diode.WirelessLink{ + InterfaceA: &diode.Interface{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Color: diode.String("0000ff"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Type: diode.String("Example Type"), + Metadata: diode.Metadata{"source": "example"}, + }, + InterfaceB: &diode.Interface{ + Device: &diode.Device{ + DeviceType: &diode.DeviceType{ + Manufacturer: &diode.Manufacturer{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Model: diode.String("Model X"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Role: &diode.DeviceRole{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Color: diode.String("0000ff"), + Metadata: diode.Metadata{"source": "example"}, + }, + Site: &diode.Site{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Status: diode.String("active"), + Metadata: diode.Metadata{"source": "example"}, + }, + Name: diode.String("Example Name"), + Type: diode.String("Example Type"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example", "custom_key": "custom_value", "collected_at": "2024-01-15T10:30:00Z"}, + Status: diode.String("connected"), + Description: diode.String("Example description"), + Comments: diode.String("Example comments"), + Ssid: diode.String("ExampleSSID"), + AuthType: diode.String("open"), + AuthCipher: diode.String("aes"), + AuthPsk: diode.String("Example AuthPsk"), + Distance: diode.Float64(1.0), + DistanceUnit: diode.String("ft"), + Tenant: &diode.Tenant{ + Name: diode.String("Example Name"), + Slug: diode.String("example-slug"), + Metadata: diode.Metadata{"source": "example"}, + }, + Owner: &diode.Owner{ + Name: diode.String("Example Name"), + Group: &diode.OwnerGroup{ + Name: diode.String("Example Name"), + Metadata: diode.Metadata{"source": "example"}, + }, + Metadata: diode.Metadata{"source": "example"}, + }, + Tags: []*diode.Tag{{Name: diode.String("production")}}, + } +} diff --git a/examples/main.go b/examples/main.go deleted file mode 100644 index c408041..0000000 --- a/examples/main.go +++ /dev/null @@ -1,411 +0,0 @@ -package main - -import ( - "context" - "log" - - "github.com/netboxlabs/diode-sdk-go/diode" -) - -func main() { - client, err := diode.NewClient( - "grpc://localhost:8080/diode", - "example-app", - "0.1.0", - diode.WithClientID("YOUR_CLIENT_ID"), - diode.WithClientSecret("YOUR_CLIENT_SECRET"), - ) - if err != nil { - log.Fatal(err) - } - - // Create a device - deviceEntity := &diode.Device{ - Name: diode.String("Device A"), - DeviceType: &diode.DeviceType{ - Model: diode.String("Device Type A"), - Manufacturer: &diode.Manufacturer{ - Name: diode.String("Manufacturer A"), - }, - }, - Platform: &diode.Platform{ - Name: diode.String("Platform A"), - Manufacturer: &diode.Manufacturer{ - Name: diode.String("Manufacturer A"), - }, - }, - Site: &diode.Site{ - Name: diode.String("Site ABC"), - }, - Role: &diode.DeviceRole{ - Name: diode.String("Role ABC"), - Tags: []*diode.Tag{ - { - Name: diode.String("tag 1"), - }, - { - Name: diode.String("tag 2"), - }, - }, - }, - Serial: diode.String("123456"), - AssetTag: diode.String("123456"), - Status: diode.String("active"), - Comments: diode.String("Lorem ipsum dolor sit amet"), - Tags: []*diode.Tag{ - { - Name: diode.String("tag 1"), - }, - { - Name: diode.String("tag 3"), - }, - }, - } - - // Create a device type - deviceTypeEntity := &diode.DeviceType{ - Model: diode.String("Device Type A"), - Manufacturer: &diode.Manufacturer{ - Name: diode.String("Manufacturer A"), - }, - PartNumber: diode.String("123456"), - Description: diode.String("Device Type A description"), - Comments: diode.String("Lorem ipsum dolor sit amet"), - Tags: []*diode.Tag{ - { - Name: diode.String("tag 1"), - }, - { - Name: diode.String("tag 2"), - }, - }, - } - - // Create an IP address - ipAddressEntity := &diode.IPAddress{ - Address: diode.String("192.168.0.1/24"), - AssignedObject: &diode.Interface{ - Name: diode.String("Interface ABC"), - Device: &diode.Device{ - Name: diode.String("Device ABC"), - DeviceType: &diode.DeviceType{ - Model: diode.String("Device Type ABC"), - Manufacturer: &diode.Manufacturer{ - Name: diode.String("Manufacturer ABC"), - }, - }, - Platform: &diode.Platform{ - Name: diode.String("Platform ABC"), - Manufacturer: &diode.Manufacturer{ - Name: diode.String("Manufacturer ABC"), - }, - }, - Site: &diode.Site{ - Name: diode.String("Site ABC"), - }, - Role: &diode.DeviceRole{ - Name: diode.String("Role ABC"), - Tags: []*diode.Tag{ - { - Name: diode.String("tag 1"), - }, - { - Name: diode.String("tag 2"), - }, - }, - }, - }, - }, - Status: diode.String("active"), - Role: diode.String("anycast"), - Description: diode.String("IP Address description"), - Comments: diode.String("Lorem ipsum dolor sit amet"), - Tags: []*diode.Tag{ - { - Name: diode.String("tag 1"), - }, - { - Name: diode.String("tag 2"), - }, - }, - } - - // Create an interface - interfaceEntity := &diode.Interface{ - Name: diode.String("Interface A"), - Device: &diode.Device{ - Name: diode.String("Device A"), - DeviceType: &diode.DeviceType{ - Model: diode.String("Device Type A"), - Manufacturer: &diode.Manufacturer{ - Name: diode.String("Manufacturer A"), - }, - }, - Platform: &diode.Platform{ - Name: diode.String("Platform A"), - Manufacturer: &diode.Manufacturer{ - Name: diode.String("Manufacturer A"), - }, - }, - Site: &diode.Site{ - Name: diode.String("Site ABC"), - }, - Role: &diode.DeviceRole{ - Name: diode.String("Role ABC"), - Tags: []*diode.Tag{ - { - Name: diode.String("tag 1"), - }, - { - Name: diode.String("tag 2"), - }, - }, - }, - }, - Type: diode.String("virtual"), - Enabled: diode.Bool(true), - Mtu: diode.Int64(1500), - PrimaryMacAddress: &diode.MACAddress{ - MacAddress: diode.String("00:00:00:00:00:00"), - }, - Description: diode.String("Interface A description"), - Tags: []*diode.Tag{ - { - Name: diode.String("tag 1"), - }, - { - Name: diode.String("tag 2"), - }, - }, - } - - // Create a manufacturer - manufacturerEntity := &diode.Manufacturer{ - Name: diode.String("Manufacturer A"), - Description: diode.String("Manufacturer A description"), - Tags: []*diode.Tag{ - { - Name: diode.String("tag 1"), - }, - { - Name: diode.String("tag 2"), - }, - }, - } - - // Create a platform - platformEntity := &diode.Platform{ - Name: diode.String("Platform A"), - Manufacturer: &diode.Manufacturer{ - Name: diode.String("Manufacturer A"), - Tags: []*diode.Tag{ - { - Name: diode.String("tag 1"), - }, - { - Name: diode.String("tag 2"), - }, - }, - }, - Description: diode.String("Platform A description"), - Tags: []*diode.Tag{ - { - Name: diode.String("tag 1"), - }, - { - Name: diode.String("tag 2"), - }, - }, - } - - // Create a prefix - prefixEntity := &diode.Prefix{ - Prefix: diode.String("192.168.0.0/32"), - Scope: &diode.Site{ - Name: diode.String("Site ABC"), - }, - Status: diode.String("active"), - IsPool: diode.Bool(true), - MarkUtilized: diode.Bool(true), - Description: diode.String("Prefix description"), - Comments: diode.String("Lorem ipsum dolor sit amet"), - Tags: []*diode.Tag{ - { - Name: diode.String("tag 1"), - }, - { - Name: diode.String("tag 2"), - }, - }, - } - - // Create a role - roleEntity := &diode.DeviceRole{ - Name: diode.String("Role A"), - Color: diode.String("ffffff"), - Description: diode.String("Role A description"), - Tags: []*diode.Tag{ - { - Name: diode.String("tag 1"), - }, - { - Name: diode.String("tag 2"), - }, - }, - } - - // Create a site - siteEntity := &diode.Site{ - Name: diode.String("site A"), - Comments: diode.String("aaa"), - Tags: []*diode.Tag{ - { - Name: diode.String("tag 2"), - }, - }, - } - - // Create a cluster group - clusterGroupEntity := &diode.ClusterGroup{ - Name: diode.String("cluster group B"), - Description: diode.String("cluster group B description"), - Tags: []*diode.Tag{ - { - Name: diode.String("tag 1"), - }, - }, - } - - // Create a cluster type - clusterTypeEntity := &diode.ClusterType{ - Name: diode.String("cluster type B"), - Description: diode.String("cluster type B description"), - Tags: []*diode.Tag{ - { - Name: diode.String("tag 1"), - }, - }, - } - - // Create a cluster - clusterEntity := &diode.Cluster{ - Name: diode.String("cluster A"), - Type: &diode.ClusterType{ - Name: diode.String("cluster type A"), - Description: diode.String("cluster type A description"), - }, - Group: &diode.ClusterGroup{ - Name: diode.String("cluster group A"), - }, - Scope: &diode.Site{ - Name: diode.String("site A"), - }, - Status: diode.String("active"), - Description: diode.String("cluster A description"), - Tags: []*diode.Tag{ - { - Name: diode.String("tag 1"), - }, - }, - } - - // Create a virtual machine - virtualMachineEntity := &diode.VirtualMachine{ - Name: diode.String("Virtual Machine A"), - Status: diode.String("active"), - Site: &diode.Site{ - Name: diode.String("site 10"), - }, - Cluster: &diode.Cluster{ - Name: diode.String("cluster 10"), - Type: &diode.ClusterType{ - Name: diode.String("cluster type 10"), - }, - Group: &diode.ClusterGroup{ - Name: diode.String("cluster group 10"), - }, - Scope: &diode.Site{ - Name: diode.String("site 10"), - }, - Status: diode.String("active"), - }, - Role: &diode.DeviceRole{ - Name: diode.String("Role 10"), - }, - Platform: &diode.Platform{ - Name: diode.String("Platform 10"), - Manufacturer: &diode.Manufacturer{ - Name: diode.String("Manufacturer 10"), - }, - }, - Vcpus: diode.Float64(1), - Memory: diode.Int64(4096), - Disk: diode.Int64(100), - Description: diode.String("Virtual Machine A description"), - Comments: diode.String("Lorem ipsum dolor sit amet"), - Tags: []*diode.Tag{ - { - Name: diode.String("tag 1"), - }, - }, - } - - // Create a virtual machine interface - virtualMachineInterfaceEntity := &diode.VMInterface{ - VirtualMachine: virtualMachineEntity, - Name: diode.String("Interface A"), - Enabled: diode.Bool(true), - Mtu: diode.Int64(1500), - PrimaryMacAddress: &diode.MACAddress{ - MacAddress: diode.String("00:00:00:00:00:00"), - }, - Description: diode.String("Interface A description"), - Tags: []*diode.Tag{ - { - Name: diode.String("tag 1"), - }, - }, - } - - // Create a virtual disk - virtualDiskEntity := &diode.VirtualDisk{ - VirtualMachine: virtualMachineEntity, - Name: diode.String("Disk A"), - Size: diode.Int64(100), - Description: diode.String("Disk A description"), - Tags: []*diode.Tag{ - { - Name: diode.String("tag 1"), - }, - }, - } - - entities := []diode.Entity{ - deviceEntity, - deviceTypeEntity, - ipAddressEntity, - interfaceEntity, - manufacturerEntity, - platformEntity, - prefixEntity, - roleEntity, - siteEntity, - clusterGroupEntity, - clusterTypeEntity, - clusterEntity, - virtualMachineEntity, - virtualMachineInterfaceEntity, - virtualDiskEntity, - } - - // Ingest entities - resp, err := client.Ingest(context.Background(), entities) - if err != nil { - log.Fatal(err) - } - if resp != nil && resp.Errors != nil { - log.Printf("Errors: %v\n", resp.Errors) - } else { - log.Printf("Success\n") - } -}