Files
decort-golang-sdk/pkg/cloudapi/k8s/get_node_annotations.go

37 lines
907 B
Go
Raw Normal View History

2022-10-03 16:56:47 +03:00
package k8s
import (
"context"
"net/http"
2023-03-24 17:09:30 +03:00
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
2022-10-03 16:56:47 +03:00
)
2023-10-25 17:37:18 +03:00
// GetNodeAnnotationsRequest struct to get node annotations
2022-10-03 16:56:47 +03:00
type GetNodeAnnotationsRequest struct {
2022-12-22 17:56:47 +03:00
// Kubernetes cluster ID
// Required: true
2023-03-24 17:09:30 +03:00
K8SID uint64 `url:"k8sId" json:"k8sId" validate:"required"`
2022-12-22 17:56:47 +03:00
// Node ID
// Required: true
2023-03-24 17:09:30 +03:00
NodeID uint64 `url:"nodeId" json:"nodeId" validate:"required"`
2022-10-03 16:56:47 +03:00
}
2022-12-22 17:56:47 +03:00
// GetNodeAnnotations gets kubernetes cluster worker node annotations
2022-10-03 16:56:47 +03:00
func (k8s K8S) GetNodeAnnotations(ctx context.Context, req GetNodeAnnotationsRequest) (string, error) {
2023-03-24 17:09:30 +03:00
err := validators.ValidateRequest(req)
2022-10-03 16:56:47 +03:00
if err != nil {
2023-10-25 17:37:18 +03:00
return "", validators.ValidationErrors(validators.GetErrors(err))
2022-10-03 16:56:47 +03:00
}
url := "/cloudapi/k8s/getNodeAnnotations"
res, err := k8s.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return "", err
}
return string(res), nil
}