refactor: re-impl sdk3rd
This commit is contained in:
41
internal/pkg/sdk3rd/dogecloud/api_upload_cdn_cert.go
Normal file
41
internal/pkg/sdk3rd/dogecloud/api_upload_cdn_cert.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package dogecloud
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type UploadCdnCertRequest struct {
|
||||
Note string `json:"note"`
|
||||
Certificate string `json:"cert"`
|
||||
PrivateKey string `json:"private"`
|
||||
}
|
||||
|
||||
type UploadCdnCertResponse struct {
|
||||
apiResponseBase
|
||||
|
||||
Data *struct {
|
||||
Id int64 `json:"id"`
|
||||
} `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
func (c *Client) UploadCdnCert(req *UploadCdnCertRequest) (*UploadCdnCertResponse, error) {
|
||||
return c.UploadCdnCertWithContext(context.Background(), req)
|
||||
}
|
||||
|
||||
func (c *Client) UploadCdnCertWithContext(ctx context.Context, req *UploadCdnCertRequest) (*UploadCdnCertResponse, error) {
|
||||
httpreq, err := c.newRequest(http.MethodPost, "/cdn/cert/upload.json")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
httpreq.SetBody(req)
|
||||
httpreq.SetContext(ctx)
|
||||
}
|
||||
|
||||
result := &UploadCdnCertResponse{}
|
||||
if _, err := c.doRequestWithResult(httpreq, result); err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
Reference in New Issue
Block a user