forked from mindjiver/gopherstack
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate.go
More file actions
Latest commit
99 lines (87 loc) · 3 KB
/
Copy pathtemplate.go
File metadata and controls
99 lines (87 loc) · 3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package gopherstack
import (
"net/url"
)
// Creates a Template of a Virtual Machine by it's ID
func (cCloudstackClient) CreateTemplate(displaytextstring, namestring, volumeidstring, ostypeidstring) (CreateTemplateResponse, error) {
varrespCreateTemplateResponse
params:= url.Values{}
params.Set("displaytext", displaytext)
params.Set("name", name)
params.Set("ostypeid", ostypeid)
params.Set("volumeid", volumeid)
response, err:=NewRequest(c, "createTemplate", params)
iferr!=nil {
returnresp, err
}
resp=response.(CreateTemplateResponse)
returnresp, err
}
// Returns all available templates
func (cCloudstackClient) ListTemplates(namestring, filterstring) (ListTemplatesResponse, error) {
varrespListTemplatesResponse
params:= url.Values{}
params.Set("name", name)
params.Set("templatefilter", filter)
response, err:=NewRequest(c, "listTemplates", params)
iferr!=nil {
returnresp, err
}
resp=response.(ListTemplatesResponse)
returnresp, err
}
// Deletes an template by its ID.
func (cCloudstackClient) DeleteTemplate(idstring) (DeleteTemplateResponse, error) {
varrespDeleteTemplateResponse
params:= url.Values{}
params.Set("id", id)
response, err:=NewRequest(c, "deleteTemplate", params)
iferr!=nil {
returnresp, err
}
resp=response.(DeleteTemplateResponse)
returnresp, err
}
typeCreateTemplateResponsestruct {
Createtemplateresponsestruct {
IDstring`json:"id"`
Jobidstring`json:"jobid"`
} `json:"createtemplateresponse"`
}
typeDeleteTemplateResponsestruct {
Deletetemplateresponsestruct {
}
}
typeTemplatestruct {
Accountstring`json:"account"`
Createdstring`json:"created"`
CrossZonesbool`json:"crossZones"`
Displaytextstring`json:"displaytext"`
Domainstring`json:"domain"`
Domainidstring`json:"domainid"`
Formatstring`json:"format"`
Hypervisorstring`json:"hypervisor"`
IDstring`json:"id"`
Isextractablebool`json:"isextractable"`
Isfeaturedbool`json:"isfeatured"`
Ispublicbool`json:"ispublic"`
Isreadybool`json:"isready"`
Namestring`json:"name"`
Ostypeidstring`json:"ostypeid"`
Ostypenamestring`json:"ostypename"`
Passwordenabledbool`json:"passwordenabled"`
Sizefloat64`json:"size"`
Sourcetemplateidstring`json:"sourcetemplateid"`
Sshkeyenabledbool`json:"sshkeyenabled"`
Statusstring`json:"status"`
Tags []interface{} `json:"tags"`
Templatetypestring`json:"templatetype"`
Zoneidstring`json:"zoneid"`
Zonenamestring`json:"zonename"`
}
typeListTemplatesResponsestruct {
Listtemplatesresponsestruct {
Countfloat64`json:"count"`
Template []Template`json:"template"`
} `json:"listtemplatesresponse"`
}