From b2e9729afc9d063d94e5e78b6e3029c9a9668375 Mon Sep 17 00:00:00 2001 From: andrew Date: Thu, 26 Dec 2024 15:46:59 +0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=8C=B1=20add:=20add=20health=20when=20get?= =?UTF-8?q?=20pool?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/lb_global_test.go | 1 + vngcloud/entity/loadbalancer_global.go | 25 ++++++++++--------- .../loadbalancer/global/glb_pool_response.go | 24 +++++++++++++++++- 3 files changed, 37 insertions(+), 13 deletions(-) diff --git a/test/lb_global_test.go b/test/lb_global_test.go index a696fd2..fc44dbc 100644 --- a/test/lb_global_test.go +++ b/test/lb_global_test.go @@ -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") } diff --git a/vngcloud/entity/loadbalancer_global.go b/vngcloud/entity/loadbalancer_global.go index 37e138a..b495659 100644 --- a/vngcloud/entity/loadbalancer_global.go +++ b/vngcloud/entity/loadbalancer_global.go @@ -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 { diff --git a/vngcloud/services/loadbalancer/global/glb_pool_response.go b/vngcloud/services/loadbalancer/global/glb_pool_response.go index 834d8f8..a24057d 100644 --- a/vngcloud/services/loadbalancer/global/glb_pool_response.go +++ b/vngcloud/services/loadbalancer/global/glb_pool_response.go @@ -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(), } } @@ -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"`