v1.0.0
This commit is contained in:
@@ -7,14 +7,26 @@ import (
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// Request struct for clone compute instance
|
||||
type CloneRequest struct {
|
||||
ComputeID uint64 `url:"computeId"`
|
||||
Name string `url:"name"`
|
||||
// ID of compute instance
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"computeId"`
|
||||
|
||||
// Name of the clone
|
||||
// Required: true
|
||||
Name string `url:"name"`
|
||||
|
||||
// Timestamp of the parent's snapshot to create clone from
|
||||
// Required: false
|
||||
SnapshotTimestamp uint64 `url:"snapshotTimestamp"`
|
||||
SnapshotName string `url:"snapshotName"`
|
||||
|
||||
// Name of the parent's snapshot to create clone from
|
||||
// Required: false
|
||||
SnapshotName string `url:"snapshotName"`
|
||||
}
|
||||
|
||||
func (crq CloneRequest) Validate() error {
|
||||
func (crq CloneRequest) validate() error {
|
||||
if crq.ComputeID == 0 {
|
||||
return errors.New("validation-error: field ComputeID can not be empty or equal to 0")
|
||||
}
|
||||
@@ -25,8 +37,9 @@ func (crq CloneRequest) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Clone clones compute instance
|
||||
func (c Compute) Clone(ctx context.Context, req CloneRequest) (uint64, error) {
|
||||
err := req.Validate()
|
||||
err := req.validate()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
@@ -42,5 +55,6 @@ func (c Compute) Clone(ctx context.Context, req CloneRequest) (uint64, error) {
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user