refactor: clean code

This commit is contained in:
Fu Diwei
2025-06-15 20:51:28 +08:00
parent 94a0292fad
commit 769b24aa88
7 changed files with 36 additions and 36 deletions

View File

@@ -31,7 +31,7 @@ func (c *Client) GetDomainConfig(req *GetDomainConfigRequest) (*GetDomainConfigR
}
func (c *Client) GetDomainConfigWithContext(ctx context.Context, req *GetDomainConfigRequest) (*GetDomainConfigResponse, error) {
httpreq, err := c.newRequest(http.MethodGet, "/ctapi/v1/accessone/domain/config")
httpreq, err := c.newRequest(http.MethodPost, "/ctapi/v1/accessone/domain/config")
if err != nil {
return nil, err
} else {

View File

@@ -6,13 +6,13 @@ import (
"strconv"
)
type ListCertRequest struct {
type ListCertsRequest struct {
Page *int32 `json:"page,omitempty"`
PerPage *int32 `json:"per_page,omitempty"`
UsageMode *int32 `json:"usage_mode,omitempty"`
}
type ListCertResponse struct {
type ListCertsResponse struct {
baseResult
ReturnObj *struct {
@@ -24,11 +24,11 @@ type ListCertResponse struct {
} `json:"returnObj,omitempty"`
}
func (c *Client) ListCert(req *ListCertRequest) (*ListCertResponse, error) {
return c.ListCertWithContext(context.Background(), req)
func (c *Client) ListCerts(req *ListCertsRequest) (*ListCertsResponse, error) {
return c.ListCertsWithContext(context.Background(), req)
}
func (c *Client) ListCertWithContext(ctx context.Context, req *ListCertRequest) (*ListCertResponse, error) {
func (c *Client) ListCertsWithContext(ctx context.Context, req *ListCertsRequest) (*ListCertsResponse, error) {
httpreq, err := c.newRequest(http.MethodGet, "/ctapi/v1/accessone/cert/list")
if err != nil {
return nil, err
@@ -46,7 +46,7 @@ func (c *Client) ListCertWithContext(ctx context.Context, req *ListCertRequest)
httpreq.SetContext(ctx)
}
result := &ListCertResponse{}
result := &ListCertsResponse{}
if _, err := c.doRequestWithResult(httpreq, result); err != nil {
return result, err
}

View File

@@ -5,7 +5,7 @@ import (
"net/http"
)
type ListCertificateRequest struct {
type ListCertificatesRequest struct {
ClientToken *string `json:"clientToken,omitempty"`
RegionID *string `json:"regionID,omitempty"`
IDs *string `json:"IDs,omitempty"`
@@ -13,17 +13,17 @@ type ListCertificateRequest struct {
Type *string `json:"type,omitempty"`
}
type ListCertificateResponse struct {
type ListCertificatesResponse struct {
baseResult
ReturnObj []*CertificateRecord `json:"returnObj,omitempty"`
}
func (c *Client) ListCertificate(req *ListCertificateRequest) (*ListCertificateResponse, error) {
return c.ListCertificateWithContext(context.Background(), req)
func (c *Client) ListCertificates(req *ListCertificatesRequest) (*ListCertificatesResponse, error) {
return c.ListCertificatesWithContext(context.Background(), req)
}
func (c *Client) ListCertificateWithContext(ctx context.Context, req *ListCertificateRequest) (*ListCertificateResponse, error) {
func (c *Client) ListCertificatesWithContext(ctx context.Context, req *ListCertificatesRequest) (*ListCertificatesResponse, error) {
httpreq, err := c.newRequest(http.MethodGet, "/v4/elb/list-certificate")
if err != nil {
return nil, err
@@ -47,7 +47,7 @@ func (c *Client) ListCertificateWithContext(ctx context.Context, req *ListCertif
httpreq.SetContext(ctx)
}
result := &ListCertificateResponse{}
result := &ListCertificatesResponse{}
if _, err := c.doRequestWithResult(httpreq, result); err != nil {
return result, err
}

View File

@@ -5,7 +5,7 @@ import (
"net/http"
)
type ListListenerRequest struct {
type ListListenersRequest struct {
ClientToken *string `json:"clientToken,omitempty"`
RegionID *string `json:"regionID,omitempty"`
ProjectID *string `json:"projectID,omitempty"`
@@ -15,17 +15,17 @@ type ListListenerRequest struct {
AccessControlID *string `json:"accessControlID,omitempty"`
}
type ListListenerResponse struct {
type ListListenersResponse struct {
baseResult
ReturnObj []*ListenerRecord `json:"returnObj,omitempty"`
}
func (c *Client) ListListener(req *ListListenerRequest) (*ListListenerResponse, error) {
return c.ListListenerWithContext(context.Background(), req)
func (c *Client) ListListeners(req *ListListenersRequest) (*ListListenersResponse, error) {
return c.ListListenersWithContext(context.Background(), req)
}
func (c *Client) ListListenerWithContext(ctx context.Context, req *ListListenerRequest) (*ListListenerResponse, error) {
func (c *Client) ListListenersWithContext(ctx context.Context, req *ListListenersRequest) (*ListListenersResponse, error) {
httpreq, err := c.newRequest(http.MethodGet, "/v4/elb/list-listener")
if err != nil {
return nil, err
@@ -55,7 +55,7 @@ func (c *Client) ListListenerWithContext(ctx context.Context, req *ListListenerR
httpreq.SetContext(ctx)
}
result := &ListListenerResponse{}
result := &ListListenersResponse{}
if _, err := c.doRequestWithResult(httpreq, result); err != nil {
return result, err
}