Skip to content

Commit 659e0a1

Browse files
Project: Unified Migration (#445)
* Add fields for unified migration (#428) * Add fixture for TestInstance_Resize
1 parent 17895ae commit 659e0a1

File tree

3 files changed

+693
-3
lines changed

3 files changed

+693
-3
lines changed

instances.go

+23-3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ const (
3535
InstanceResizing InstanceStatus = "resizing"
3636
)
3737

38+
type InstanceMigrationType string
39+
40+
const (
41+
WarmMigration InstanceMigrationType = "warm"
42+
ColdMigration InstanceMigrationType = "cold"
43+
)
44+
3845
// Instance represents a linode object
3946
type Instance struct {
4047
ID int `json:"id"`
@@ -192,12 +199,19 @@ type InstanceCloneOptions struct {
192199

193200
// InstanceResizeOptions is an options struct used when resizing an instance
194201
type InstanceResizeOptions struct {
195-
Type string `json:"type"`
202+
Type string `json:"type"`
203+
MigrationType InstanceMigrationType `json:"migration_type,omitempty"`
196204

197205
// When enabled, an instance resize will also resize a data disk if the instance has no more than one data disk and one swap disk
198206
AllowAutoDiskResize *bool `json:"allow_auto_disk_resize,omitempty"`
199207
}
200208

209+
// InstanceResizeOptions is an options struct used when resizing an instance
210+
type InstanceMigrateOptions struct {
211+
Type InstanceMigrationType `json:"type,omitempty"`
212+
Region string `json:"region,omitempty"`
213+
}
214+
201215
// InstancesPagedResponse represents a linode API response for listing
202216
type InstancesPagedResponse struct {
203217
*PageOptions
@@ -417,8 +431,14 @@ func (c *Client) MutateInstance(ctx context.Context, id int) error {
417431
}
418432

419433
// MigrateInstance - Migrate an instance
420-
func (c *Client) MigrateInstance(ctx context.Context, id int) error {
421-
return c.simpleInstanceAction(ctx, "migrate", id)
434+
func (c *Client) MigrateInstance(ctx context.Context, linodeID int, opts InstanceMigrateOptions) error {
435+
body, err := json.Marshal(opts)
436+
if err != nil {
437+
return err
438+
}
439+
e := fmt.Sprintf("linode/instances/%d/migrate", linodeID)
440+
_, err = coupleAPIErrors(c.R(ctx).SetBody(string(body)).Post(e))
441+
return err
422442
}
423443

424444
// simpleInstanceAction is a helper for Instance actions that take no parameters

0 commit comments

Comments
 (0)