You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.2 KiB
46 lines
1.2 KiB
package rg
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"strconv"
|
|
|
|
"github.com/rudecs/decort-sdk/opts"
|
|
"github.com/rudecs/decort-sdk/typed"
|
|
)
|
|
|
|
type UpdateRequest struct {
|
|
RGID uint64 `url:"rgId"`
|
|
Name string `url:"name,omitempty"`
|
|
Desc string `url:"desc,omitempty"`
|
|
MaxMemoryCapacity uint64 `url:"maxMemoryCapacity,omitempty"`
|
|
MaxVDiskCapacity uint64 `url:"maxVDiskCapacity,omitempty"`
|
|
MaxCPUCapacity uint64 `url:"maxCPUCapacity,omitempty"`
|
|
MaxNetworkPeerTransfer uint64 `url:"maxNetworkPeerTransfer,omitempty"`
|
|
MaxNumPublicIP uint64 `url:"maxNumPublicIP,omitempty"`
|
|
RegisterComputes bool `url:"registerComputes,omitempty"`
|
|
Reason string `url:"reason,omitempty"`
|
|
}
|
|
|
|
func (rgrq UpdateRequest) Validate() error {
|
|
if rgrq.RGID == 0 {
|
|
return errors.New("field RGID can not be empty or equal to 0")
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (r RG) Update(ctx context.Context, req UpdateRequest, options ...opts.DecortOpts) (bool, error) {
|
|
if err := req.Validate(); err != nil {
|
|
return false, err
|
|
}
|
|
|
|
url := "/cloudapi/rg/update"
|
|
res, err := r.client.DecortApiCall(ctx, typed.POST, url, req)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
return strconv.ParseBool(string(res))
|
|
}
|