v1.15.0
This commit is contained in:
@@ -19,16 +19,27 @@ type MigrateToZoneRequest struct {
|
||||
ZoneID uint64 `url:"zoneId" json:"zoneId" validate:"required"`
|
||||
}
|
||||
|
||||
// MoveToZone moves compute to new zone
|
||||
type wrapperMigrateToZoneRequest struct {
|
||||
MigrateToZoneRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
}
|
||||
|
||||
// MigrateToZone moves compute to new zone
|
||||
func (c Compute) MigrateToZone(ctx context.Context, req MigrateToZoneRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperMigrateToZoneRequest{
|
||||
MigrateToZoneRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
url := "/cloudbroker/compute/migrateToZone"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -40,3 +51,25 @@ func (c Compute) MigrateToZone(ctx context.Context, req MigrateToZoneRequest) (b
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// MigrateToZoneAsync moves compute to new zone with AsyncMode
|
||||
func (c Compute) MigrateToZoneAsync(ctx context.Context, req MigrateToZoneRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperMigrateToZoneRequest{
|
||||
MigrateToZoneRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
url := "/cloudbroker/compute/migrateToZone"
|
||||
|
||||
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