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.
53 lines
1.4 KiB
53 lines
1.4 KiB
package disks
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
"strconv"
|
|
|
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
|
)
|
|
|
|
// ReplicateRequest struct to create an empty disk in chosen SEP and pool combination.
|
|
type ReplicateRequest struct {
|
|
// Id of the disk to replicate. This disk will become master in replication
|
|
// Required: true
|
|
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
|
|
|
// Name of replica disk to create
|
|
// Required: true
|
|
Name string `url:"name" json:"name" validate:"required"`
|
|
|
|
// ID of SEP to create slave disk
|
|
// Required: true
|
|
SepID uint64 `url:"sepId" json:"sepId" validate:"required"`
|
|
|
|
// Pool name to create slave disk in
|
|
// Required: true
|
|
PoolName string `url:"poolName" json:"poolName" validate:"required"`
|
|
}
|
|
|
|
// Create an empty disk in chosen SEP and pool combination.
|
|
// Starts replication between chosen disk and newly created disk
|
|
// Note: only TATLIN type SEP are supported for replications between
|
|
func (d Disks) Replicate(ctx context.Context, req ReplicateRequest) (uint64, error) {
|
|
err := validators.ValidateRequest(req)
|
|
if err != nil {
|
|
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
|
}
|
|
|
|
url := "/cloudbroker/disks/replicate"
|
|
|
|
res, err := d.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
|
|
}
|