|
|
|
@@ -57,6 +57,10 @@ func (c *Client) GetClusterInfo(req GetClusterInfoReq) ([]ClusterDetail, error) |
|
|
|
return nil, fmt.Errorf("unknow response content type: %s", contType) |
|
|
|
} |
|
|
|
|
|
|
|
type CreateInferenceJobResp struct { |
|
|
|
TaskId string `json:"taskId"` |
|
|
|
} |
|
|
|
|
|
|
|
type CreateJobReq struct { |
|
|
|
Name string `json:"name"` |
|
|
|
Description string `json:"description"` |
|
|
|
@@ -121,8 +125,42 @@ type ScheduleData struct { |
|
|
|
ClusterIDs []schsdk.ClusterID `json:"clusterIDs"` |
|
|
|
} |
|
|
|
|
|
|
|
func (c *Client) CreateInferenceJob(req CreateJobReq, token string) (*CreateInferenceJobResp, error) { |
|
|
|
targetUrl, err := url.JoinPath(c.baseURL, "inference/createTask") |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
|
|
|
|
resp, err := http2.PostJSON(targetUrl, http2.RequestParam{ |
|
|
|
Body: req, |
|
|
|
Header: map[string]string{ |
|
|
|
"Authorization": token, |
|
|
|
}, |
|
|
|
}) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
|
|
|
|
contType := resp.Header.Get("Content-Type") |
|
|
|
if strings.Contains(contType, http2.ContentTypeJSON) { |
|
|
|
var codeResp respons2[CreateInferenceJobResp] |
|
|
|
if err := serder.JSONToObjectStream(resp.Body, &codeResp); err != nil { |
|
|
|
return nil, fmt.Errorf("parsing response: %w", err) |
|
|
|
} |
|
|
|
|
|
|
|
if codeResp.Code == ResponseCodeOK { |
|
|
|
return &codeResp.Data, nil |
|
|
|
} |
|
|
|
|
|
|
|
return nil, fmt.Errorf("error: %s", codeResp.Message) |
|
|
|
} |
|
|
|
|
|
|
|
return nil, fmt.Errorf("unknow response content type: %s", contType) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
func (c *Client) CreateJob(req CreateJobReq, token string) (*CreateJobResp, error) { |
|
|
|
targetUrl, err := url.JoinPath(c.baseURL, "/createTask") |
|
|
|
targetUrl, err := url.JoinPath(c.baseURL, "schedule/createTask") |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
@@ -181,7 +219,7 @@ type DataScheduleResults struct { |
|
|
|
} |
|
|
|
|
|
|
|
func (c *Client) RunJob(req RunJobReq, token string) error { |
|
|
|
targetUrl, err := url.JoinPath(c.baseURL, "runTask") |
|
|
|
targetUrl, err := url.JoinPath(c.baseURL, "schedule/runTask") |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
@@ -220,7 +258,7 @@ type CancelJobReq struct { |
|
|
|
} |
|
|
|
|
|
|
|
func (c *Client) CancelJob(req CancelJobReq) error { |
|
|
|
targetUrl, err := url.JoinPath(c.baseURL, "/queryResources") |
|
|
|
targetUrl, err := url.JoinPath(c.baseURL, "schedule/queryResources") |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
|