Skip to content

Commit

Permalink
🌱 add: add health when get pool
Browse files Browse the repository at this point in the history
  • Loading branch information
anngdinh committed Dec 26, 2024
1 parent bdb18ad commit b2e9729
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 13 deletions.
1 change: 1 addition & 0 deletions test/lb_global_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ func TestListGlobalPoolsSuccess(t *ltesting.T) {
t.Logf("Result: %+v", pools)
for _, pool := range pools.Items {
t.Logf("Pool: %+v", pool)
t.Logf("Health: %+v", pool.Health)
}
t.Log("PASS")
}
Expand Down
25 changes: 13 additions & 12 deletions vngcloud/entity/loadbalancer_global.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,19 @@ type ListGlobalLoadBalancers struct {
}

type GlobalPool struct {
CreatedAt string `json:"createdAt"`
UpdatedAt string `json:"updatedAt"`
DeletedAt *string `json:"deletedAt"`
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
GlobalLoadBalancerID string `json:"globalLoadBalancerId"`
Algorithm string `json:"algorithm"`
StickySession *string `json:"stickySession"`
TLSEnabled *string `json:"tlsEnabled"`
Protocol string `json:"protocol"`
Status string `json:"status"`
CreatedAt string `json:"createdAt"`
UpdatedAt string `json:"updatedAt"`
DeletedAt *string `json:"deletedAt"`
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
GlobalLoadBalancerID string `json:"globalLoadBalancerId"`
Algorithm string `json:"algorithm"`
StickySession *string `json:"stickySession"`
TLSEnabled *string `json:"tlsEnabled"`
Protocol string `json:"protocol"`
Status string `json:"status"`
Health *GlobalPoolHealthMonitor `json:"health"`
}

type GlobalPoolHealthMonitor struct {
Expand Down
24 changes: 23 additions & 1 deletion vngcloud/services/loadbalancer/global/glb_pool_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (s *GlobalPoolResponse) ToEntityPool() *lsentity.GlobalPool {
TLSEnabled: s.TLSEnabled,
Protocol: s.Protocol,
Status: s.Status,
// Health: s.Health.ToEntityHealthMonitor(),
Health: s.Health.ToEntityGlobalPoolHealthMonitor(),
}
}

Expand All @@ -57,6 +57,28 @@ type HealthResponse struct {
Status string `json:"status"`
}

func (s *HealthResponse) ToEntityGlobalPoolHealthMonitor() *lsentity.GlobalPoolHealthMonitor {
return &lsentity.GlobalPoolHealthMonitor{
CreatedAt: s.CreatedAt,
UpdatedAt: s.UpdatedAt,
DeletedAt: s.DeletedAt,
ID: s.ID,
GlobalPoolID: s.GlobalPoolID,
GlobalLoadBalancerID: s.GlobalLoadBalancerID,
Protocol: s.Protocol,
Path: s.Path,
Timeout: s.Timeout,
IntervalTime: s.IntervalTime,
HealthyThreshold: s.HealthyThreshold,
UnhealthyThreshold: s.UnhealthyThreshold,
DomainName: s.DomainName,
HTTPVersion: s.HttpVersion,
HTTPMethod: s.HttpMethod,
SuccessCode: s.SuccessCode,
Status: s.Status,
}
}

type GlobalPoolMemberResponse struct {
CreatedAt string `json:"createdAt"`
UpdatedAt string `json:"updatedAt"`
Expand Down

0 comments on commit b2e9729

Please sign in to comment.