This commit is contained in:
stSolo
2022-12-22 17:56:47 +03:00
parent 8712561853
commit d4b1ab7133
672 changed files with 28509 additions and 4419 deletions

View File

@@ -7,11 +7,14 @@ import (
"net/http"
)
// Request struct for get information about K8CI
type GetRequest struct {
// ID of the K8 catalog item to get
// Required: true
K8CIID uint64 `url:"k8ciId"`
}
func (krq GetRequest) Validate() error {
func (krq GetRequest) validate() error {
if krq.K8CIID == 0 {
return errors.New("field K8CIID can not be empty or equal to 0")
}
@@ -19,21 +22,24 @@ func (krq GetRequest) Validate() error {
return nil
}
func (k K8CI) Get(ctx context.Context, req GetRequest) (*K8CIRecord, error) {
if err := req.Validate(); err != nil {
// Get gets details of the specified K8 catalog item
func (k K8CI) Get(ctx context.Context, req GetRequest) (*RecordK8CI, error) {
if err := req.validate(); err != nil {
return nil, err
}
url := "/cloudapi/k8ci/get"
k8ciRaw, err := k.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return nil, err
}
k8ci := &K8CIRecord{}
if err := json.Unmarshal(k8ciRaw, k8ci); err != nil {
info := RecordK8CI{}
err = json.Unmarshal(res, &info)
if err != nil {
return nil, err
}
return k8ci, nil
return &info, nil
}