Merge 'dev' into 'main'

This commit is contained in:
stSolo
2022-10-03 16:56:47 +03:00
parent 6271fa6d45
commit 5fd450382c
400 changed files with 14394 additions and 13407 deletions

View File

@@ -1,49 +1,39 @@
package k8s
import (
"context"
"errors"
"github.com/rudecs/decort-sdk/opts"
"github.com/rudecs/decort-sdk/typed"
)
type GetNodeAnnotationsRequest struct {
K8SId uint64 `url:"k8sId"`
NodeId uint64 `url:"nodeId"`
}
func (krq GetNodeAnnotationsRequest) Validate() error {
if krq.K8SId == 0 {
return errors.New("validation-error: field K8SId can not be empty or equal to 0")
}
if krq.NodeId == 0 {
return errors.New("validation-error: field NodeId can not be empty or equal to 0")
}
return nil
}
func (k8s K8S) GetNodeAnnotations(ctx context.Context, req GetNodeAnnotationsRequest, options ...opts.DecortOpts) (string, error) {
err := req.Validate()
if err != nil {
return "", err
}
url := "/k8s/getNodeAnnotations"
prefix := "/cloudapi"
option := opts.New(options)
if option != nil {
if option.IsAdmin {
prefix = "/" + option.AdminValue
}
}
url = prefix + url
res, err := k8s.client.DecortApiCall(ctx, typed.POST, url, req)
if err != nil {
return "", err
}
return string(res), nil
}
package k8s
import (
"context"
"errors"
"net/http"
)
type GetNodeAnnotationsRequest struct {
K8SID uint64 `url:"k8sId"`
NodeID uint64 `url:"nodeId"`
}
func (krq GetNodeAnnotationsRequest) Validate() error {
if krq.K8SID == 0 {
return errors.New("validation-error: field K8SID can not be empty or equal to 0")
}
if krq.NodeID == 0 {
return errors.New("validation-error: field NodeID can not be empty or equal to 0")
}
return nil
}
func (k8s K8S) GetNodeAnnotations(ctx context.Context, req GetNodeAnnotationsRequest) (string, error) {
err := req.Validate()
if err != nil {
return "", err
}
url := "/cloudapi/k8s/getNodeAnnotations"
res, err := k8s.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return "", err
}
return string(res), nil
}