feat: add baotapanel console deployer
This commit is contained in:
42
internal/pkg/vendors/btpanel-sdk/api.go
vendored
42
internal/pkg/vendors/btpanel-sdk/api.go
vendored
@@ -5,22 +5,44 @@ type BaseResponse interface {
|
||||
GetMsg() *string
|
||||
}
|
||||
|
||||
type SetSiteSSLRequest struct {
|
||||
Type string `json:"type"`
|
||||
SiteName string `json:"siteName"`
|
||||
Key string `json:"key"`
|
||||
Csr string `json:"csr"`
|
||||
}
|
||||
|
||||
type SetSiteSSLResponse struct {
|
||||
type baseResponse struct {
|
||||
Status *bool `json:"status,omitempty"`
|
||||
Msg *string `json:"msg,omitempty"`
|
||||
}
|
||||
|
||||
func (r *SetSiteSSLResponse) GetStatus() *bool {
|
||||
func (r *baseResponse) GetStatus() *bool {
|
||||
return r.Status
|
||||
}
|
||||
|
||||
func (r *SetSiteSSLResponse) GetMsg() *string {
|
||||
func (r *baseResponse) GetMsg() *string {
|
||||
return r.Msg
|
||||
}
|
||||
|
||||
type ConfigSavePanelSSLRequest struct {
|
||||
PrivateKey string `json:"privateKey"`
|
||||
Certificate string `json:"certPem"`
|
||||
}
|
||||
|
||||
type ConfigSavePanelSSLResponse struct {
|
||||
baseResponse
|
||||
}
|
||||
|
||||
type SiteSetSSLRequest struct {
|
||||
Type string `json:"type"`
|
||||
SiteName string `json:"siteName"`
|
||||
PrivateKey string `json:"key"`
|
||||
Certificate string `json:"csr"`
|
||||
}
|
||||
|
||||
type SiteSetSSLResponse struct {
|
||||
baseResponse
|
||||
}
|
||||
|
||||
type SystemServiceAdminRequest struct {
|
||||
Name string `json:"name"`
|
||||
Type string `json:"type"`
|
||||
}
|
||||
|
||||
type SystemServiceAdminResponse struct {
|
||||
baseResponse
|
||||
}
|
||||
|
||||
30
internal/pkg/vendors/btpanel-sdk/client.go
vendored
30
internal/pkg/vendors/btpanel-sdk/client.go
vendored
@@ -34,12 +34,25 @@ func (c *BaoTaPanelClient) WithTimeout(timeout time.Duration) *BaoTaPanelClient
|
||||
return c
|
||||
}
|
||||
|
||||
func (c *BaoTaPanelClient) SetSiteSSL(req *SetSiteSSLRequest) (*SetSiteSSLResponse, error) {
|
||||
func (c *BaoTaPanelClient) ConfigSavePanelSSL(req *ConfigSavePanelSSLRequest) (*ConfigSavePanelSSLResponse, error) {
|
||||
params := make(map[string]any)
|
||||
jsonData, _ := json.Marshal(req)
|
||||
json.Unmarshal(jsonData, ¶ms)
|
||||
|
||||
result := SetSiteSSLResponse{}
|
||||
result := ConfigSavePanelSSLResponse{}
|
||||
err := c.sendRequestWithResult("/config?action=SavePanelSSL", params, &result)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
func (c *BaoTaPanelClient) SiteSetSSL(req *SiteSetSSLRequest) (*SiteSetSSLResponse, error) {
|
||||
params := make(map[string]any)
|
||||
jsonData, _ := json.Marshal(req)
|
||||
json.Unmarshal(jsonData, ¶ms)
|
||||
|
||||
result := SiteSetSSLResponse{}
|
||||
err := c.sendRequestWithResult("/site?action=SetSSL", params, &result)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -47,6 +60,19 @@ func (c *BaoTaPanelClient) SetSiteSSL(req *SetSiteSSLRequest) (*SetSiteSSLRespon
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
func (c *BaoTaPanelClient) SystemServiceAdmin(req *SystemServiceAdminRequest) (*SystemServiceAdminResponse, error) {
|
||||
params := make(map[string]any)
|
||||
jsonData, _ := json.Marshal(req)
|
||||
json.Unmarshal(jsonData, ¶ms)
|
||||
|
||||
result := SystemServiceAdminResponse{}
|
||||
err := c.sendRequestWithResult("/system?action=ServiceAdmin", params, &result)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
func (c *BaoTaPanelClient) generateSignature(timestamp string) string {
|
||||
keyMd5 := md5.Sum([]byte(c.apiKey))
|
||||
keyMd5Hex := strings.ToLower(hex.EncodeToString(keyMd5[:]))
|
||||
|
||||
Reference in New Issue
Block a user