Skip to content

Commit

Permalink
client: Add GetNetworkLoadBalancerState
Browse files Browse the repository at this point in the history
Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
Sponsored-by: Luizalabs (https://luizalabs.com)
  • Loading branch information
stgraber committed Sep 25, 2024
1 parent f905c77 commit ee2cb9a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
19 changes: 19 additions & 0 deletions client/incus_network_load_balancers.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,22 @@ func (r *ProtocolIncus) DeleteNetworkLoadBalancer(networkName string, listenAddr

return nil
}

// GetNetworkLoadBalancerState returns a Network load balancer state for the provided network and listen address.
func (r *ProtocolIncus) GetNetworkLoadBalancerState(networkName string, listenAddress string) (*api.NetworkLoadBalancerState, error) {
err := r.CheckExtension("network_load_balancer_state")
if err != nil {
return nil, err
}

lbState := api.NetworkLoadBalancerState{}

// Fetch the raw value.
u := api.NewURL().Path("networks", networkName, "load-balancers", listenAddress, "state")
_, err = r.queryStruct("GET", u.String(), nil, "", &lbState)
if err != nil {
return nil, err
}

return &lbState, nil
}
1 change: 1 addition & 0 deletions client/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ type InstanceServer interface {
CreateNetworkLoadBalancer(networkName string, forward api.NetworkLoadBalancersPost) error
UpdateNetworkLoadBalancer(networkName string, listenAddress string, forward api.NetworkLoadBalancerPut, ETag string) (err error)
DeleteNetworkLoadBalancer(networkName string, listenAddress string) (err error)
GetNetworkLoadBalancerState(networkName string, listenAddress string) (lbState *api.NetworkLoadBalancerState, err error)

// Network peer functions ("network_peer" API extension)
GetNetworkPeerNames(networkName string) ([]string, error)
Expand Down

0 comments on commit ee2cb9a

Please sign in to comment.