|
|
@@ -155,7 +155,7 @@ func (c *Client) CreateInferenceJob(req CreateAIJobReq, token string) (*CreateIn |
|
|
|
|
|
|
|
|
contType := resp.Header.Get("Content-Type") |
|
|
contType := resp.Header.Get("Content-Type") |
|
|
if strings.Contains(contType, http2.ContentTypeJSON) { |
|
|
if strings.Contains(contType, http2.ContentTypeJSON) { |
|
|
var codeResp respons2[CreateInferenceJobResp] |
|
|
|
|
|
|
|
|
var codeResp response2[CreateInferenceJobResp] |
|
|
if err := serder.JSONToObjectStream(resp.Body, &codeResp); err != nil { |
|
|
if err := serder.JSONToObjectStream(resp.Body, &codeResp); err != nil { |
|
|
return nil, fmt.Errorf("parsing response: %w", err) |
|
|
return nil, fmt.Errorf("parsing response: %w", err) |
|
|
} |
|
|
} |
|
|
@@ -195,7 +195,7 @@ func (c *Client) StopInferenceJob(req StopInferenceJobReq, token string) error { |
|
|
|
|
|
|
|
|
contType := resp.Header.Get("Content-Type") |
|
|
contType := resp.Header.Get("Content-Type") |
|
|
if strings.Contains(contType, http2.ContentTypeJSON) { |
|
|
if strings.Contains(contType, http2.ContentTypeJSON) { |
|
|
var codeResp respons2[CreateInferenceJobResp] |
|
|
|
|
|
|
|
|
var codeResp response2[CreateInferenceJobResp] |
|
|
if err := serder.JSONToObjectStream(resp.Body, &codeResp); err != nil { |
|
|
if err := serder.JSONToObjectStream(resp.Body, &codeResp); err != nil { |
|
|
return fmt.Errorf("parsing response: %w", err) |
|
|
return fmt.Errorf("parsing response: %w", err) |
|
|
} |
|
|
} |
|
|
@@ -228,7 +228,7 @@ func (c *Client) CreateJob(req CreateAIJobReq, token string) (*CreateJobResp, er |
|
|
|
|
|
|
|
|
contType := resp.Header.Get("Content-Type") |
|
|
contType := resp.Header.Get("Content-Type") |
|
|
if strings.Contains(contType, http2.ContentTypeJSON) { |
|
|
if strings.Contains(contType, http2.ContentTypeJSON) { |
|
|
var codeResp respons2[CreateJobResp] |
|
|
|
|
|
|
|
|
var codeResp response2[CreateJobResp] |
|
|
if err := serder.JSONToObjectStream(resp.Body, &codeResp); err != nil { |
|
|
if err := serder.JSONToObjectStream(resp.Body, &codeResp); err != nil { |
|
|
return nil, fmt.Errorf("parsing response: %w", err) |
|
|
return nil, fmt.Errorf("parsing response: %w", err) |
|
|
} |
|
|
} |
|
|
@@ -280,7 +280,7 @@ func (c *Client) RunJob(req RunJobReq, token string) error { |
|
|
|
|
|
|
|
|
contType := resp.Header.Get("Content-Type") |
|
|
contType := resp.Header.Get("Content-Type") |
|
|
if strings.Contains(contType, http2.ContentTypeJSON) { |
|
|
if strings.Contains(contType, http2.ContentTypeJSON) { |
|
|
var codeResp respons2[string] |
|
|
|
|
|
|
|
|
var codeResp response2[string] |
|
|
if err := serder.JSONToObjectStream(resp.Body, &codeResp); err != nil { |
|
|
if err := serder.JSONToObjectStream(resp.Body, &codeResp); err != nil { |
|
|
return fmt.Errorf("parsing response: %w", err) |
|
|
return fmt.Errorf("parsing response: %w", err) |
|
|
} |
|
|
} |
|
|
@@ -327,3 +327,53 @@ func (c *Client) CancelJob(req CancelJobReq) error { |
|
|
|
|
|
|
|
|
return fmt.Errorf("unknow response content type: %s", contType) |
|
|
return fmt.Errorf("unknow response content type: %s", contType) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
type GetResourceSpecReq struct { |
|
|
|
|
|
ClusterID schsdk.ClusterID `form:"clusterId"` |
|
|
|
|
|
Tag string `form:"tag"` |
|
|
|
|
|
PageNum int64 `form:"pageNum"` |
|
|
|
|
|
PageSize int64 `form:"pageSize"` |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
type GetResourceSpecResp struct { |
|
|
|
|
|
Total int64 `json:"total"` |
|
|
|
|
|
PageNum int64 `json:"pageNum"` |
|
|
|
|
|
PageSize int64 `json:"pageSize"` |
|
|
|
|
|
List []ResourceDetail `json:"list"` |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (c *Client) GetResourceSpec(req GetResourceSpecReq, token string) ([]ResourceDetail, int64, error) { |
|
|
|
|
|
targetUrl, err := url.JoinPath(c.baseURL, "core/ai/resourceSpec/page") |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return nil, 0, err |
|
|
|
|
|
} |
|
|
|
|
|
resp, err := http2.GetJSON(targetUrl, http2.RequestParam{ |
|
|
|
|
|
Query: req, |
|
|
|
|
|
Header: map[string]string{ |
|
|
|
|
|
"Authorization": token, |
|
|
|
|
|
}, |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
//all, err := io.ReadAll(resp.Body) |
|
|
|
|
|
//println(string(all)) |
|
|
|
|
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return nil, 0, err |
|
|
|
|
|
} |
|
|
|
|
|
contType := resp.Header.Get("Content-Type") |
|
|
|
|
|
if strings.Contains(contType, http2.ContentTypeJSON) { |
|
|
|
|
|
|
|
|
|
|
|
var codeResp response2[GetResourceSpecResp] |
|
|
|
|
|
if err := serder.JSONToObjectStream(resp.Body, &codeResp); err != nil { |
|
|
|
|
|
return nil, 0, fmt.Errorf("parsing response: %w", err) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if codeResp.Code == ResponseCodeOK { |
|
|
|
|
|
return codeResp.Data.List, codeResp.Data.Total, nil |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return nil, 0, codeResp.ToError() |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return nil, 0, fmt.Errorf("unknow response content type: %s", contType) |
|
|
|
|
|
} |