@@ -5,13 +5,34 @@ import (
55)
66
77// Creates a Template of a Virtual Machine by it's ID
8- func (c CloudstackClient ) CreateTemplate (displaytext string , name string , volumeid string , ostypeid string ) (CreateTemplateResponse , error ) {
8+ func (c CloudstackClient ) CreateTemplate (options * CreateTemplate ) (CreateTemplateResponse , error ) {
99 var resp CreateTemplateResponse
1010 params := url.Values {}
11- params .Set ("displaytext" , displaytext )
12- params .Set ("name" , name )
13- params .Set ("ostypeid" , ostypeid )
14- params .Set ("volumeid" , volumeid )
11+ params .Set ("displaytext" , options .Displaytext )
12+ params .Set ("name" , options .Name )
13+ params .Set ("ostypeid" , options .Ostypeid )
14+ if options .Volumeid != "" {
15+ params .Set ("volumeid" , options .Volumeid )
16+ }
17+ if options .Snapshotid != "" {
18+ params .Set ("snapshotid" , options .Snapshotid )
19+ }
20+
21+ if options .Isdynamicallyscalable {
22+ params .Set ("isdynamicallyscalable" , "true" )
23+ }
24+ if options .Isextractable {
25+ params .Set ("isextractable" , "true" )
26+ }
27+ if options .Isfeatured {
28+ params .Set ("isfeatured" , "true" )
29+ }
30+ if options .Ispublic {
31+ params .Set ("ispublic" , "true" )
32+ }
33+ if options .Passwordenabled {
34+ params .Set ("passwordenabled" , "true" )
35+ }
1536
1637 response , err := NewRequest (c , "createTemplate" , params )
1738 if err != nil {
@@ -97,3 +118,16 @@ type ListTemplatesResponse struct {
97118 Template []Template `json:"template"`
98119 } `json:"listtemplatesresponse"`
99120}
121+
122+ type CreateTemplate struct {
123+ Displaytext string `json:"displaytext"`
124+ Isdynamicallyscalable bool `json:"isdynamicallyscalable"`
125+ Isextractable bool `json:"isextractable"`
126+ Isfeatured bool `json:"isfeatured"`
127+ Ispublic bool `json:"ispublic"`
128+ Name string `json:"name"`
129+ Ostypeid string `json:"ostypeid"`
130+ Passwordenabled bool `json:"passwordenabled"`
131+ Snapshotid string `json:"snapshotid"`
132+ Volumeid string `json:"volumeid"`
133+ }
0 commit comments