v1.15.0
This commit is contained in:
@@ -20,18 +20,33 @@ type SnapshotCreateRequest struct {
|
||||
// Maximum length: 36 characters
|
||||
// Required: true
|
||||
Label string `url:"label" json:"label" validate:"required,max=36,excludesall=<>"`
|
||||
|
||||
// Create snapshot with memory dump
|
||||
// Required: false
|
||||
// Default: false
|
||||
WithMemory bool `url:"with_memory" json:"with_memory"`
|
||||
}
|
||||
|
||||
// SnapshotCreate create compute snapshot
|
||||
type wrapperSnapshotCreateRequest struct {
|
||||
SnapshotCreateRequest
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
}
|
||||
|
||||
// SnapshotCreate creates compute snapshot
|
||||
func (c Compute) SnapshotCreate(ctx context.Context, req SnapshotCreateRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperSnapshotCreateRequest{
|
||||
SnapshotCreateRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/snapshotCreate"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -40,3 +55,25 @@ func (c Compute) SnapshotCreate(ctx context.Context, req SnapshotCreateRequest)
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// SnapshotCreateAsync creates compute snapshot in async mode
|
||||
func (c Compute) SnapshotCreateAsync(ctx context.Context, req SnapshotCreateRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperSnapshotCreateRequest{
|
||||
SnapshotCreateRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/snapshotCreate"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(res), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user