【新增】增加API接口测试功能接口 为部分供应商API增加测试功能

This commit is contained in:
wantoper
2025-05-20 17:27:42 +08:00
parent 4a2f500006
commit 77d82ad8a0
18 changed files with 284 additions and 5 deletions

View File

@@ -130,3 +130,33 @@ func DeployToTX(cfg map[string]any) error {
fmt.Println(response.Response.DeployRecordId)
return nil
}
func TencentCloudAPITest(providerID string) error {
providerData, err := access.GetAccess(providerID)
if err != nil {
return err
}
providerConfigStr, ok := providerData["config"].(string)
if !ok {
return fmt.Errorf("api配置错误")
}
// 解析 JSON 配置
var providerConfig map[string]string
err = json.Unmarshal([]byte(providerConfigStr), &providerConfig)
if err != nil {
return err
}
// 创建客户端
client := ClientTencentcloud(providerConfig["secret_id"], providerConfig["secret_key"], "")
request := ssl.NewDescribeCertificatesRequest()
_, err = client.DescribeCertificates(request)
if err != nil {
return fmt.Errorf("测试请求失败: %v", err)
}
return nil
}