feat: add baishan cdn deployer

This commit is contained in:
Fu Diwei
2025-02-17 20:19:31 +08:00
parent c72dc0d2c4
commit b2eb5d2754
34 changed files with 866 additions and 285 deletions

45
internal/pkg/vendors/baishan-sdk/api.go vendored Normal file
View File

@@ -0,0 +1,45 @@
package baishansdk
import (
"encoding/json"
"net/http"
)
func (c *Client) CreateCertificate(req *CreateCertificateRequest) (*CreateCertificateResponse, error) {
params := make(map[string]any)
jsonData, _ := json.Marshal(req)
json.Unmarshal(jsonData, &params)
result := CreateCertificateResponse{}
err := c.sendRequestWithResult(http.MethodPost, "/v2/domain/certificate", params, &result)
if err != nil {
return nil, err
}
return &result, nil
}
func (c *Client) GetDomainConfig(req *GetDomainConfigRequest) (*GetDomainConfigResponse, error) {
params := make(map[string]any)
jsonData, _ := json.Marshal(req)
json.Unmarshal(jsonData, &params)
result := GetDomainConfigResponse{}
err := c.sendRequestWithResult(http.MethodGet, "/v2/domain/config", params, &result)
if err != nil {
return nil, err
}
return &result, nil
}
func (c *Client) SetDomainConfig(req *SetDomainConfigRequest) (*SetDomainConfigResponse, error) {
params := make(map[string]any)
jsonData, _ := json.Marshal(req)
json.Unmarshal(jsonData, &params)
result := SetDomainConfigResponse{}
err := c.sendRequestWithResult(http.MethodPost, "/v2/domain/config", params, &result)
if err != nil {
return nil, err
}
return &result, nil
}