fix:显示详情接口修改
Former-commit-id: 134e81b4a224b56479bad06f1813b003449d53a8
This commit is contained in:
parent
38cc3765e3
commit
0c32d599c3
|
@ -1,10 +1,14 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"APIGW-go-sdk/core"
|
||||
"PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/common"
|
||||
"PCM/common/tool"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc"
|
||||
|
@ -30,15 +34,50 @@ func NewGetVisualizationJobLogic(ctx context.Context, svcCtx *svc.ServiceContext
|
|||
// visualization-jobs
|
||||
func (l *GetVisualizationJobLogic) GetVisualizationJob(in *modelarts.GetVisualizationJobReq) (*modelarts.GetVisualizationJobResp, error) {
|
||||
var resp modelarts.GetVisualizationJobResp
|
||||
getVisualJobUrl := "https://modelarts.cn-east-3.myhuaweicloud.com/v1/{project_id}/visualization-jobs"
|
||||
getVisualJobUrl = strings.Replace(getVisualJobUrl, "{project_id}", in.ProjectId, -1)
|
||||
modelArtsType := in.ModelArtsType
|
||||
if modelArtsType == l.svcCtx.Config.HaweiModelArtsType {
|
||||
modelArtsUrl := l.svcCtx.Config.ModelArtsUrl
|
||||
getVisualJobUrl := modelArtsUrl + "v1/{project_id}/visualization-jobs"
|
||||
getVisualJobUrl = strings.Replace(getVisualJobUrl, "{project_id}", in.ProjectId, -1)
|
||||
|
||||
token := common.GetToken()
|
||||
token := common.GetToken()
|
||||
|
||||
body, err := tool.HttpClientWithQueries(tool.GET, getVisualJobUrl, nil, token, in.Param)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
body, err := tool.HttpClientWithQueries(tool.GET, getVisualJobUrl, nil, token, in.Param)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
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+"/visualization-jobs",
|
||||
nil)
|
||||
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)
|
||||
}
|
||||
json.Unmarshal(body, &resp)
|
||||
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"APIGW-go-sdk/core"
|
||||
"PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/common"
|
||||
"PCM/common/tool"
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc"
|
||||
|
@ -29,20 +34,54 @@ func NewMountNotebookStorageLogic(ctx context.Context, svcCtx *svc.ServiceContex
|
|||
|
||||
func (l *MountNotebookStorageLogic) MountNotebookStorage(in *modelarts.MountNotebookStorageReq) (*modelarts.MountNotebookStorageResp, error) {
|
||||
var resp modelarts.MountNotebookStorageResp
|
||||
mountUrl := "https://modelarts.cn-east-3.myhuaweicloud.com/v1/{project_id}/notebooks/{instance_id}/storage"
|
||||
mountUrl = strings.Replace(mountUrl, "{project_id}", in.ProjectId, -1)
|
||||
mountUrl = strings.Replace(mountUrl, "{instance_id}", in.InstanceId, -1)
|
||||
modelArtsType := in.ModelArtsType
|
||||
if modelArtsType == l.svcCtx.Config.HaweiModelArtsType {
|
||||
modelArtsUrl := l.svcCtx.Config.ModelArtsUrl
|
||||
mountUrl := modelArtsUrl + "v1/{project_id}/notebooks/{instance_id}/storage"
|
||||
mountUrl = strings.Replace(mountUrl, "{project_id}", in.ProjectId, -1)
|
||||
mountUrl = strings.Replace(mountUrl, "{instance_id}", in.InstanceId, -1)
|
||||
reqByte, err := json.Marshal(in.Param)
|
||||
if err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
token := common.GetToken()
|
||||
body, err := tool.HttpClient(tool.POST, mountUrl, payload, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
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,
|
||||
}
|
||||
reqByte, err := json.Marshal(in)
|
||||
r, err := http.NewRequest("POST", NanjingModelArtsUrl+"v1/"+in.ProjectId+"/notebooks"+in.InstanceId+"/storage",
|
||||
bytes.NewBuffer(reqByte))
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
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)
|
||||
}
|
||||
|
||||
reqByte, err := json.Marshal(in.Param)
|
||||
if err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
payload := strings.NewReader(string(reqByte))
|
||||
token := common.GetToken()
|
||||
body, err := tool.HttpClient(tool.POST, mountUrl, payload, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
json.Unmarshal(body, &resp)
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"APIGW-go-sdk/core"
|
||||
"PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/common"
|
||||
"PCM/common/tool"
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc"
|
||||
|
@ -29,15 +34,49 @@ func NewStartNotebookLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Sta
|
|||
|
||||
func (l *StartNotebookLogic) StartNotebook(in *modelarts.StartNotebookReq) (*modelarts.StartNotebookResp, error) {
|
||||
var resp modelarts.StartNotebookResp
|
||||
startUrl := "https://modelarts.cn-east-3.myhuaweicloud.com/v1/{project_id}/notebooks/{id}/start"
|
||||
startUrl = strings.Replace(startUrl, "{project_id}", in.ProjectId, -1)
|
||||
startUrl = strings.Replace(startUrl, "{id}", in.Id, -1)
|
||||
|
||||
token := common.GetToken()
|
||||
body, err := tool.HttpClientWithQueries(tool.POST, startUrl, nil, token, in.Param)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
modelArtsType := in.ModelArtsType
|
||||
if modelArtsType == l.svcCtx.Config.NanjingModelArtsType {
|
||||
modelArtsUrl := l.svcCtx.Config.ModelArtsUrl
|
||||
startUrl := modelArtsUrl + "v1/{project_id}/notebooks/{id}/start"
|
||||
startUrl = strings.Replace(startUrl, "{project_id}", in.ProjectId, -1)
|
||||
startUrl = strings.Replace(startUrl, "{id}", in.Id, -1)
|
||||
token := common.GetToken()
|
||||
body, err := tool.HttpClientWithQueries(tool.POST, startUrl, nil, token, in.Param)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
json.Unmarshal(body, &resp.NotebookResp)
|
||||
} else if modelArtsType == l.svcCtx.Config.HaweiModelArtsType {
|
||||
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,
|
||||
}
|
||||
reqByte, err := json.Marshal(in)
|
||||
r, err := http.NewRequest("POST", NanjingModelArtsUrl+"v1/"+in.ProjectId+"/notebooks"+in.Id+"/start",
|
||||
bytes.NewBuffer(reqByte))
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
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)
|
||||
}
|
||||
json.Unmarshal(body, &resp.NotebookResp)
|
||||
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"APIGW-go-sdk/core"
|
||||
"PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/common"
|
||||
"PCM/common/tool"
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/internal/svc"
|
||||
|
@ -29,18 +34,50 @@ func NewStopNotebookLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Stop
|
|||
|
||||
func (l *StopNotebookLogic) StopNotebook(in *modelarts.StopNotebookReq) (*modelarts.StopNotebookResp, error) {
|
||||
var resp modelarts.StopNotebookResp
|
||||
stopUrl := "https://modelarts.cn-east-3.myhuaweicloud.com/v1/{project_id}/notebooks/{id}/stop"
|
||||
stopUrl = strings.Replace(stopUrl, "{project_id}", in.ProjectId, -1)
|
||||
stopUrl = strings.Replace(stopUrl, "{id}", in.Id, -1)
|
||||
|
||||
token := common.GetToken()
|
||||
//empty struct
|
||||
var e struct{}
|
||||
|
||||
body, err := tool.HttpClientWithQueries(tool.POST, stopUrl, nil, token, e)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
modelArtsType := in.ModelArtsType
|
||||
if modelArtsType == l.svcCtx.Config.HaweiModelArtsType {
|
||||
modelArtsUrl := l.svcCtx.Config.ModelArtsUrl
|
||||
stopUrl := modelArtsUrl + "v1/{project_id}/notebooks/{id}/stop"
|
||||
stopUrl = strings.Replace(stopUrl, "{project_id}", in.ProjectId, -1)
|
||||
stopUrl = strings.Replace(stopUrl, "{id}", in.Id, -1)
|
||||
token := common.GetToken()
|
||||
//empty struct
|
||||
var e struct{}
|
||||
body, err := tool.HttpClientWithQueries(tool.POST, stopUrl, nil, token, e)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
json.Unmarshal(body, &resp.NotebookResp)
|
||||
} 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,
|
||||
}
|
||||
reqByte, err := json.Marshal(in)
|
||||
r, err := http.NewRequest("POST", NanjingModelArtsUrl+"v1/"+in.ProjectId+"/notebooks"+in.Id+"/stop",
|
||||
bytes.NewBuffer(reqByte))
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
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)
|
||||
}
|
||||
json.Unmarshal(body, &resp.NotebookResp)
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue