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.
decort-golang-sdk/pkg/cloudapi/rg/update.go

75 lines
2.0 KiB

3 years ago
package rg
import (
"context"
"net/http"
3 years ago
"strconv"
3 years ago
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
3 years ago
)
2 years ago
// UpdateRequest struct to update resource group
3 years ago
type UpdateRequest struct {
3 years ago
// Resource group ID
// Required: true
3 years ago
RGID uint64 `url:"rgId" json:"rgId" validate:"required"`
3 years ago
// New name
// Required: false
3 years ago
Name string `url:"name,omitempty" json:"name,omitempty"`
3 years ago
// New description
// Required: false
3 years ago
Description string `url:"desc,omitempty" json:"desc,omitempty"`
3 years ago
// Max size of memory in MB
// Required: false
3 years ago
MaxMemoryCapacity int64 `url:"maxMemoryCapacity,omitempty" json:"maxMemoryCapacity,omitempty"`
3 years ago
// Max size of aggregated virtual disks in GB
// Required: false
3 years ago
MaxVDiskCapacity int64 `url:"maxVDiskCapacity,omitempty" json:"maxVDiskCapacity,omitempty"`
3 years ago
// Max number of CPU cores
// Required: false
3 years ago
MaxCPUCapacity int64 `url:"maxCPUCapacity,omitempty" json:"maxCPUCapacity,omitempty"`
3 years ago
// Max sent/received network transfer peering
// Required: false
3 years ago
MaxNetworkPeerTransfer int64 `url:"maxNetworkPeerTransfer,omitempty" json:"maxNetworkPeerTransfer,omitempty"`
3 years ago
// Max number of assigned public IPs
// Required: false
3 years ago
MaxNumPublicIP int64 `url:"maxNumPublicIP,omitempty" json:"maxNumPublicIP,omitempty"`
3 years ago
// Register computes in registration system
// Required: false
3 years ago
RegisterComputes bool `url:"registerComputes,omitempty" json:"registerComputes,omitempty"`
3 years ago
// Reason for action
// Required: false
3 years ago
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
3 years ago
}
3 years ago
// Update updates resource group
func (r RG) Update(ctx context.Context, req UpdateRequest) (bool, error) {
3 years ago
err := validators.ValidateRequest(req)
3 years ago
if err != nil {
2 years ago
return false, validators.ValidationErrors(validators.GetErrors(err))
3 years ago
}
url := "/cloudapi/rg/update"
3 years ago
res, err := r.client.DecortApiCall(ctx, http.MethodPost, url, req)
3 years ago
if err != nil {
return false, err
}
3 years ago
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, err
}
return result, nil
3 years ago
}