mirror of
https://github.com/certimate-go/certimate.git
synced 2026-09-24 23:10:13 +08:00
refactor: clean code
This commit is contained in:
@@ -45,7 +45,7 @@ func (c *Client) WebsiteGet(websiteId int64) (*WebsiteGetResponse, error) {
|
||||
|
||||
func (c *Client) WebsiteGetWithContext(ctx context.Context, websiteId int64) (*WebsiteGetResponse, error) {
|
||||
if websiteId == 0 {
|
||||
return nil, fmt.Errorf("sdkerr: unset websiteId")
|
||||
return nil, fmt.Errorf("sdkerr: bad request: unset websiteId")
|
||||
}
|
||||
|
||||
httpreq, err := c.newRequest(http.MethodGet, fmt.Sprintf("/websites/%d", websiteId))
|
||||
|
||||
@@ -25,7 +25,7 @@ func (c *Client) WebsiteHttpsGet(websiteId int64) (*WebsiteHttpsGetResponse, err
|
||||
|
||||
func (c *Client) WebsiteHttpsGetWithContext(ctx context.Context, websiteId int64) (*WebsiteHttpsGetResponse, error) {
|
||||
if websiteId == 0 {
|
||||
return nil, fmt.Errorf("sdkerr: unset websiteId")
|
||||
return nil, fmt.Errorf("sdkerr: bad request: unset websiteId")
|
||||
}
|
||||
|
||||
httpreq, err := c.newRequest(http.MethodGet, fmt.Sprintf("/websites/%d/https", websiteId))
|
||||
|
||||
@@ -27,7 +27,7 @@ func (c *Client) WebsiteHttpsPost(websiteId int64, req *WebsiteHttpsPostRequest)
|
||||
|
||||
func (c *Client) WebsiteHttpsPostWithContext(ctx context.Context, websiteId int64, req *WebsiteHttpsPostRequest) (*WebsiteHttpsPostResponse, error) {
|
||||
if websiteId == 0 {
|
||||
return nil, fmt.Errorf("sdkerr: unset websiteId")
|
||||
return nil, fmt.Errorf("sdkerr: bad request: unset websiteId")
|
||||
}
|
||||
|
||||
httpreq, err := c.newRequest(http.MethodPost, fmt.Sprintf("/websites/%d/https", websiteId))
|
||||
|
||||
@@ -31,7 +31,7 @@ func (c *Client) WebsiteSSLGet(sslId int64) (*WebsiteSSLGetResponse, error) {
|
||||
|
||||
func (c *Client) WebsiteSSLGetWithContext(ctx context.Context, sslId int64) (*WebsiteSSLGetResponse, error) {
|
||||
if sslId == 0 {
|
||||
return nil, fmt.Errorf("sdkerr: unset sslId")
|
||||
return nil, fmt.Errorf("sdkerr: bad request: unset sslId")
|
||||
}
|
||||
|
||||
httpreq, err := c.newRequest(http.MethodGet, fmt.Sprintf("/websites/ssl/%d", sslId))
|
||||
|
||||
@@ -45,7 +45,7 @@ func (c *Client) WebsiteGet(websiteId int64) (*WebsiteGetResponse, error) {
|
||||
|
||||
func (c *Client) WebsiteGetWithContext(ctx context.Context, websiteId int64) (*WebsiteGetResponse, error) {
|
||||
if websiteId == 0 {
|
||||
return nil, fmt.Errorf("sdkerr: unset websiteId")
|
||||
return nil, fmt.Errorf("sdkerr: bad request: unset websiteId")
|
||||
}
|
||||
|
||||
httpreq, err := c.newRequest(http.MethodGet, fmt.Sprintf("/websites/%d", websiteId))
|
||||
|
||||
@@ -26,7 +26,7 @@ func (c *Client) WebsiteHttpsGet(websiteId int64) (*WebsiteHttpsGetResponse, err
|
||||
|
||||
func (c *Client) WebsiteHttpsGetWithContext(ctx context.Context, websiteId int64) (*WebsiteHttpsGetResponse, error) {
|
||||
if websiteId == 0 {
|
||||
return nil, fmt.Errorf("sdkerr: unset websiteId")
|
||||
return nil, fmt.Errorf("sdkerr: bad request: unset websiteId")
|
||||
}
|
||||
|
||||
httpreq, err := c.newRequest(http.MethodGet, fmt.Sprintf("/websites/%d/https", websiteId))
|
||||
|
||||
@@ -28,7 +28,7 @@ func (c *Client) WebsiteHttpsPost(websiteId int64, req *WebsiteHttpsPostRequest)
|
||||
|
||||
func (c *Client) WebsiteHttpsPostWithContext(ctx context.Context, websiteId int64, req *WebsiteHttpsPostRequest) (*WebsiteHttpsPostResponse, error) {
|
||||
if websiteId == 0 {
|
||||
return nil, fmt.Errorf("sdkerr: unset websiteId")
|
||||
return nil, fmt.Errorf("sdkerr: bad request: unset websiteId")
|
||||
}
|
||||
|
||||
httpreq, err := c.newRequest(http.MethodPost, fmt.Sprintf("/websites/%d/https", websiteId))
|
||||
|
||||
@@ -31,7 +31,7 @@ func (c *Client) WebsiteSSLGet(sslId int64) (*WebsiteSSLGetResponse, error) {
|
||||
|
||||
func (c *Client) WebsiteSSLGetWithContext(ctx context.Context, sslId int64) (*WebsiteSSLGetResponse, error) {
|
||||
if sslId == 0 {
|
||||
return nil, fmt.Errorf("sdkerr: unset sslId")
|
||||
return nil, fmt.Errorf("sdkerr: bad request: unset sslId")
|
||||
}
|
||||
|
||||
httpreq, err := c.newRequest(http.MethodGet, fmt.Sprintf("/websites/ssl/%d", sslId))
|
||||
|
||||
@@ -17,7 +17,7 @@ func (c *Client) UpdateSSL(sslId string, req *UpdateSSLRequest) (*UpdateSSLRespo
|
||||
|
||||
func (c *Client) UpdateSSLWithContext(ctx context.Context, sslId string, req *UpdateSSLRequest) (*UpdateSSLResponse, error) {
|
||||
if sslId == "" {
|
||||
return nil, fmt.Errorf("sdkerr: unset sslId")
|
||||
return nil, fmt.Errorf("sdkerr: bad request: unset sslId")
|
||||
}
|
||||
|
||||
httpreq, err := c.newRequest(http.MethodPut, fmt.Sprintf("/ssls/%s", url.PathEscape(sslId)))
|
||||
|
||||
@@ -19,7 +19,7 @@ func (c *Client) AddCustomCertificate(pullZoneId string, req *AddCustomCertifica
|
||||
|
||||
func (c *Client) AddCustomCertificateWithContext(ctx context.Context, pullZoneId string, req *AddCustomCertificateRequest) error {
|
||||
if pullZoneId == "" {
|
||||
return fmt.Errorf("sdkerr: unset pullZoneId")
|
||||
return fmt.Errorf("sdkerr: bad request: unset pullZoneId")
|
||||
}
|
||||
|
||||
httpreq, err := c.newRequest(http.MethodPost, fmt.Sprintf("/pullzone/%s/addCertificate", url.PathEscape(pullZoneId)))
|
||||
|
||||
@@ -24,7 +24,7 @@ func (c *Client) GetSite(siteId string) (*GetSiteResponse, error) {
|
||||
|
||||
func (c *Client) GetSiteWithContext(ctx context.Context, siteId string) (*GetSiteResponse, error) {
|
||||
if siteId == "" {
|
||||
return nil, fmt.Errorf("sdkerr: unset siteId")
|
||||
return nil, fmt.Errorf("sdkerr: bad request: unset siteId")
|
||||
}
|
||||
|
||||
httpreq, err := c.newRequest(http.MethodGet, fmt.Sprintf("/sites/%s", url.PathEscape(siteId)))
|
||||
|
||||
@@ -26,7 +26,7 @@ func (c *Client) UpdateCert(certId string, req *UpdateCertRequest) (*UpdateCertR
|
||||
|
||||
func (c *Client) UpdateCertWithContext(ctx context.Context, certId string, req *UpdateCertRequest) (*UpdateCertResponse, error) {
|
||||
if certId == "" {
|
||||
return nil, fmt.Errorf("sdkerr: unset certId")
|
||||
return nil, fmt.Errorf("sdkerr: bad request: unset certId")
|
||||
}
|
||||
|
||||
httpreq, err := c.newRequest(http.MethodPut, fmt.Sprintf("/certs/%s", url.PathEscape(certId)))
|
||||
|
||||
@@ -22,7 +22,7 @@ func (c *Client) UpdateSite(siteId string, req *UpdateSiteRequest) (*UpdateSiteR
|
||||
|
||||
func (c *Client) UpdateSiteWithContext(ctx context.Context, siteId string, req *UpdateSiteRequest) (*UpdateSiteResponse, error) {
|
||||
if siteId == "" {
|
||||
return nil, fmt.Errorf("sdkerr: unset siteId")
|
||||
return nil, fmt.Errorf("sdkerr: bad request: unset siteId")
|
||||
}
|
||||
|
||||
httpreq, err := c.newRequest(http.MethodPut, fmt.Sprintf("/sites/%s", url.PathEscape(siteId)))
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package cloudflare
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
@@ -40,11 +39,6 @@ func (c *Client) SetTimeout(timeout time.Duration) *Client {
|
||||
return c
|
||||
}
|
||||
|
||||
func (c *Client) SetTLSConfig(config *tls.Config) *Client {
|
||||
c.rc.SetTLSClientConfig(config)
|
||||
return c
|
||||
}
|
||||
|
||||
func (c *Client) newRequest(method string, path string) (*resty.Request, error) {
|
||||
if method == "" {
|
||||
return nil, fmt.Errorf("sdkerr: unset method")
|
||||
@@ -94,8 +88,8 @@ func (c *Client) doRequestWithResult(req *resty.Request, res sdkResponse) (*rest
|
||||
if err := json.Unmarshal(resp.Body(), &res); err != nil {
|
||||
return resp, fmt.Errorf("sdkerr: failed to unmarshal response: %w (resp: %s)", err, resp.String())
|
||||
} else {
|
||||
if rErrors := res.GetErrors(); rErrors != nil {
|
||||
return resp, fmt.Errorf("sdkerr: errors='%s'", rErrors.Error())
|
||||
if err := res.GetAPIError(); err != nil {
|
||||
return resp, fmt.Errorf("sdkerr: errors='%s'", err.Error())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
)
|
||||
|
||||
type sdkResponse interface {
|
||||
GetErrors() error
|
||||
GetAPIError() error
|
||||
GetSuccess() bool
|
||||
}
|
||||
|
||||
@@ -39,17 +39,17 @@ func (e sdkAPIErrors) Error() string {
|
||||
builder := &strings.Builder{}
|
||||
|
||||
for _, item := range e {
|
||||
fmt.Fprintf(builder, "%d: %s", item.Code, item.Message)
|
||||
fmt.Fprintf(builder, "[%d] %s", item.Code, item.Message)
|
||||
|
||||
for _, link := range item.ErrorChain {
|
||||
fmt.Fprintf(builder, "; %d: %s", link.Code, link.Message)
|
||||
fmt.Fprintf(builder, "; [%d] %s", link.Code, link.Message)
|
||||
}
|
||||
}
|
||||
|
||||
return builder.String()
|
||||
return strings.TrimSpace(builder.String())
|
||||
}
|
||||
|
||||
func (r *sdkResponseBase) GetErrors() error {
|
||||
func (r *sdkResponseBase) GetAPIError() error {
|
||||
if len(r.Errors) > 0 {
|
||||
return r.Errors
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ func (c *Client) DnsCreateRecord(domainId string, req *DnsCreateRecordRequest) (
|
||||
|
||||
func (c *Client) DnsCreateRecordWithContext(ctx context.Context, domainId string, req *DnsCreateRecordRequest) (*DnsCreateRecordResponse, error) {
|
||||
if domainId == "" {
|
||||
return nil, fmt.Errorf("sdkerr: unset domainId")
|
||||
return nil, fmt.Errorf("sdkerr: bad request: unset domainId")
|
||||
}
|
||||
|
||||
if err := c.ensureAccessTokenExists(); err != nil {
|
||||
|
||||
@@ -17,10 +17,10 @@ func (c *Client) DnsDeleteRecord(domainId string, recordId string) (*DnsDeleteRe
|
||||
|
||||
func (c *Client) DnsDeleteRecordWithContext(ctx context.Context, domainId string, recordId string) (*DnsDeleteRecordResponse, error) {
|
||||
if domainId == "" {
|
||||
return nil, fmt.Errorf("sdkerr: unset domainId")
|
||||
return nil, fmt.Errorf("sdkerr: bad request: unset domainId")
|
||||
}
|
||||
if recordId == "" {
|
||||
return nil, fmt.Errorf("sdkerr: unset recordId")
|
||||
return nil, fmt.Errorf("sdkerr: bad request: unset recordId")
|
||||
}
|
||||
|
||||
if err := c.ensureAccessTokenExists(); err != nil {
|
||||
|
||||
@@ -25,7 +25,7 @@ func (c *Client) AddRecord(zoneID int64, req *AddRecordRequest) (*AddRecordRespo
|
||||
|
||||
func (c *Client) AddRecordWithContext(ctx context.Context, zoneID int64, req *AddRecordRequest) (*AddRecordResponse, error) {
|
||||
if zoneID == 0 {
|
||||
return nil, fmt.Errorf("sdkerr: unset zoneID")
|
||||
return nil, fmt.Errorf("sdkerr: bad request: unset zoneID")
|
||||
}
|
||||
|
||||
httpreq, err := c.newRequest(http.MethodPost, fmt.Sprintf("/zones/%d/records", zoneID))
|
||||
|
||||
@@ -14,10 +14,10 @@ func (c *Client) DeleteRecord(zoneID int64, recordID int64) (*DeleteRecordRespon
|
||||
|
||||
func (c *Client) DeleteRecordWithContext(ctx context.Context, zoneID int64, recordID int64) (*DeleteRecordResponse, error) {
|
||||
if zoneID == 0 {
|
||||
return nil, fmt.Errorf("sdkerr: unset zoneID")
|
||||
return nil, fmt.Errorf("sdkerr: bad request: unset zoneID")
|
||||
}
|
||||
if recordID == 0 {
|
||||
return nil, fmt.Errorf("sdkerr: unset recordID")
|
||||
return nil, fmt.Errorf("sdkerr: bad request: unset recordID")
|
||||
}
|
||||
|
||||
httpreq, err := c.newRequest(http.MethodDelete, fmt.Sprintf("/zones/%d/records/%d", zoneID, recordID))
|
||||
|
||||
@@ -14,7 +14,7 @@ func (c *Client) ListRecords(zoneID int64) (*ListRecordsResponse, error) {
|
||||
|
||||
func (c *Client) ListRecordsWithContext(ctx context.Context, zoneID int64) (*ListRecordsResponse, error) {
|
||||
if zoneID == 0 {
|
||||
return nil, fmt.Errorf("sdkerr: unset zoneID")
|
||||
return nil, fmt.Errorf("sdkerr: bad request: unset zoneID")
|
||||
}
|
||||
|
||||
httpreq, err := c.newRequest(http.MethodGet, fmt.Sprintf("/zones/%d/records", zoneID))
|
||||
|
||||
@@ -35,7 +35,7 @@ func (c *Client) ImportCustomCertificate(req *ImportCustomCertificateRequest) (*
|
||||
|
||||
func (c *Client) ImportCustomCertificateWithContext(ctx context.Context, req *ImportCustomCertificateRequest) (*ImportCustomCertificateResponse, error) {
|
||||
if req.AppName == "" {
|
||||
return nil, fmt.Errorf("sdkerr: unset appName")
|
||||
return nil, fmt.Errorf("sdkerr: bad request: unset appName")
|
||||
}
|
||||
|
||||
path := fmt.Sprintf("/apps/%s/certificates/custom", url.PathEscape(req.AppName))
|
||||
|
||||
@@ -17,7 +17,7 @@ func (c *Client) UpsertCertificate(certificateId string, req *UpsertCertificateR
|
||||
|
||||
func (c *Client) UpsertCertificateWithContext(ctx context.Context, certificateId string, req *UpsertCertificateRequest) (*UpsertCertificateResponse, error) {
|
||||
if certificateId == "" {
|
||||
return nil, fmt.Errorf("sdkerr: unset certificateId")
|
||||
return nil, fmt.Errorf("sdkerr: bad request: unset certificateId")
|
||||
}
|
||||
|
||||
httpreq, err := c.newRequest(http.MethodPut, fmt.Sprintf("/certificates/%s", url.PathEscape(certificateId)))
|
||||
|
||||
@@ -25,7 +25,7 @@ func (c *Client) UpdateCertificate(certId int64, req *UpdateCertificateRequest)
|
||||
|
||||
func (c *Client) UpdateCertificateWithContext(ctx context.Context, certId int64, req *UpdateCertificateRequest) (*UpdateCertificateResponse, error) {
|
||||
if certId == 0 {
|
||||
return nil, fmt.Errorf("sdkerr: unset certId")
|
||||
return nil, fmt.Errorf("sdkerr: bad request: unset certId")
|
||||
}
|
||||
|
||||
if err := c.ensureAccessTokenExists(); err != nil {
|
||||
|
||||
@@ -26,7 +26,7 @@ func (c *Client) UpdateCertificate(certId int64, req *UpdateCertificateRequest)
|
||||
|
||||
func (c *Client) UpdateCertificateWithContext(ctx context.Context, certId int64, req *UpdateCertificateRequest) (*UpdateCertificateResponse, error) {
|
||||
if certId == 0 {
|
||||
return nil, fmt.Errorf("sdkerr: unset certId")
|
||||
return nil, fmt.Errorf("sdkerr: bad request: unset certId")
|
||||
}
|
||||
|
||||
if err := c.ensureAccessTokenExists(); err != nil {
|
||||
|
||||
@@ -28,7 +28,7 @@ func (c *Client) ProvisionSiteTLSCertificate(siteId string, req *ProvisionSiteTL
|
||||
|
||||
func (c *Client) ProvisionSiteTLSCertificateWithContext(ctx context.Context, siteId string, req *ProvisionSiteTLSCertificateRequest) (*ProvisionSiteTLSCertificateResponse, error) {
|
||||
if siteId == "" {
|
||||
return nil, fmt.Errorf("sdkerr: unset siteId")
|
||||
return nil, fmt.Errorf("sdkerr: bad request: unset siteId")
|
||||
}
|
||||
|
||||
httpreq, err := c.newRequest(http.MethodPost, fmt.Sprintf("/sites/%s/ssl", url.PathEscape(siteId)))
|
||||
|
||||
@@ -20,7 +20,7 @@ func (c *Client) NginxUpdateDeadHost(hostId int64, req *NginxUpdateDeadHostReque
|
||||
|
||||
func (c *Client) NginxUpdateDeadHostWithContext(ctx context.Context, hostId int64, req *NginxUpdateDeadHostRequest) (*NginxUpdateDeadHostResponse, error) {
|
||||
if hostId == 0 {
|
||||
return nil, fmt.Errorf("sdkerr: unset hostId")
|
||||
return nil, fmt.Errorf("sdkerr: bad request: unset hostId")
|
||||
}
|
||||
|
||||
if err := c.ensureJwtTokenExists(); err != nil {
|
||||
|
||||
@@ -20,7 +20,7 @@ func (c *Client) NginxUpdateProxyHost(hostId int64, req *NginxUpdateProxyHostReq
|
||||
|
||||
func (c *Client) NginxUpdateProxyHostWithContext(ctx context.Context, hostId int64, req *NginxUpdateProxyHostRequest) (*NginxUpdateProxyHostResponse, error) {
|
||||
if hostId == 0 {
|
||||
return nil, fmt.Errorf("sdkerr: unset hostId")
|
||||
return nil, fmt.Errorf("sdkerr: bad request: unset hostId")
|
||||
}
|
||||
|
||||
if err := c.ensureJwtTokenExists(); err != nil {
|
||||
|
||||
@@ -20,7 +20,7 @@ func (c *Client) NginxUpdateRedirectionHost(hostId int64, req *NginxUpdateRedire
|
||||
|
||||
func (c *Client) NginxUpdateRedirectionHostWithContext(ctx context.Context, hostId int64, req *NginxUpdateRedirectionHostRequest) (*NginxUpdateRedirectionHostResponse, error) {
|
||||
if hostId == 0 {
|
||||
return nil, fmt.Errorf("sdkerr: unset hostId")
|
||||
return nil, fmt.Errorf("sdkerr: bad request: unset hostId")
|
||||
}
|
||||
|
||||
if err := c.ensureJwtTokenExists(); err != nil {
|
||||
|
||||
@@ -20,7 +20,7 @@ func (c *Client) NginxUpdateStream(hostId int64, req *NginxUpdateStreamRequest)
|
||||
|
||||
func (c *Client) NginxUpdateStreamWithContext(ctx context.Context, hostId int64, req *NginxUpdateStreamRequest) (*NginxUpdateStreamResponse, error) {
|
||||
if hostId == 0 {
|
||||
return nil, fmt.Errorf("sdkerr: unset hostId")
|
||||
return nil, fmt.Errorf("sdkerr: bad request: unset hostId")
|
||||
}
|
||||
|
||||
if err := c.ensureJwtTokenExists(); err != nil {
|
||||
|
||||
@@ -21,7 +21,7 @@ func (c *Client) NginxUploadCertificate(certId int64, req *NginxUploadCertificat
|
||||
|
||||
func (c *Client) NginxUploadCertificateWithContext(ctx context.Context, certId int64, req *NginxUploadCertificateRequest) (*NginxUploadCertificateResponse, error) {
|
||||
if certId == 0 {
|
||||
return nil, fmt.Errorf("sdkerr: unset certId")
|
||||
return nil, fmt.Errorf("sdkerr: bad request: unset certId")
|
||||
}
|
||||
|
||||
if err := c.ensureJwtTokenExists(); err != nil {
|
||||
|
||||
@@ -26,7 +26,7 @@ func (c *Client) NodeUploadCustomCertificate(node string, req *NodeUploadCustomC
|
||||
|
||||
func (c *Client) NodeUploadCustomCertificateWithContext(ctx context.Context, node string, req *NodeUploadCustomCertificateRequest) (*NodeUploadCustomCertificateResponse, error) {
|
||||
if node == "" {
|
||||
return nil, fmt.Errorf("sdkerr: unset node")
|
||||
return nil, fmt.Errorf("sdkerr: bad request: unset node")
|
||||
}
|
||||
|
||||
path := fmt.Sprintf("/nodes/%s/certificates/custom", node)
|
||||
|
||||
@@ -16,7 +16,7 @@ func (c *Client) DeleteRecord(recordIds []*int64) (*DeleteRecordResponse, error)
|
||||
|
||||
func (c *Client) DeleteRecordWithContext(ctx context.Context, recordIds []*int64) (*DeleteRecordResponse, error) {
|
||||
if len(recordIds) == 0 {
|
||||
return nil, fmt.Errorf("sdkerr: unset recordIds")
|
||||
return nil, fmt.Errorf("sdkerr: bad request: unset recordIds")
|
||||
}
|
||||
|
||||
httpreq, err := c.newRequest(http.MethodPost, "/v1/change_record_status/")
|
||||
|
||||
@@ -21,7 +21,7 @@ func (c *Client) RcdnInstanceSslBind(instanceId int64, req *RcdnInstanceSslBindR
|
||||
|
||||
func (c *Client) RcdnInstanceSslBindWithContext(ctx context.Context, instanceId int64, req *RcdnInstanceSslBindRequest) (*RcdnInstanceSslBindResponse, error) {
|
||||
if instanceId == 0 {
|
||||
return nil, fmt.Errorf("sdkerr: unset instanceId")
|
||||
return nil, fmt.Errorf("sdkerr: bad request: unset instanceId")
|
||||
}
|
||||
|
||||
httpreq, err := c.newRequest(http.MethodPost, fmt.Sprintf("/product/rcdn/instance/%d/ssl_bind", instanceId))
|
||||
|
||||
@@ -18,7 +18,7 @@ func (c *Client) SslCenterGet(sslId int64) (*SslCenterGetResponse, error) {
|
||||
|
||||
func (c *Client) SslCenterGetWithContext(ctx context.Context, sslId int64) (*SslCenterGetResponse, error) {
|
||||
if sslId == 0 {
|
||||
return nil, fmt.Errorf("sdkerr: unset sslId")
|
||||
return nil, fmt.Errorf("sdkerr: bad request: unset sslId")
|
||||
}
|
||||
|
||||
httpreq, err := c.newRequest(http.MethodGet, fmt.Sprintf("/product/sslcenter/%d", sslId))
|
||||
|
||||
@@ -21,7 +21,7 @@ func (c *Client) SslCenterUpdate(certId int64, req *SslCenterUpdateRequest) (*Ss
|
||||
|
||||
func (c *Client) SslCenterUpdateWithContext(ctx context.Context, certId int64, req *SslCenterUpdateRequest) (*SslCenterUpdateResponse, error) {
|
||||
if certId == 0 {
|
||||
return nil, fmt.Errorf("sdkerr: unset certId")
|
||||
return nil, fmt.Errorf("sdkerr: bad request: unset certId")
|
||||
}
|
||||
|
||||
httpreq, err := c.newRequest(http.MethodPut, fmt.Sprintf("/product/sslcenter/%d", certId))
|
||||
|
||||
@@ -17,7 +17,7 @@ func (c *Client) SslConfigDetail(sslId string) (*SslConfigDetailResponse, error)
|
||||
|
||||
func (c *Client) SslConfigDetailWithContext(ctx context.Context, sslId string) (*SslConfigDetailResponse, error) {
|
||||
if sslId == "" {
|
||||
return nil, fmt.Errorf("sdkerr: unset sslId")
|
||||
return nil, fmt.Errorf("sdkerr: bad request: unset sslId")
|
||||
}
|
||||
|
||||
httpreq, err := c.newRequest(http.MethodGet, "/sslconfig/detail")
|
||||
|
||||
@@ -31,7 +31,7 @@ func (c *Client) GetHttpsCertificateManager(certificateId string) (*GetHttpsCert
|
||||
|
||||
func (c *Client) GetHttpsCertificateManagerWithContext(ctx context.Context, certificateId string) (*GetHttpsCertificateManagerResponse, error) {
|
||||
if certificateId == "" {
|
||||
return nil, fmt.Errorf("sdkerr: unset certificateId")
|
||||
return nil, fmt.Errorf("sdkerr: bad request: unset certificateId")
|
||||
}
|
||||
|
||||
if err := c.ensureCookieExists(); err != nil {
|
||||
|
||||
@@ -36,7 +36,7 @@ func (c *Client) GetHttpsServiceManager(domain string) (*GetHttpsServiceManagerR
|
||||
|
||||
func (c *Client) GetHttpsServiceManagerWithContext(ctx context.Context, domain string) (*GetHttpsServiceManagerResponse, error) {
|
||||
if domain == "" {
|
||||
return nil, fmt.Errorf("sdkerr: unset domain")
|
||||
return nil, fmt.Errorf("sdkerr: bad request: unset domain")
|
||||
}
|
||||
|
||||
if err := c.ensureCookieExists(); err != nil {
|
||||
|
||||
@@ -26,7 +26,7 @@ func (c *Client) GetDeploymentTaskDetail(deploymentTaskId string) (*GetDeploymen
|
||||
|
||||
func (c *Client) GetDeploymentTaskDetailWithContext(ctx context.Context, deploymentTaskId string) (*GetDeploymentTaskDetailResponse, error) {
|
||||
if deploymentTaskId == "" {
|
||||
return nil, fmt.Errorf("sdkerr: unset deploymentTaskId")
|
||||
return nil, fmt.Errorf("sdkerr: bad request: unset deploymentTaskId")
|
||||
}
|
||||
|
||||
httpreq, err := c.newRequest(http.MethodGet, fmt.Sprintf("/cdn/deploymentTasks/%s", url.PathEscape(deploymentTaskId)))
|
||||
|
||||
@@ -21,7 +21,7 @@ func (c *Client) GetHostnameDetail(hostname string) (*GetHostnameDetailResponse,
|
||||
|
||||
func (c *Client) GetHostnameDetailWithContext(ctx context.Context, hostname string) (*GetHostnameDetailResponse, error) {
|
||||
if hostname == "" {
|
||||
return nil, fmt.Errorf("sdkerr: unset hostname")
|
||||
return nil, fmt.Errorf("sdkerr: bad request: unset hostname")
|
||||
}
|
||||
|
||||
httpreq, err := c.newRequest(http.MethodGet, fmt.Sprintf("/cdn/hostnames/%s", url.PathEscape(hostname)))
|
||||
|
||||
@@ -28,7 +28,7 @@ func (c *Client) UpdateCertificate(certificateId string, req *UpdateCertificateR
|
||||
|
||||
func (c *Client) UpdateCertificateWithContext(ctx context.Context, certificateId string, req *UpdateCertificateRequest) (*UpdateCertificateResponse, error) {
|
||||
if certificateId == "" {
|
||||
return nil, fmt.Errorf("sdkerr: unset certificateId")
|
||||
return nil, fmt.Errorf("sdkerr: bad request: unset certificateId")
|
||||
}
|
||||
|
||||
httpreq, err := c.newRequest(http.MethodPatch, fmt.Sprintf("/cdn/certificates/%s", url.PathEscape(certificateId)))
|
||||
|
||||
@@ -24,7 +24,7 @@ func (c *Client) UpdateCertificate(certificateId string, req *UpdateCertificateR
|
||||
|
||||
func (c *Client) UpdateCertificateWithContext(ctx context.Context, certificateId string, req *UpdateCertificateRequest) (*UpdateCertificateResponse, error) {
|
||||
if certificateId == "" {
|
||||
return nil, fmt.Errorf("sdkerr: unset certificateId")
|
||||
return nil, fmt.Errorf("sdkerr: bad request: unset certificateId")
|
||||
}
|
||||
|
||||
httpreq, err := c.newRequest(http.MethodPut, fmt.Sprintf("/api/certificate/%s", url.PathEscape(certificateId)))
|
||||
|
||||
Reference in New Issue
Block a user