47 lines
1.1 KiB
Go
47 lines
1.1 KiB
Go
package backup
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
"strconv"
|
|
|
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
|
)
|
|
|
|
type SetBackupSpeedRequest struct {
|
|
// Compute ID
|
|
// Required: true
|
|
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
|
|
|
|
// Device to set backup speed ongit
|
|
// Required: true
|
|
Device string `url:"device" json:"device" validate:"required"`
|
|
|
|
// New backup speed in Mb/s. 0 means no limits
|
|
// Required: true
|
|
Speed uint64 `url:"speed" json:"speed" validate:"required"`
|
|
}
|
|
|
|
// Set speed limit for device backup on ruining machine
|
|
func (b Backup) SetBackupSpeed(ctx context.Context, req SetBackupSpeedRequest) (bool, error) {
|
|
err := validators.ValidateRequest(req)
|
|
if err != nil {
|
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
|
}
|
|
|
|
url := "/cloudbroker/backup/set_backup_speed"
|
|
|
|
res, err := b.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
result, err := strconv.ParseBool(string(res))
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
return result, nil
|
|
}
|