Skip to content

Commit

Permalink
🌱 add: glb, package, paymentFlow
Browse files Browse the repository at this point in the history
  • Loading branch information
anngdinh committed Feb 18, 2025
1 parent 5449848 commit 8ecb96e
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
2 changes: 1 addition & 1 deletion test/lb_global_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ func TestCreateGlobalLoadBalancerSuccess(t *ltesting.T) {
opt := global.NewCreateGlobalLoadBalancerRequest("annd2-testtt").
WithDescription("hihi").
WithGlobalListener(listener).
WithGlobalPool(pool)
WithGlobalPool(pool).WithPackage("pkg-b02e62ab-a282-4faf-8732-a172ef497a7b")

lb, sdkerr := vngcloud.VLBGateway().Global().LoadBalancerService().CreateGlobalLoadBalancer(opt)
if sdkerr != nil {
Expand Down
2 changes: 1 addition & 1 deletion vngcloud/services/loadbalancer/global/glb.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ func (s *LoadBalancerServiceGlobal) CreateGlobalLoadBalancer(popts ICreateGlobal
errResp := lserr.NewErrorResponse(lserr.GlobalLoadBalancerErrorType)
req := lsclient.NewRequest().
WithHeader("User-Agent", popts.ParseUserAgent()).
WithOkCodes(200).
WithOkCodes(202).
WithJsonBody(popts.ToRequestBody()).
WithJsonResponse(resp).
WithJsonError(errResp)
Expand Down
30 changes: 23 additions & 7 deletions vngcloud/services/loadbalancer/global/glb_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ import (
)

type (
GlobalLoadBalancerType string
GlobalLoadBalancerType string
GlobalLoadBalancerPaymentFlow string
)

const (
GlobalLoadBalancerTypeLayer4 GlobalLoadBalancerType = "Layer 4"
GlobalLoadBalancerTypeLayer4 GlobalLoadBalancerType = "Layer 4"
GlobalLoadBalancerPaymentFlowAutomated GlobalLoadBalancerPaymentFlow = "automated"
)

// --------------------------------------------------------------------------
Expand Down Expand Up @@ -93,11 +95,13 @@ func (s *ListGlobalLoadBalancersRequest) GetDefaultQuery() string {
var _ ICreateGlobalLoadBalancerRequest = &CreateGlobalLoadBalancerRequest{}

type CreateGlobalLoadBalancerRequest struct {
Description string `json:"description"`
Name string `json:"name"`
Type GlobalLoadBalancerType `json:"type"`
GlobalListener ICreateGlobalListenerRequest `json:"globalListener"`
GlobalPool ICreateGlobalPoolRequest `json:"globalPool"`
Description string `json:"description"`
Name string `json:"name"`
Type GlobalLoadBalancerType `json:"type"`
Package string `json:"package"`
PaymentFlow GlobalLoadBalancerPaymentFlow `json:"paymentFlow"`
GlobalListener ICreateGlobalListenerRequest `json:"globalListener"`
GlobalPool ICreateGlobalPoolRequest `json:"globalPool"`

lscommon.UserAgent
}
Expand All @@ -117,6 +121,16 @@ func (s *CreateGlobalLoadBalancerRequest) WithType(ptype GlobalLoadBalancerType)
return s
}

func (s *CreateGlobalLoadBalancerRequest) WithPackage(ppackageId string) ICreateGlobalLoadBalancerRequest {
s.Package = ppackageId
return s
}

func (s *CreateGlobalLoadBalancerRequest) WithPaymentFlow(ppaymentFlow GlobalLoadBalancerPaymentFlow) ICreateGlobalLoadBalancerRequest {
s.PaymentFlow = ppaymentFlow
return s
}

func (s *CreateGlobalLoadBalancerRequest) WithGlobalListener(plistener ICreateGlobalListenerRequest) ICreateGlobalLoadBalancerRequest {
s.GlobalListener = plistener
return s
Expand Down Expand Up @@ -146,6 +160,8 @@ func NewCreateGlobalLoadBalancerRequest(name string) ICreateGlobalLoadBalancerRe
Description: "",
Name: name,
Type: GlobalLoadBalancerTypeLayer4,
Package: "",
PaymentFlow: GlobalLoadBalancerPaymentFlowAutomated,
GlobalListener: nil,
GlobalPool: nil,
}
Expand Down
2 changes: 2 additions & 0 deletions vngcloud/services/loadbalancer/global/irequest.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ type ICreateGlobalLoadBalancerRequest interface {
WithType(ptype GlobalLoadBalancerType) ICreateGlobalLoadBalancerRequest
WithGlobalListener(plistener ICreateGlobalListenerRequest) ICreateGlobalLoadBalancerRequest
WithGlobalPool(ppool ICreateGlobalPoolRequest) ICreateGlobalLoadBalancerRequest
WithPackage(ppackageId string) ICreateGlobalLoadBalancerRequest
WithPaymentFlow(ppaymentFlow GlobalLoadBalancerPaymentFlow) ICreateGlobalLoadBalancerRequest

// WithTags(ptags ...string) ICreateGlobalLoadBalancerRequest
// WithScheme(pscheme LoadBalancerScheme) ICreateGlobalLoadBalancerRequest
Expand Down

0 comments on commit 8ecb96e

Please sign in to comment.