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

80 lines
2.2 KiB
Go
Raw Normal View History

2022-10-03 16:56:47 +03:00
package account
import (
"context"
"net/http"
"strconv"
2023-03-17 12:54:34 +03:00
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
2022-10-03 16:56:47 +03:00
)
2023-10-25 17:37:18 +03:00
// UpdateRequest struct to update account
2022-10-03 16:56:47 +03:00
type UpdateRequest struct {
2022-12-22 17:56:47 +03:00
// ID an account
// Required: true
2023-03-17 12:54:34 +03:00
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
2022-12-22 17:56:47 +03:00
2025-04-09 11:21:07 +03:00
// Description
// Required: false
Description string `url:"desc,omitempty" json:"desc,omitempty"`
2022-12-22 17:56:47 +03:00
// Name of the account
// 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
// 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 vdisks 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
// If true send emails when a user is granted access to resources
// Required: false
2023-05-04 16:15:35 +03:00
SendAccessEmails bool `url:"sendAccessEmails" json:"sendAccessEmails"`
2022-12-22 17:56:47 +03:00
// Limit (positive) or disable (0) GPU resources
// Required: false
2023-04-20 11:17:35 +03:00
GPUUnits int64 `url:"gpu_units,omitempty" json:"gpu_units,omitempty"`
2024-11-12 12:51:21 +03:00
// List of strings with pools
// i.e.: ["sep1_poolName1", "sep2_poolName2", etc]
// Required: false
UniqPools []string `url:"uniqPools,omitempty" json:"uniqPools,omitempty"`
2025-07-15 17:39:18 +03:00
// Default zone ID
// Required: false
DefaultZoneID uint64 `url:"defaultZoneId,omitempty" json:"defaultZoneId,omitempty"`
2022-10-03 16:56:47 +03:00
}
2022-12-22 17:56:47 +03:00
// Update updates an account name and resource types and limits
2022-10-03 16:56:47 +03:00
func (a Account) Update(ctx context.Context, req UpdateRequest) (bool, error) {
2023-03-17 12:54:34 +03:00
err := validators.ValidateRequest(req)
2022-10-03 16:56:47 +03:00
if err != nil {
2023-10-25 17:37:18 +03:00
return false, validators.ValidationErrors(validators.GetErrors(err))
2022-10-03 16:56:47 +03:00
}
url := "/cloudapi/account/update"
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
}