fix:查询开发环境接口修改
Former-commit-id: 271f1e85ef8aa460de784df2d52986bccc69c2cd
This commit is contained in:
parent
03d498f4d5
commit
9d0b9b4cae
|
@ -1,14 +1,19 @@
|
||||||
package logic
|
package logic
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"APIGW-go-sdk/core"
|
||||||
"PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/common"
|
"PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/common"
|
||||||
"PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc"
|
"PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc"
|
||||||
"PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelarts"
|
"PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelarts"
|
||||||
"PCM/common/tool"
|
"PCM/common/tool"
|
||||||
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"github.com/bitly/go-simplejson"
|
"github.com/bitly/go-simplejson"
|
||||||
"github.com/zeromicro/go-zero/core/logx"
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
"io/ioutil"
|
||||||
"k8s.io/apimachinery/pkg/util/json"
|
"k8s.io/apimachinery/pkg/util/json"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -31,14 +36,50 @@ func (l *ListTrainingJobConfigLogic) ListTrainingJobConfig(in *modelarts.ListTra
|
||||||
var resp modelarts.ListTrainingJobConfigResp
|
var resp modelarts.ListTrainingJobConfigResp
|
||||||
perPage := strconv.Itoa(int(in.PerPage))
|
perPage := strconv.Itoa(int(in.PerPage))
|
||||||
page := strconv.Itoa(int(in.Page))
|
page := strconv.Itoa(int(in.Page))
|
||||||
url := "https://modelarts.cn-north-4.myhuaweicloud.com/v1/" + in.ProjectId + "/training-job-configs?" + perPage + "&" + page
|
//根据智算类型判断走华为智算还是南京智算
|
||||||
token := common.GetToken()
|
modelArtsType := in.ModelArtsType
|
||||||
body, err := tool.HttpClient(tool.GET, url, nil, token)
|
if modelArtsType == l.svcCtx.Config.HaweiModelArtsType {
|
||||||
if err != nil {
|
modelArtsUrl := l.svcCtx.Config.ModelArtsUrl
|
||||||
return nil, err
|
url := modelArtsUrl + "v1/" + in.ProjectId + "/training-job-configs?" + perPage + "&" + page
|
||||||
|
token := common.GetToken()
|
||||||
|
body, err := tool.HttpClient(tool.GET, url, nil, token)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
jsonResult, err := simplejson.NewJson(body)
|
||||||
|
println(&jsonResult)
|
||||||
|
json.Unmarshal(body, &resp)
|
||||||
|
} else if modelArtsType == l.svcCtx.Config.NanjingModelArtsType {
|
||||||
|
AK := l.svcCtx.Config.AK
|
||||||
|
SK := l.svcCtx.Config.SK
|
||||||
|
NanjingModelArtsUrl := l.svcCtx.Config.NanjingModelArtsUrl
|
||||||
|
XProjectId := l.svcCtx.Config.XProjectId
|
||||||
|
s := core.Signer{
|
||||||
|
Key: AK,
|
||||||
|
Secret: SK,
|
||||||
|
}
|
||||||
|
r, err := http.NewRequest("GET", NanjingModelArtsUrl+"v1/"+in.ProjectId+"/training-job-configs?"+perPage+"&"+page,
|
||||||
|
bytes.NewBuffer([]byte("foo=bar")))
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
//return
|
||||||
|
}
|
||||||
|
r.Header.Add("content-type", "application/json;charset=UTF-8")
|
||||||
|
r.Header.Add("X-Project-Id", XProjectId)
|
||||||
|
r.Header.Add("x-stage", "RELEASE")
|
||||||
|
s.Sign(r)
|
||||||
|
client := http.DefaultClient
|
||||||
|
res, err := client.Do(r)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
|
defer res.Body.Close()
|
||||||
|
body, err := ioutil.ReadAll(res.Body)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
|
json.Unmarshal(body, &resp)
|
||||||
}
|
}
|
||||||
jsonResult, err := simplejson.NewJson(body)
|
|
||||||
println(&jsonResult)
|
|
||||||
json.Unmarshal(body, &resp)
|
|
||||||
return &resp, nil
|
return &resp, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue