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/bservice/group_update.go

77 lines
2.0 KiB

3 years ago
package bservice
import (
"context"
"net/http"
3 years ago
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
3 years ago
)
2 years ago
// GroupUpdateRequest struct to update existing Compute group
3 years ago
type GroupUpdateRequest struct {
3 years ago
// ID of the Basic Service of Compute Group
// Required: true
2 years ago
ServiceID uint64 `url:"serviceId" json:"serviceId" validate:"required"`
3 years ago
// ID of the Compute Group
// Required: true
2 years ago
CompGroupID uint64 `url:"compgroupId" json:"compgroupId" validate:"required"`
3 years ago
// Specify non-empty string to update Compute Group name
// Required: false
3 years ago
Name string `url:"name,omitempty" json:"name,omitempty"`
3 years ago
// Specify non-empty string to update group role
// Required: false
3 years ago
Role string `url:"role,omitempty" json:"role,omitempty"`
3 years ago
// Specify positive value to set new compute CPU count
// Required: false
3 years ago
CPU uint64 `url:"cpu,omitempty" json:"cpu,omitempty"`
3 years ago
// Specify positive value to set new compute RAM volume in MB
// Required: false
3 years ago
RAM uint64 `url:"ram,omitempty" json:"ram,omitempty"`
3 years ago
// Specify new compute boot disk size in GB
// Required: false
3 years ago
Disk uint64 `url:"disk,omitempty" json:"disk,omitempty"`
3 years ago
// Force resize Compute Group
// Required: false
3 years ago
Force bool `url:"force,omitempty" json:"force,omitempty"`
3 years ago
}
2 years ago
// GetRAM returns RAM field values
func (r GroupUpdateRequest) GetRAM() map[string]uint64 {
res := make(map[string]uint64, 1)
res["RAM"] = r.RAM
return res
}
3 years ago
// GroupUpdate updates existing Compute group within Basic Service and apply new settings to its computes as necessary
func (b BService) GroupUpdate(ctx context.Context, req GroupUpdateRequest) (bool, error) {
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/bservice/groupUpdate"
3 years ago
res, err := b.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
}