parent
ef0dac9b3a
commit
7ddd8c5fbe
@ -1,6 +1,46 @@
|
|||||||
## Version 1.0.2
|
## Version 1.1.0
|
||||||
|
|
||||||
### Bug fixes
|
### Features
|
||||||
|
|
||||||
- Update tags for Kubernetes create
|
#### CloudAPI
|
||||||
- Add License file
|
|
||||||
|
- Account
|
||||||
|
- Delete "ResTypes" field in Create/Update request structs
|
||||||
|
- Add fields "DiskSizeMax", "Shareable", "SEPs" in Get/List response structs
|
||||||
|
- BService
|
||||||
|
- Add fields "SEPID", "SEPPool" in GroupAdd request structs
|
||||||
|
- Add field "PoolName" in List/ListDeleted response structs
|
||||||
|
- Compute
|
||||||
|
- Add fields "PresentTo", "Shareable" in Get/List/ListDeleted response structs
|
||||||
|
- Disks
|
||||||
|
- Add fields "PresentTo", "Shareable", "Computes" in Get/List/ListDeleted/ListUnattached/Search response structs
|
||||||
|
- Delete fields "ComputeID", "ComputeName" in List/ListDeleted/ListUnattached/Search response structs
|
||||||
|
- FLIPgroup
|
||||||
|
- Add field "ClientNames" in Get response struct
|
||||||
|
- Image
|
||||||
|
- Add field "PresentTo" in Get response struct
|
||||||
|
- RG
|
||||||
|
- Delete "ResTypes" field in Create/Update request structs
|
||||||
|
- Add fields "DiskSizeMax", "Shareable", "SEPs" in Get/List response structs
|
||||||
|
|
||||||
|
#### Cloudbroker
|
||||||
|
|
||||||
|
- Account
|
||||||
|
- Add fields "SEPs", "ResourceTypes", "PresentTo", "DiskSizeMax", "UniqPools", "Shareable" in Get/List/ListDeleted/ListDisks/ListRG response structs
|
||||||
|
- Compute
|
||||||
|
- Add fields "VINSConnected", "TotalDiskSize", "Shareable", "PresentTo" in Get/List/ListDeleted response structs
|
||||||
|
- Disks
|
||||||
|
- Add fields "ReferenceID", "Shareable", "PresentTo", "Computes" in List/ListDeleted/ListUnattached/Search response structs
|
||||||
|
- Delete fields "ComputeID", "ComputeName" in List/ListDeleted/ListUnattached/Search response structs
|
||||||
|
- Grid
|
||||||
|
- Add fields "SEPs", "DiskSizeMax" in Get/List response structs
|
||||||
|
- Image
|
||||||
|
- Add field "PresentTo" in Get response struct
|
||||||
|
- KVMX86
|
||||||
|
- Add field "Userdata" in MassCreate request struct
|
||||||
|
- Delete field "IPAddr" in MassCreate request struct
|
||||||
|
- KVMPPC
|
||||||
|
- Add field "Userdata" in MassCreate request struct
|
||||||
|
- Delete field "IPAddr" in MassCreate request struct
|
||||||
|
- RG
|
||||||
|
- Add fields "DiskSizeMax", "Shareable", "SEPs" in Get/List response structs
|
||||||
|
@ -0,0 +1,45 @@
|
|||||||
|
package disks
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Request struct for share data disk
|
||||||
|
type ShareRequest struct {
|
||||||
|
// ID of the disk to share
|
||||||
|
// Required: true
|
||||||
|
DiskID uint64 `url:"diskId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (drq ShareRequest) validate() error {
|
||||||
|
if drq.DiskID == 0 {
|
||||||
|
return errors.New("validation-error: field DiskID can not be empty or equal to 0")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Share shares data disk
|
||||||
|
func (d Disks) Share(ctx context.Context, req ShareRequest) (bool, error) {
|
||||||
|
err := req.validate()
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/disks/share"
|
||||||
|
|
||||||
|
res, err := d.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
|
||||||
|
}
|
@ -0,0 +1,45 @@
|
|||||||
|
package disks
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Request struct for unshare data disk
|
||||||
|
type UnshareRequest struct {
|
||||||
|
// ID of the disk to unshare
|
||||||
|
// Required: true
|
||||||
|
DiskID uint64 `url:"diskId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (drq UnshareRequest) validate() error {
|
||||||
|
if drq.DiskID == 0 {
|
||||||
|
return errors.New("validation-error: field DiskID can not be empty or equal to 0")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unshare unshares data disk
|
||||||
|
func (d Disks) Unshare(ctx context.Context, req UnshareRequest) (bool, error) {
|
||||||
|
err := req.validate()
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/disks/unshare"
|
||||||
|
|
||||||
|
res, err := d.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
|
||||||
|
}
|
@ -0,0 +1,46 @@
|
|||||||
|
package k8s
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Request struct for get node labels
|
||||||
|
type GetNodeLabelsRequest struct {
|
||||||
|
// Kubernetes cluster ID
|
||||||
|
// Required: true
|
||||||
|
K8SID uint64 `url:"k8sId"`
|
||||||
|
|
||||||
|
// Node ID
|
||||||
|
// Required: false
|
||||||
|
NodeID uint64 `url:"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
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetNodeLabels gets kubernetes cluster worker node labels
|
||||||
|
func (k8s K8S) GetNodeLabels(ctx context.Context, req GetNodeLabelsRequest) (string, error) {
|
||||||
|
err := req.validate()
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/k8s/getNodeLabels"
|
||||||
|
|
||||||
|
res, err := k8s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
return string(res), nil
|
||||||
|
}
|
@ -0,0 +1,45 @@
|
|||||||
|
package lb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Request struct for start load balancer
|
||||||
|
type StartRequest struct {
|
||||||
|
// ID of the load balancer instance to start
|
||||||
|
// Required: true
|
||||||
|
LBID uint64 `url:"lbId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (lbrq StartRequest) validate() error {
|
||||||
|
if lbrq.LBID == 0 {
|
||||||
|
return errors.New("validation-error: field LBID can not be empty or equal to 0")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start starts specified load balancer instance
|
||||||
|
func (l LB) Start(ctx context.Context, req StartRequest) (bool, error) {
|
||||||
|
err := req.validate()
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/lb/start"
|
||||||
|
|
||||||
|
res, err := l.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
|
||||||
|
}
|
@ -0,0 +1,45 @@
|
|||||||
|
package lb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Request struct for stop load balancer
|
||||||
|
type StopRequest struct {
|
||||||
|
// ID of the load balancer instance to stop
|
||||||
|
// Required: true
|
||||||
|
LBID uint64 `url:"lbId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (lbrq StopRequest) validate() error {
|
||||||
|
if lbrq.LBID == 0 {
|
||||||
|
return errors.New("validation-error: field LBID can not be empty or equal to 0")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stop stops specified load balancer instance
|
||||||
|
func (l LB) Stop(ctx context.Context, req StopRequest) (bool, error) {
|
||||||
|
err := req.validate()
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/lb/start"
|
||||||
|
|
||||||
|
res, err := l.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
|
||||||
|
}
|
@ -0,0 +1,65 @@
|
|||||||
|
package account
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/rudecs/decort-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Request struct for update resource types in account
|
||||||
|
type UpdateResourceTypesRequest struct {
|
||||||
|
// ID of account
|
||||||
|
// Required: true
|
||||||
|
AccountID uint64 `url:"accountId"`
|
||||||
|
|
||||||
|
// Resource types available to create in this account
|
||||||
|
// Each element in a resource type slice must be one of:
|
||||||
|
// - compute
|
||||||
|
// - vins
|
||||||
|
// - k8s
|
||||||
|
// - openshift
|
||||||
|
// - lb
|
||||||
|
// - flipgroup
|
||||||
|
// Required: true
|
||||||
|
ResTypes []string `url:"resourceTypes"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (arq UpdateResourceTypesRequest) validate() error {
|
||||||
|
if arq.AccountID == 0 {
|
||||||
|
return errors.New("validation-error: field AccountID must be set")
|
||||||
|
}
|
||||||
|
if len(arq.ResTypes) > 0 {
|
||||||
|
for _, value := range arq.ResTypes {
|
||||||
|
validate := validators.StringInSlice(value, []string{"compute", "vins", "k8s", "openshift", "lb", "flipgroup"})
|
||||||
|
if !validate {
|
||||||
|
return errors.New("validation-error: Every resource type specified should be one of [compute, vins, k8s, openshift, lb, flipgroup]")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a Account) UpdateResourceTypes(ctx context.Context, req UpdateResourceTypesRequest) (bool, error) {
|
||||||
|
err := req.validate()
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/account/updateResourceTypes"
|
||||||
|
|
||||||
|
res, err := a.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
|
||||||
|
}
|
@ -0,0 +1,65 @@
|
|||||||
|
package rg
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/rudecs/decort-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Request struct for update resource types in account
|
||||||
|
type UpdateResourceTypesRequest struct {
|
||||||
|
// ID of resource group
|
||||||
|
// Required: true
|
||||||
|
RGID uint64 `url:"rgId"`
|
||||||
|
|
||||||
|
// Resource types available to create in this resource group
|
||||||
|
// Each element in a resource type slice must be one of:
|
||||||
|
// - compute
|
||||||
|
// - vins
|
||||||
|
// - k8s
|
||||||
|
// - openshift
|
||||||
|
// - lb
|
||||||
|
// - flipgroup
|
||||||
|
// Required: true
|
||||||
|
ResTypes []string `url:"resourceTypes"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (rgrq UpdateResourceTypesRequest) validate() error {
|
||||||
|
if rgrq.RGID == 0 {
|
||||||
|
return errors.New("validation-error: field RGID must be set")
|
||||||
|
}
|
||||||
|
if len(rgrq.ResTypes) > 0 {
|
||||||
|
for _, value := range rgrq.ResTypes {
|
||||||
|
validate := validators.StringInSlice(value, []string{"compute", "vins", "k8s", "openshift", "lb", "flipgroup"})
|
||||||
|
if !validate {
|
||||||
|
return errors.New("validation-error: Every resource type specified should be one of [compute, vins, k8s, openshift, lb, flipgroup]")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r RG) UpdateResourceTypes(ctx context.Context, req UpdateResourceTypesRequest) (bool, error) {
|
||||||
|
err := req.validate()
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/rg/updateResourceTypes"
|
||||||
|
|
||||||
|
res, err := r.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
|
||||||
|
}
|
Loading…
Reference in new issue