支持策略创建、删除,脚本列表、创建、删除、获取、使用

This commit is contained in:
algotao
2025-11-10 15:57:31 +08:00
parent f9b7857b24
commit 00fb793d9a
17 changed files with 1939 additions and 273 deletions

View File

@@ -14,13 +14,25 @@ const (
taskDeletePath = "/saas/task/delete"
taskRunPath = "/saas/task/run"
targetListPath = "/saas/target/list"
targetCreatePath = "/saas/target/create"
targetDeletePath = "/saas/target/delete"
bindSetPath = "/saas/bind/set"
bindDeletePath = "/saas/bind/delete"
scriptRunPath = "/saas/script/run"
scriptCreatePath = "/saas/script/create"
scriptListPath = "/saas/script/list"
scriptDeletePath = "/saas/script/delete"
scriptGetPath = "/saas/script/get"
scriptUsePath = "/saas/script/use"
expListPath = "/saas/exp/list"
expGetPath = "/saas/exp/get"
)
type Auth struct {
Account string
Token string
}
type ApiUrls struct {
BaseUrl string
InfoPath string
@@ -35,9 +47,16 @@ type ApiUrls struct {
TaskUploadPath string
TaskDownloadPath string
TargetListPath string
TargetCreatePath string
TargetDeletePath string
BindSetPath string
BindDeletePath string
ScriptRunPath string
ScriptCreatePath string
ScriptListPath string
ScriptDeletePath string
ScriptGetPath string
ScriptUsePath string
ExpListPath string
ExpGetPath string
}
@@ -49,79 +68,76 @@ func InitAPIUrl(c *ApiUrls) *ApiUrls {
} else {
r.BaseUrl = baseUrl
}
if c.InfoPath != "" {
r.InfoPath = c.InfoPath
} else {
r.InfoPath = infoPath
}
if c.WritePath != "" {
r.WritePath = c.WritePath
} else {
r.WritePath = writePath
}
if c.ReadPath != "" {
r.ReadPath = c.ReadPath
} else {
r.ReadPath = readPath
}
if c.ColumnWritePath != "" {
r.ColumnWritePath = c.ColumnWritePath
} else {
r.ColumnWritePath = columnWritePath
}
if c.TaskCreatePath != "" {
r.TaskCreatePath = c.TaskCreatePath
} else {
r.TaskCreatePath = taskCreatePath
}
if c.TaskListPath != "" {
r.TaskListPath = c.TaskListPath
} else {
r.TaskListPath = taskListPath
}
if c.TaskInfoPath != "" {
r.TaskInfoPath = c.TaskInfoPath
} else {
r.TaskInfoPath = taskInfoPath
}
if c.TaskDeletePath != "" {
r.TaskDeletePath = c.TaskDeletePath
} else {
r.TaskDeletePath = taskDeletePath
}
if c.TaskRunPath != "" {
r.TaskRunPath = c.TaskRunPath
} else {
r.TaskRunPath = taskRunPath
}
if c.TaskUploadPath != "" {
r.TaskUploadPath = c.TaskUploadPath
} else {
r.TaskUploadPath = taskUploadPath
}
if c.TaskDownloadPath != "" {
r.TaskDownloadPath = c.TaskDownloadPath
} else {
r.TaskDownloadPath = taskDownloadPath
}
if c.TargetListPath != "" {
r.TargetListPath = c.TargetListPath
} else {
r.TargetListPath = targetListPath
}
if c.TargetCreatePath != "" {
r.TargetCreatePath = c.TargetCreatePath
} else {
r.TargetCreatePath = targetCreatePath
}
if c.TargetDeletePath != "" {
r.TargetDeletePath = c.TargetDeletePath
} else {
r.TargetDeletePath = targetDeletePath
}
if c.BindSetPath != "" {
r.BindSetPath = c.BindSetPath
} else {
@@ -140,6 +156,36 @@ func InitAPIUrl(c *ApiUrls) *ApiUrls {
r.ScriptRunPath = scriptRunPath
}
if c.ScriptCreatePath != "" {
r.ScriptCreatePath = c.ScriptCreatePath
} else {
r.ScriptCreatePath = scriptCreatePath
}
if c.ScriptListPath != "" {
r.ScriptListPath = c.ScriptListPath
} else {
r.ScriptListPath = scriptListPath
}
if c.ScriptDeletePath != "" {
r.ScriptDeletePath = c.ScriptDeletePath
} else {
r.ScriptDeletePath = scriptDeletePath
}
if c.ScriptGetPath != "" {
r.ScriptGetPath = c.ScriptGetPath
} else {
r.ScriptGetPath = scriptGetPath
}
if c.ScriptUsePath != "" {
r.ScriptUsePath = c.ScriptUsePath
} else {
r.ScriptUsePath = scriptUsePath
}
if c.ExpListPath != "" {
r.ExpListPath = c.ExpListPath
} else {
@@ -154,8 +200,3 @@ func InitAPIUrl(c *ApiUrls) *ApiUrls {
return r
}
type Auth struct {
Account string
Token string
}

View File

@@ -93,6 +93,16 @@ func (c *SaasClient) TargetList(saasReq *saasapi.SaasReq) (saasRes *saasapi.Saas
return c.post(postUrl, saasReq)
}
func (c *SaasClient) TargetCreate(saasReq *saasapi.SaasReq) (saasRes *saasapi.SaasRes, err error) {
postUrl := c.makeUrl(c.ApiUrls.BaseUrl, c.ApiUrls.TargetCreatePath)
return c.post(postUrl, saasReq)
}
func (c *SaasClient) TargetDelete(saasReq *saasapi.SaasReq) (saasRes *saasapi.SaasRes, err error) {
postUrl := c.makeUrl(c.ApiUrls.BaseUrl, c.ApiUrls.TargetDeletePath)
return c.post(postUrl, saasReq)
}
func (c *SaasClient) BindSet(saasReq *saasapi.SaasReq) (saasRes *saasapi.SaasRes, err error) {
postUrl := c.makeUrl(c.ApiUrls.BaseUrl, c.ApiUrls.BindSetPath)
return c.post(postUrl, saasReq)
@@ -356,3 +366,28 @@ func (c *SaasClient) download(url string, file *os.File, offset int64, size int)
return saasRes, nil
}
func (c *SaasClient) ScriptCreate(saasReq *saasapi.SaasReq) (saasRes *saasapi.SaasRes, err error) {
postUrl := c.makeUrl(c.ApiUrls.BaseUrl, c.ApiUrls.ScriptCreatePath)
return c.post(postUrl, saasReq)
}
func (c *SaasClient) ScriptList(saasReq *saasapi.SaasReq) (saasRes *saasapi.SaasRes, err error) {
postUrl := c.makeUrl(c.ApiUrls.BaseUrl, c.ApiUrls.ScriptListPath)
return c.post(postUrl, saasReq)
}
func (c *SaasClient) ScriptDelete(saasReq *saasapi.SaasReq) (saasRes *saasapi.SaasRes, err error) {
postUrl := c.makeUrl(c.ApiUrls.BaseUrl, c.ApiUrls.ScriptDeletePath)
return c.post(postUrl, saasReq)
}
func (c *SaasClient) ScriptGet(saasReq *saasapi.SaasReq) (saasRes *saasapi.SaasRes, err error) {
postUrl := c.makeUrl(c.ApiUrls.BaseUrl, c.ApiUrls.ScriptGetPath)
return c.post(postUrl, saasReq)
}
func (c *SaasClient) ScriptUse(saasReq *saasapi.SaasReq) (saasRes *saasapi.SaasRes, err error) {
postUrl := c.makeUrl(c.ApiUrls.BaseUrl, c.ApiUrls.ScriptUsePath)
return c.post(postUrl, saasReq)
}