Skip to content

Commit

Permalink
[build][fix] api list system tags
Browse files Browse the repository at this point in the history
  • Loading branch information
cuongpiger committed Oct 15, 2024
1 parent 8a50b66 commit 9297420
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 10 deletions.
10 changes: 5 additions & 5 deletions test/endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,18 @@ func TestEndpoint(t *ltesting.T) {
}

func TestListEndpointTags(t *ltesting.T) {
vngcloud := validSdkConfig()
opt := lsnwv1.NewListEndpointsRequest(1, 100).WithUuid("enp-9349271b-af44-4e39-8829-615d945fa6c2")
vngcloud := validSuperSdkConfig()
opt := lsnwv1.NewListTagsByEndpointIdRequest("60108", "enp-7e8e4476-feeb-414c-ac03-3501aae607d0")

lb, sdkerr := vngcloud.VNetworkGateway().V1().NetworkService().ListEndpoints(opt)
lb, sdkerr := vngcloud.VNetworkGateway().InternalV1().NetworkService().ListTagsByEndpointId(opt)
if sdkerr != nil {
t.Fatalf("Expect nil but got %+v", sdkerr.GetErrorCode())
t.Logf("Expect nil but got %+v", sdkerr.GetErrorCode())
}

if lb == nil {
t.Fatalf("Expect not nil but got nil")
}

t.Log("Result: ", lb.At(0))
t.Log("Result: ", lb)
t.Log("PASS")
}
10 changes: 8 additions & 2 deletions test/identity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package test

import (
lctx "context"
"fmt"
ltesting "testing"

lgodotenv "github.com/joho/godotenv"
Expand Down Expand Up @@ -121,10 +122,12 @@ func validSuperSdkConfig() lsclient.IClient {
sdkConfig := lsclient.NewSdkConfigure().
WithClientId(clientId).
WithClientSecret(clientSecret).
WithZoneId(getValueOfEnv("VNGCLOUD_ZONE_ID")).
WithProjectId(getValueOfEnv("VNGCLOUD_PROJECT_ID")).
WithIamEndpoint("https://iamapis.vngcloud.vn/accounts-api").
WithVServerEndpoint("https://hcm-3.api.vngcloud.vn/vserver/vserver-gateway").
WithVLBEndpoint("https://hcm-3.api.vngcloud.vn/vserver/vlb-gateway")
WithVLBEndpoint("https://hcm-3.api.vngcloud.vn/vserver/vlb-gateway").
WithVNetworkEndpoint("https://vnetwork-hcm03-api.vngcloud.vn/vnetwork-gateway")

return lsclient.NewClient(lctx.TODO()).WithRetryCount(1).WithSleep(10).Configure(sdkConfig)
}
Expand Down Expand Up @@ -223,6 +226,8 @@ func TestAuthenPass(t *ltesting.T) {
t.Log("PASS")
}



func TestASuperuthenPass(t *ltesting.T) {
clientId, clientSecret := getValueOfEnv("VNGCLOUD_SUPER_CLIENT_ID"), getValueOfEnv("VNGCLOUD_SUPER_CLIENT_SECRET")
vngcloud := validSdkConfig()
Expand All @@ -233,7 +238,8 @@ func TestASuperuthenPass(t *ltesting.T) {
t.Error("This testcase MUST pass")
}

t.Log("RESULT:", token)
fmt.Println("RESULT 2:", token.Token)
t.Log("RESULT:", token.Token)
t.Log("PASS")
}

Expand Down
4 changes: 4 additions & 0 deletions vngcloud/gateway/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,7 @@ func (s *vnetworkGateway) V1() IVNetworkGatewayV1 {
func (s *vnetworkGateway) GetEndpoint() string {
return s.endpoint
}

func (s *vnetworkGateway) InternalV1() IVNetworkGatewayInternalV1 {
return s.vnetworkGatewayInternalV1
}
2 changes: 2 additions & 0 deletions vngcloud/gateway/igateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type IVServerGateway interface {

type IVNetworkGateway interface {
V1() IVNetworkGatewayV1
InternalV1() IVNetworkGatewayInternalV1
GetEndpoint() string
}

Expand All @@ -51,6 +52,7 @@ type IVNetworkGatewayV1 interface {
}

type IVNetworkGatewayInternalV1 interface {
NetworkService() lsnetworkSvc.INetworkServiceInternalV1
}

type IVLBGatewayInternal interface {
Expand Down
4 changes: 4 additions & 0 deletions vngcloud/gateway/vnetwork_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ func (s *vnetworkGatewayV1) NetworkService() lsnwSvc.INetworkServiceV1 {
return s.networkService
}

func (s *vnetworkGatewayInternalV1) NetworkService() lsnwSvc.INetworkServiceInternalV1 {
return s.networkService
}

func NewVNetworkGatewayV1(psvcClient lsclient.IServiceClient) IVNetworkGatewayV1 {
return &vnetworkGatewayV1{
networkService: lsnwSvc.NewNetworkServiceV1(psvcClient),
Expand Down
2 changes: 2 additions & 0 deletions vngcloud/services/network/v1/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ func (s *NetworkServiceInternalV1) ListTagsByEndpointId(popts IListTagsByEndpoin
resp := new(ListTagsByEndpointIdResponse)
errResp := lserr.NewErrorResponse(lserr.NetworkGatewayErrorType)
req := lsclient.NewRequest().
WithMapHeaders(popts.GetMapHeaders()).
WithHeader("User-Agent", popts.ParseUserAgent()).
WithOkCodes(200).
WithJsonResponse(resp).
WithJsonError(errResp)
Expand Down
13 changes: 12 additions & 1 deletion vngcloud/services/network/v1/endpoint_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,11 @@ func NewListEndpointsRequest(ppage, psize int) IListEndpointsRequest {
}
}

func NewListTagsByEndpointIdRequest(pendpointId string) IListTagsByEndpointIdRequest {
func NewListTagsByEndpointIdRequest(puserId, pendpointId string) IListTagsByEndpointIdRequest {
opt := new(ListTagsByEndpointIdRequest)
opt.Id = pendpointId
opt.EndpointId = pendpointId
opt.SetPortalUserId(puserId)
return opt
}

Expand Down Expand Up @@ -300,6 +301,7 @@ func (s *ListEndpointsRequest) AddUserAgent(pagent ...string) IListEndpointsRequ
type ListTagsByEndpointIdRequest struct {
lscommon.UserAgent
lscommon.EndpointCommon
lscommon.PortalUser

Id string `q:"resourceUuid"`
}
Expand Down Expand Up @@ -331,3 +333,12 @@ func (s *ListTagsByEndpointIdRequest) GetParameters() map[string]interface{} {

return res
}

func (s *ListTagsByEndpointIdRequest) GetMapHeaders() map[string]string {
return s.PortalUser.GetMapHeaders()
}

func (s *ListTagsByEndpointIdRequest) AddUserAgent(pagent ...string) IListTagsByEndpointIdRequest {
s.UserAgent.Agent = append(s.UserAgent.Agent, pagent...)
return s
}
6 changes: 4 additions & 2 deletions vngcloud/services/network/v1/irequest.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ type IListEndpointsRequest interface {
GetParameters() map[string]interface{}
}


type IListTagsByEndpointIdRequest interface {
ToListQuery() (string, error)
GetDefaultQuery() string
GetParameters() map[string]interface{}
}
GetMapHeaders() map[string]string
ParseUserAgent() string
AddUserAgent(pagent ...string) IListTagsByEndpointIdRequest
}

0 comments on commit 9297420

Please sign in to comment.