@@ -35,6 +35,13 @@ const (
35
35
InstanceResizing InstanceStatus = "resizing"
36
36
)
37
37
38
+ type InstanceMigrationType string
39
+
40
+ const (
41
+ WarmMigration InstanceMigrationType = "warm"
42
+ ColdMigration InstanceMigrationType = "cold"
43
+ )
44
+
38
45
// Instance represents a linode object
39
46
type Instance struct {
40
47
ID int `json:"id"`
@@ -192,12 +199,19 @@ type InstanceCloneOptions struct {
192
199
193
200
// InstanceResizeOptions is an options struct used when resizing an instance
194
201
type InstanceResizeOptions struct {
195
- Type string `json:"type"`
202
+ Type string `json:"type"`
203
+ MigrationType InstanceMigrationType `json:"migration_type,omitempty"`
196
204
197
205
// 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
198
206
AllowAutoDiskResize * bool `json:"allow_auto_disk_resize,omitempty"`
199
207
}
200
208
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
+
201
215
// InstancesPagedResponse represents a linode API response for listing
202
216
type InstancesPagedResponse struct {
203
217
* PageOptions
@@ -417,8 +431,14 @@ func (c *Client) MutateInstance(ctx context.Context, id int) error {
417
431
}
418
432
419
433
// 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
422
442
}
423
443
424
444
// simpleInstanceAction is a helper for Instance actions that take no parameters
0 commit comments