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.
dynamix-golang-sdk/pkg/cloudbroker/bservice/group_resize.go

60 lines
1.5 KiB

1 month ago
package bservice
import (
"context"
"net/http"
"strconv"
1 month ago
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
1 month ago
)
// GroupResizeRequest struct to resize the group
type GroupResizeRequest struct {
// ID of the Basic Service of Compute Group
// Required: true
ServiceID uint64 `url:"serviceId" json:"serviceId" validate:"required"`
// ID of the Compute Group to resize
// Required: true
CompGroupID uint64 `url:"compgroupId" json:"compgroupId" validate:"required"`
// Either delta or absolute value of computes
// Required: true
Count int64 `url:"count" json:"count" validate:"required"`
//Chipset for new computes, either i440fx or Q35 (i440fx by default)
//Available values : i440fx, Q35
//Default value : i440fx
//Required: true
Chipset string `url:"chipset" json:"chipset" validate:"required,chipset"`
// Either delta or absolute value of computes
// Should be one of:
// - ABSOLUTE
// - RELATIVE
// Required: true
Mode string `url:"mode" json:"mode" validate:"bserviceMode"`
}
// GroupResize resize the group by changing the number of computes
func (b BService) GroupResize(ctx context.Context, req GroupResizeRequest) (uint64, error) {
err := validators.ValidateRequest(req)
if err != nil {
return 0, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/bservice/groupResize"
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return 0, err
}
result, err := strconv.ParseUint(string(res), 10, 64)
if err != nil {
return 0, err
}
return result, nil
}