| @@ -1,9 +1,9 @@ | |||||
| package pcm | |||||
| package pcmsdk | |||||
| import ( | import ( | ||||
| "fmt" | "fmt" | ||||
| "gitlink.org.cn/cloudream/common/api" | |||||
| "gitlink.org.cn/cloudream/common/sdks" | |||||
| ) | ) | ||||
| type response[T any] struct { | type response[T any] struct { | ||||
| @@ -12,8 +12,8 @@ type response[T any] struct { | |||||
| Data T `json:"data"` | Data T `json:"data"` | ||||
| } | } | ||||
| func (r *response[T]) ToError() *api.CodeMessageError { | |||||
| return &api.CodeMessageError{ | |||||
| func (r *response[T]) ToError() *sdks.CodeMessageError { | |||||
| return &sdks.CodeMessageError{ | |||||
| Code: fmt.Sprintf("%d", r.Code), | Code: fmt.Sprintf("%d", r.Code), | ||||
| Message: r.Message, | Message: r.Message, | ||||
| } | } | ||||
| @@ -1,4 +1,4 @@ | |||||
| package pcm | |||||
| package pcmsdk | |||||
| type Config struct { | type Config struct { | ||||
| URL string `json:"url"` | URL string `json:"url"` | ||||
| @@ -1,11 +1,12 @@ | |||||
| package pcm | |||||
| package pcmsdk | |||||
| import ( | import ( | ||||
| "fmt" | "fmt" | ||||
| "net/url" | "net/url" | ||||
| "strings" | "strings" | ||||
| "gitlink.org.cn/cloudream/common/models" | |||||
| schsdk "gitlink.org.cn/cloudream/common/sdks/scheduler" | |||||
| uopsdk "gitlink.org.cn/cloudream/common/sdks/unifyops" | |||||
| myhttp "gitlink.org.cn/cloudream/common/utils/http" | myhttp "gitlink.org.cn/cloudream/common/utils/http" | ||||
| "gitlink.org.cn/cloudream/common/utils/serder" | "gitlink.org.cn/cloudream/common/utils/serder" | ||||
| ) | ) | ||||
| @@ -13,13 +14,13 @@ import ( | |||||
| const CORRECT_CODE int = 200 | const CORRECT_CODE int = 200 | ||||
| type UploadImageReq struct { | type UploadImageReq struct { | ||||
| SlwNodeID models.SlwNodeID `json:"slwNodeID"` | |||||
| SlwNodeID uopsdk.SlwNodeID `json:"slwNodeID"` | |||||
| ImagePath string `json:"imagePath"` | ImagePath string `json:"imagePath"` | ||||
| } | } | ||||
| type UploadImageResp struct { | type UploadImageResp struct { | ||||
| Result string `json:"result"` | Result string `json:"result"` | ||||
| ImageID models.SlwNodeImageID `json:"imageID"` | |||||
| ImageID uopsdk.SlwNodeImageID `json:"imageID"` | |||||
| } | } | ||||
| func (c *Client) UploadImage(req UploadImageReq) (*UploadImageResp, error) { | func (c *Client) UploadImage(req UploadImageReq) (*UploadImageResp, error) { | ||||
| @@ -130,9 +131,9 @@ func (c *Client) DeleteImage(req DeleteImageReq) (*DeleteImageResp, error) { | |||||
| } | } | ||||
| type ScheduleTaskReq struct { | type ScheduleTaskReq struct { | ||||
| SlwNodeID models.SlwNodeID `json:"slwNodeID"` | |||||
| Envs []models.EnvVar `json:"envs"` | |||||
| ImageID models.SlwNodeImageID `json:"imageID"` | |||||
| SlwNodeID uopsdk.SlwNodeID `json:"slwNodeID"` | |||||
| Envs []schsdk.EnvVar `json:"envs"` | |||||
| ImageID uopsdk.SlwNodeImageID `json:"imageID"` | |||||
| CMDLine string `json:"cmdLine"` | CMDLine string `json:"cmdLine"` | ||||
| } | } | ||||
| @@ -172,7 +173,7 @@ func (c *Client) ScheduleTask(req ScheduleTaskReq) (*ScheduleTaskResp, error) { | |||||
| } | } | ||||
| type GetTaskStatusReq struct { | type GetTaskStatusReq struct { | ||||
| SlwNodeID models.SlwNodeID `json:"slwNodeID"` | |||||
| SlwNodeID uopsdk.SlwNodeID `json:"slwNodeID"` | |||||
| PCMJobID int64 `json:"pcmJobID"` | PCMJobID int64 `json:"pcmJobID"` | ||||
| } | } | ||||
| @@ -1,6 +1,6 @@ | |||||
| package scheduler | |||||
| package schsdk | |||||
| import "gitlink.org.cn/cloudream/common/api" | |||||
| import "gitlink.org.cn/cloudream/common/sdks" | |||||
| type response[T any] struct { | type response[T any] struct { | ||||
| Code string `json:"code"` | Code string `json:"code"` | ||||
| @@ -8,8 +8,8 @@ type response[T any] struct { | |||||
| Data T `json:"data"` | Data T `json:"data"` | ||||
| } | } | ||||
| func (r *response[T]) ToError() *api.CodeMessageError { | |||||
| return &api.CodeMessageError{ | |||||
| func (r *response[T]) ToError() *sdks.CodeMessageError { | |||||
| return &sdks.CodeMessageError{ | |||||
| Code: r.Code, | Code: r.Code, | ||||
| Message: r.Message, | Message: r.Message, | ||||
| } | } | ||||
| @@ -1,4 +1,4 @@ | |||||
| package storage | |||||
| package schsdk | |||||
| type Config struct { | type Config struct { | ||||
| URL string `json:"url"` | URL string `json:"url"` | ||||
| @@ -1,4 +1,4 @@ | |||||
| package scheduler | |||||
| package schsdk | |||||
| import ( | import ( | ||||
| "fmt" | "fmt" | ||||
| @@ -6,18 +6,17 @@ import ( | |||||
| "strings" | "strings" | ||||
| "gitlink.org.cn/cloudream/common/consts/errorcode" | "gitlink.org.cn/cloudream/common/consts/errorcode" | ||||
| "gitlink.org.cn/cloudream/common/models" | |||||
| myhttp "gitlink.org.cn/cloudream/common/utils/http" | myhttp "gitlink.org.cn/cloudream/common/utils/http" | ||||
| "gitlink.org.cn/cloudream/common/utils/serder" | "gitlink.org.cn/cloudream/common/utils/serder" | ||||
| ) | ) | ||||
| type JobSetSumbitReq struct { | type JobSetSumbitReq struct { | ||||
| models.JobSetInfo | |||||
| JobSetInfo | |||||
| } | } | ||||
| type JobSetSumbitResp struct { | type JobSetSumbitResp struct { | ||||
| JobSetID string `json:"jobSetID"` | |||||
| FilesUploadScheme models.JobSetFilesUploadScheme `json:"filesUploadScheme"` | |||||
| JobSetID string `json:"jobSetID"` | |||||
| FilesUploadScheme JobSetFilesUploadScheme `json:"filesUploadScheme"` | |||||
| } | } | ||||
| func (c *Client) JobSetSumbit(req JobSetSumbitReq) (*JobSetSumbitResp, error) { | func (c *Client) JobSetSumbit(req JobSetSumbitReq) (*JobSetSumbitResp, error) { | ||||
| @@ -1,7 +1,8 @@ | |||||
| package models | |||||
| package schsdk | |||||
| import ( | import ( | ||||
| "gitlink.org.cn/cloudream/common/pkgs/types" | "gitlink.org.cn/cloudream/common/pkgs/types" | ||||
| stgsdk "gitlink.org.cn/cloudream/common/sdks/storage" | |||||
| myreflect "gitlink.org.cn/cloudream/common/utils/reflect" | myreflect "gitlink.org.cn/cloudream/common/utils/reflect" | ||||
| "gitlink.org.cn/cloudream/common/utils/serder" | "gitlink.org.cn/cloudream/common/utils/serder" | ||||
| ) | ) | ||||
| @@ -52,10 +53,10 @@ type NormalJobInfo struct { | |||||
| type ResourceJobInfo struct { | type ResourceJobInfo struct { | ||||
| JobInfoBase | JobInfoBase | ||||
| Type string `json:"type" union:"Resource"` | |||||
| BucketID int64 `json:"bucketID"` | |||||
| Redundancy TypedRedundancyInfo `json:"redundancy"` | |||||
| TargetLocalJobID string `json:"targetLocalJobID"` | |||||
| Type string `json:"type" union:"Resource"` | |||||
| BucketID int64 `json:"bucketID"` | |||||
| Redundancy stgsdk.TypedRedundancyInfo `json:"redundancy"` | |||||
| TargetLocalJobID string `json:"targetLocalJobID"` | |||||
| } | } | ||||
| type JobFilesInfo struct { | type JobFilesInfo struct { | ||||
| @@ -1,10 +1,9 @@ | |||||
| package scheduler | |||||
| package schsdk | |||||
| import ( | import ( | ||||
| "testing" | "testing" | ||||
| . "github.com/smartystreets/goconvey/convey" | . "github.com/smartystreets/goconvey/convey" | ||||
| "gitlink.org.cn/cloudream/common/models" | |||||
| ) | ) | ||||
| func Test_JobSet(t *testing.T) { | func Test_JobSet(t *testing.T) { | ||||
| @@ -14,23 +13,23 @@ func Test_JobSet(t *testing.T) { | |||||
| }) | }) | ||||
| id, err := cli.JobSetSumbit(JobSetSumbitReq{ | id, err := cli.JobSetSumbit(JobSetSumbitReq{ | ||||
| JobSetInfo: models.JobSetInfo{ | |||||
| Jobs: []models.JobInfo{ | |||||
| &models.ResourceJobInfo{ | |||||
| Type: models.JobTypeResource, | |||||
| JobSetInfo: JobSetInfo{ | |||||
| Jobs: []JobInfo{ | |||||
| &ResourceJobInfo{ | |||||
| Type: JobTypeResource, | |||||
| }, | }, | ||||
| &models.NormalJobInfo{ | |||||
| Type: models.JobTypeNormal, | |||||
| Files: models.JobFilesInfo{ | |||||
| Dataset: &models.PackageJobFileInfo{ | |||||
| Type: models.FileInfoTypePackage, | |||||
| &NormalJobInfo{ | |||||
| Type: JobTypeNormal, | |||||
| Files: JobFilesInfo{ | |||||
| Dataset: &PackageJobFileInfo{ | |||||
| Type: FileInfoTypePackage, | |||||
| }, | }, | ||||
| Code: &models.LocalJobFileInfo{ | |||||
| Type: models.FileInfoTypeLocalFile, | |||||
| Code: &LocalJobFileInfo{ | |||||
| Type: FileInfoTypeLocalFile, | |||||
| LocalPath: "code", | LocalPath: "code", | ||||
| }, | }, | ||||
| Image: &models.ImageJobFileInfo{ | |||||
| Type: models.FileInfoTypeImage, | |||||
| Image: &ImageJobFileInfo{ | |||||
| Type: FileInfoTypeImage, | |||||
| }, | }, | ||||
| }, | }, | ||||
| }, | }, | ||||
| @@ -1,4 +1,4 @@ | |||||
| package api | |||||
| package sdks | |||||
| import "fmt" | import "fmt" | ||||
| @@ -1,4 +1,4 @@ | |||||
| package storage | |||||
| package stgsdk | |||||
| import ( | import ( | ||||
| "fmt" | "fmt" | ||||
| @@ -6,7 +6,6 @@ import ( | |||||
| "strings" | "strings" | ||||
| "gitlink.org.cn/cloudream/common/consts/errorcode" | "gitlink.org.cn/cloudream/common/consts/errorcode" | ||||
| "gitlink.org.cn/cloudream/common/models" | |||||
| myhttp "gitlink.org.cn/cloudream/common/utils/http" | myhttp "gitlink.org.cn/cloudream/common/utils/http" | ||||
| "gitlink.org.cn/cloudream/common/utils/serder" | "gitlink.org.cn/cloudream/common/utils/serder" | ||||
| ) | ) | ||||
| @@ -17,7 +16,7 @@ type CacheMovePackageReq struct { | |||||
| NodeID int64 `json:"nodeID"` | NodeID int64 `json:"nodeID"` | ||||
| } | } | ||||
| type CacheMovePackageResp struct { | type CacheMovePackageResp struct { | ||||
| CacheInfos []models.ObjectCacheInfo `json:"cacheInfos"` | |||||
| CacheInfos []ObjectCacheInfo `json:"cacheInfos"` | |||||
| } | } | ||||
| func (c *Client) CacheMovePackage(req CacheMovePackageReq) (*CacheMovePackageResp, error) { | func (c *Client) CacheMovePackage(req CacheMovePackageReq) (*CacheMovePackageResp, error) { | ||||
| @@ -1,6 +1,6 @@ | |||||
| package storage | |||||
| package stgsdk | |||||
| import "gitlink.org.cn/cloudream/common/api" | |||||
| import "gitlink.org.cn/cloudream/common/sdks" | |||||
| type response[T any] struct { | type response[T any] struct { | ||||
| Code string `json:"code"` | Code string `json:"code"` | ||||
| @@ -8,8 +8,8 @@ type response[T any] struct { | |||||
| Data T `json:"data"` | Data T `json:"data"` | ||||
| } | } | ||||
| func (r *response[T]) ToError() *api.CodeMessageError { | |||||
| return &api.CodeMessageError{ | |||||
| func (r *response[T]) ToError() *sdks.CodeMessageError { | |||||
| return &sdks.CodeMessageError{ | |||||
| Code: r.Code, | Code: r.Code, | ||||
| Message: r.Message, | Message: r.Message, | ||||
| } | } | ||||
| @@ -1,4 +1,4 @@ | |||||
| package unifyops | |||||
| package stgsdk | |||||
| type Config struct { | type Config struct { | ||||
| URL string `json:"url"` | URL string `json:"url"` | ||||
| @@ -1,4 +1,4 @@ | |||||
| package models | |||||
| package stgsdk | |||||
| import ( | import ( | ||||
| "fmt" | "fmt" | ||||
| @@ -1,4 +1,4 @@ | |||||
| package storage | |||||
| package stgsdk | |||||
| import ( | import ( | ||||
| "fmt" | "fmt" | ||||
| @@ -1,4 +1,4 @@ | |||||
| package storage | |||||
| package stgsdk | |||||
| import ( | import ( | ||||
| "fmt" | "fmt" | ||||
| @@ -7,19 +7,18 @@ import ( | |||||
| "strings" | "strings" | ||||
| "gitlink.org.cn/cloudream/common/consts/errorcode" | "gitlink.org.cn/cloudream/common/consts/errorcode" | ||||
| "gitlink.org.cn/cloudream/common/models" | |||||
| "gitlink.org.cn/cloudream/common/pkgs/iterator" | "gitlink.org.cn/cloudream/common/pkgs/iterator" | ||||
| myhttp "gitlink.org.cn/cloudream/common/utils/http" | myhttp "gitlink.org.cn/cloudream/common/utils/http" | ||||
| "gitlink.org.cn/cloudream/common/utils/serder" | "gitlink.org.cn/cloudream/common/utils/serder" | ||||
| ) | ) | ||||
| type PackageUploadReq struct { | type PackageUploadReq struct { | ||||
| UserID int64 `json:"userID"` | |||||
| BucketID int64 `json:"bucketID"` | |||||
| Name string `json:"name"` | |||||
| Redundancy models.TypedRedundancyInfo `json:"redundancy"` | |||||
| NodeAffinity *int64 `json:"nodeAffinity"` | |||||
| Files PackageUploadFileIterator `json:"-"` | |||||
| UserID int64 `json:"userID"` | |||||
| BucketID int64 `json:"bucketID"` | |||||
| Name string `json:"name"` | |||||
| Redundancy TypedRedundancyInfo `json:"redundancy"` | |||||
| NodeAffinity *int64 `json:"nodeAffinity"` | |||||
| Files PackageUploadFileIterator `json:"-"` | |||||
| } | } | ||||
| type IterPackageUploadFile struct { | type IterPackageUploadFile struct { | ||||
| @@ -118,7 +117,7 @@ type PackageGetCachedNodesReq struct { | |||||
| } | } | ||||
| type PackageGetCachedNodesResp struct { | type PackageGetCachedNodesResp struct { | ||||
| models.PackageCachingInfo | |||||
| PackageCachingInfo | |||||
| } | } | ||||
| func (c *Client) PackageGetCachedNodes(req PackageGetCachedNodesReq) (*PackageGetCachedNodesResp, error) { | func (c *Client) PackageGetCachedNodes(req PackageGetCachedNodesReq) (*PackageGetCachedNodesResp, error) { | ||||
| @@ -1,4 +1,4 @@ | |||||
| package storage | |||||
| package stgsdk | |||||
| import ( | import ( | ||||
| "fmt" | "fmt" | ||||
| @@ -6,7 +6,6 @@ import ( | |||||
| "strings" | "strings" | ||||
| "gitlink.org.cn/cloudream/common/consts/errorcode" | "gitlink.org.cn/cloudream/common/consts/errorcode" | ||||
| "gitlink.org.cn/cloudream/common/models" | |||||
| myhttp "gitlink.org.cn/cloudream/common/utils/http" | myhttp "gitlink.org.cn/cloudream/common/utils/http" | ||||
| "gitlink.org.cn/cloudream/common/utils/serder" | "gitlink.org.cn/cloudream/common/utils/serder" | ||||
| ) | ) | ||||
| @@ -48,12 +47,12 @@ func (c *Client) StorageLoadPackage(req StorageLoadPackageReq) error { | |||||
| } | } | ||||
| type StorageCreatePackageReq struct { | type StorageCreatePackageReq struct { | ||||
| UserID int64 `json:"userID"` | |||||
| StorageID int64 `json:"storageID"` | |||||
| Path string `json:"path"` | |||||
| BucketID int64 `json:"bucketID"` | |||||
| Name string `json:"name"` | |||||
| Redundancy models.TypedRedundancyInfo `json:"redundancy"` | |||||
| UserID int64 `json:"userID"` | |||||
| StorageID int64 `json:"storageID"` | |||||
| Path string `json:"path"` | |||||
| BucketID int64 `json:"bucketID"` | |||||
| Name string `json:"name"` | |||||
| Redundancy TypedRedundancyInfo `json:"redundancy"` | |||||
| } | } | ||||
| type StorageCreatePackageResp struct { | type StorageCreatePackageResp struct { | ||||
| @@ -1,4 +1,4 @@ | |||||
| package storage | |||||
| package stgsdk | |||||
| import ( | import ( | ||||
| "bytes" | "bytes" | ||||
| @@ -8,7 +8,6 @@ import ( | |||||
| "github.com/google/uuid" | "github.com/google/uuid" | ||||
| . "github.com/smartystreets/goconvey/convey" | . "github.com/smartystreets/goconvey/convey" | ||||
| "gitlink.org.cn/cloudream/common/models" | |||||
| "gitlink.org.cn/cloudream/common/pkgs/iterator" | "gitlink.org.cn/cloudream/common/pkgs/iterator" | ||||
| ) | ) | ||||
| @@ -28,9 +27,9 @@ func Test_Object(t *testing.T) { | |||||
| UserID: 0, | UserID: 0, | ||||
| BucketID: 1, | BucketID: 1, | ||||
| Name: uuid.NewString(), | Name: uuid.NewString(), | ||||
| Redundancy: models.TypedRedundancyInfo{ | |||||
| Type: models.RedundancyRep, | |||||
| Info: models.NewRepRedundancyInfo(1), | |||||
| Redundancy: TypedRedundancyInfo{ | |||||
| Type: RedundancyRep, | |||||
| Info: NewRepRedundancyInfo(1), | |||||
| }, | }, | ||||
| NodeAffinity: &nodeAff, | NodeAffinity: &nodeAff, | ||||
| Files: iterator.Array( | Files: iterator.Array( | ||||
| @@ -80,9 +79,9 @@ func Test_Storage(t *testing.T) { | |||||
| UserID: 0, | UserID: 0, | ||||
| BucketID: 1, | BucketID: 1, | ||||
| Name: uuid.NewString(), | Name: uuid.NewString(), | ||||
| Redundancy: models.TypedRedundancyInfo{ | |||||
| Type: models.RedundancyRep, | |||||
| Info: models.NewRepRedundancyInfo(1), | |||||
| Redundancy: TypedRedundancyInfo{ | |||||
| Type: RedundancyRep, | |||||
| Info: NewRepRedundancyInfo(1), | |||||
| }, | }, | ||||
| Files: iterator.Array( | Files: iterator.Array( | ||||
| &IterPackageUploadFile{ | &IterPackageUploadFile{ | ||||
| @@ -127,9 +126,9 @@ func Test_Cache(t *testing.T) { | |||||
| UserID: 0, | UserID: 0, | ||||
| BucketID: 1, | BucketID: 1, | ||||
| Name: uuid.NewString(), | Name: uuid.NewString(), | ||||
| Redundancy: models.TypedRedundancyInfo{ | |||||
| Type: models.RedundancyRep, | |||||
| Info: models.NewRepRedundancyInfo(1), | |||||
| Redundancy: TypedRedundancyInfo{ | |||||
| Type: RedundancyRep, | |||||
| Info: NewRepRedundancyInfo(1), | |||||
| }, | }, | ||||
| Files: iterator.Array( | Files: iterator.Array( | ||||
| &IterPackageUploadFile{ | &IterPackageUploadFile{ | ||||
| @@ -1,4 +1,4 @@ | |||||
| package storage | |||||
| package stgsdk | |||||
| import "path/filepath" | import "path/filepath" | ||||
| @@ -1,9 +1,9 @@ | |||||
| package unifyops | |||||
| package uopsdk | |||||
| import ( | import ( | ||||
| "fmt" | "fmt" | ||||
| "gitlink.org.cn/cloudream/common/api" | |||||
| "gitlink.org.cn/cloudream/common/sdks" | |||||
| ) | ) | ||||
| type response[T any] struct { | type response[T any] struct { | ||||
| @@ -12,8 +12,8 @@ type response[T any] struct { | |||||
| Data T `json:"data"` | Data T `json:"data"` | ||||
| } | } | ||||
| func (r *response[T]) ToError() *api.CodeMessageError { | |||||
| return &api.CodeMessageError{ | |||||
| func (r *response[T]) ToError() *sdks.CodeMessageError { | |||||
| return &sdks.CodeMessageError{ | |||||
| Code: fmt.Sprintf("%d", r.Code), | Code: fmt.Sprintf("%d", r.Code), | ||||
| Message: r.Message, | Message: r.Message, | ||||
| } | } | ||||
| @@ -1,4 +1,4 @@ | |||||
| package scheduler | |||||
| package uopsdk | |||||
| type Config struct { | type Config struct { | ||||
| URL string `json:"url"` | URL string `json:"url"` | ||||
| @@ -1,4 +1,4 @@ | |||||
| package models | |||||
| package uopsdk | |||||
| import ( | import ( | ||||
| "gitlink.org.cn/cloudream/common/pkgs/types" | "gitlink.org.cn/cloudream/common/pkgs/types" | ||||
| @@ -1,11 +1,10 @@ | |||||
| package unifyops | |||||
| package uopsdk | |||||
| import ( | import ( | ||||
| "fmt" | "fmt" | ||||
| "net/url" | "net/url" | ||||
| "strings" | "strings" | ||||
| "gitlink.org.cn/cloudream/common/models" | |||||
| myhttp "gitlink.org.cn/cloudream/common/utils/http" | myhttp "gitlink.org.cn/cloudream/common/utils/http" | ||||
| "gitlink.org.cn/cloudream/common/utils/serder" | "gitlink.org.cn/cloudream/common/utils/serder" | ||||
| ) | ) | ||||
| @@ -13,7 +12,7 @@ import ( | |||||
| const CORRECT_CODE int = 200 | const CORRECT_CODE int = 200 | ||||
| type GetAllSlwNodeInfoResp struct { | type GetAllSlwNodeInfoResp struct { | ||||
| Nodes []models.SlwNode `json:"nodes"` | |||||
| Nodes []SlwNode `json:"nodes"` | |||||
| } | } | ||||
| func (c *Client) GetAllSlwNodeInfo() (*GetAllSlwNodeInfoResp, error) { | func (c *Client) GetAllSlwNodeInfo() (*GetAllSlwNodeInfoResp, error) { | ||||
| @@ -44,10 +43,10 @@ func (c *Client) GetAllSlwNodeInfo() (*GetAllSlwNodeInfoResp, error) { | |||||
| } | } | ||||
| type GetOneResourceDataReq struct { | type GetOneResourceDataReq struct { | ||||
| SlwNodeID models.SlwNodeID `json:"nodeId"` | |||||
| SlwNodeID SlwNodeID `json:"nodeId"` | |||||
| } | } | ||||
| func (c *Client) GetCPUData(node GetOneResourceDataReq) (*models.CPUResourceData, error) { | |||||
| func (c *Client) GetCPUData(node GetOneResourceDataReq) (*CPUResourceData, error) { | |||||
| url, err := url.JoinPath(c.baseURL, "/cmdb/resApi/getCPUData") | url, err := url.JoinPath(c.baseURL, "/cmdb/resApi/getCPUData") | ||||
| if err != nil { | if err != nil { | ||||
| return nil, err | return nil, err | ||||
| @@ -62,7 +61,7 @@ func (c *Client) GetCPUData(node GetOneResourceDataReq) (*models.CPUResourceData | |||||
| contType := resp.Header.Get("Content-Type") | contType := resp.Header.Get("Content-Type") | ||||
| if strings.Contains(contType, myhttp.ContentTypeJSON) { | if strings.Contains(contType, myhttp.ContentTypeJSON) { | ||||
| var codeResp response[models.CPUResourceData] | |||||
| var codeResp response[CPUResourceData] | |||||
| 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) | ||||
| } | } | ||||
| @@ -77,7 +76,7 @@ func (c *Client) GetCPUData(node GetOneResourceDataReq) (*models.CPUResourceData | |||||
| return nil, fmt.Errorf("unknow response content type: %s", contType) | return nil, fmt.Errorf("unknow response content type: %s", contType) | ||||
| } | } | ||||
| func (c *Client) GetNPUData(node GetOneResourceDataReq) (*models.NPUResourceData, error) { | |||||
| func (c *Client) GetNPUData(node GetOneResourceDataReq) (*NPUResourceData, error) { | |||||
| url, err := url.JoinPath(c.baseURL, "/cmdb/resApi/getNPUData") | url, err := url.JoinPath(c.baseURL, "/cmdb/resApi/getNPUData") | ||||
| if err != nil { | if err != nil { | ||||
| return nil, err | return nil, err | ||||
| @@ -92,7 +91,7 @@ func (c *Client) GetNPUData(node GetOneResourceDataReq) (*models.NPUResourceData | |||||
| contType := resp.Header.Get("Content-Type") | contType := resp.Header.Get("Content-Type") | ||||
| if strings.Contains(contType, myhttp.ContentTypeJSON) { | if strings.Contains(contType, myhttp.ContentTypeJSON) { | ||||
| var codeResp response[models.NPUResourceData] | |||||
| var codeResp response[NPUResourceData] | |||||
| 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) | ||||
| } | } | ||||
| @@ -107,7 +106,7 @@ func (c *Client) GetNPUData(node GetOneResourceDataReq) (*models.NPUResourceData | |||||
| return nil, fmt.Errorf("unknow response content type: %s", contType) | return nil, fmt.Errorf("unknow response content type: %s", contType) | ||||
| } | } | ||||
| func (c *Client) GetGPUData(node GetOneResourceDataReq) (*models.GPUResourceData, error) { | |||||
| func (c *Client) GetGPUData(node GetOneResourceDataReq) (*GPUResourceData, error) { | |||||
| url, err := url.JoinPath(c.baseURL, "/cmdb/resApi/getGPUData") | url, err := url.JoinPath(c.baseURL, "/cmdb/resApi/getGPUData") | ||||
| if err != nil { | if err != nil { | ||||
| return nil, err | return nil, err | ||||
| @@ -122,7 +121,7 @@ func (c *Client) GetGPUData(node GetOneResourceDataReq) (*models.GPUResourceData | |||||
| contType := resp.Header.Get("Content-Type") | contType := resp.Header.Get("Content-Type") | ||||
| if strings.Contains(contType, myhttp.ContentTypeJSON) { | if strings.Contains(contType, myhttp.ContentTypeJSON) { | ||||
| var codeResp response[models.GPUResourceData] | |||||
| var codeResp response[GPUResourceData] | |||||
| 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) | ||||
| } | } | ||||
| @@ -137,7 +136,7 @@ func (c *Client) GetGPUData(node GetOneResourceDataReq) (*models.GPUResourceData | |||||
| return nil, fmt.Errorf("unknow response content type: %s", contType) | return nil, fmt.Errorf("unknow response content type: %s", contType) | ||||
| } | } | ||||
| func (c *Client) GetMLUData(node GetOneResourceDataReq) (*models.MLUResourceData, error) { | |||||
| func (c *Client) GetMLUData(node GetOneResourceDataReq) (*MLUResourceData, error) { | |||||
| url, err := url.JoinPath(c.baseURL, "/cmdb/resApi/getMLUData") | url, err := url.JoinPath(c.baseURL, "/cmdb/resApi/getMLUData") | ||||
| if err != nil { | if err != nil { | ||||
| return nil, err | return nil, err | ||||
| @@ -152,7 +151,7 @@ func (c *Client) GetMLUData(node GetOneResourceDataReq) (*models.MLUResourceData | |||||
| contType := resp.Header.Get("Content-Type") | contType := resp.Header.Get("Content-Type") | ||||
| if strings.Contains(contType, myhttp.ContentTypeJSON) { | if strings.Contains(contType, myhttp.ContentTypeJSON) { | ||||
| var codeResp response[models.MLUResourceData] | |||||
| var codeResp response[MLUResourceData] | |||||
| 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) | ||||
| } | } | ||||
| @@ -167,7 +166,7 @@ func (c *Client) GetMLUData(node GetOneResourceDataReq) (*models.MLUResourceData | |||||
| return nil, fmt.Errorf("unknow response content type: %s", contType) | return nil, fmt.Errorf("unknow response content type: %s", contType) | ||||
| } | } | ||||
| func (c *Client) GetStorageData(node GetOneResourceDataReq) (*models.StorageResourceData, error) { | |||||
| func (c *Client) GetStorageData(node GetOneResourceDataReq) (*StorageResourceData, error) { | |||||
| url, err := url.JoinPath(c.baseURL, "/cmdb/resApi/getStorageData") | url, err := url.JoinPath(c.baseURL, "/cmdb/resApi/getStorageData") | ||||
| if err != nil { | if err != nil { | ||||
| return nil, err | return nil, err | ||||
| @@ -182,7 +181,7 @@ func (c *Client) GetStorageData(node GetOneResourceDataReq) (*models.StorageReso | |||||
| contType := resp.Header.Get("Content-Type") | contType := resp.Header.Get("Content-Type") | ||||
| if strings.Contains(contType, myhttp.ContentTypeJSON) { | if strings.Contains(contType, myhttp.ContentTypeJSON) { | ||||
| var codeResp response[models.StorageResourceData] | |||||
| var codeResp response[StorageResourceData] | |||||
| 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) | ||||
| } | } | ||||
| @@ -197,7 +196,7 @@ func (c *Client) GetStorageData(node GetOneResourceDataReq) (*models.StorageReso | |||||
| return nil, fmt.Errorf("unknow response content type: %s", contType) | return nil, fmt.Errorf("unknow response content type: %s", contType) | ||||
| } | } | ||||
| func (c *Client) GetMemoryData(node GetOneResourceDataReq) (*models.MemoryResourceData, error) { | |||||
| func (c *Client) GetMemoryData(node GetOneResourceDataReq) (*MemoryResourceData, error) { | |||||
| url, err := url.JoinPath(c.baseURL, "/cmdb/resApi/getMemoryData") | url, err := url.JoinPath(c.baseURL, "/cmdb/resApi/getMemoryData") | ||||
| if err != nil { | if err != nil { | ||||
| return nil, err | return nil, err | ||||
| @@ -212,7 +211,7 @@ func (c *Client) GetMemoryData(node GetOneResourceDataReq) (*models.MemoryResour | |||||
| contType := resp.Header.Get("Content-Type") | contType := resp.Header.Get("Content-Type") | ||||
| if strings.Contains(contType, myhttp.ContentTypeJSON) { | if strings.Contains(contType, myhttp.ContentTypeJSON) { | ||||
| var codeResp response[models.MemoryResourceData] | |||||
| var codeResp response[MemoryResourceData] | |||||
| 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) | ||||
| } | } | ||||
| @@ -227,7 +226,7 @@ func (c *Client) GetMemoryData(node GetOneResourceDataReq) (*models.MemoryResour | |||||
| return nil, fmt.Errorf("unknow response content type: %s", contType) | return nil, fmt.Errorf("unknow response content type: %s", contType) | ||||
| } | } | ||||
| func (c *Client) GetIndicatorData(node GetOneResourceDataReq) (*[]models.ResourceData, error) { | |||||
| func (c *Client) GetIndicatorData(node GetOneResourceDataReq) (*[]ResourceData, error) { | |||||
| url, err := url.JoinPath(c.baseURL, "/cmdb/resApi/getIndicatorData") | url, err := url.JoinPath(c.baseURL, "/cmdb/resApi/getIndicatorData") | ||||
| if err != nil { | if err != nil { | ||||
| return nil, err | return nil, err | ||||
| @@ -253,12 +252,12 @@ func (c *Client) GetIndicatorData(node GetOneResourceDataReq) (*[]models.Resourc | |||||
| mapToObjOpt := serder.MapToObjectOption{ | mapToObjOpt := serder.MapToObjectOption{ | ||||
| UnionTypes: []serder.TaggedUnionType{ | UnionTypes: []serder.TaggedUnionType{ | ||||
| models.ResourceDataTaggedTypeUnion, | |||||
| ResourceDataTaggedTypeUnion, | |||||
| }, | }, | ||||
| } | } | ||||
| var ret []models.ResourceData | |||||
| var ret []ResourceData | |||||
| for _, mp := range codeResp.Data { | for _, mp := range codeResp.Data { | ||||
| var data models.ResourceData | |||||
| var data ResourceData | |||||
| err := serder.MapToObject(mp, &data, mapToObjOpt) | err := serder.MapToObject(mp, &data, mapToObjOpt) | ||||
| if err != nil { | if err != nil { | ||||
| return nil, err | return nil, err | ||||
| @@ -1,4 +1,4 @@ | |||||
| package unifyops | |||||
| package uopsdk | |||||
| import ( | import ( | ||||
| "fmt" | "fmt" | ||||