feat: new deployment provider: ctcccloud icdn

This commit is contained in:
Fu Diwei
2025-06-13 19:18:40 +08:00
parent 0d44373de6
commit b7d1ff8960
21 changed files with 959 additions and 7 deletions

View File

@@ -35,6 +35,6 @@ func (c *Client) doRequest(request *resty.Request) (*resty.Response, error) {
return c.client.DoRequest(request)
}
func (c *Client) doRequestWithResult(request *resty.Request, result any) (*resty.Response, error) {
func (c *Client) doRequestWithResult(request *resty.Request, result baseResultInterface) (*resty.Response, error) {
return c.client.DoRequestWithResult(request, result)
}

View File

@@ -1,6 +1,17 @@
package cdn
import "encoding/json"
import (
"bytes"
"encoding/json"
"strconv"
)
type baseResultInterface interface {
GetStatusCode() string
GetMessage() string
GetError() string
GetErrorMessage() string
}
type baseResult struct {
StatusCode json.RawMessage `json:"statusCode,omitempty"`
@@ -10,6 +21,55 @@ type baseResult struct {
RequestId *string `json:"requestId,omitempty"`
}
func (r *baseResult) GetStatusCode() string {
if r.StatusCode == nil {
return ""
}
decoder := json.NewDecoder(bytes.NewReader(r.StatusCode))
token, err := decoder.Token()
if err != nil {
return ""
}
switch t := token.(type) {
case string:
return t
case float64:
return strconv.FormatFloat(t, 'f', -1, 64)
case json.Number:
return t.String()
default:
return ""
}
}
func (r *baseResult) GetMessage() string {
if r.Message == nil {
return ""
}
return *r.Message
}
func (r *baseResult) GetError() string {
if r.Error == nil {
return ""
}
return *r.Error
}
func (r *baseResult) GetErrorMessage() string {
if r.ErrorMessage == nil {
return ""
}
return *r.ErrorMessage
}
var _ baseResultInterface = (*baseResult)(nil)
type CertRecord struct {
Id int32 `json:"id"`
Name string `json:"name"`