mirror of
https://github.com/usual2970/certimate.git
synced 2025-06-09 05:59:50 +00:00
refactor: clean code
This commit is contained in:
parent
445541c38f
commit
12102ef641
@ -37,7 +37,7 @@ Shell command to run this test:
|
|||||||
--CERTIMATE_DEPLOYER_QINIUCDN_INPUTKEYPATH="/path/to/your-input-key.pem" \
|
--CERTIMATE_DEPLOYER_QINIUCDN_INPUTKEYPATH="/path/to/your-input-key.pem" \
|
||||||
--CERTIMATE_DEPLOYER_QINIUCDN_ACCESSKEY="your-access-key" \
|
--CERTIMATE_DEPLOYER_QINIUCDN_ACCESSKEY="your-access-key" \
|
||||||
--CERTIMATE_DEPLOYER_QINIUCDN_SECRETKEY="your-secret-key" \
|
--CERTIMATE_DEPLOYER_QINIUCDN_SECRETKEY="your-secret-key" \
|
||||||
--CERTIMATE_DEPLOYER_QINIUCDN_DOMAIN="example.com" \
|
--CERTIMATE_DEPLOYER_QINIUCDN_DOMAIN="example.com"
|
||||||
*/
|
*/
|
||||||
func TestDeploy(t *testing.T) {
|
func TestDeploy(t *testing.T) {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
@ -40,7 +40,7 @@ Shell command to run this test:
|
|||||||
--CERTIMATE_DEPLOYER_QINIUPILI_ACCESSKEY="your-access-key" \
|
--CERTIMATE_DEPLOYER_QINIUPILI_ACCESSKEY="your-access-key" \
|
||||||
--CERTIMATE_DEPLOYER_QINIUPILI_SECRETKEY="your-secret-key" \
|
--CERTIMATE_DEPLOYER_QINIUPILI_SECRETKEY="your-secret-key" \
|
||||||
--CERTIMATE_DEPLOYER_QINIUPILI_HUB="your-hub-name" \
|
--CERTIMATE_DEPLOYER_QINIUPILI_HUB="your-hub-name" \
|
||||||
--CERTIMATE_DEPLOYER_QINIUPILI_DOMAIN="example.com" \
|
--CERTIMATE_DEPLOYER_QINIUPILI_DOMAIN="example.com"
|
||||||
*/
|
*/
|
||||||
func TestDeploy(t *testing.T) {
|
func TestDeploy(t *testing.T) {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
@ -37,7 +37,7 @@ Shell command to run this test:
|
|||||||
--CERTIMATE_DEPLOYER_UPYUNCDN_INPUTKEYPATH="/path/to/your-input-key.pem" \
|
--CERTIMATE_DEPLOYER_UPYUNCDN_INPUTKEYPATH="/path/to/your-input-key.pem" \
|
||||||
--CERTIMATE_DEPLOYER_UPYUNCDN_USERNAME="your-username" \
|
--CERTIMATE_DEPLOYER_UPYUNCDN_USERNAME="your-username" \
|
||||||
--CERTIMATE_DEPLOYER_UPYUNCDN_PASSWORD="your-password" \
|
--CERTIMATE_DEPLOYER_UPYUNCDN_PASSWORD="your-password" \
|
||||||
--CERTIMATE_DEPLOYER_UPYUNCDN_DOMAIN="example.com" \
|
--CERTIMATE_DEPLOYER_UPYUNCDN_DOMAIN="example.com"
|
||||||
*/
|
*/
|
||||||
func TestDeploy(t *testing.T) {
|
func TestDeploy(t *testing.T) {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
@ -59,9 +59,9 @@ func (u *UploaderProvider) Upload(ctx context.Context, certPem string, privkeyPe
|
|||||||
PrivateKey: privkeyPem,
|
PrivateKey: privkeyPem,
|
||||||
}
|
}
|
||||||
uploadHttpsCertificateResp, err := u.sdkClient.UploadHttpsCertificate(uploadHttpsCertificateReq)
|
uploadHttpsCertificateResp, err := u.sdkClient.UploadHttpsCertificate(uploadHttpsCertificateReq)
|
||||||
u.logger.Debug("sdk request 'ssl.UploadHttpsCertificate'", slog.Any("response", uploadHttpsCertificateResp))
|
u.logger.Debug("sdk request 'console.UploadHttpsCertificate'", slog.Any("response", uploadHttpsCertificateResp))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, xerrors.Wrap(err, "failed to execute sdk request 'ssl.UploadHttpsCertificate'")
|
return nil, xerrors.Wrap(err, "failed to execute sdk request 'console.UploadHttpsCertificate'")
|
||||||
}
|
}
|
||||||
|
|
||||||
return &uploader.UploadResult{
|
return &uploader.UploadResult{
|
||||||
|
25
internal/pkg/vendors/1panel-sdk/api.go
vendored
25
internal/pkg/vendors/1panel-sdk/api.go
vendored
@ -8,44 +8,29 @@ import (
|
|||||||
func (c *Client) UpdateSystemSSL(req *UpdateSystemSSLRequest) (*UpdateSystemSSLResponse, error) {
|
func (c *Client) UpdateSystemSSL(req *UpdateSystemSSLRequest) (*UpdateSystemSSLResponse, error) {
|
||||||
resp := &UpdateSystemSSLResponse{}
|
resp := &UpdateSystemSSLResponse{}
|
||||||
err := c.sendRequestWithResult(http.MethodPost, "/settings/ssl/update", req, resp)
|
err := c.sendRequestWithResult(http.MethodPost, "/settings/ssl/update", req, resp)
|
||||||
if err != nil {
|
return resp, err
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return resp, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) SearchWebsiteSSL(req *SearchWebsiteSSLRequest) (*SearchWebsiteSSLResponse, error) {
|
func (c *Client) SearchWebsiteSSL(req *SearchWebsiteSSLRequest) (*SearchWebsiteSSLResponse, error) {
|
||||||
resp := &SearchWebsiteSSLResponse{}
|
resp := &SearchWebsiteSSLResponse{}
|
||||||
err := c.sendRequestWithResult(http.MethodPost, "/websites/ssl/search", req, resp)
|
err := c.sendRequestWithResult(http.MethodPost, "/websites/ssl/search", req, resp)
|
||||||
if err != nil {
|
return resp, err
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return resp, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) UploadWebsiteSSL(req *UploadWebsiteSSLRequest) (*UploadWebsiteSSLResponse, error) {
|
func (c *Client) UploadWebsiteSSL(req *UploadWebsiteSSLRequest) (*UploadWebsiteSSLResponse, error) {
|
||||||
resp := &UploadWebsiteSSLResponse{}
|
resp := &UploadWebsiteSSLResponse{}
|
||||||
err := c.sendRequestWithResult(http.MethodPost, "/websites/ssl/upload", req, resp)
|
err := c.sendRequestWithResult(http.MethodPost, "/websites/ssl/upload", req, resp)
|
||||||
if err != nil {
|
return resp, err
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return resp, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) GetHttpsConf(req *GetHttpsConfRequest) (*GetHttpsConfResponse, error) {
|
func (c *Client) GetHttpsConf(req *GetHttpsConfRequest) (*GetHttpsConfResponse, error) {
|
||||||
resp := &GetHttpsConfResponse{}
|
resp := &GetHttpsConfResponse{}
|
||||||
err := c.sendRequestWithResult(http.MethodGet, fmt.Sprintf("/websites/%d/https", req.WebsiteID), req, resp)
|
err := c.sendRequestWithResult(http.MethodGet, fmt.Sprintf("/websites/%d/https", req.WebsiteID), req, resp)
|
||||||
if err != nil {
|
return resp, err
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return resp, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) UpdateHttpsConf(req *UpdateHttpsConfRequest) (*UpdateHttpsConfResponse, error) {
|
func (c *Client) UpdateHttpsConf(req *UpdateHttpsConfRequest) (*UpdateHttpsConfResponse, error) {
|
||||||
resp := &UpdateHttpsConfResponse{}
|
resp := &UpdateHttpsConfResponse{}
|
||||||
err := c.sendRequestWithResult(http.MethodPost, fmt.Sprintf("/websites/%d/https", req.WebsiteID), req, resp)
|
err := c.sendRequestWithResult(http.MethodPost, fmt.Sprintf("/websites/%d/https", req.WebsiteID), req, resp)
|
||||||
if err != nil {
|
return resp, err
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return resp, nil
|
|
||||||
}
|
}
|
||||||
|
4
internal/pkg/vendors/1panel-sdk/client.go
vendored
4
internal/pkg/vendors/1panel-sdk/client.go
vendored
@ -77,9 +77,9 @@ func (c *Client) sendRequest(method string, path string, params interface{}) (*r
|
|||||||
|
|
||||||
resp, err := req.Send()
|
resp, err := req.Send()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("1panel api error: failed to send request: %w", err)
|
return resp, fmt.Errorf("1panel api error: failed to send request: %w", err)
|
||||||
} else if resp.IsError() {
|
} else if resp.IsError() {
|
||||||
return nil, fmt.Errorf("1panel api error: unexpected status code: %d, %s", resp.StatusCode(), resp.Body())
|
return resp, fmt.Errorf("1panel api error: unexpected status code: %d, %s", resp.StatusCode(), resp.Body())
|
||||||
}
|
}
|
||||||
|
|
||||||
return resp, nil
|
return resp, nil
|
||||||
|
22
internal/pkg/vendors/1panel-sdk/models.go
vendored
22
internal/pkg/vendors/1panel-sdk/models.go
vendored
@ -6,16 +6,22 @@ type BaseResponse interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type baseResponse struct {
|
type baseResponse struct {
|
||||||
Code int32 `json:"code"`
|
Code *int32 `json:"code,omitempty"`
|
||||||
Message string `json:"message"`
|
Message *string `json:"message,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *baseResponse) GetCode() int32 {
|
func (r *baseResponse) GetCode() int32 {
|
||||||
return r.Code
|
if r.Code != nil {
|
||||||
|
return *r.Code
|
||||||
|
}
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *baseResponse) GetMessage() string {
|
func (r *baseResponse) GetMessage() string {
|
||||||
return r.Message
|
if r.Message != nil {
|
||||||
|
return *r.Message
|
||||||
|
}
|
||||||
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
type UpdateSystemSSLRequest struct {
|
type UpdateSystemSSLRequest struct {
|
||||||
@ -38,7 +44,7 @@ type SearchWebsiteSSLRequest struct {
|
|||||||
|
|
||||||
type SearchWebsiteSSLResponse struct {
|
type SearchWebsiteSSLResponse struct {
|
||||||
baseResponse
|
baseResponse
|
||||||
Data struct {
|
Data *struct {
|
||||||
Items []*struct {
|
Items []*struct {
|
||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
PEM string `json:"pem"`
|
PEM string `json:"pem"`
|
||||||
@ -50,7 +56,7 @@ type SearchWebsiteSSLResponse struct {
|
|||||||
CreatedAt string `json:"createdAt"`
|
CreatedAt string `json:"createdAt"`
|
||||||
} `json:"items"`
|
} `json:"items"`
|
||||||
Total int32 `json:"total"`
|
Total int32 `json:"total"`
|
||||||
} `json:"data"`
|
} `json:"data,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type UploadWebsiteSSLRequest struct {
|
type UploadWebsiteSSLRequest struct {
|
||||||
@ -73,13 +79,13 @@ type GetHttpsConfRequest struct {
|
|||||||
|
|
||||||
type GetHttpsConfResponse struct {
|
type GetHttpsConfResponse struct {
|
||||||
baseResponse
|
baseResponse
|
||||||
Data struct {
|
Data *struct {
|
||||||
Enable bool `json:"enable"`
|
Enable bool `json:"enable"`
|
||||||
HttpConfig string `json:"httpConfig"`
|
HttpConfig string `json:"httpConfig"`
|
||||||
SSLProtocol []string `json:"SSLProtocol"`
|
SSLProtocol []string `json:"SSLProtocol"`
|
||||||
Algorithm string `json:"algorithm"`
|
Algorithm string `json:"algorithm"`
|
||||||
Hsts bool `json:"hsts"`
|
Hsts bool `json:"hsts"`
|
||||||
} `json:"data"`
|
} `json:"data,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type UpdateHttpsConfRequest struct {
|
type UpdateHttpsConfRequest struct {
|
||||||
|
27
internal/pkg/vendors/baishan-sdk/api.go
vendored
27
internal/pkg/vendors/baishan-sdk/api.go
vendored
@ -5,28 +5,19 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (c *Client) CreateCertificate(req *CreateCertificateRequest) (*CreateCertificateResponse, error) {
|
func (c *Client) CreateCertificate(req *CreateCertificateRequest) (*CreateCertificateResponse, error) {
|
||||||
resp := CreateCertificateResponse{}
|
resp := &CreateCertificateResponse{}
|
||||||
err := c.sendRequestWithResult(http.MethodPost, "/v2/domain/certificate", req, &resp)
|
err := c.sendRequestWithResult(http.MethodPost, "/v2/domain/certificate", req, resp)
|
||||||
if err != nil {
|
return resp, err
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &resp, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) GetDomainConfig(req *GetDomainConfigRequest) (*GetDomainConfigResponse, error) {
|
func (c *Client) GetDomainConfig(req *GetDomainConfigRequest) (*GetDomainConfigResponse, error) {
|
||||||
resp := GetDomainConfigResponse{}
|
resp := &GetDomainConfigResponse{}
|
||||||
err := c.sendRequestWithResult(http.MethodGet, "/v2/domain/config", req, &resp)
|
err := c.sendRequestWithResult(http.MethodGet, "/v2/domain/config", req, resp)
|
||||||
if err != nil {
|
return resp, err
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &resp, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) SetDomainConfig(req *SetDomainConfigRequest) (*SetDomainConfigResponse, error) {
|
func (c *Client) SetDomainConfig(req *SetDomainConfigRequest) (*SetDomainConfigResponse, error) {
|
||||||
resp := SetDomainConfigResponse{}
|
resp := &SetDomainConfigResponse{}
|
||||||
err := c.sendRequestWithResult(http.MethodPost, "/v2/domain/config", req, &resp)
|
err := c.sendRequestWithResult(http.MethodPost, "/v2/domain/config", req, resp)
|
||||||
if err != nil {
|
return resp, err
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &resp, nil
|
|
||||||
}
|
}
|
||||||
|
6
internal/pkg/vendors/baishan-sdk/client.go
vendored
6
internal/pkg/vendors/baishan-sdk/client.go
vendored
@ -63,7 +63,7 @@ func (c *Client) sendRequest(method string, path string, params interface{}) (*r
|
|||||||
|
|
||||||
req = req.
|
req = req.
|
||||||
SetQueryParam("token", c.apiToken).
|
SetQueryParam("token", c.apiToken).
|
||||||
SetQueryParamsFromValues(qs).SetDebug(true)
|
SetQueryParamsFromValues(qs)
|
||||||
} else {
|
} else {
|
||||||
req = req.
|
req = req.
|
||||||
SetHeader("Content-Type", "application/json").
|
SetHeader("Content-Type", "application/json").
|
||||||
@ -73,9 +73,9 @@ func (c *Client) sendRequest(method string, path string, params interface{}) (*r
|
|||||||
|
|
||||||
resp, err := req.Send()
|
resp, err := req.Send()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("baishan api error: failed to send request: %w", err)
|
return resp, fmt.Errorf("baishan api error: failed to send request: %w", err)
|
||||||
} else if resp.IsError() {
|
} else if resp.IsError() {
|
||||||
return nil, fmt.Errorf("baishan api error: unexpected status code: %d, %s", resp.StatusCode(), resp.Body())
|
return resp, fmt.Errorf("baishan api error: unexpected status code: %d, %s", resp.StatusCode(), resp.Body())
|
||||||
}
|
}
|
||||||
|
|
||||||
return resp, nil
|
return resp, nil
|
||||||
|
20
internal/pkg/vendors/baishan-sdk/models.go
vendored
20
internal/pkg/vendors/baishan-sdk/models.go
vendored
@ -6,16 +6,22 @@ type BaseResponse interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type baseResponse struct {
|
type baseResponse struct {
|
||||||
Code int `json:"code"`
|
Code *int `json:"code,omitempty"`
|
||||||
Message string `json:"message"`
|
Message *string `json:"message,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *baseResponse) GetCode() int {
|
func (r *baseResponse) GetCode() int {
|
||||||
return r.Code
|
if r.Code != nil {
|
||||||
|
return *r.Code
|
||||||
|
}
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *baseResponse) GetMessage() string {
|
func (r *baseResponse) GetMessage() string {
|
||||||
return r.Message
|
if r.Message != nil {
|
||||||
|
return *r.Message
|
||||||
|
}
|
||||||
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
type CreateCertificateRequest struct {
|
type CreateCertificateRequest struct {
|
||||||
@ -26,7 +32,7 @@ type CreateCertificateRequest struct {
|
|||||||
|
|
||||||
type CreateCertificateResponse struct {
|
type CreateCertificateResponse struct {
|
||||||
baseResponse
|
baseResponse
|
||||||
Data *DomainCertificate `json:"data"`
|
Data *DomainCertificate `json:"data,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetDomainConfigRequest struct {
|
type GetDomainConfigRequest struct {
|
||||||
@ -39,7 +45,7 @@ type GetDomainConfigResponse struct {
|
|||||||
Data []*struct {
|
Data []*struct {
|
||||||
Domain string `json:"domain"`
|
Domain string `json:"domain"`
|
||||||
Config *DomainConfig `json:"config"`
|
Config *DomainConfig `json:"config"`
|
||||||
} `json:"data"`
|
} `json:"data,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SetDomainConfigRequest struct {
|
type SetDomainConfigRequest struct {
|
||||||
@ -51,7 +57,7 @@ type SetDomainConfigResponse struct {
|
|||||||
baseResponse
|
baseResponse
|
||||||
Data *struct {
|
Data *struct {
|
||||||
Config *DomainConfig `json:"config"`
|
Config *DomainConfig `json:"config"`
|
||||||
} `json:"data"`
|
} `json:"data,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type DomainCertificate struct {
|
type DomainCertificate struct {
|
||||||
|
45
internal/pkg/vendors/btpanel-sdk/api.go
vendored
45
internal/pkg/vendors/btpanel-sdk/api.go
vendored
@ -1,46 +1,31 @@
|
|||||||
package btpanelsdk
|
package btpanelsdk
|
||||||
|
|
||||||
func (c *Client) ConfigSavePanelSSL(req *ConfigSavePanelSSLRequest) (*ConfigSavePanelSSLResponse, error) {
|
func (c *Client) ConfigSavePanelSSL(req *ConfigSavePanelSSLRequest) (*ConfigSavePanelSSLResponse, error) {
|
||||||
resp := ConfigSavePanelSSLResponse{}
|
resp := &ConfigSavePanelSSLResponse{}
|
||||||
err := c.sendRequestWithResult("/config?action=SavePanelSSL", req, &resp)
|
err := c.sendRequestWithResult("/config?action=SavePanelSSL", req, resp)
|
||||||
if err != nil {
|
return resp, err
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &resp, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) SiteSetSSL(req *SiteSetSSLRequest) (*SiteSetSSLResponse, error) {
|
func (c *Client) SiteSetSSL(req *SiteSetSSLRequest) (*SiteSetSSLResponse, error) {
|
||||||
resp := SiteSetSSLResponse{}
|
resp := &SiteSetSSLResponse{}
|
||||||
err := c.sendRequestWithResult("/site?action=SetSSL", req, &resp)
|
err := c.sendRequestWithResult("/site?action=SetSSL", req, resp)
|
||||||
if err != nil {
|
return resp, err
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &resp, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) SystemServiceAdmin(req *SystemServiceAdminRequest) (*SystemServiceAdminResponse, error) {
|
func (c *Client) SystemServiceAdmin(req *SystemServiceAdminRequest) (*SystemServiceAdminResponse, error) {
|
||||||
resp := SystemServiceAdminResponse{}
|
resp := &SystemServiceAdminResponse{}
|
||||||
err := c.sendRequestWithResult("/system?action=ServiceAdmin", req, &resp)
|
err := c.sendRequestWithResult("/system?action=ServiceAdmin", req, resp)
|
||||||
if err != nil {
|
return resp, err
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &resp, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) SSLCertSaveCert(req *SSLCertSaveCertRequest) (*SSLCertSaveCertResponse, error) {
|
func (c *Client) SSLCertSaveCert(req *SSLCertSaveCertRequest) (*SSLCertSaveCertResponse, error) {
|
||||||
resp := SSLCertSaveCertResponse{}
|
resp := &SSLCertSaveCertResponse{}
|
||||||
err := c.sendRequestWithResult("/ssl/cert/save_cert", req, &resp)
|
err := c.sendRequestWithResult("/ssl/cert/save_cert", req, resp)
|
||||||
if err != nil {
|
return resp, err
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &resp, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) SSLSetBatchCertToSite(req *SSLSetBatchCertToSiteRequest) (*SSLSetBatchCertToSiteResponse, error) {
|
func (c *Client) SSLSetBatchCertToSite(req *SSLSetBatchCertToSiteRequest) (*SSLSetBatchCertToSiteResponse, error) {
|
||||||
resp := SSLSetBatchCertToSiteResponse{}
|
resp := &SSLSetBatchCertToSiteResponse{}
|
||||||
err := c.sendRequestWithResult("/ssl?action=SetBatchCertToSite", req, &resp)
|
err := c.sendRequestWithResult("/ssl?action=SetBatchCertToSite", req, resp)
|
||||||
if err != nil {
|
return resp, err
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &resp, nil
|
|
||||||
}
|
}
|
||||||
|
4
internal/pkg/vendors/btpanel-sdk/client.go
vendored
4
internal/pkg/vendors/btpanel-sdk/client.go
vendored
@ -84,9 +84,9 @@ func (c *Client) sendRequest(path string, params interface{}) (*resty.Response,
|
|||||||
SetFormData(data)
|
SetFormData(data)
|
||||||
resp, err := req.Post(url)
|
resp, err := req.Post(url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("baota api error: failed to send request: %w", err)
|
return resp, fmt.Errorf("baota api error: failed to send request: %w", err)
|
||||||
} else if resp.IsError() {
|
} else if resp.IsError() {
|
||||||
return nil, fmt.Errorf("baota api error: unexpected status code: %d, %s", resp.StatusCode(), resp.Body())
|
return resp, fmt.Errorf("baota api error: unexpected status code: %d, %s", resp.StatusCode(), resp.Body())
|
||||||
}
|
}
|
||||||
|
|
||||||
return resp, nil
|
return resp, nil
|
||||||
|
9
internal/pkg/vendors/cachefly-sdk/api.go
vendored
9
internal/pkg/vendors/cachefly-sdk/api.go
vendored
@ -5,10 +5,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (c *Client) CreateCertificate(req *CreateCertificateRequest) (*CreateCertificateResponse, error) {
|
func (c *Client) CreateCertificate(req *CreateCertificateRequest) (*CreateCertificateResponse, error) {
|
||||||
resp := CreateCertificateResponse{}
|
resp := &CreateCertificateResponse{}
|
||||||
err := c.sendRequestWithResult(http.MethodPost, "/certificates", req, &resp)
|
err := c.sendRequestWithResult(http.MethodPost, "/certificates", req, resp)
|
||||||
if err != nil {
|
return resp, err
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &resp, nil
|
|
||||||
}
|
}
|
||||||
|
4
internal/pkg/vendors/cachefly-sdk/client.go
vendored
4
internal/pkg/vendors/cachefly-sdk/client.go
vendored
@ -57,9 +57,9 @@ func (c *Client) sendRequest(method string, path string, params interface{}) (*r
|
|||||||
|
|
||||||
resp, err := req.Send()
|
resp, err := req.Send()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("cachefly api error: failed to send request: %w", err)
|
return resp, fmt.Errorf("cachefly api error: failed to send request: %w", err)
|
||||||
} else if resp.IsError() {
|
} else if resp.IsError() {
|
||||||
return nil, fmt.Errorf("cachefly api error: unexpected status code: %d, %s", resp.StatusCode(), resp.Body())
|
return resp, fmt.Errorf("cachefly api error: unexpected status code: %d, %s", resp.StatusCode(), resp.Body())
|
||||||
}
|
}
|
||||||
|
|
||||||
return resp, nil
|
return resp, nil
|
||||||
|
9
internal/pkg/vendors/cachefly-sdk/models.go
vendored
9
internal/pkg/vendors/cachefly-sdk/models.go
vendored
@ -1,15 +1,18 @@
|
|||||||
package cacheflysdk
|
package cacheflysdk
|
||||||
|
|
||||||
type BaseResponse interface {
|
type BaseResponse interface {
|
||||||
GetMessage() *string
|
GetMessage() string
|
||||||
}
|
}
|
||||||
|
|
||||||
type baseResponse struct {
|
type baseResponse struct {
|
||||||
Message *string `json:"message,omitempty"`
|
Message *string `json:"message,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *baseResponse) GetMessage() *string {
|
func (r *baseResponse) GetMessage() string {
|
||||||
return r.Message
|
if r.Message != nil {
|
||||||
|
return *r.Message
|
||||||
|
}
|
||||||
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
type CreateCertificateRequest struct {
|
type CreateCertificateRequest struct {
|
||||||
|
36
internal/pkg/vendors/cdnfly-sdk/api.go
vendored
36
internal/pkg/vendors/cdnfly-sdk/api.go
vendored
@ -6,37 +6,25 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (c *Client) GetSite(req *GetSiteRequest) (*GetSiteResponse, error) {
|
func (c *Client) GetSite(req *GetSiteRequest) (*GetSiteResponse, error) {
|
||||||
resp := GetSiteResponse{}
|
resp := &GetSiteResponse{}
|
||||||
err := c.sendRequestWithResult(http.MethodGet, fmt.Sprintf("/v1/sites/%s", req.Id), req, &resp)
|
err := c.sendRequestWithResult(http.MethodGet, fmt.Sprintf("/v1/sites/%s", req.Id), req, resp)
|
||||||
if err != nil {
|
return resp, err
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &resp, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) UpdateSite(req *UpdateSiteRequest) (*UpdateSiteResponse, error) {
|
func (c *Client) UpdateSite(req *UpdateSiteRequest) (*UpdateSiteResponse, error) {
|
||||||
resp := UpdateSiteResponse{}
|
resp := &UpdateSiteResponse{}
|
||||||
err := c.sendRequestWithResult(http.MethodPut, fmt.Sprintf("/v1/sites/%s", req.Id), req, &resp)
|
err := c.sendRequestWithResult(http.MethodPut, fmt.Sprintf("/v1/sites/%s", req.Id), req, resp)
|
||||||
if err != nil {
|
return resp, err
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &resp, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) CreateCertificate(req *CreateCertificateRequest) (*CreateCertificateResponse, error) {
|
func (c *Client) CreateCertificate(req *CreateCertificateRequest) (*CreateCertificateResponse, error) {
|
||||||
resp := CreateCertificateResponse{}
|
resp := &CreateCertificateResponse{}
|
||||||
err := c.sendRequestWithResult(http.MethodPost, "/v1/certs", req, &resp)
|
err := c.sendRequestWithResult(http.MethodPost, "/v1/certs", req, resp)
|
||||||
if err != nil {
|
return resp, err
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &resp, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) UpdateCertificate(req *UpdateCertificateRequest) (*UpdateCertificateResponse, error) {
|
func (c *Client) UpdateCertificate(req *UpdateCertificateRequest) (*UpdateCertificateResponse, error) {
|
||||||
resp := UpdateCertificateResponse{}
|
resp := &UpdateCertificateResponse{}
|
||||||
err := c.sendRequestWithResult(http.MethodPut, fmt.Sprintf("/v1/certs/%s", req.Id), req, &resp)
|
err := c.sendRequestWithResult(http.MethodPut, fmt.Sprintf("/v1/certs/%s", req.Id), req, resp)
|
||||||
if err != nil {
|
return resp, err
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &resp, nil
|
|
||||||
}
|
}
|
||||||
|
4
internal/pkg/vendors/cdnfly-sdk/client.go
vendored
4
internal/pkg/vendors/cdnfly-sdk/client.go
vendored
@ -63,9 +63,9 @@ func (c *Client) sendRequest(method string, path string, params interface{}) (*r
|
|||||||
|
|
||||||
resp, err := req.Send()
|
resp, err := req.Send()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("cdnfly api error: failed to send request: %w", err)
|
return resp, fmt.Errorf("cdnfly api error: failed to send request: %w", err)
|
||||||
} else if resp.IsError() {
|
} else if resp.IsError() {
|
||||||
return nil, fmt.Errorf("cdnfly api error: unexpected status code: %d, %s", resp.StatusCode(), resp.Body())
|
return resp, fmt.Errorf("cdnfly api error: unexpected status code: %d, %s", resp.StatusCode(), resp.Body())
|
||||||
}
|
}
|
||||||
|
|
||||||
return resp, nil
|
return resp, nil
|
||||||
|
2
internal/pkg/vendors/cdnfly-sdk/models.go
vendored
2
internal/pkg/vendors/cdnfly-sdk/models.go
vendored
@ -31,7 +31,7 @@ type GetSiteResponse struct {
|
|||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Domain string `json:"domain"`
|
Domain string `json:"domain"`
|
||||||
HttpsListen string `json:"https_listen"`
|
HttpsListen string `json:"https_listen"`
|
||||||
} `json:"data"`
|
} `json:"data,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type UpdateSiteRequest struct {
|
type UpdateSiteRequest struct {
|
||||||
|
45
internal/pkg/vendors/dnsla-sdk/api.go
vendored
45
internal/pkg/vendors/dnsla-sdk/api.go
vendored
@ -7,46 +7,31 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (c *Client) ListDomains(req *ListDomainsRequest) (*ListDomainsResponse, error) {
|
func (c *Client) ListDomains(req *ListDomainsRequest) (*ListDomainsResponse, error) {
|
||||||
resp := ListDomainsResponse{}
|
resp := &ListDomainsResponse{}
|
||||||
err := c.sendRequestWithResult(http.MethodGet, "/domainList", req, &resp)
|
err := c.sendRequestWithResult(http.MethodGet, "/domainList", req, resp)
|
||||||
if err != nil {
|
return resp, err
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &resp, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) ListRecords(req *ListRecordsRequest) (*ListRecordsResponse, error) {
|
func (c *Client) ListRecords(req *ListRecordsRequest) (*ListRecordsResponse, error) {
|
||||||
resp := ListRecordsResponse{}
|
resp := &ListRecordsResponse{}
|
||||||
err := c.sendRequestWithResult(http.MethodGet, "/recordList", req, &resp)
|
err := c.sendRequestWithResult(http.MethodGet, "/recordList", req, resp)
|
||||||
if err != nil {
|
return resp, err
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &resp, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) CreateRecord(req *CreateRecordRequest) (*CreateRecordResponse, error) {
|
func (c *Client) CreateRecord(req *CreateRecordRequest) (*CreateRecordResponse, error) {
|
||||||
resp := CreateRecordResponse{}
|
resp := &CreateRecordResponse{}
|
||||||
err := c.sendRequestWithResult(http.MethodPost, "/record", req, &resp)
|
err := c.sendRequestWithResult(http.MethodPost, "/record", req, resp)
|
||||||
if err != nil {
|
return resp, err
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &resp, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) UpdateRecord(req *UpdateRecordRequest) (*UpdateRecordResponse, error) {
|
func (c *Client) UpdateRecord(req *UpdateRecordRequest) (*UpdateRecordResponse, error) {
|
||||||
resp := UpdateRecordResponse{}
|
resp := &UpdateRecordResponse{}
|
||||||
err := c.sendRequestWithResult(http.MethodPut, "/record", req, &resp)
|
err := c.sendRequestWithResult(http.MethodPut, "/record", req, resp)
|
||||||
if err != nil {
|
return resp, err
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &resp, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) DeleteRecord(req *DeleteRecordRequest) (*DeleteRecordResponse, error) {
|
func (c *Client) DeleteRecord(req *DeleteRecordRequest) (*DeleteRecordResponse, error) {
|
||||||
resp := DeleteRecordResponse{}
|
resp := &DeleteRecordResponse{}
|
||||||
err := c.sendRequestWithResult(http.MethodDelete, fmt.Sprintf("/record?id=%s", url.QueryEscape(req.Id)), req, &resp)
|
err := c.sendRequestWithResult(http.MethodDelete, fmt.Sprintf("/record?id=%s", url.QueryEscape(req.Id)), req, resp)
|
||||||
if err != nil {
|
return resp, err
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &resp, nil
|
|
||||||
}
|
}
|
||||||
|
4
internal/pkg/vendors/dnsla-sdk/client.go
vendored
4
internal/pkg/vendors/dnsla-sdk/client.go
vendored
@ -58,9 +58,9 @@ func (c *Client) sendRequest(method string, path string, params interface{}) (*r
|
|||||||
|
|
||||||
resp, err := req.Send()
|
resp, err := req.Send()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("dnsla api error: failed to send request: %w", err)
|
return resp, fmt.Errorf("dnsla api error: failed to send request: %w", err)
|
||||||
} else if resp.IsError() {
|
} else if resp.IsError() {
|
||||||
return nil, fmt.Errorf("dnsla api error: unexpected status code: %d, %s", resp.StatusCode(), resp.Body())
|
return resp, fmt.Errorf("dnsla api error: unexpected status code: %d, %s", resp.StatusCode(), resp.Body())
|
||||||
}
|
}
|
||||||
|
|
||||||
return resp, nil
|
return resp, nil
|
||||||
|
14
internal/pkg/vendors/dnsla-sdk/models.go
vendored
14
internal/pkg/vendors/dnsla-sdk/models.go
vendored
@ -6,16 +6,22 @@ type BaseResponse interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type baseResponse struct {
|
type baseResponse struct {
|
||||||
Code int `json:"code"`
|
Code *int `json:"code,omitempty"`
|
||||||
Message string `json:"message"`
|
Message *string `json:"message,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *baseResponse) GetCode() int {
|
func (r *baseResponse) GetCode() int {
|
||||||
return r.Code
|
if r.Code != nil {
|
||||||
|
return *r.Code
|
||||||
|
}
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *baseResponse) GetMessage() string {
|
func (r *baseResponse) GetMessage() string {
|
||||||
return r.Message
|
if r.Message != nil {
|
||||||
|
return *r.Message
|
||||||
|
}
|
||||||
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
type DomainInfo struct {
|
type DomainInfo struct {
|
||||||
|
36
internal/pkg/vendors/gname-sdk/api.go
vendored
36
internal/pkg/vendors/gname-sdk/api.go
vendored
@ -1,37 +1,25 @@
|
|||||||
package gnamesdk
|
package gnamesdk
|
||||||
|
|
||||||
func (c *Client) AddDomainResolution(req *AddDomainResolutionRequest) (*AddDomainResolutionResponse, error) {
|
func (c *Client) AddDomainResolution(req *AddDomainResolutionRequest) (*AddDomainResolutionResponse, error) {
|
||||||
result := AddDomainResolutionResponse{}
|
resp := &AddDomainResolutionResponse{}
|
||||||
err := c.sendRequestWithResult("/api/resolution/add", req, &result)
|
err := c.sendRequestWithResult("/api/resolution/add", req, resp)
|
||||||
if err != nil {
|
return resp, err
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &result, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) ModifyDomainResolution(req *ModifyDomainResolutionRequest) (*ModifyDomainResolutionResponse, error) {
|
func (c *Client) ModifyDomainResolution(req *ModifyDomainResolutionRequest) (*ModifyDomainResolutionResponse, error) {
|
||||||
resp := ModifyDomainResolutionResponse{}
|
resp := &ModifyDomainResolutionResponse{}
|
||||||
err := c.sendRequestWithResult("/api/resolution/edit", req, &resp)
|
err := c.sendRequestWithResult("/api/resolution/edit", req, resp)
|
||||||
if err != nil {
|
return resp, err
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &resp, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) DeleteDomainResolution(req *DeleteDomainResolutionRequest) (*DeleteDomainResolutionResponse, error) {
|
func (c *Client) DeleteDomainResolution(req *DeleteDomainResolutionRequest) (*DeleteDomainResolutionResponse, error) {
|
||||||
resp := DeleteDomainResolutionResponse{}
|
resp := &DeleteDomainResolutionResponse{}
|
||||||
err := c.sendRequestWithResult("/api/resolution/delete", req, &resp)
|
err := c.sendRequestWithResult("/api/resolution/delete", req, resp)
|
||||||
if err != nil {
|
return resp, err
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &resp, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) ListDomainResolution(req *ListDomainResolutionRequest) (*ListDomainResolutionResponse, error) {
|
func (c *Client) ListDomainResolution(req *ListDomainResolutionRequest) (*ListDomainResolutionResponse, error) {
|
||||||
resp := ListDomainResolutionResponse{}
|
resp := &ListDomainResolutionResponse{}
|
||||||
err := c.sendRequestWithResult("/api/resolution/list", req, &resp)
|
err := c.sendRequestWithResult("/api/resolution/list", req, resp)
|
||||||
if err != nil {
|
return resp, err
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &resp, nil
|
|
||||||
}
|
}
|
||||||
|
4
internal/pkg/vendors/gname-sdk/client.go
vendored
4
internal/pkg/vendors/gname-sdk/client.go
vendored
@ -80,9 +80,9 @@ func (c *Client) sendRequest(path string, params interface{}) (*resty.Response,
|
|||||||
SetFormData(data)
|
SetFormData(data)
|
||||||
resp, err := req.Post(url)
|
resp, err := req.Post(url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("gname api error: failed to send request: %w", err)
|
return resp, fmt.Errorf("gname api error: failed to send request: %w", err)
|
||||||
} else if resp.IsError() {
|
} else if resp.IsError() {
|
||||||
return nil, fmt.Errorf("gname api error: unexpected status code: %d, %s", resp.StatusCode(), resp.Body())
|
return resp, fmt.Errorf("gname api error: unexpected status code: %d, %s", resp.StatusCode(), resp.Body())
|
||||||
}
|
}
|
||||||
|
|
||||||
return resp, nil
|
return resp, nil
|
||||||
|
9
internal/pkg/vendors/safeline-sdk/api.go
vendored
9
internal/pkg/vendors/safeline-sdk/api.go
vendored
@ -1,10 +1,7 @@
|
|||||||
package safelinesdk
|
package safelinesdk
|
||||||
|
|
||||||
func (c *Client) UpdateCertificate(req *UpdateCertificateRequest) (*UpdateCertificateResponse, error) {
|
func (c *Client) UpdateCertificate(req *UpdateCertificateRequest) (*UpdateCertificateResponse, error) {
|
||||||
resp := UpdateCertificateResponse{}
|
resp := &UpdateCertificateResponse{}
|
||||||
err := c.sendRequestWithResult("/api/open/cert", req, &resp)
|
err := c.sendRequestWithResult("/api/open/cert", req, resp)
|
||||||
if err != nil {
|
return resp, err
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &resp, nil
|
|
||||||
}
|
}
|
||||||
|
4
internal/pkg/vendors/safeline-sdk/client.go
vendored
4
internal/pkg/vendors/safeline-sdk/client.go
vendored
@ -45,9 +45,9 @@ func (c *Client) sendRequest(path string, params interface{}) (*resty.Response,
|
|||||||
SetBody(params)
|
SetBody(params)
|
||||||
resp, err := req.Post(url)
|
resp, err := req.Post(url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("safeline api error: failed to send request: %w", err)
|
return resp, fmt.Errorf("safeline api error: failed to send request: %w", err)
|
||||||
} else if resp.IsError() {
|
} else if resp.IsError() {
|
||||||
return nil, fmt.Errorf("safeline api error: unexpected status code: %d, %s", resp.StatusCode(), resp.Body())
|
return resp, fmt.Errorf("safeline api error: unexpected status code: %d, %s", resp.StatusCode(), resp.Body())
|
||||||
}
|
}
|
||||||
|
|
||||||
return resp, nil
|
return resp, nil
|
||||||
|
49
internal/pkg/vendors/upyun-sdk/console/api.go
vendored
49
internal/pkg/vendors/upyun-sdk/console/api.go
vendored
@ -33,12 +33,9 @@ func (c *Client) UploadHttpsCertificate(req *UploadHttpsCertificateRequest) (*Up
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
resp := UploadHttpsCertificateResponse{}
|
resp := &UploadHttpsCertificateResponse{}
|
||||||
err := c.sendRequestWithResult(http.MethodPost, "/api/https/certificate/", req, &resp)
|
err := c.sendRequestWithResult(http.MethodPost, "/api/https/certificate/", req, resp)
|
||||||
if err != nil {
|
return resp, err
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &resp, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) GetHttpsCertificateManager(certificateId string) (*GetHttpsCertificateManagerResponse, error) {
|
func (c *Client) GetHttpsCertificateManager(certificateId string) (*GetHttpsCertificateManagerResponse, error) {
|
||||||
@ -48,13 +45,10 @@ func (c *Client) GetHttpsCertificateManager(certificateId string) (*GetHttpsCert
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
req := GetHttpsCertificateManagerRequest{CertificateId: certificateId}
|
req := &GetHttpsCertificateManagerRequest{CertificateId: certificateId}
|
||||||
resp := GetHttpsCertificateManagerResponse{}
|
resp := &GetHttpsCertificateManagerResponse{}
|
||||||
err := c.sendRequestWithResult(http.MethodGet, "/api/https/certificate/manager/", &req, &resp)
|
err := c.sendRequestWithResult(http.MethodGet, "/api/https/certificate/manager/", req, resp)
|
||||||
if err != nil {
|
return resp, err
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &resp, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) UpdateHttpsCertificateManager(req *UpdateHttpsCertificateManagerRequest) (*UpdateHttpsCertificateManagerResponse, error) {
|
func (c *Client) UpdateHttpsCertificateManager(req *UpdateHttpsCertificateManagerRequest) (*UpdateHttpsCertificateManagerResponse, error) {
|
||||||
@ -64,12 +58,9 @@ func (c *Client) UpdateHttpsCertificateManager(req *UpdateHttpsCertificateManage
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
resp := UpdateHttpsCertificateManagerResponse{}
|
resp := &UpdateHttpsCertificateManagerResponse{}
|
||||||
err := c.sendRequestWithResult(http.MethodPost, "/api/https/certificate/manager", req, &resp)
|
err := c.sendRequestWithResult(http.MethodPost, "/api/https/certificate/manager", req, resp)
|
||||||
if err != nil {
|
return resp, err
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &resp, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) GetHttpsServiceManager(domain string) (*GetHttpsServiceManagerResponse, error) {
|
func (c *Client) GetHttpsServiceManager(domain string) (*GetHttpsServiceManagerResponse, error) {
|
||||||
@ -79,13 +70,10 @@ func (c *Client) GetHttpsServiceManager(domain string) (*GetHttpsServiceManagerR
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
req := GetHttpsServiceManagerRequest{Domain: domain}
|
req := &GetHttpsServiceManagerRequest{Domain: domain}
|
||||||
resp := GetHttpsServiceManagerResponse{}
|
resp := &GetHttpsServiceManagerResponse{}
|
||||||
err := c.sendRequestWithResult(http.MethodGet, "/api/https/services/manager", &req, &resp)
|
err := c.sendRequestWithResult(http.MethodGet, "/api/https/services/manager", req, resp)
|
||||||
if err != nil {
|
return resp, err
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &resp, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) MigrateHttpsDomain(req *MigrateHttpsDomainRequest) (*MigrateHttpsDomainResponse, error) {
|
func (c *Client) MigrateHttpsDomain(req *MigrateHttpsDomainRequest) (*MigrateHttpsDomainResponse, error) {
|
||||||
@ -95,10 +83,7 @@ func (c *Client) MigrateHttpsDomain(req *MigrateHttpsDomainRequest) (*MigrateHtt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
resp := MigrateHttpsDomainResponse{}
|
resp := &MigrateHttpsDomainResponse{}
|
||||||
err := c.sendRequestWithResult(http.MethodPost, "/api/https/migrate/domain", req, &resp)
|
err := c.sendRequestWithResult(http.MethodPost, "/api/https/migrate/domain", req, resp)
|
||||||
if err != nil {
|
return resp, err
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &resp, nil
|
|
||||||
}
|
}
|
||||||
|
@ -60,12 +60,11 @@ func (c *Client) sendRequest(method string, path string, params interface{}) (*r
|
|||||||
SetBody(params)
|
SetBody(params)
|
||||||
}
|
}
|
||||||
|
|
||||||
req = req.SetDebug(true)
|
|
||||||
resp, err := req.Send()
|
resp, err := req.Send()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("upyun api error: failed to send request: %w", err)
|
return resp, fmt.Errorf("upyun api error: failed to send request: %w", err)
|
||||||
} else if resp.IsError() {
|
} else if resp.IsError() {
|
||||||
return nil, fmt.Errorf("upyun api error: unexpected status code: %d, %s", resp.StatusCode(), resp.Body())
|
return resp, fmt.Errorf("upyun api error: unexpected status code: %d, %s", resp.StatusCode(), resp.Body())
|
||||||
}
|
}
|
||||||
|
|
||||||
return resp, nil
|
return resp, nil
|
||||||
|
14
internal/pkg/vendors/upyun-sdk/console/models.go
vendored
14
internal/pkg/vendors/upyun-sdk/console/models.go
vendored
@ -41,10 +41,10 @@ type signinRequest struct {
|
|||||||
|
|
||||||
type signinResponse struct {
|
type signinResponse struct {
|
||||||
baseResponse
|
baseResponse
|
||||||
Data struct {
|
Data *struct {
|
||||||
baseResponseData
|
baseResponseData
|
||||||
Result bool `json:"result"`
|
Result bool `json:"result"`
|
||||||
} `json:"data"`
|
} `json:"data,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type UploadHttpsCertificateRequest struct {
|
type UploadHttpsCertificateRequest struct {
|
||||||
@ -62,7 +62,7 @@ type UploadHttpsCertificateResponse struct {
|
|||||||
CommonName string `json:"commonName"`
|
CommonName string `json:"commonName"`
|
||||||
Serial string `json:"serial"`
|
Serial string `json:"serial"`
|
||||||
} `json:"result"`
|
} `json:"result"`
|
||||||
} `json:"data"`
|
} `json:"data,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetHttpsCertificateManagerRequest struct {
|
type GetHttpsCertificateManagerRequest struct {
|
||||||
@ -76,7 +76,7 @@ type GetHttpsCertificateManagerResponse struct {
|
|||||||
AuthenticateNum int32 `json:"authenticate_num"`
|
AuthenticateNum int32 `json:"authenticate_num"`
|
||||||
AuthenticateDomains []string `json:"authenticate_domain"`
|
AuthenticateDomains []string `json:"authenticate_domain"`
|
||||||
Domains []HttpsCertificateManagerDomain `json:"domains"`
|
Domains []HttpsCertificateManagerDomain `json:"domains"`
|
||||||
} `json:"data"`
|
} `json:"data,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type HttpsCertificateManagerDomain struct {
|
type HttpsCertificateManagerDomain struct {
|
||||||
@ -98,7 +98,7 @@ type UpdateHttpsCertificateManagerResponse struct {
|
|||||||
Data *struct {
|
Data *struct {
|
||||||
baseResponseData
|
baseResponseData
|
||||||
Status bool `json:"status"`
|
Status bool `json:"status"`
|
||||||
} `json:"data"`
|
} `json:"data,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetHttpsServiceManagerRequest struct {
|
type GetHttpsServiceManagerRequest struct {
|
||||||
@ -111,7 +111,7 @@ type GetHttpsServiceManagerResponse struct {
|
|||||||
baseResponseData
|
baseResponseData
|
||||||
Status int `json:"status"`
|
Status int `json:"status"`
|
||||||
Domains []HttpsServiceManagerDomain `json:"result"`
|
Domains []HttpsServiceManagerDomain `json:"result"`
|
||||||
} `json:"data"`
|
} `json:"data,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type HttpsServiceManagerDomain struct {
|
type HttpsServiceManagerDomain struct {
|
||||||
@ -137,5 +137,5 @@ type MigrateHttpsDomainResponse struct {
|
|||||||
Data *struct {
|
Data *struct {
|
||||||
baseResponseData
|
baseResponseData
|
||||||
Status bool `json:"status"`
|
Status bool `json:"status"`
|
||||||
} `json:"data"`
|
} `json:"data,omitempty"`
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user