v1.3.0
This commit is contained in:
@@ -2,28 +2,29 @@ package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// Request struct for create kubernetes cluster
|
||||
type CreateRequest struct {
|
||||
// Name of Kubernetes cluster
|
||||
// Required: true
|
||||
Name string `url:"name" json:"name"`
|
||||
Name string `url:"name" json:"name" validate:"required"`
|
||||
|
||||
// Resource Group ID for cluster placement
|
||||
// Required: true
|
||||
RGID uint64 `url:"rgId" json:"rgId"`
|
||||
RGID uint64 `url:"rgId" json:"rgId" validate:"required"`
|
||||
|
||||
// ID of Kubernetes catalog item (k8sci) for cluster
|
||||
// Required: true
|
||||
K8SCIID uint64 `url:"k8ciId" json:"k8ciId"`
|
||||
K8SCIID uint64 `url:"k8ciId" json:"k8ciId" validate:"required"`
|
||||
|
||||
// Name for first worker group created with cluster
|
||||
// Required: true
|
||||
WorkerGroupName string `url:"workerGroupName" json:"workerGroupName"`
|
||||
WorkerGroupName string `url:"workerGroupName" json:"workerGroupName" validate:"required"`
|
||||
|
||||
// ID of SEP to create boot disks for master nodes. Uses images SEP ID if not set
|
||||
// Required: false
|
||||
@@ -102,28 +103,13 @@ type CreateRequest struct {
|
||||
Description string `url:"desc,omitempty" json:"desc,omitempty"`
|
||||
}
|
||||
|
||||
func (krq CreateRequest) validate() error {
|
||||
if krq.Name == "" {
|
||||
return errors.New("validation-error: field Name can not be empty")
|
||||
}
|
||||
if krq.RGID == 0 {
|
||||
return errors.New("validation-error: field RGID can not be empty or equal to 0")
|
||||
}
|
||||
if krq.K8SCIID == 0 {
|
||||
return errors.New("validation-error: field K8SCIID can not be empty or equal to 0")
|
||||
}
|
||||
if krq.WorkerGroupName == "" {
|
||||
return errors.New("validation-error: field WorkerGroupName can not be empty")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Create creates a new Kubernetes cluster in the specified Resource Group
|
||||
func (k8s K8S) Create(ctx context.Context, req CreateRequest) (string, error) {
|
||||
err := req.validate()
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", err
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return "", validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudapi/k8s/create"
|
||||
|
||||
@@ -2,36 +2,31 @@ package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// Request struct for delete kubernetes cluster
|
||||
type DeleteRequest struct {
|
||||
// Kubernetes cluster ID
|
||||
// Required: true
|
||||
K8SID uint64 `url:"k8sId" json:"k8sId"`
|
||||
K8SID uint64 `url:"k8sId" json:"k8sId" validate:"required"`
|
||||
|
||||
// True if cluster is destroyed permanently.
|
||||
// Otherwise it can be restored from Recycle Bin
|
||||
// Required: true
|
||||
Permanently bool `url:"permanently" json:"permanently"`
|
||||
}
|
||||
|
||||
func (krq DeleteRequest) validate() error {
|
||||
if krq.K8SID == 0 {
|
||||
return errors.New("validation-error: field K8SID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
Permanently bool `url:"permanently" json:"permanently" validate:"required"`
|
||||
}
|
||||
|
||||
// Delete deletes kubernetes cluster
|
||||
func (k8s K8S) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
|
||||
err := req.validate()
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return false, validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudapi/k8s/delete"
|
||||
|
||||
@@ -2,45 +2,34 @@ package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// Request struct for delete master from group
|
||||
type DeleteMasterFromGroupRequest struct {
|
||||
// Kubernetes cluster ID
|
||||
// Required: true
|
||||
K8SID uint64 `url:"k8sId" json:"k8sId"`
|
||||
K8SID uint64 `url:"k8sId" json:"k8sId" validate:"required"`
|
||||
|
||||
// ID of the masters compute group
|
||||
// Required: true
|
||||
MasterGroupID uint64 `url:"masterGroupId" json:"masterGroupId"`
|
||||
MasterGroupID uint64 `url:"masterGroupId" json:"masterGroupId" validate:"required"`
|
||||
|
||||
// List of Compute IDs of master nodes to delete
|
||||
// Required: true
|
||||
MasterIDs []string `url:"masterIds" json:"masterIds"`
|
||||
}
|
||||
|
||||
func (krq DeleteMasterFromGroupRequest) validate() error {
|
||||
if krq.K8SID == 0 {
|
||||
return errors.New("validation-error: field K8SID can not be empty or equal to 0")
|
||||
}
|
||||
if krq.MasterGroupID == 0 {
|
||||
return errors.New("validation-error: field MasterGroupID can not be empty or equal to 0")
|
||||
}
|
||||
if len(krq.MasterIDs) == 0 {
|
||||
return errors.New("validation-error: field MasterIDs can not be empty")
|
||||
}
|
||||
|
||||
return nil
|
||||
MasterIDs []string `url:"masterIds" json:"masterIds" validate:"min=1"`
|
||||
}
|
||||
|
||||
// DeleteMasterFromGroup deletes compute from masters group in selected Kubernetes cluster
|
||||
func (k8s K8S) DeleteMasterFromGroup(ctx context.Context, req DeleteMasterFromGroupRequest) (bool, error) {
|
||||
err := req.validate()
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return false, validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudapi/k8s/deleteMasterFromGroup"
|
||||
|
||||
@@ -2,45 +2,34 @@ package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// Request struct for delete worker from group
|
||||
type DeleteWorkerFromGroupRequest struct {
|
||||
// Kubernetes cluster ID
|
||||
// Required: true
|
||||
K8SID uint64 `url:"k8sId" json:"k8sId"`
|
||||
K8SID uint64 `url:"k8sId" json:"k8sId" validate:"required"`
|
||||
|
||||
// ID of the workers compute group
|
||||
// Required: true
|
||||
WorkersGroupID uint64 `url:"workersGroupId" json:"workersGroupId"`
|
||||
WorkersGroupID uint64 `url:"workersGroupId" json:"workersGroupId" validate:"required"`
|
||||
|
||||
// Compute ID of worker node to delete
|
||||
// Required: true
|
||||
WorkerID uint64 `url:"workerId" json:"workerId"`
|
||||
}
|
||||
|
||||
func (krq DeleteWorkerFromGroupRequest) validate() error {
|
||||
if krq.K8SID == 0 {
|
||||
return errors.New("validation-error: field K8SID can not be empty or equal to 0")
|
||||
}
|
||||
if krq.WorkersGroupID == 0 {
|
||||
return errors.New("validation-error: field WorkersGroupID can not be empty or equal to 0")
|
||||
}
|
||||
if krq.WorkerID == 0 {
|
||||
return errors.New("validation-error: field WorkerID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
WorkerID uint64 `url:"workerId" json:"workerId" validate:"required"`
|
||||
}
|
||||
|
||||
// DeleteWorkerFromGroup deletes worker compute from workers group in selected Kubernetes cluster
|
||||
func (k8s K8S) DeleteWorkerFromGroup(ctx context.Context, req DeleteWorkerFromGroupRequest) (bool, error) {
|
||||
err := req.validate()
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return false, validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudapi/k8s/deleteWorkerFromGroup"
|
||||
|
||||
@@ -2,31 +2,26 @@ package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// Request struct for disable/enable kubernetes cluster
|
||||
type DisabelEnableRequest struct {
|
||||
// Kubernetes cluster ID
|
||||
// Required: true
|
||||
K8SID uint64 `url:"k8sId" json:"k8sId"`
|
||||
}
|
||||
|
||||
func (krq DisabelEnableRequest) validate() error {
|
||||
if krq.K8SID == 0 {
|
||||
return errors.New("validation-error: field K8SID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
K8SID uint64 `url:"k8sId" json:"k8sId" validate:"required"`
|
||||
}
|
||||
|
||||
// Disable disables kubernetes cluster by ID
|
||||
func (k8s K8S) Disable(ctx context.Context, req DisabelEnableRequest) (bool, error) {
|
||||
err := req.validate()
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return false, validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudapi/k8s/disable"
|
||||
@@ -46,9 +41,11 @@ func (k8s K8S) Disable(ctx context.Context, req DisabelEnableRequest) (bool, err
|
||||
|
||||
// Enable enables kubernetes cluster by ID
|
||||
func (k8s K8S) Enable(ctx context.Context, req DisabelEnableRequest) (bool, error) {
|
||||
err := req.validate()
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return false, validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudapi/k8s/enable"
|
||||
|
||||
@@ -3,42 +3,34 @@ package k8s
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// Request struct for get information about group of kubernetes cluster
|
||||
type FindGroupByLabelRequest struct {
|
||||
// Kubernetes cluster ID
|
||||
// Required: true
|
||||
K8SID uint64 `url:"k8sId" json:"k8sId"`
|
||||
K8SID uint64 `url:"k8sId" json:"k8sId" validate:"required"`
|
||||
|
||||
// List of labels to search
|
||||
// Required: true
|
||||
Labels []string `url:"labels" json:"labels"`
|
||||
Labels []string `url:"labels" json:"labels" validate:"min=1"`
|
||||
|
||||
// If true and more than one label provided, select only groups that have all provided labels.
|
||||
// If false - groups that have at least one label
|
||||
// Required: true
|
||||
Strict bool `url:"strict" json:"strict"`
|
||||
}
|
||||
|
||||
func (krq FindGroupByLabelRequest) validate() error {
|
||||
if krq.K8SID == 0 {
|
||||
return errors.New("validation-error: field K8SID can not be empty or equal to 0")
|
||||
}
|
||||
if len(krq.Labels) == 0 {
|
||||
return errors.New("validation-error: field Labels can not be empty")
|
||||
}
|
||||
|
||||
return nil
|
||||
// Required: false
|
||||
Strict bool `url:"strict,omitempty" json:"strict,omitempty"`
|
||||
}
|
||||
|
||||
// FindGroupByLabel find worker group information by one on more labels
|
||||
func (k8s K8S) FindGroupByLabel(ctx context.Context, req FindGroupByLabelRequest) (ListK8SGroups, error) {
|
||||
err := req.validate()
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return nil, validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudapi/k8s/findGroupByLabel"
|
||||
|
||||
@@ -3,30 +3,25 @@ package k8s
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// Request struct for get detailed information about kubernetes cluster
|
||||
type GetRequest struct {
|
||||
// Kubernetes cluster ID
|
||||
// Required: true
|
||||
K8SID uint64 `url:"k8sId" json:"k8sId"`
|
||||
}
|
||||
|
||||
func (krq GetRequest) validate() error {
|
||||
if krq.K8SID == 0 {
|
||||
return errors.New("validation-error: field K8SID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
K8SID uint64 `url:"k8sId" json:"k8sId" validate:"required"`
|
||||
}
|
||||
|
||||
// Get gets information about Kubernetes cluster
|
||||
func (k8s K8S) Get(ctx context.Context, req GetRequest) (*RecordK8S, error) {
|
||||
err := req.validate()
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return nil, validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudapi/k8s/get"
|
||||
|
||||
@@ -2,30 +2,25 @@ package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// Request struct for get configuration of kubernetes cluster
|
||||
type GetConfigRequest struct {
|
||||
// Kubernetes cluster ID
|
||||
// Required: true
|
||||
K8SID uint64 `url:"k8sId" json:"k8sId"`
|
||||
}
|
||||
|
||||
func (krq GetConfigRequest) validate() error {
|
||||
if krq.K8SID == 0 {
|
||||
return errors.New("validation-error: field K8SID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
K8SID uint64 `url:"k8sId" json:"k8sId" validate:"required"`
|
||||
}
|
||||
|
||||
// GetConfig gets configuration data to access Kubernetes cluster
|
||||
func (k8s K8S) GetConfig(ctx context.Context, req GetConfigRequest) (string, error) {
|
||||
err := req.validate()
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", err
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return "", validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudapi/k8s/getConfig"
|
||||
|
||||
@@ -2,37 +2,29 @@ package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// Request struct for get node annotations
|
||||
type GetNodeAnnotationsRequest struct {
|
||||
// Kubernetes cluster ID
|
||||
// Required: true
|
||||
K8SID uint64 `url:"k8sId" json:"k8sId"`
|
||||
K8SID uint64 `url:"k8sId" json:"k8sId" validate:"required"`
|
||||
|
||||
// Node ID
|
||||
// Required: true
|
||||
NodeID uint64 `url:"nodeId" json:"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
|
||||
NodeID uint64 `url:"nodeId" json:"nodeId" validate:"required"`
|
||||
}
|
||||
|
||||
// GetNodeAnnotations gets kubernetes cluster worker node annotations
|
||||
func (k8s K8S) GetNodeAnnotations(ctx context.Context, req GetNodeAnnotationsRequest) (string, error) {
|
||||
err := req.validate()
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", err
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return "", validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudapi/k8s/getNodeAnnotations"
|
||||
|
||||
@@ -2,37 +2,29 @@ package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// Request struct for get node labels
|
||||
type GetNodeLabelsRequest struct {
|
||||
// Kubernetes cluster ID
|
||||
// Required: true
|
||||
K8SID uint64 `url:"k8sId" json:"k8sId"`
|
||||
K8SID uint64 `url:"k8sId" json:"k8sId" validate:"required"`
|
||||
|
||||
// Node ID
|
||||
// Required: false
|
||||
NodeID uint64 `url:"nodeId" json:"nodeId"`
|
||||
}
|
||||
|
||||
func (krq GetNodeLabelsRequest) 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
|
||||
// Required: true
|
||||
NodeID uint64 `url:"nodeId" json:"nodeId" validate:"required"`
|
||||
}
|
||||
|
||||
// GetNodeLabels gets kubernetes cluster worker node labels
|
||||
func (k8s K8S) GetNodeLabels(ctx context.Context, req GetNodeLabelsRequest) (string, error) {
|
||||
err := req.validate()
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", err
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return "", validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudapi/k8s/getNodeLabels"
|
||||
|
||||
@@ -2,37 +2,29 @@ package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// Request struct for get node taints
|
||||
type GetNodeTaintsRequest struct {
|
||||
// Kubernetes cluster ID
|
||||
// Required: true
|
||||
K8SID uint64 `url:"k8sId" json:"k8sId"`
|
||||
K8SID uint64 `url:"k8sId" json:"k8sId" validate:"required"`
|
||||
|
||||
// Node ID
|
||||
// Required: false
|
||||
NodeID uint64 `url:"nodeId" json:"nodeId"`
|
||||
}
|
||||
|
||||
func (krq GetNodeTaintsRequest) 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
|
||||
// Required: true
|
||||
NodeID uint64 `url:"nodeId" json:"nodeId" validate:"required"`
|
||||
}
|
||||
|
||||
// GetNodeTaints gets kubernetes cluster worker node taints
|
||||
func (k8s K8S) GetNodeTaints(ctx context.Context, req GetNodeTaintsRequest) (string, error) {
|
||||
err := req.validate()
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", err
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return "", validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudapi/k8s/getNodeTaints"
|
||||
|
||||
@@ -2,31 +2,26 @@ package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// Request struct for restore kubernetes cluster
|
||||
type RestoreRequest struct {
|
||||
// Kubernetes cluster ID
|
||||
// Required: true
|
||||
K8SID uint64 `url:"k8sId" json:"k8sId"`
|
||||
}
|
||||
|
||||
func (krq RestoreRequest) validate() error {
|
||||
if krq.K8SID == 0 {
|
||||
return errors.New("validation-error: field K8SID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
K8SID uint64 `url:"k8sId" json:"k8sId" validate:"required"`
|
||||
}
|
||||
|
||||
// Restore restore kubernetes cluster from Recycle Bin
|
||||
func (k8s K8S) Restore(ctx context.Context, req RestoreRequest) (bool, error) {
|
||||
err := req.validate()
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return false, validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudapi/k8s/restore"
|
||||
|
||||
@@ -2,31 +2,26 @@ package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// Request struct for start kubernetes cluster
|
||||
type StartRequest struct {
|
||||
// Kubernetes cluster ID
|
||||
// Required: true
|
||||
K8SID uint64 `url:"k8sId" json:"k8sId"`
|
||||
}
|
||||
|
||||
func (krq StartRequest) validate() error {
|
||||
if krq.K8SID == 0 {
|
||||
return errors.New("validation-error: field K8SID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
K8SID uint64 `url:"k8sId" json:"k8sId" validate:"required"`
|
||||
}
|
||||
|
||||
// Start starts kubernetes cluster by ID
|
||||
func (k8s K8S) Start(ctx context.Context, req StartRequest) (bool, error) {
|
||||
err := req.validate()
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return false, validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudapi/k8s/start"
|
||||
|
||||
@@ -2,31 +2,26 @@ package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// Request struct for stop kubernetes cluster
|
||||
type StopRequest struct {
|
||||
// Kubernetes cluster ID
|
||||
// Required: true
|
||||
K8SID uint64 `url:"k8sId" json:"k8sId"`
|
||||
}
|
||||
|
||||
func (krq StopRequest) validate() error {
|
||||
if krq.K8SID == 0 {
|
||||
return errors.New("validation-error: field K8SID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
K8SID uint64 `url:"k8sId" json:"k8sId" validate:"required"`
|
||||
}
|
||||
|
||||
// Stop stops kubernetes cluster by ID
|
||||
func (k8s K8S) Stop(ctx context.Context, req StopRequest) (bool, error) {
|
||||
err := req.validate()
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return false, validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudapi/k8s/stop"
|
||||
|
||||
@@ -2,16 +2,17 @@ package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// Request struct for update kubernetes cluster
|
||||
type UpdateRequest struct {
|
||||
// Kubernetes cluster ID
|
||||
// Required: true
|
||||
K8SID uint64 `url:"k8sId" json:"k8sId"`
|
||||
K8SID uint64 `url:"k8sId" json:"k8sId" validate:"required"`
|
||||
|
||||
// New name to set.
|
||||
// If empty string is passed, name is not updated
|
||||
@@ -24,19 +25,13 @@ type UpdateRequest struct {
|
||||
Description string `url:"desc,omitempty" json:"desc,omitempty"`
|
||||
}
|
||||
|
||||
func (krq UpdateRequest) validate() error {
|
||||
if krq.K8SID == 0 {
|
||||
return errors.New("validation-error: field K8SID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Update updates name or description of Kubernetes cluster
|
||||
func (k8s K8S) Update(ctx context.Context, req UpdateRequest) (bool, error) {
|
||||
err := req.validate()
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return false, validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudapi/k8s/update"
|
||||
|
||||
@@ -2,45 +2,34 @@ package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// Request struct for add worker to a kubernetes cluster
|
||||
type WorkerAddRequest struct {
|
||||
// Kubernetes cluster ID
|
||||
// Required: true
|
||||
K8SID uint64 `url:"k8sId" json:"k8sId"`
|
||||
K8SID uint64 `url:"k8sId" json:"k8sId" validate:"required"`
|
||||
|
||||
// ID of the workers compute group
|
||||
// Required: true
|
||||
WorkersGroupID uint64 `url:"workersGroupId" json:"workersGroupId"`
|
||||
WorkersGroupID uint64 `url:"workersGroupId" json:"workersGroupId" validate:"required"`
|
||||
|
||||
// How many worker nodes to add
|
||||
// Required: true
|
||||
Num uint64 `url:"num" json:"num"`
|
||||
}
|
||||
|
||||
func (krq WorkerAddRequest) validate() error {
|
||||
if krq.K8SID == 0 {
|
||||
return errors.New("validation-error: field K8SID can not be empty or equal to 0")
|
||||
}
|
||||
if krq.WorkersGroupID == 0 {
|
||||
return errors.New("validation-error: field WorkersGroupID can not be empty or equal to 0")
|
||||
}
|
||||
if krq.Num == 0 {
|
||||
return errors.New("validation-error: field Num can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
Num uint64 `url:"num" json:"num" validate:"required"`
|
||||
}
|
||||
|
||||
// WorkerAdd add worker nodes to a Kubernetes cluster
|
||||
func (k8s K8S) WorkerAdd(ctx context.Context, req WorkerAddRequest) (bool, error) {
|
||||
err := req.validate()
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return false, validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudapi/k8s/workerAdd"
|
||||
|
||||
@@ -2,45 +2,34 @@ package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// Request struct for hard reset kubernetes cluster
|
||||
type WorkerResetRequest struct {
|
||||
// Kubernetes cluster ID
|
||||
// Required: true
|
||||
K8SID uint64 `url:"k8sId" json:"k8sId"`
|
||||
K8SID uint64 `url:"k8sId" json:"k8sId" validate:"required"`
|
||||
|
||||
// ID of the workers compute group
|
||||
// Required: true
|
||||
WorkersGroupID uint64 `url:"workersGroupId" json:"workersGroupId"`
|
||||
WorkersGroupID uint64 `url:"workersGroupId" json:"workersGroupId" validate:"required"`
|
||||
|
||||
// Compute ID of worker node to reset
|
||||
// Required: true
|
||||
WorkerID uint64 `url:"workerId" json:"workerId"`
|
||||
}
|
||||
|
||||
func (krq WorkerResetRequest) validate() error {
|
||||
if krq.K8SID == 0 {
|
||||
return errors.New("validation-error: field K8SID can not be empty or equal to 0")
|
||||
}
|
||||
if krq.WorkersGroupID == 0 {
|
||||
return errors.New("validation-error: field WorkersGroupID can not be empty or equal to 0")
|
||||
}
|
||||
if krq.WorkerID == 0 {
|
||||
return errors.New("validation-error: field WorkerID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
WorkerID uint64 `url:"workerId" json:"workerId" validate:"required"`
|
||||
}
|
||||
|
||||
// WorkerReset hard reset (compute start + stop) worker node of the Kubernetes cluster
|
||||
func (k8s K8S) WorkerReset(ctx context.Context, req WorkerResetRequest) (bool, error) {
|
||||
err := req.validate()
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return false, validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudapi/k8s/workerReset"
|
||||
|
||||
@@ -2,45 +2,34 @@ package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// Request struct for restart worker node
|
||||
type WorkerRestartRequest struct {
|
||||
// Kubernetes cluster ID
|
||||
// Required: true
|
||||
K8SID uint64 `url:"k8sId" json:"k8sId"`
|
||||
K8SID uint64 `url:"k8sId" json:"k8sId" validate:"required"`
|
||||
|
||||
// ID of the workers compute group
|
||||
// Required: true
|
||||
WorkersGroupID uint64 `url:"workersGroupId" json:"workersGroupId"`
|
||||
WorkersGroupID uint64 `url:"workersGroupId" json:"workersGroupId" validate:"required"`
|
||||
|
||||
// Compute ID of worker node to restart
|
||||
// Required: true
|
||||
WorkerID uint64 `url:"workerId" json:"workerId"`
|
||||
}
|
||||
|
||||
func (krq WorkerRestartRequest) validate() error {
|
||||
if krq.K8SID == 0 {
|
||||
return errors.New("validation-error: field K8SID can not be empty or equal to 0")
|
||||
}
|
||||
if krq.WorkersGroupID == 0 {
|
||||
return errors.New("validation-error: field WorkersGroupID can not be empty or equal to 0")
|
||||
}
|
||||
if krq.WorkerID == 0 {
|
||||
return errors.New("validation-error: field WorkerID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
WorkerID uint64 `url:"workerId" json:"workerId" validate:"required"`
|
||||
}
|
||||
|
||||
// WorkerRestart soft restart (reboot OS) worker node of the Kubernetes cluster
|
||||
func (k8s K8S) WorkerRestart(ctx context.Context, req WorkerRestartRequest) (bool, error) {
|
||||
err := req.validate()
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return false, validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudapi/k8s/workerRestart"
|
||||
|
||||
@@ -2,20 +2,21 @@ package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// Request struct for add workers group
|
||||
type WorkersGroupAddRequest struct {
|
||||
// Kubernetes cluster ID
|
||||
// Required: true
|
||||
K8SID uint64 `url:"k8sId" json:"k8sId"`
|
||||
K8SID uint64 `url:"k8sId" json:"k8sId" validate:"required"`
|
||||
|
||||
// Worker group name
|
||||
// Required: true
|
||||
Name string `url:"name" json:"name"`
|
||||
Name string `url:"name" json:"name" validate:"required"`
|
||||
|
||||
// ID of SEP to create boot disks for default worker nodes group. Uses images SEP ID if not set
|
||||
// Required: false
|
||||
@@ -57,21 +58,13 @@ type WorkersGroupAddRequest struct {
|
||||
WorkerDisk uint64 `url:"workerDisk,omitempty" json:"workerDisk,omitempty"`
|
||||
}
|
||||
|
||||
func (krq WorkersGroupAddRequest) validate() error {
|
||||
if krq.K8SID == 0 {
|
||||
return errors.New("validation-error: field K8SID can not be empty or equal to 0")
|
||||
}
|
||||
if krq.Name == "" {
|
||||
return errors.New("validation-error: field Name must be set")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// WorkersGroupAdd adds workers group to Kubernetes cluster
|
||||
func (k8s K8S) WorkersGroupAdd(ctx context.Context, req WorkersGroupAddRequest) (bool, error) {
|
||||
err := req.validate()
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return false, validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudapi/k8s/workersGroupAdd"
|
||||
|
||||
@@ -2,38 +2,30 @@ package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// Request struct for delete workers group
|
||||
type WorkersGroupDeleteRequest struct {
|
||||
// Kubernetes cluster ID
|
||||
// Required: true
|
||||
K8SID uint64 `url:"k8sId" json:"k8sId"`
|
||||
K8SID uint64 `url:"k8sId" json:"k8sId" validate:"required"`
|
||||
|
||||
// Worker group ID
|
||||
// Required: true
|
||||
WorkersGroupID uint64 `url:"workersGroupId" json:"workersGroupId"`
|
||||
}
|
||||
|
||||
func (krq WorkersGroupDeleteRequest) validate() error {
|
||||
if krq.K8SID == 0 {
|
||||
return errors.New("validation-error: field K8SID can not be empty or equal to 0")
|
||||
}
|
||||
if krq.WorkersGroupID == 0 {
|
||||
return errors.New("validation-error: field WorkersGroupID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
WorkersGroupID uint64 `url:"workersGroupId" json:"workersGroupId" validate:"required"`
|
||||
}
|
||||
|
||||
// WorkersGroupDelete deletes workers group from Kubernetes cluster
|
||||
func (k8s K8S) WorkersGroupDelete(ctx context.Context, req WorkersGroupDeleteRequest) (bool, error) {
|
||||
err := req.validate()
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return false, validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudapi/k8s/workersGroupDelete"
|
||||
|
||||
@@ -3,37 +3,29 @@ package k8s
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// Request struct for get information about worker group
|
||||
type WorkersGroupGetByNameRequest struct {
|
||||
// Kubernetes cluster ID
|
||||
// Required: true
|
||||
K8SID uint64 `url:"k8sId" json:"k8sId"`
|
||||
K8SID uint64 `url:"k8sId" json:"k8sId" validate:"required"`
|
||||
|
||||
// Worker group name
|
||||
// Required: true
|
||||
GroupName string `url:"groupName" json:"groupName"`
|
||||
}
|
||||
|
||||
func (krq WorkersGroupGetByNameRequest) validate() error {
|
||||
if krq.K8SID == 0 {
|
||||
return errors.New("validation-error: field K8SID can not be empty or equal to 0")
|
||||
}
|
||||
if krq.GroupName == "" {
|
||||
return errors.New("validation-error: field WorkersGroupID can not be empty")
|
||||
}
|
||||
|
||||
return nil
|
||||
GroupName string `url:"groupName" json:"groupName" validate:"required"`
|
||||
}
|
||||
|
||||
// WorkersGroupGetByName gets worker group metadata by name
|
||||
func (k8s K8S) WorkersGroupGetByName(ctx context.Context, req WorkersGroupGetByNameRequest) (*RecordK8SGroups, error) {
|
||||
err := req.validate()
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return nil, validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudapi/k8s/workersGroupGetByName"
|
||||
|
||||
Reference in New Issue
Block a user