Skip to content

Commit b3c91f4

Browse files
author
Peter Jönsson
committed
Add response to ListTemplates
1 parent ab3faee commit b3c91f4

2 files changed

Lines changed: 45 additions & 3 deletions

File tree

client.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@ func NewRequest(c CloudStackClient, request string, params url.Values) (interfac
118118
json.Unmarshal(body, &decodedResponse)
119119
return decodedResponse, nil
120120

121+
case "ListTemplatesResponse":
122+
var decodedResponse ListTemplatesResponse
123+
json.Unmarshal(body, &decodedResponse)
124+
return decodedResponse, nil
125+
121126
case "queryAsyncJobResult":
122127
var decodedResponse QueryAsyncJobResultResponse
123128
json.Unmarshal(body, &decodedResponse)

template.go

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,16 @@ func (c CloudStackClient) CreateTemplate(displaytext string, name string, volume
2222
}
2323

2424
// Returns all available templates
25-
func (c CloudStackClient) ListTemplates(name string) ([]string, error) {
25+
func (c CloudStackClient) ListTemplates(name string, filter string) (string, error) {
2626
params := url.Values{}
2727
params.Set("name", name)
28+
params.Set("templatefilter", filter)
2829
_, err := NewRequest(c, "listTemplates", params)
2930
if err != nil {
30-
return nil, err
31+
return "", err
3132
}
3233

33-
return nil, err
34+
return "", err
3435
}
3536

3637
// Deletes an template by its ID.
@@ -50,3 +51,39 @@ type CreateTemplateResponse struct {
5051
Jobid string `json:"jobid"`
5152
} `json:"createtemplateresponse"`
5253
}
54+
55+
56+
type Template struct {
57+
Account string `json:"account"`
58+
Created string `json:"created"`
59+
CrossZones bool `json:"crossZones"`
60+
Displaytext string `json:"displaytext"`
61+
Domain string `json:"domain"`
62+
Domainid string `json:"domainid"`
63+
Format string `json:"format"`
64+
Hypervisor string `json:"hypervisor"`
65+
ID string `json:"id"`
66+
Isextractable bool `json:"isextractable"`
67+
Isfeatured bool `json:"isfeatured"`
68+
Ispublic bool `json:"ispublic"`
69+
Isready bool `json:"isready"`
70+
Name string `json:"name"`
71+
Ostypeid string `json:"ostypeid"`
72+
Ostypename string `json:"ostypename"`
73+
Passwordenabled bool `json:"passwordenabled"`
74+
Size float64 `json:"size"`
75+
Sourcetemplateid string `json:"sourcetemplateid"`
76+
Sshkeyenabled bool `json:"sshkeyenabled"`
77+
Status string `json:"status"`
78+
Tags []interface{} `json:"tags"`
79+
Templatetype string `json:"templatetype"`
80+
Zoneid string `json:"zoneid"`
81+
Zonename string `json:"zonename"`
82+
}
83+
84+
type ListTemplatesResponse struct {
85+
Listtemplatesresponse struct {
86+
Count float64 `json:"count"`
87+
Template []Template `json:"template"`
88+
} `json:"listtemplatesresponse"`
89+
}

0 commit comments

Comments
 (0)