From 103cf5e3392b424c6ee16e9f590d8082be6977b7 Mon Sep 17 00:00:00 2001 From: "Jonas L." Date: Tue, 17 Dec 2024 16:02:56 +0100 Subject: [PATCH] fix: missing load-balancers property in network schema (#568) Fixes #567 See https://docs.hetzner.cloud/#networks-get-a-network --- hcloud/network.go | 19 ++++++++++--------- hcloud/schema/network.go | 1 + hcloud/zz_schema.go | 13 +++++++++++++ 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/hcloud/network.go b/hcloud/network.go index a0a0bf13..95e42cd8 100644 --- a/hcloud/network.go +++ b/hcloud/network.go @@ -44,15 +44,16 @@ const ( // Network represents a network in the Hetzner Cloud. type Network struct { - ID int64 - Name string - Created time.Time - IPRange *net.IPNet - Subnets []NetworkSubnet - Routes []NetworkRoute - Servers []*Server - Protection NetworkProtection - Labels map[string]string + ID int64 + Name string + Created time.Time + IPRange *net.IPNet + Subnets []NetworkSubnet + Routes []NetworkRoute + Servers []*Server + LoadBalancers []*LoadBalancer + Protection NetworkProtection + Labels map[string]string // ExposeRoutesToVSwitch indicates if the routes from this network should be exposed to the vSwitch connection. ExposeRoutesToVSwitch bool diff --git a/hcloud/schema/network.go b/hcloud/schema/network.go index 2344aea4..0e89c70e 100644 --- a/hcloud/schema/network.go +++ b/hcloud/schema/network.go @@ -11,6 +11,7 @@ type Network struct { Subnets []NetworkSubnet `json:"subnets"` Routes []NetworkRoute `json:"routes"` Servers []int64 `json:"servers"` + LoadBalancers []int64 `json:"load_balancers"` Protection NetworkProtection `json:"protection"` Labels map[string]string `json:"labels"` ExposeRoutesToVSwitch bool `json:"expose_routes_to_vswitch"` diff --git a/hcloud/zz_schema.go b/hcloud/zz_schema.go index 4f4b866f..1d737e92 100644 --- a/hcloud/zz_schema.go +++ b/hcloud/zz_schema.go @@ -357,6 +357,13 @@ func (c *converterImpl) NetworkFromSchema(source schema.Network) *Network { hcloudNetwork.Servers[k] = &hcloudServer } } + if source.LoadBalancers != nil { + hcloudNetwork.LoadBalancers = make([]*LoadBalancer, len(source.LoadBalancers)) + for l := 0; l < len(source.LoadBalancers); l++ { + hcloudLoadBalancer := loadBalancerFromInt64(source.LoadBalancers[l]) + hcloudNetwork.LoadBalancers[l] = &hcloudLoadBalancer + } + } hcloudNetwork.Protection = c.schemaNetworkProtectionToHcloudNetworkProtection(source.Protection) hcloudNetwork.Labels = source.Labels hcloudNetwork.ExposeRoutesToVSwitch = source.ExposeRoutesToVSwitch @@ -856,6 +863,12 @@ func (c *converterImpl) SchemaFromNetwork(source *Network) schema.Network { schemaNetwork2.Servers[k] = c.pHcloudServerToInt64((*source).Servers[k]) } } + if (*source).LoadBalancers != nil { + schemaNetwork2.LoadBalancers = make([]int64, len((*source).LoadBalancers)) + for l := 0; l < len((*source).LoadBalancers); l++ { + schemaNetwork2.LoadBalancers[l] = c.pHcloudLoadBalancerToInt64((*source).LoadBalancers[l]) + } + } schemaNetwork2.Protection = c.hcloudNetworkProtectionToSchemaNetworkProtection((*source).Protection) schemaNetwork2.Labels = (*source).Labels schemaNetwork2.ExposeRoutesToVSwitch = (*source).ExposeRoutesToVSwitch