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.
56 lines
1.3 KiB
56 lines
1.3 KiB
package compute
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
"strconv"
|
|
|
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
|
)
|
|
|
|
// CloneRequest struct to clone compute instance
|
|
type CloneRequest struct {
|
|
// ID of compute instance
|
|
// Required: true
|
|
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
|
|
|
// Name of the clone
|
|
// Required: true
|
|
Name string `url:"name" json:"name" validate:"required"`
|
|
|
|
// Timestamp of the parent's snapshot to create clone from
|
|
// Required: false
|
|
SnapshotTimestamp uint64 `url:"snapshotTimestamp" json:"snapshotTimestamp"`
|
|
|
|
// Name of the parent's snapshot to create clone from
|
|
// Required: false
|
|
SnapshotName string `url:"snapshotName" json:"snapshotName"`
|
|
|
|
// true ignore that the compute is running
|
|
// Default: false
|
|
// Required: false
|
|
Force bool `url:"force" json:"force"`
|
|
}
|
|
|
|
// Clone clones compute instance
|
|
func (c Compute) Clone(ctx context.Context, req CloneRequest) (uint64, error) {
|
|
err := validators.ValidateRequest(req)
|
|
if err != nil {
|
|
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
|
}
|
|
|
|
url := "/cloudbroker/compute/clone"
|
|
|
|
res, err := c.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
|
|
}
|