Skip to content

Commit

Permalink
Add support for LB capacity units
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Zarechenskyi committed May 15, 2024
1 parent e9a655a commit 111389c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
12 changes: 12 additions & 0 deletions ah/loadbalancers.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ type LoadBalancer struct {
ForwardingRules []LBForwardingRule `json:"forwarding_rules,omitempty"`
BackendNodes []LBBackendNode `json:"backend_nodes,omitempty"`
HealthCheck LBHealthCheck `json:"health_check,omitempty"`
CUCount int `json:"cu_count,omitempty"`
CUMax int `json:"cu_max,omitempty"`
InstanceCount int `json:"instance_count,omitempty"`
HAOn bool `json:"ha_on,omitempty"`
}

// LBIPAddress object
Expand Down Expand Up @@ -187,7 +191,11 @@ type LoadBalancerCreateRequest struct {
PrivateNetworkIDs []string `json:"private_network_ids,omitempty"`
ForwardingRules []LBForwardingRuleCreateRequest `json:"forwarding_rules,omitempty"`
BackendNodes []LBBackendNodeCreateRequest `json:"backend_nodes,omitempty"`
CUCount int `json:"cu_count,omitempty"`
CUMax int `json:"cu_max,omitempty"`
InstanceCount int `json:"instance_count,omitempty"`
CreatePublicIPAddress bool `json:"create_public_ip_address"`
HAOn bool `json:"ha_on,omitempty"`
}

// LBForwardingRuleCreateRequest object
Expand Down Expand Up @@ -241,6 +249,10 @@ type LoadBalancerUpdateRequest struct {
Name string `json:"name,omitempty"`
BalancingAlgorithm string `json:"balancing_algorithm,omitempty"`
ProxyProtocol string `json:"proxy_protocol,omitempty"`
HAOn bool `json:"ha_on,omitempty"`
CUCount int `json:"cu_count,omitempty"`
CUMax int `json:"cu_max,omitempty"`
InstanceCount int `json:"instance_count,omitempty"`
}

// Update load balancer
Expand Down
14 changes: 13 additions & 1 deletion ah/loadbalancers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ const loadBalancerResponse = `{
"datacenter_id": "5839cebe-c7a5-4a27-8253-7bd619ca430d",
"state": "defined",
"balancing_algorithm": "round_robin",
"ha_on": true,
"instance_count": 1,
"cu_count": 1,
"cu_max": 1,
"ip_addresses": [{
"wcs_ip_address_id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"type": "string",
Expand Down Expand Up @@ -210,7 +214,11 @@ func TestLoadBalancers_Create(t *testing.T) {
DatacenterID: "test_dc_id",
CreatePublicIPAddress: true,
BalancingAlgorithm: "round_robin",
ProxyProtocol: "proxy_protocol",
ProxyProtocol: "v2",
HAOn: true,
InstanceCount: 1,
CUCount: 1,
CUMax: 1,
IPAddressIDs: []string{"ip_address_id1", "ip_address_id2"},
PrivateNetworkIDs: []string{"pn_id1", "pn_id2"},
ForwardingRules: []LBForwardingRuleCreateRequest{
Expand Down Expand Up @@ -285,6 +293,10 @@ func TestLoadBalancers_Update(t *testing.T) {
Name: "test-name",
BalancingAlgorithm: "round_robin",
ProxyProtocol: "v1",
HAOn: false,
InstanceCount: 2,
CUCount: 2,
CUMax: 2,
}

fakeResponse := &fakeServerResponse{
Expand Down

0 comments on commit 111389c

Please sign in to comment.