Files
decort-golang-sdk/pkg/cloudapi/rg/update.go

77 lines
2.1 KiB
Go
Raw Normal View History

2022-08-11 08:09:54 +00:00
package rg
import (
"context"
2022-10-03 16:56:47 +03:00
"net/http"
2022-08-11 08:09:54 +00:00
"strconv"
2023-03-24 17:09:30 +03:00
2025-08-29 12:51:25 +03:00
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
2023-03-24 17:09:30 +03:00
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
2022-08-11 08:09:54 +00:00
)
2023-10-25 17:37:18 +03:00
// UpdateRequest struct to update resource group
2022-08-11 08:09:54 +00:00
type UpdateRequest struct {
2022-12-22 17:56:47 +03:00
// Resource group ID
// Required: true
2023-03-24 17:09:30 +03:00
RGID uint64 `url:"rgId" json:"rgId" validate:"required"`
2022-12-22 17:56:47 +03:00
// New name
// Required: false
2023-03-01 19:05:53 +03:00
Name string `url:"name,omitempty" json:"name,omitempty"`
2022-12-22 17:56:47 +03:00
// New description
// Required: false
2023-03-01 19:05:53 +03:00
Description string `url:"desc,omitempty" json:"desc,omitempty"`
2022-12-22 17:56:47 +03:00
// Max size of memory in MB
// Required: false
2023-04-20 11:17:35 +03:00
MaxMemoryCapacity int64 `url:"maxMemoryCapacity,omitempty" json:"maxMemoryCapacity,omitempty"`
2022-12-22 17:56:47 +03:00
// Max size of aggregated virtual disks in GB
// Required: false
2023-04-20 11:17:35 +03:00
MaxVDiskCapacity int64 `url:"maxVDiskCapacity,omitempty" json:"maxVDiskCapacity,omitempty"`
2022-12-22 17:56:47 +03:00
// Max number of CPU cores
// Required: false
2023-04-20 11:17:35 +03:00
MaxCPUCapacity int64 `url:"maxCPUCapacity,omitempty" json:"maxCPUCapacity,omitempty"`
2022-12-22 17:56:47 +03:00
// Max number of assigned public IPs
// Required: false
2023-04-20 11:17:35 +03:00
MaxNumPublicIP int64 `url:"maxNumPublicIP,omitempty" json:"maxNumPublicIP,omitempty"`
2022-12-22 17:56:47 +03:00
2024-11-12 12:51:21 +03:00
// List of strings with pools i.e.: ["sep1_poolName1", "sep2_poolName2", etc]
2022-12-22 17:56:47 +03:00
// Required: false
2024-11-12 12:51:21 +03:00
UniqPools []string `url:"uniqPools,omitempty" json:"uniqPools,omitempty"`
// if True the field will be cleared
// Default: false
// Required: false
ClearUniqPools bool `url:"clearUniqPools" json:"clearUniqPools"`
2025-08-29 12:51:25 +03:00
// Storage policies
// Required: false
StoragePolicies []StoragePolicy `url:"-" json:"storage_policies,omitempty"`
2022-08-11 08:09:54 +00:00
}
2022-12-22 17:56:47 +03:00
// Update updates resource group
2022-10-03 16:56:47 +03:00
func (r RG) Update(ctx context.Context, req UpdateRequest) (bool, error) {
2023-03-24 17:09:30 +03:00
err := validators.ValidateRequest(req)
2022-12-22 17:56:47 +03:00
if err != nil {
2023-10-25 17:37:18 +03:00
return false, validators.ValidationErrors(validators.GetErrors(err))
2022-08-11 08:09:54 +00:00
}
url := "/cloudapi/rg/update"
2022-12-22 17:56:47 +03:00
2025-08-29 12:51:25 +03:00
res, err := r.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
2022-08-11 08:09:54 +00:00
if err != nil {
return false, err
}
2022-12-22 17:56:47 +03:00
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, err
}
return result, nil
2022-08-11 08:09:54 +00:00
}