v1.16.1
v1.16.1
This commit is contained in:
38
pkg/cloudbroker/backup/abort_disks_backup.go
Normal file
38
pkg/cloudbroker/backup/abort_disks_backup.go
Normal file
@@ -0,0 +1,38 @@
|
||||
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 AbortDisksBackupRequest struct {
|
||||
// Compute ID
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
|
||||
}
|
||||
|
||||
// AbortDisksBackup aborts disks backup
|
||||
func (b Backup) AbortDisksBackup(ctx context.Context, req AbortDisksBackupRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/backup/abort_disks_backup"
|
||||
|
||||
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
|
||||
}
|
||||
40
pkg/cloudbroker/backup/backup_disks_with_speed.go
Normal file
40
pkg/cloudbroker/backup/backup_disks_with_speed.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package backup
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
type BackupDisksWithSpeedRequest struct {
|
||||
// Compute ID
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
|
||||
}
|
||||
|
||||
// Get backup disk list and speeds for a compute
|
||||
func (b Backup) BackupDisksWithSpeed(ctx context.Context, req BackupDisksWithSpeedRequest) (ListDisksWithSpeed, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/backup/backup_disks_with_speed"
|
||||
|
||||
res, err := b.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
result := make(ListDisksWithSpeed, 0)
|
||||
|
||||
err = json.Unmarshal(res, &result)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
@@ -22,6 +22,10 @@ type CreateDiskBackupRequest struct {
|
||||
// Backup path
|
||||
// Required: true
|
||||
BackupPath string `url:"backupPath" json:"backupPath" validate:"required"`
|
||||
|
||||
// Backup speed in Mb/s. 0 means no limits. Applicable only for STARTED computes
|
||||
// Required: false
|
||||
Speed uint64 `url:"speed,omitempty" json:"speed,omitempty"`
|
||||
}
|
||||
|
||||
type wrapperCreateDiskBackupRequest struct {
|
||||
|
||||
@@ -15,6 +15,10 @@ type Disk struct {
|
||||
|
||||
// Backup path
|
||||
BackupPath string `url:"backupPath" json:"backupPath" validate:"required"`
|
||||
|
||||
// Backup speed in Mb/s. 0 means no limits. Applicable only for STARTED computes
|
||||
// Required: false
|
||||
Speed uint64 `url:"speed,omitempty" json:"speed,omitempty"`
|
||||
}
|
||||
|
||||
// CreateDisksBackupRequest struct for creating disks backup
|
||||
|
||||
40
pkg/cloudbroker/backup/info.go
Normal file
40
pkg/cloudbroker/backup/info.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package backup
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
type InfoRequest struct {
|
||||
// Compute ID
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
|
||||
}
|
||||
|
||||
// Information about all backups running on the machine
|
||||
func (b Backup) Info(ctx context.Context, req InfoRequest) (*TotalBackupsInfo, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/backup/info"
|
||||
|
||||
res, err := b.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
result := TotalBackupsInfo{}
|
||||
|
||||
err = json.Unmarshal(res, &result)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &result, nil
|
||||
}
|
||||
@@ -29,3 +29,53 @@ type InfoRestoredDisk struct {
|
||||
|
||||
// RestoreDisksFromFile response
|
||||
type ListInfoRestoredDisk []InfoRestoredDisk
|
||||
|
||||
// Main info about all backups running on the machine
|
||||
type TotalBackupsInfo struct {
|
||||
// Backup type
|
||||
Type uint64 `json:"type"`
|
||||
|
||||
// Time elapsed, ms
|
||||
TimeElapsedMs uint64 `json:"time_elapsed_ms"`
|
||||
|
||||
// Time remaining, ms
|
||||
TimeRemainingMs uint64 `json:"time_remaining_ms"`
|
||||
|
||||
// Total data size, bytes
|
||||
DataTotalBytes uint64 `json:"data_total_bytes"`
|
||||
|
||||
// Processed data size, bytes
|
||||
DataProcessedBytes uint64 `json:"data_processed_bytes"`
|
||||
|
||||
// Remaining data size, bytes
|
||||
DataRemainingBytes uint64 `json:"data_remaining_bytes"`
|
||||
|
||||
// Total memory size, bytes
|
||||
MemTotalBytes uint64 `json:"mem_total_bytes"`
|
||||
|
||||
// Processed memory size, bytes
|
||||
MemProcessedBytes uint64 `json:"mem_processed_bytes"`
|
||||
|
||||
// Remaining memory size, bytes
|
||||
MemRemainingBytes uint64 `json:"mem_remaining_bytes"`
|
||||
|
||||
// Total file size, bytes
|
||||
FileTotalBytes uint64 `json:"file_total_bytes"`
|
||||
|
||||
// Processed file size, bytes
|
||||
FileProcessedBytes uint64 `json:"file_processed_bytes"`
|
||||
|
||||
// Remaining file size, bytes
|
||||
FileRemainingBytes uint64 `json:"file_remaining_bytes"`
|
||||
}
|
||||
|
||||
// List of disk names and backup speed
|
||||
type ListDisksWithSpeed []DiskWithSpeed
|
||||
|
||||
type DiskWithSpeed struct {
|
||||
// Device name
|
||||
Device string `json:"device"`
|
||||
|
||||
// Backup speed limit in MB/s; 0 means unlimited
|
||||
Speed uint64 `json:"speed"`
|
||||
}
|
||||
|
||||
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