Merge 'dev' into 'main'
This commit is contained in:
@@ -1,75 +1,64 @@
|
||||
package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"strings"
|
||||
|
||||
"github.com/rudecs/decort-sdk/opts"
|
||||
"github.com/rudecs/decort-sdk/typed"
|
||||
)
|
||||
|
||||
type CreateRequest struct {
|
||||
Name string `url:"name"`
|
||||
RGID uint64 `url:"rgId"`
|
||||
K8SCIId uint64 `url:"k8ciId"`
|
||||
WorkerGroupName string `url:"workerGroupName"`
|
||||
Labels []string `url:"labels,omitempty"`
|
||||
Taints []string `url:"taints,omitempty"`
|
||||
Annotations []string `url:"annotations,omitempty"`
|
||||
MasterNum uint `url:"masterNum,omitempty"`
|
||||
MasterCPU uint `url:"masterCPU,omitempty"`
|
||||
MasterRAM uint `url:"masterRam,omitempty"`
|
||||
MasterDisk uint `url:"masterDisk,omitempty"`
|
||||
WorkerNum uint `url:"workerNum,omitempty"`
|
||||
WorkerCPU uint `url:"workerCPU,omitempty"`
|
||||
WorkerRAM uint `url:"workerRam,omitempty"`
|
||||
WorkerDisk uint `url:"workerDisk,omitempty"`
|
||||
ExtnetId uint64 `url:"extnetId,omitempty"`
|
||||
WithLB bool `url:"withLB,omitempty"`
|
||||
Description string `url:"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
|
||||
}
|
||||
|
||||
func (k8s K8S) Create(ctx context.Context, req CreateRequest, options ...opts.DecortOpts) (string, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
url := "/k8s/create"
|
||||
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 strings.ReplaceAll(string(res), "\"", ""), nil
|
||||
|
||||
}
|
||||
package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type CreateRequest struct {
|
||||
Name string `url:"name"`
|
||||
RGID uint64 `url:"rgId"`
|
||||
K8SCIID uint64 `url:"k8ciId"`
|
||||
WorkerGroupName string `url:"workerGroupName"`
|
||||
Labels []string `url:"labels,omitempty"`
|
||||
Taints []string `url:"taints,omitempty"`
|
||||
Annotations []string `url:"annotations,omitempty"`
|
||||
MasterNum uint `url:"masterNum,omitempty"`
|
||||
MasterCPU uint `url:"masterCPU,omitempty"`
|
||||
MasterRAM uint `url:"masterRam,omitempty"`
|
||||
MasterDisk uint `url:"masterDisk,omitempty"`
|
||||
WorkerNum uint `url:"workerNum,omitempty"`
|
||||
WorkerCPU uint `url:"workerCPU,omitempty"`
|
||||
WorkerRAM uint `url:"workerRam,omitempty"`
|
||||
WorkerDisk uint `url:"workerDisk,omitempty"`
|
||||
ExtNetID uint64 `url:"extnetId,omitempty"`
|
||||
WithLB bool `url:"withLB,omitempty"`
|
||||
Description string `url:"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
|
||||
}
|
||||
|
||||
func (k8s K8S) Create(ctx context.Context, req CreateRequest) (string, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
url := "/cloudapi/k8s/create"
|
||||
|
||||
res, err := k8s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return strings.ReplaceAll(string(res), "\"", ""), nil
|
||||
|
||||
}
|
||||
|
||||
@@ -1,51 +1,41 @@
|
||||
package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"strconv"
|
||||
|
||||
"github.com/rudecs/decort-sdk/opts"
|
||||
"github.com/rudecs/decort-sdk/typed"
|
||||
)
|
||||
|
||||
type DeleteRequest struct {
|
||||
K8SId uint64 `url:"k8sId"`
|
||||
Permanently bool `url:"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
|
||||
}
|
||||
|
||||
func (k8s K8S) Delete(ctx context.Context, req DeleteRequest, options ...opts.DecortOpts) (bool, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
url := "/k8s/delete"
|
||||
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 false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type DeleteRequest struct {
|
||||
K8SID uint64 `url:"k8sId"`
|
||||
Permanently bool `url:"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
|
||||
}
|
||||
|
||||
func (k8s K8S) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
url := "/cloudapi/k8s/delete"
|
||||
|
||||
res, err := k8s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -1,59 +1,49 @@
|
||||
package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"strconv"
|
||||
|
||||
"github.com/rudecs/decort-sdk/opts"
|
||||
"github.com/rudecs/decort-sdk/typed"
|
||||
)
|
||||
|
||||
type DeleteMasterFromGroupRequest struct {
|
||||
K8SId uint64 `url:"k8sId"`
|
||||
MasterGroupId uint64 `url:"masterGroupId"`
|
||||
MasterIds []string `url:"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
|
||||
}
|
||||
|
||||
func (k8s K8S) DeleteMasterFromGroup(ctx context.Context, req DeleteMasterFromGroupRequest, options ...opts.DecortOpts) (bool, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
url := "/k8s/deleteMasterFromGroup"
|
||||
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 false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type DeleteMasterFromGroupRequest struct {
|
||||
K8SID uint64 `url:"k8sId"`
|
||||
MasterGroupID uint64 `url:"masterGroupId"`
|
||||
MasterIDs []string `url:"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
|
||||
}
|
||||
|
||||
func (k8s K8S) DeleteMasterFromGroup(ctx context.Context, req DeleteMasterFromGroupRequest) (bool, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
url := "/cloudapi/k8s/deleteMasterFromGroup"
|
||||
|
||||
res, err := k8s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -1,59 +1,49 @@
|
||||
package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"strconv"
|
||||
|
||||
"github.com/rudecs/decort-sdk/opts"
|
||||
"github.com/rudecs/decort-sdk/typed"
|
||||
)
|
||||
|
||||
type DeleteWorkerFromGroupRequest struct {
|
||||
K8SId uint64 `url:"k8sId"`
|
||||
WorkersGroupId uint64 `url:"workersGroupId"`
|
||||
WorkerId uint64 `url:"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
|
||||
}
|
||||
|
||||
func (k8s K8S) DeleteWorkerFromGroup(ctx context.Context, req DeleteWorkerFromGroupRequest, options ...opts.DecortOpts) (bool, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
url := "/k8s/deleteWorkerFromGroup"
|
||||
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 false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type DeleteWorkerFromGroupRequest struct {
|
||||
K8SID uint64 `url:"k8sId"`
|
||||
WorkersGroupID uint64 `url:"workersGroupId"`
|
||||
WorkerID uint64 `url:"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
|
||||
}
|
||||
|
||||
func (k8s K8S) DeleteWorkerFromGroup(ctx context.Context, req DeleteWorkerFromGroupRequest) (bool, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
url := "/cloudapi/k8s/deleteWorkerFromGroup"
|
||||
|
||||
res, err := k8s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -1,78 +1,60 @@
|
||||
package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"strconv"
|
||||
|
||||
"github.com/rudecs/decort-sdk/opts"
|
||||
"github.com/rudecs/decort-sdk/typed"
|
||||
)
|
||||
|
||||
type DisabelEnableRequest struct {
|
||||
K8SId uint64 `url:"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
|
||||
}
|
||||
|
||||
func (k8s K8S) Disable(ctx context.Context, req DisabelEnableRequest, options ...opts.DecortOpts) (bool, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
url := "/k8s/disable"
|
||||
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 false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (k8s K8S) Enable(ctx context.Context, req DisabelEnableRequest, options ...opts.DecortOpts) (bool, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
url := "/k8s/enable"
|
||||
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 false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type DisabelEnableRequest struct {
|
||||
K8SID uint64 `url:"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
|
||||
}
|
||||
|
||||
func (k8s K8S) Disable(ctx context.Context, req DisabelEnableRequest) (bool, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
url := "/cloudapi/k8s/disable"
|
||||
|
||||
res, err := k8s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (k8s K8S) Enable(ctx context.Context, req DisabelEnableRequest) (bool, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
url := "/cloudapi/k8s/enable"
|
||||
|
||||
res, err := k8s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -1,59 +1,49 @@
|
||||
package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
|
||||
"github.com/rudecs/decort-sdk/opts"
|
||||
"github.com/rudecs/decort-sdk/typed"
|
||||
)
|
||||
|
||||
type FindGroupByLabelRequest struct {
|
||||
K8SId uint64 `url:"k8sId"`
|
||||
Labels []string `url:"labels"`
|
||||
Strict bool `url:"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
|
||||
}
|
||||
|
||||
func (k8s K8S) FindGroupByLabel(ctx context.Context, req FindGroupByLabelRequest, options ...opts.DecortOpts) (K8SGroupList, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
url := "/k8s/findGroupByLabel"
|
||||
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 nil, err
|
||||
}
|
||||
|
||||
k8sGroupList := K8SGroupList{}
|
||||
|
||||
err = json.Unmarshal(res, &k8sGroupList)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return k8sGroupList, nil
|
||||
}
|
||||
package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type FindGroupByLabelRequest struct {
|
||||
K8SID uint64 `url:"k8sId"`
|
||||
Labels []string `url:"labels"`
|
||||
Strict bool `url:"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
|
||||
}
|
||||
|
||||
func (k8s K8S) FindGroupByLabel(ctx context.Context, req FindGroupByLabelRequest) (K8SGroupList, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
url := "/cloudapi/k8s/findGroupByLabel"
|
||||
|
||||
res, err := k8s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
k8sGroupList := K8SGroupList{}
|
||||
|
||||
err = json.Unmarshal(res, &k8sGroupList)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return k8sGroupList, nil
|
||||
}
|
||||
|
||||
@@ -1,53 +1,43 @@
|
||||
package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
|
||||
"github.com/rudecs/decort-sdk/opts"
|
||||
"github.com/rudecs/decort-sdk/typed"
|
||||
)
|
||||
|
||||
type GetRequest struct {
|
||||
K8SId uint64 `url:"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
|
||||
}
|
||||
|
||||
func (k8s K8S) Get(ctx context.Context, req GetRequest, options ...opts.DecortOpts) (*K8SRecord, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
url := "/k8s/get"
|
||||
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 nil, err
|
||||
}
|
||||
|
||||
k8sInfo := &K8SRecord{}
|
||||
|
||||
err = json.Unmarshal(res, k8sInfo)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return k8sInfo, nil
|
||||
}
|
||||
package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type GetRequest struct {
|
||||
K8SID uint64 `url:"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
|
||||
}
|
||||
|
||||
func (k8s K8S) Get(ctx context.Context, req GetRequest) (*K8SRecord, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
url := "/cloudapi/k8s/get"
|
||||
|
||||
res, err := k8s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
k8sInfo := &K8SRecord{}
|
||||
|
||||
err = json.Unmarshal(res, k8sInfo)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return k8sInfo, nil
|
||||
}
|
||||
|
||||
@@ -1,45 +1,35 @@
|
||||
package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"github.com/rudecs/decort-sdk/opts"
|
||||
"github.com/rudecs/decort-sdk/typed"
|
||||
)
|
||||
|
||||
type GetConfigRequest struct {
|
||||
K8SId uint64 `url:"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
|
||||
}
|
||||
|
||||
func (k8s K8S) GetConfig(ctx context.Context, req GetConfigRequest, options ...opts.DecortOpts) (string, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
url := "/k8s/getConfig"
|
||||
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 GetConfigRequest struct {
|
||||
K8SID uint64 `url:"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
|
||||
}
|
||||
|
||||
func (k8s K8S) GetConfig(ctx context.Context, req GetConfigRequest) (string, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
url := "/cloudapi/k8s/getConfig"
|
||||
|
||||
res, err := k8s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(res), nil
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -1,49 +1,39 @@
|
||||
package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"github.com/rudecs/decort-sdk/opts"
|
||||
"github.com/rudecs/decort-sdk/typed"
|
||||
)
|
||||
|
||||
type GetNodeTaintsRequest struct {
|
||||
K8SId uint64 `url:"k8sId"`
|
||||
NodeId uint64 `url:"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
|
||||
}
|
||||
|
||||
func (k8s K8S) GetNodeTaints(ctx context.Context, req GetNodeTaintsRequest, options ...opts.DecortOpts) (string, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
url := "/k8s/getNodeTaints"
|
||||
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 GetNodeTaintsRequest struct {
|
||||
K8SID uint64 `url:"k8sId"`
|
||||
NodeID uint64 `url:"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
|
||||
}
|
||||
|
||||
func (k8s K8S) GetNodeTaints(ctx context.Context, req GetNodeTaintsRequest) (string, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
url := "/cloudapi/k8s/getNodeTaints"
|
||||
|
||||
res, err := k8s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(res), nil
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
package k8s
|
||||
|
||||
import (
|
||||
"github.com/rudecs/decort-sdk/interfaces"
|
||||
)
|
||||
|
||||
type K8S struct {
|
||||
client interfaces.Caller
|
||||
}
|
||||
|
||||
func New(client interfaces.Caller) *K8S {
|
||||
return &K8S{
|
||||
client,
|
||||
}
|
||||
}
|
||||
package k8s
|
||||
|
||||
import (
|
||||
"github.com/rudecs/decort-sdk/interfaces"
|
||||
)
|
||||
|
||||
type K8S struct {
|
||||
client interfaces.Caller
|
||||
}
|
||||
|
||||
func New(client interfaces.Caller) *K8S {
|
||||
return &K8S{
|
||||
client,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,42 +1,32 @@
|
||||
package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/rudecs/decort-sdk/opts"
|
||||
"github.com/rudecs/decort-sdk/typed"
|
||||
)
|
||||
|
||||
type ListRequest struct {
|
||||
IncludeDeleted bool `url:"includedeleted"`
|
||||
Page uint64 `url:"page"`
|
||||
Size uint64 `url:"size"`
|
||||
}
|
||||
|
||||
func (k8s K8S) List(ctx context.Context, req ListRequest, options ...opts.DecortOpts) (K8SList, error) {
|
||||
|
||||
url := "/k8s/list"
|
||||
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 nil, err
|
||||
}
|
||||
|
||||
k8sList := K8SList{}
|
||||
|
||||
err = json.Unmarshal(res, &k8sList)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return k8sList, nil
|
||||
}
|
||||
package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type ListRequest struct {
|
||||
IncludeDeleted bool `url:"includedeleted"`
|
||||
Page uint64 `url:"page"`
|
||||
Size uint64 `url:"size"`
|
||||
}
|
||||
|
||||
func (k8s K8S) List(ctx context.Context, req ListRequest) (K8SList, error) {
|
||||
|
||||
url := "/cloudapi/k8s/list"
|
||||
|
||||
res, err := k8s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
k8sList := K8SList{}
|
||||
|
||||
err = json.Unmarshal(res, &k8sList)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return k8sList, nil
|
||||
}
|
||||
|
||||
@@ -1,41 +1,31 @@
|
||||
package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/rudecs/decort-sdk/opts"
|
||||
"github.com/rudecs/decort-sdk/typed"
|
||||
)
|
||||
|
||||
type ListDeletedRequest struct {
|
||||
Page uint64 `url:"page"`
|
||||
Size uint64 `url:"size"`
|
||||
}
|
||||
|
||||
func (k8s K8S) ListDeleted(ctx context.Context, req ListDeletedRequest, options ...opts.DecortOpts) (K8SList, error) {
|
||||
|
||||
url := "/k8s/listDeleted"
|
||||
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 nil, err
|
||||
}
|
||||
|
||||
k8sList := K8SList{}
|
||||
|
||||
err = json.Unmarshal(res, &k8sList)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return k8sList, nil
|
||||
}
|
||||
package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type ListDeletedRequest struct {
|
||||
Page uint64 `url:"page"`
|
||||
Size uint64 `url:"size"`
|
||||
}
|
||||
|
||||
func (k8s K8S) ListDeleted(ctx context.Context, req ListDeletedRequest) (K8SList, error) {
|
||||
|
||||
url := "/cloudapi/k8s/listDeleted"
|
||||
|
||||
res, err := k8s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
k8sList := K8SList{}
|
||||
|
||||
err = json.Unmarshal(res, &k8sList)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return k8sList, nil
|
||||
}
|
||||
|
||||
@@ -1,119 +1,119 @@
|
||||
package k8s
|
||||
|
||||
type K8SGroup struct {
|
||||
Annotations []string `json:"annotations"`
|
||||
CPU uint `json:"cpu"`
|
||||
DetailedInfo DetailedInfoList `json:"detailedInfo"`
|
||||
Disk uint `json:"disk"`
|
||||
GUID string `json:"guid"`
|
||||
ID uint64 `json:"id"`
|
||||
Labels []string `json:"labels"`
|
||||
Name string `json:"name"`
|
||||
Num uint `json:"num"`
|
||||
RAM uint `json:"ram"`
|
||||
Taints []string `json:"taints"`
|
||||
}
|
||||
|
||||
type K8SGroupList []K8SGroup
|
||||
|
||||
type DetailedInfo struct {
|
||||
ID uint64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Status string `json:"status"`
|
||||
TechStatus string `json:"techStatus"`
|
||||
}
|
||||
|
||||
type DetailedInfoList []DetailedInfo
|
||||
|
||||
type K8SRecord struct {
|
||||
ACL ACLGroup `json:"ACL"`
|
||||
AccountId uint64 `json:"accountId"`
|
||||
AccountName string `json:"accountName"`
|
||||
BServiceId uint64 `json:"bserviceId"`
|
||||
CIId uint64 `json:"ciId"`
|
||||
CreatedBy string `json:"createdBy"`
|
||||
CreatedTime uint64 `json:"createdTime"`
|
||||
DeletedBy string `json:"deletedBy"`
|
||||
DeletedTime uint64 `json:"deletedTime"`
|
||||
ID uint64 `json:"id"`
|
||||
K8CIName string `json:"k8ciName"`
|
||||
K8SGroups K8SGroups `json:"k8sGroups"`
|
||||
LBId uint64 `json:"lbId"`
|
||||
Name string `json:"name"`
|
||||
RGID uint64 `json:"rgId"`
|
||||
RGName string `json:"rgName"`
|
||||
Status string `json:"status"`
|
||||
TechStatus string `json:"techStatus"`
|
||||
UpdatedBy string `json:"updatedBy"`
|
||||
UpdatedTime uint64 `json:"updatedTime"`
|
||||
}
|
||||
|
||||
type K8SGroups struct {
|
||||
Masters MasterGroup `json:"masters"`
|
||||
Workers K8SGroupList `json:"workers"`
|
||||
}
|
||||
|
||||
type MasterGroup struct {
|
||||
CPU uint `json:"cpu"`
|
||||
DetailedInfo DetailedInfoList `json:"detailedInfo"`
|
||||
Disk uint `json:"disk"`
|
||||
ID uint64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Num uint `json:"num"`
|
||||
RAM uint `json:"ram"`
|
||||
}
|
||||
|
||||
type ACLGroup struct {
|
||||
AccountAcl AclList `json:"accountAcl"`
|
||||
K8SAcl AclList `json:"k8sAcl"`
|
||||
RGAcl AclList `json:"rgAcl"`
|
||||
}
|
||||
|
||||
type Acl struct {
|
||||
Explicit bool `json:"explicit"`
|
||||
GUID string `json:"guid"`
|
||||
Right string `json:"right"`
|
||||
Status string `json:"status"`
|
||||
Type string `json:"type"`
|
||||
UserGroupId string `json:"userGroupId"`
|
||||
}
|
||||
|
||||
type AclList []Acl
|
||||
|
||||
type K8SItem struct {
|
||||
AccountId uint64 `json:"accountId"`
|
||||
AccountName string `json:"accountName"`
|
||||
Acl []interface{} `json:"acl"`
|
||||
BServiceId uint64 `json:"bserviceId"`
|
||||
CIId uint64 `json:"ciId"`
|
||||
Config interface{} `json:"config"`
|
||||
CreatedBy string `json:"createdBy"`
|
||||
CreatedTime uint64 `json:"createdTime"`
|
||||
DeletedBy string `json:"deletedBy"`
|
||||
DeletedTime uint64 `json:"deletedTime"`
|
||||
Description string `json:"desc"`
|
||||
ExtnetId uint64 `json:"extnetId"`
|
||||
GID uint64 `json:"gid"`
|
||||
GUID uint64 `json:"guid"`
|
||||
ID uint64 `json:"id"`
|
||||
LBId uint64 `json:"lbId"`
|
||||
Milestones uint64 `json:"milestones"`
|
||||
Name string `json:"name"`
|
||||
RGID uint64 `json:"rgId"`
|
||||
RGName string `json:"rgName"`
|
||||
ServiceAccount ServiceAccount `json:"serviceAccount"`
|
||||
Status string `json:"status"`
|
||||
TechStatus string `json:"techStatus"`
|
||||
UpdatedBy string `json:"updatedBy"`
|
||||
UpdatedTime uint64 `json:"updatedTime"`
|
||||
VinsId uint64 `json:"vinsId"`
|
||||
WorkersGroup K8SGroupList `json:"workersGroups"`
|
||||
}
|
||||
|
||||
type ServiceAccount struct {
|
||||
GUID string `json:"guid"`
|
||||
Password string `json:"password"`
|
||||
Username string `json:"username"`
|
||||
}
|
||||
|
||||
type K8SList []K8SItem
|
||||
package k8s
|
||||
|
||||
type K8SGroup struct {
|
||||
Annotations []string `json:"annotations"`
|
||||
CPU uint64 `json:"cpu"`
|
||||
DetailedInfo DetailedInfoList `json:"detailedInfo"`
|
||||
Disk uint64 `json:"disk"`
|
||||
GUID string `json:"guid"`
|
||||
ID uint64 `json:"id"`
|
||||
Labels []string `json:"labels"`
|
||||
Name string `json:"name"`
|
||||
Num uint64 `json:"num"`
|
||||
RAM uint64 `json:"ram"`
|
||||
Taints []string `json:"taints"`
|
||||
}
|
||||
|
||||
type K8SGroupList []K8SGroup
|
||||
|
||||
type DetailedInfo struct {
|
||||
ID uint64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Status string `json:"status"`
|
||||
TechStatus string `json:"techStatus"`
|
||||
}
|
||||
|
||||
type DetailedInfoList []DetailedInfo
|
||||
|
||||
type K8SRecord struct {
|
||||
ACL ACLGroup `json:"ACL"`
|
||||
AccountID uint64 `json:"accountId"`
|
||||
AccountName string `json:"accountName"`
|
||||
BServiceID uint64 `json:"bserviceId"`
|
||||
CIID uint64 `json:"ciId"`
|
||||
CreatedBy string `json:"createdBy"`
|
||||
CreatedTime uint64 `json:"createdTime"`
|
||||
DeletedBy string `json:"deletedBy"`
|
||||
DeletedTime uint64 `json:"deletedTime"`
|
||||
ID uint64 `json:"id"`
|
||||
K8CIName string `json:"k8ciName"`
|
||||
K8SGroups K8SGroups `json:"k8sGroups"`
|
||||
LBID uint64 `json:"lbId"`
|
||||
Name string `json:"name"`
|
||||
RGID uint64 `json:"rgId"`
|
||||
RGName string `json:"rgName"`
|
||||
Status string `json:"status"`
|
||||
TechStatus string `json:"techStatus"`
|
||||
UpdatedBy string `json:"updatedBy"`
|
||||
UpdatedTime uint64 `json:"updatedTime"`
|
||||
}
|
||||
|
||||
type K8SGroups struct {
|
||||
Masters MasterGroup `json:"masters"`
|
||||
Workers K8SGroupList `json:"workers"`
|
||||
}
|
||||
|
||||
type MasterGroup struct {
|
||||
CPU uint64 `json:"cpu"`
|
||||
DetailedInfo DetailedInfoList `json:"detailedInfo"`
|
||||
Disk uint64 `json:"disk"`
|
||||
ID uint64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Num uint64 `json:"num"`
|
||||
RAM uint64 `json:"ram"`
|
||||
}
|
||||
|
||||
type ACLGroup struct {
|
||||
AccountACL ACLList `json:"accountAcl"`
|
||||
K8SACL ACLList `json:"k8sAcl"`
|
||||
RGACL ACLList `json:"rgAcl"`
|
||||
}
|
||||
|
||||
type ACL struct {
|
||||
Explicit bool `json:"explicit"`
|
||||
GUID string `json:"guid"`
|
||||
Right string `json:"right"`
|
||||
Status string `json:"status"`
|
||||
Type string `json:"type"`
|
||||
UserGroupID string `json:"userGroupId"`
|
||||
}
|
||||
|
||||
type ACLList []ACL
|
||||
|
||||
type K8SItem struct {
|
||||
AccountID uint64 `json:"accountId"`
|
||||
AccountName string `json:"accountName"`
|
||||
ACL []interface{} `json:"acl"`
|
||||
BServiceID uint64 `json:"bserviceId"`
|
||||
CIID uint64 `json:"ciId"`
|
||||
Config interface{} `json:"config"`
|
||||
CreatedBy string `json:"createdBy"`
|
||||
CreatedTime uint64 `json:"createdTime"`
|
||||
DeletedBy string `json:"deletedBy"`
|
||||
DeletedTime uint64 `json:"deletedTime"`
|
||||
Description string `json:"desc"`
|
||||
ExtNetID uint64 `json:"extnetId"`
|
||||
GID uint64 `json:"gid"`
|
||||
GUID uint64 `json:"guid"`
|
||||
ID uint64 `json:"id"`
|
||||
LBID uint64 `json:"lbId"`
|
||||
Milestones uint64 `json:"milestones"`
|
||||
Name string `json:"name"`
|
||||
RGID uint64 `json:"rgId"`
|
||||
RGName string `json:"rgName"`
|
||||
ServiceAccount ServiceAccount `json:"serviceAccount"`
|
||||
Status string `json:"status"`
|
||||
TechStatus string `json:"techStatus"`
|
||||
UpdatedBy string `json:"updatedBy"`
|
||||
UpdatedTime uint64 `json:"updatedTime"`
|
||||
VINSID uint64 `json:"vinsId"`
|
||||
WorkersGroup K8SGroupList `json:"workersGroups"`
|
||||
}
|
||||
|
||||
type ServiceAccount struct {
|
||||
GUID string `json:"guid"`
|
||||
Password string `json:"password"`
|
||||
Username string `json:"username"`
|
||||
}
|
||||
|
||||
type K8SList []K8SItem
|
||||
|
||||
@@ -1,50 +1,40 @@
|
||||
package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"strconv"
|
||||
|
||||
"github.com/rudecs/decort-sdk/opts"
|
||||
"github.com/rudecs/decort-sdk/typed"
|
||||
)
|
||||
|
||||
type RestoreRequest struct {
|
||||
K8SId uint64 `url:"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
|
||||
}
|
||||
|
||||
func (k8s K8S) Restore(ctx context.Context, req RestoreRequest, options ...opts.DecortOpts) (bool, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
url := "/k8s/restore"
|
||||
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 false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type RestoreRequest struct {
|
||||
K8SID uint64 `url:"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
|
||||
}
|
||||
|
||||
func (k8s K8S) Restore(ctx context.Context, req RestoreRequest) (bool, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
url := "/cloudapi/k8s/restore"
|
||||
|
||||
res, err := k8s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -1,50 +1,40 @@
|
||||
package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"strconv"
|
||||
|
||||
"github.com/rudecs/decort-sdk/opts"
|
||||
"github.com/rudecs/decort-sdk/typed"
|
||||
)
|
||||
|
||||
type StartRequest struct {
|
||||
K8SId uint64 `url:"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
|
||||
}
|
||||
|
||||
func (k8s K8S) Start(ctx context.Context, req StartRequest, options ...opts.DecortOpts) (bool, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
url := "/k8s/start"
|
||||
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 false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type StartRequest struct {
|
||||
K8SID uint64 `url:"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
|
||||
}
|
||||
|
||||
func (k8s K8S) Start(ctx context.Context, req StartRequest) (bool, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
url := "/cloudapi/k8s/start"
|
||||
|
||||
res, err := k8s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -1,50 +1,40 @@
|
||||
package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"strconv"
|
||||
|
||||
"github.com/rudecs/decort-sdk/opts"
|
||||
"github.com/rudecs/decort-sdk/typed"
|
||||
)
|
||||
|
||||
type StopRequest struct {
|
||||
K8SId uint64 `url:"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
|
||||
}
|
||||
|
||||
func (k8s K8S) Stop(ctx context.Context, req StopRequest, options ...opts.DecortOpts) (bool, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
url := "/k8s/stop"
|
||||
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 false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type StopRequest struct {
|
||||
K8SID uint64 `url:"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
|
||||
}
|
||||
|
||||
func (k8s K8S) Stop(ctx context.Context, req StopRequest) (bool, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
url := "/cloudapi/k8s/stop"
|
||||
|
||||
res, err := k8s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -1,52 +1,42 @@
|
||||
package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"strconv"
|
||||
|
||||
"github.com/rudecs/decort-sdk/opts"
|
||||
"github.com/rudecs/decort-sdk/typed"
|
||||
)
|
||||
|
||||
type UpdateRequest struct {
|
||||
K8SId uint64 `url:"k8sId"`
|
||||
Name string `url:"name,omitempty"`
|
||||
Description string `url:"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
|
||||
}
|
||||
|
||||
func (k8s K8S) Update(ctx context.Context, req UpdateRequest, options ...opts.DecortOpts) (bool, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
url := "/k8s/update"
|
||||
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 false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type UpdateRequest struct {
|
||||
K8SID uint64 `url:"k8sId"`
|
||||
Name string `url:"name,omitempty"`
|
||||
Description string `url:"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
|
||||
}
|
||||
|
||||
func (k8s K8S) Update(ctx context.Context, req UpdateRequest) (bool, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
url := "/cloudapi/k8s/update"
|
||||
|
||||
res, err := k8s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -1,60 +1,50 @@
|
||||
package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"strconv"
|
||||
|
||||
"github.com/rudecs/decort-sdk/opts"
|
||||
"github.com/rudecs/decort-sdk/typed"
|
||||
)
|
||||
|
||||
type WorkerAddRequest struct {
|
||||
K8SId uint64 `url:"k8sId"`
|
||||
WorkersGroupId uint64 `url:"workersGroupId"`
|
||||
Num uint `url:"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
|
||||
}
|
||||
|
||||
func (k8s K8S) WorkerAdd(ctx context.Context, req WorkerAddRequest, options ...opts.DecortOpts) (bool, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
url := "/k8s/workerAdd"
|
||||
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 false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type WorkerAddRequest struct {
|
||||
K8SID uint64 `url:"k8sId"`
|
||||
WorkersGroupID uint64 `url:"workersGroupId"`
|
||||
Num uint `url:"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
|
||||
}
|
||||
|
||||
func (k8s K8S) WorkerAdd(ctx context.Context, req WorkerAddRequest) (bool, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
url := "/cloudapi/k8s/workerAdd"
|
||||
|
||||
res, err := k8s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -1,60 +1,50 @@
|
||||
package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"strconv"
|
||||
|
||||
"github.com/rudecs/decort-sdk/opts"
|
||||
"github.com/rudecs/decort-sdk/typed"
|
||||
)
|
||||
|
||||
type WorkerResetRequest struct {
|
||||
K8SId uint64 `url:"k8sId"`
|
||||
WorkersGroupId uint64 `url:"workersGroupId"`
|
||||
WorkerId uint64 `url:"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
|
||||
}
|
||||
|
||||
func (k8s K8S) WorkerReset(ctx context.Context, req WorkerResetRequest, options ...opts.DecortOpts) (bool, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
url := "/k8s/workerReset"
|
||||
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 false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type WorkerResetRequest struct {
|
||||
K8SID uint64 `url:"k8sId"`
|
||||
WorkersGroupID uint64 `url:"workersGroupId"`
|
||||
WorkerID uint64 `url:"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
|
||||
}
|
||||
|
||||
func (k8s K8S) WorkerReset(ctx context.Context, req WorkerResetRequest) (bool, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
url := "/cloudapi/k8s/workerReset"
|
||||
|
||||
res, err := k8s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -1,60 +1,50 @@
|
||||
package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"strconv"
|
||||
|
||||
"github.com/rudecs/decort-sdk/opts"
|
||||
"github.com/rudecs/decort-sdk/typed"
|
||||
)
|
||||
|
||||
type WorkerRestartRequest struct {
|
||||
K8SId uint64 `url:"k8sId"`
|
||||
WorkersGroupId uint64 `url:"workersGroupId"`
|
||||
WorkerId uint64 `url:"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
|
||||
}
|
||||
|
||||
func (k8s K8S) WorkerRestart(ctx context.Context, req WorkerRestartRequest, options ...opts.DecortOpts) (bool, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
url := "/k8s/workerRestart"
|
||||
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 false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type WorkerRestartRequest struct {
|
||||
K8SID uint64 `url:"k8sId"`
|
||||
WorkersGroupID uint64 `url:"workersGroupId"`
|
||||
WorkerID uint64 `url:"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
|
||||
}
|
||||
|
||||
func (k8s K8S) WorkerRestart(ctx context.Context, req WorkerRestartRequest) (bool, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
url := "/cloudapi/k8s/workerRestart"
|
||||
|
||||
res, err := k8s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -1,74 +1,64 @@
|
||||
package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"strconv"
|
||||
|
||||
"github.com/rudecs/decort-sdk/opts"
|
||||
"github.com/rudecs/decort-sdk/typed"
|
||||
)
|
||||
|
||||
type WorkersGroupAddRequest struct {
|
||||
K8SId uint64 `url:"k8sId"`
|
||||
Name string `url:"name"`
|
||||
Labels []string `url:"labels"`
|
||||
Taints []string `url:"taints"`
|
||||
Annotations []string `url:"annotations"`
|
||||
WorkerNum uint `url:"workerNum"`
|
||||
WorkerCpu uint `url:"workerCpu"`
|
||||
WorkerRam uint `url:"workerRam"`
|
||||
WorkerDisk uint `url:"workerDisk"`
|
||||
}
|
||||
|
||||
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 can not be empty")
|
||||
}
|
||||
|
||||
if krq.WorkerNum == 0 {
|
||||
return errors.New("validation-error: field WorkerNum can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
if krq.WorkerCpu == 0 {
|
||||
return errors.New("validation-error: field WorkerCpu can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
if krq.WorkerRam < 1024 {
|
||||
return errors.New("validation-error: field WorkerRam must be greater or equal 1024")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (k8s K8S) WorkersGroupAdd(ctx context.Context, req WorkersGroupAddRequest, options ...opts.DecortOpts) (bool, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
url := "/k8s/workersGroupAdd"
|
||||
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 false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type WorkersGroupAddRequest struct {
|
||||
K8SID uint64 `url:"k8sId"`
|
||||
Name string `url:"name"`
|
||||
Labels []string `url:"labels"`
|
||||
Taints []string `url:"taints"`
|
||||
Annotations []string `url:"annotations"`
|
||||
WorkerNum uint `url:"workerNum"`
|
||||
WorkerCPU uint `url:"workerCpu"`
|
||||
WorkerRam uint `url:"workerRam"`
|
||||
WorkerDisk uint `url:"workerDisk"`
|
||||
}
|
||||
|
||||
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 can not be empty")
|
||||
}
|
||||
|
||||
if krq.WorkerNum == 0 {
|
||||
return errors.New("validation-error: field WorkerNum can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
if krq.WorkerCPU == 0 {
|
||||
return errors.New("validation-error: field WorkerCPU can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
if krq.WorkerRam < 1024 {
|
||||
return errors.New("validation-error: field WorkerRam must be greater or equal 1024")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (k8s K8S) WorkersGroupAdd(ctx context.Context, req WorkersGroupAddRequest) (bool, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
url := "/cloudapi/k8s/workersGroupAdd"
|
||||
|
||||
res, err := k8s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -1,55 +1,45 @@
|
||||
package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"strconv"
|
||||
|
||||
"github.com/rudecs/decort-sdk/opts"
|
||||
"github.com/rudecs/decort-sdk/typed"
|
||||
)
|
||||
|
||||
type WorkersGroupDeleteRequest struct {
|
||||
K8SId uint64 `url:"k8sId"`
|
||||
WorkersGroupId uint64 `url:"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
|
||||
}
|
||||
|
||||
func (k8s K8S) WorkersGroupDelete(ctx context.Context, req WorkersGroupDeleteRequest, options ...opts.DecortOpts) (bool, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
url := "/k8s/workersGroupDelete"
|
||||
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 false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type WorkersGroupDeleteRequest struct {
|
||||
K8SID uint64 `url:"k8sId"`
|
||||
WorkersGroupID uint64 `url:"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
|
||||
}
|
||||
|
||||
func (k8s K8S) WorkersGroupDelete(ctx context.Context, req WorkersGroupDeleteRequest) (bool, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
url := "/cloudapi/k8s/workersGroupDelete"
|
||||
|
||||
res, err := k8s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -1,58 +1,48 @@
|
||||
package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
|
||||
"github.com/rudecs/decort-sdk/opts"
|
||||
"github.com/rudecs/decort-sdk/typed"
|
||||
)
|
||||
|
||||
type WorkersGroupGetByNameRequest struct {
|
||||
K8SId uint64 `url:"k8sId"`
|
||||
GroupName string `url:"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
|
||||
}
|
||||
|
||||
func (k8s K8S) WorkersGroupGetByName(ctx context.Context, req WorkersGroupGetByNameRequest, options ...opts.DecortOpts) (*K8SGroup, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
url := "/k8s/workersGroupGetByName"
|
||||
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 nil, err
|
||||
}
|
||||
|
||||
group := &K8SGroup{}
|
||||
|
||||
err = json.Unmarshal(res, group)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return group, nil
|
||||
}
|
||||
package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type WorkersGroupGetByNameRequest struct {
|
||||
K8SID uint64 `url:"k8sId"`
|
||||
GroupName string `url:"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
|
||||
}
|
||||
|
||||
func (k8s K8S) WorkersGroupGetByName(ctx context.Context, req WorkersGroupGetByNameRequest) (*K8SGroup, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
url := "/cloudapi/k8s/workersGroupGetByName"
|
||||
|
||||
res, err := k8s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
group := &K8SGroup{}
|
||||
|
||||
err = json.Unmarshal(res, group)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return group, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user