v1.16.1
v1.16.1
This commit is contained in:
46
pkg/cloudbroker/backup/set_backup_speed.go
Normal file
46
pkg/cloudbroker/backup/set_backup_speed.go
Normal file
@@ -0,0 +1,46 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user