diff --git a/test/portal_test.go b/test/portal_test.go index 0a9d783..54968d4 100644 --- a/test/portal_test.go +++ b/test/portal_test.go @@ -136,7 +136,7 @@ func TestGetQuotaByNamePass(t *ltesting.T) { func TestListProjects(t *ltesting.T) { vngcloud := validSdkConfig() - projects, err := vngcloud.VServerGateway().V1().PortalService().ListProjects() + projects, err := vngcloud.VServerGateway().V1().PortalService().ListProjects(lsportalV1.NewListProjectsRequest()) if err != nil { t.Log("Error: ", err) } @@ -146,7 +146,7 @@ func TestListProjects(t *ltesting.T) { func TestListPortalUser11412(t *ltesting.T) { vngcloud := validUser11412() - projects, err := vngcloud.VServerGateway().V1().PortalService().ListProjects() + projects, err := vngcloud.VServerGateway().V1().PortalService().ListProjects(lsportalV1.NewListProjectsRequest()) if err != nil { t.Log("Error: ", err) } diff --git a/vngcloud/services/loadbalancer/v2/loadbalancer.go b/vngcloud/services/loadbalancer/v2/loadbalancer.go index c131614..7de438c 100644 --- a/vngcloud/services/loadbalancer/v2/loadbalancer.go +++ b/vngcloud/services/loadbalancer/v2/loadbalancer.go @@ -263,7 +263,8 @@ func (s *LoadBalancerServiceV2) UpdatePoolMembers(popts IUpdatePoolMembersReques lserr.WithErrorLoadBalancerNotFound2(errResp), lserr.WithErrorLoadBalancerNotReady(errResp), lserr.WithErrorPoolNotFound(errResp), - lserr.WithErrorMemberMustIdentical(errResp)).AppendCategories(lserr.ErrCatProductVlb) + lserr.WithErrorMemberMustIdentical(errResp)). + AppendCategories(lserr.ErrCatProductVlb) } return nil @@ -283,6 +284,7 @@ func (s *LoadBalancerServiceV2) ListPoolMembers(popts IListPoolMembersRequest) ( return nil, lserr.SdkErrorHandler(sdkErr, errResp, lserr.WithErrorLoadBalancerNotFound(errResp), lserr.WithErrorPoolNotFound(errResp)). + WithKVparameters("loadBalancerId", popts.GetLoadBalancerId(), "poolId", popts.GetPoolId()). AppendCategories(lserr.ErrCatProductVlb) } diff --git a/vngcloud/services/portal/iportal.go b/vngcloud/services/portal/iportal.go index db9b6da..ebe6f37 100644 --- a/vngcloud/services/portal/iportal.go +++ b/vngcloud/services/portal/iportal.go @@ -9,7 +9,7 @@ import ( type IPortalServiceV1 interface { GetPortalInfo(popts lsportalV1.IGetPortalInfoRequest) (*lsentity.Portal, lserr.IError) - ListProjects() (*lsentity.ListPortals, lserr.IError) + ListProjects(popts lsportalV1.IListProjectsRequest) (*lsentity.ListPortals, lserr.IError) } type IPortalServiceV2 interface { diff --git a/vngcloud/services/portal/v1/irequest.go b/vngcloud/services/portal/v1/irequest.go index ee0a51a..0f19b13 100644 --- a/vngcloud/services/portal/v1/irequest.go +++ b/vngcloud/services/portal/v1/irequest.go @@ -3,3 +3,8 @@ package v1 type IGetPortalInfoRequest interface { GetBackEndProjectId() string } + +type IListProjectsRequest interface { + AddUserAgent(pagent ...string) IListProjectsRequest + ParseUserAgent() string +} diff --git a/vngcloud/services/portal/v1/portal.go b/vngcloud/services/portal/v1/portal.go index d17090a..f47d87c 100644 --- a/vngcloud/services/portal/v1/portal.go +++ b/vngcloud/services/portal/v1/portal.go @@ -23,12 +23,12 @@ func (s *PortalServiceV1) GetPortalInfo(popts IGetPortalInfoRequest) (*lsentity. return resp.ToEntityPortal(), nil } - -func (s *PortalServiceV1) ListProjects() (*lsentity.ListPortals, lserr.IError) { +func (s *PortalServiceV1) ListProjects(popts IListProjectsRequest) (*lsentity.ListPortals, lserr.IError) { url := listProjectsUrl(s.PortalClient) resp := new(ListProjectsResponse) errResp := lserr.NewErrorResponse(lserr.NormalErrorType) req := lsclient.NewRequest(). + WithHeader("User-Agent", popts.ParseUserAgent()). WithOkCodes(200). WithJsonResponse(resp). WithJsonError(errResp) @@ -38,4 +38,4 @@ func (s *PortalServiceV1) ListProjects() (*lsentity.ListPortals, lserr.IError) { } return resp.ToEntityListPortals(), nil -} \ No newline at end of file +} diff --git a/vngcloud/services/portal/v1/portal_request.go b/vngcloud/services/portal/v1/portal_request.go index 7bd27a7..c5d3e23 100644 --- a/vngcloud/services/portal/v1/portal_request.go +++ b/vngcloud/services/portal/v1/portal_request.go @@ -1,15 +1,20 @@ package v1 +import lscommon "github.com/vngcloud/vngcloud-go-sdk/v2/vngcloud/services/common" + type GetPortalInfoRequest struct { BackEndProjectId string } -func NewGetPortalInfoRequest(pbackendProjectId string) IGetPortalInfoRequest { - return &GetPortalInfoRequest{ - BackEndProjectId: pbackendProjectId, - } -} - func (s *GetPortalInfoRequest) GetBackEndProjectId() string { return s.BackEndProjectId } + +type ListProjectsRequest struct { + lscommon.UserAgent +} + +func (s *ListProjectsRequest) AddUserAgent(pagent ...string) IListProjectsRequest { + s.UserAgent.AddUserAgent(pagent...) + return s +} diff --git a/vngcloud/services/portal/v1/requests.go b/vngcloud/services/portal/v1/requests.go new file mode 100644 index 0000000..9f38a8c --- /dev/null +++ b/vngcloud/services/portal/v1/requests.go @@ -0,0 +1,11 @@ +package v1 + +func NewGetPortalInfoRequest(pbackendProjectId string) IGetPortalInfoRequest { + return &GetPortalInfoRequest{ + BackEndProjectId: pbackendProjectId, + } +} + +func NewListProjectsRequest() IListProjectsRequest { + return &ListProjectsRequest{} +}