Merge branch 'main' into feat/providers

This commit is contained in:
Fu Diwei
2025-05-26 11:37:01 +08:00
70 changed files with 693 additions and 999 deletions

View File

@@ -19,13 +19,13 @@ type Client struct {
client *resty.Client
}
func NewClient(apiHost, apiVersion, apiKey string) *Client {
func NewClient(serverUrl, apiVersion, apiKey string) *Client {
if apiVersion == "" {
apiVersion = "v1"
}
client := resty.New().
SetBaseURL(strings.TrimRight(apiHost, "/") + "/api/" + apiVersion).
SetBaseURL(strings.TrimRight(serverUrl, "/") + "/api/" + apiVersion).
SetPreRequestHook(func(c *resty.Client, req *http.Request) error {
timestamp := fmt.Sprintf("%d", time.Now().Unix())
tokenMd5 := md5.Sum([]byte("1panel" + apiKey + timestamp))

View File

@@ -19,9 +19,9 @@ type Client struct {
client *resty.Client
}
func NewClient(apiHost, apiKey string) *Client {
func NewClient(serverUrl, apiKey string) *Client {
client := resty.New().
SetBaseURL(strings.TrimRight(apiHost, "/"))
SetBaseURL(strings.TrimRight(serverUrl, "/"))
return &Client{
apiKey: apiKey,

View File

@@ -17,9 +17,9 @@ type Client struct {
client *resty.Client
}
func NewClient(apiHost, apiKey string) *Client {
func NewClient(serverUrl, apiKey string) *Client {
client := resty.New().
SetBaseURL(strings.TrimRight(apiHost, "/") + "/api").
SetBaseURL(strings.TrimRight(serverUrl, "/") + "/api").
SetPreRequestHook(func(c *resty.Client, req *http.Request) error {
timestamp := fmt.Sprintf("%d", time.Now().Unix())
keyMd5 := md5.Sum([]byte(apiKey))

View File

@@ -15,9 +15,9 @@ type Client struct {
client *resty.Client
}
func NewClient(apiHost, apiKey, apiSecret string) *Client {
func NewClient(serverUrl, apiKey, apiSecret string) *Client {
client := resty.New().
SetBaseURL(strings.TrimRight(apiHost, "/")).
SetBaseURL(strings.TrimRight(serverUrl, "/")).
SetHeader("api-key", apiKey).
SetHeader("api-secret", apiSecret)

View File

@@ -24,14 +24,14 @@ type Client struct {
client *resty.Client
}
func NewClient(apiHost, apiRole, accessKeyId, accessKey string) *Client {
func NewClient(serverUrl, apiRole, accessKeyId, accessKey string) *Client {
client := &Client{
apiRole: apiRole,
accessKeyId: accessKeyId,
accessKey: accessKey,
}
client.client = resty.New().
SetBaseURL(strings.TrimRight(apiHost, "/")).
SetBaseURL(strings.TrimRight(serverUrl, "/")).
SetPreRequestHook(func(c *resty.Client, req *http.Request) error {
if client.accessToken != "" {
req.Header.Set("X-Cloud-Access-Token", client.accessToken)

View File

@@ -24,14 +24,14 @@ type Client struct {
client *resty.Client
}
func NewClient(apiHost, apiRole, accessKeyId, accessKey string) *Client {
func NewClient(serverUrl, apiRole, accessKeyId, accessKey string) *Client {
client := &Client{
apiRole: apiRole,
accessKeyId: accessKeyId,
accessKey: accessKey,
}
client.client = resty.New().
SetBaseURL(strings.TrimRight(apiHost, "/")).
SetBaseURL(strings.TrimRight(serverUrl, "/")).
SetPreRequestHook(func(c *resty.Client, req *http.Request) error {
if client.accessToken != "" {
req.Header.Set("X-Edge-Access-Token", client.accessToken)

View File

@@ -22,13 +22,13 @@ type Client struct {
client *resty.Client
}
func NewClient(apiHost, username, password string) *Client {
func NewClient(serverUrl, username, password string) *Client {
client := &Client{
username: username,
password: password,
}
client.client = resty.New().
SetBaseURL(strings.TrimRight(apiHost, "/") + "/prod-api").
SetBaseURL(strings.TrimRight(serverUrl, "/") + "/prod-api").
SetPreRequestHook(func(c *resty.Client, req *http.Request) error {
if client.accessToken != "" {
req.Header.Set("Authorization", "Bearer "+client.accessToken)

View File

@@ -22,13 +22,13 @@ type Client struct {
client *resty.Client
}
func NewClient(apiHost, username, password string) *Client {
func NewClient(serverUrl, username, password string) *Client {
client := &Client{
username: username,
password: password,
}
client.client = resty.New().
SetBaseURL(strings.TrimRight(apiHost, "/") + "/prod-api").
SetBaseURL(strings.TrimRight(serverUrl, "/") + "/prod-api").
SetPreRequestHook(func(c *resty.Client, req *http.Request) error {
if client.accessToken != "" {
req.Header.Set("Authorization", "Bearer "+client.accessToken)

View File

@@ -20,9 +20,9 @@ type Client struct {
client *resty.Client
}
func NewClient(apiHost string, accessTokenId int32, accessToken string) *Client {
func NewClient(serverUrl string, accessTokenId int32, accessToken string) *Client {
client := resty.New().
SetBaseURL(strings.TrimRight(apiHost, "/")+"/api").
SetBaseURL(strings.TrimRight(serverUrl, "/")+"/api").
SetHeader("Accept", "application/json").
SetHeader("Content-Type", "application/json").
SetPreRequestHook(func(c *resty.Client, req *http.Request) error {

View File

@@ -14,9 +14,9 @@ type Client struct {
client *resty.Client
}
func NewClient(apiHost, apiToken string) *Client {
func NewClient(serverUrl, apiToken string) *Client {
client := resty.New().
SetBaseURL(strings.TrimRight(apiHost, "/")).
SetBaseURL(strings.TrimRight(serverUrl, "/")).
SetHeader("X-SLCE-API-TOKEN", apiToken)
return &Client{