@@ -11,6 +11,7 @@ import (
11
11
type ImageActionsService interface {
12
12
Get (context.Context , int , int ) (* Action , * Response , error )
13
13
Transfer (context.Context , int , * ActionRequest ) (* Action , * Response , error )
14
+ Convert (context.Context , int ) (* Action , * Response , error )
14
15
}
15
16
16
17
// ImageActionsServiceOp handles communition with the image action related methods of the
@@ -47,6 +48,32 @@ func (i *ImageActionsServiceOp) Transfer(ctx context.Context, imageID int, trans
47
48
return root .Event , resp , err
48
49
}
49
50
51
+ // Convert an image to a snapshot
52
+ func (i * ImageActionsServiceOp ) Convert (ctx context.Context , imageID int ) (* Action , * Response , error ) {
53
+ if imageID < 1 {
54
+ return nil , nil , NewArgError ("imageID" , "cannont be less than 1" )
55
+ }
56
+
57
+ path := fmt .Sprintf ("v2/images/%d/actions" , imageID )
58
+
59
+ convertRequest := & ActionRequest {
60
+ "type" : "convert" ,
61
+ }
62
+
63
+ req , err := i .client .NewRequest (ctx , "POST" , path , convertRequest )
64
+ if err != nil {
65
+ return nil , nil , err
66
+ }
67
+
68
+ root := new (actionRoot )
69
+ resp , err := i .client .Do (req , root )
70
+ if err != nil {
71
+ return nil , resp , err
72
+ }
73
+
74
+ return root .Event , resp , err
75
+ }
76
+
50
77
// Get an action for a particular image by id.
51
78
func (i * ImageActionsServiceOp ) Get (ctx context.Context , imageID , actionID int ) (* Action , * Response , error ) {
52
79
if imageID < 1 {
0 commit comments