mirror of
https://github.com/usual2970/certimate.git
synced 2025-10-05 14:04:54 +00:00
feat: add safeline deployer
This commit is contained in:
59
internal/pkg/vendors/gname-sdk/api.go
vendored
59
internal/pkg/vendors/gname-sdk/api.go
vendored
@@ -5,6 +5,19 @@ type BaseResponse interface {
|
||||
GetMsg() string
|
||||
}
|
||||
|
||||
type baseResponse struct {
|
||||
Code int `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
}
|
||||
|
||||
func (r *baseResponse) GetCode() int {
|
||||
return r.Code
|
||||
}
|
||||
|
||||
func (r *baseResponse) GetMsg() string {
|
||||
return r.Msg
|
||||
}
|
||||
|
||||
type AddDomainResolutionRequest struct {
|
||||
ZoneName string `json:"ym"`
|
||||
RecordType string `json:"lx"`
|
||||
@@ -15,17 +28,8 @@ type AddDomainResolutionRequest struct {
|
||||
}
|
||||
|
||||
type AddDomainResolutionResponse struct {
|
||||
Code int `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
Data int `json:"data"`
|
||||
}
|
||||
|
||||
func (r *AddDomainResolutionResponse) GetCode() int {
|
||||
return r.Code
|
||||
}
|
||||
|
||||
func (r *AddDomainResolutionResponse) GetMsg() string {
|
||||
return r.Msg
|
||||
baseResponse
|
||||
Data int `json:"data"`
|
||||
}
|
||||
|
||||
type ModifyDomainResolutionRequest struct {
|
||||
@@ -39,16 +43,7 @@ type ModifyDomainResolutionRequest struct {
|
||||
}
|
||||
|
||||
type ModifyDomainResolutionResponse struct {
|
||||
Code int `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
}
|
||||
|
||||
func (r *ModifyDomainResolutionResponse) GetCode() int {
|
||||
return r.Code
|
||||
}
|
||||
|
||||
func (r *ModifyDomainResolutionResponse) GetMsg() string {
|
||||
return r.Msg
|
||||
baseResponse
|
||||
}
|
||||
|
||||
type DeleteDomainResolutionRequest struct {
|
||||
@@ -57,16 +52,7 @@ type DeleteDomainResolutionRequest struct {
|
||||
}
|
||||
|
||||
type DeleteDomainResolutionResponse struct {
|
||||
Code int `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
}
|
||||
|
||||
func (r *DeleteDomainResolutionResponse) GetCode() int {
|
||||
return r.Code
|
||||
}
|
||||
|
||||
func (r *DeleteDomainResolutionResponse) GetMsg() string {
|
||||
return r.Msg
|
||||
baseResponse
|
||||
}
|
||||
|
||||
type ListDomainResolutionRequest struct {
|
||||
@@ -76,8 +62,7 @@ type ListDomainResolutionRequest struct {
|
||||
}
|
||||
|
||||
type ListDomainResolutionResponse struct {
|
||||
Code int `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
baseResponse
|
||||
Count int `json:"count"`
|
||||
Data []*ResolutionRecord `json:"data"`
|
||||
Page int `json:"page"`
|
||||
@@ -92,11 +77,3 @@ type ResolutionRecord struct {
|
||||
RecordValue string `json:"jxz"`
|
||||
MX int `json:"mx"`
|
||||
}
|
||||
|
||||
func (r *ListDomainResolutionResponse) GetCode() int {
|
||||
return r.Code
|
||||
}
|
||||
|
||||
func (r *ListDomainResolutionResponse) GetMsg() string {
|
||||
return r.Msg
|
||||
}
|
||||
|
12
internal/pkg/vendors/gname-sdk/client.go
vendored
12
internal/pkg/vendors/gname-sdk/client.go
vendored
@@ -10,8 +10,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/go-resty/resty/v2"
|
||||
|
||||
"github.com/usual2970/certimate/internal/pkg/utils/maps"
|
||||
)
|
||||
|
||||
type GnameClient struct {
|
||||
@@ -131,9 +129,7 @@ func (c *GnameClient) sendRequest(path string, params map[string]any) (*resty.Re
|
||||
resp, err := req.Post(url)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("gname: failed to send request: %w", err)
|
||||
}
|
||||
|
||||
if resp.IsError() {
|
||||
} else if resp.IsError() {
|
||||
return nil, fmt.Errorf("gname: unexpected status code: %d, %s", resp.StatusCode(), resp.Body())
|
||||
}
|
||||
|
||||
@@ -146,11 +142,7 @@ func (c *GnameClient) sendRequestWithResult(path string, params map[string]any,
|
||||
return err
|
||||
}
|
||||
|
||||
jsonResp := make(map[string]any)
|
||||
if err := json.Unmarshal(resp.Body(), &jsonResp); err != nil {
|
||||
return fmt.Errorf("gname: failed to parse response: %w", err)
|
||||
}
|
||||
if err := maps.Populate(jsonResp, &result); err != nil {
|
||||
if err := json.Unmarshal(resp.Body(), &result); err != nil {
|
||||
return fmt.Errorf("gname: failed to parse response: %w", err)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user