-
Notifications
You must be signed in to change notification settings - Fork 4.7k
/
results.go
60 lines (49 loc) · 1.48 KB
/
results.go
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
package stacktemplates
import (
"github.com/mitchellh/mapstructure"
"github.com/rackspace/gophercloud"
)
// Template represents a stack template.
type Template struct {
Description string `mapstructure:"description"`
HeatTemplateVersion string `mapstructure:"heat_template_version"`
Parameters map[string]interface{} `mapstructure:"parameters"`
Resources map[string]interface{} `mapstructure:"resources"`
}
// GetResult represents the result of a Get operation.
type GetResult struct {
gophercloud.Result
}
// Extract returns a pointer to a Template object and is called after a
// Get operation.
func (r GetResult) Extract() (*Template, error) {
if r.Err != nil {
return nil, r.Err
}
var res Template
if err := mapstructure.Decode(r.Body, &res); err != nil {
return nil, err
}
return &res, nil
}
// ValidatedTemplate represents the parsed object returned from a Validate request.
type ValidatedTemplate struct {
Description string
Parameters map[string]interface{}
}
// ValidateResult represents the result of a Validate operation.
type ValidateResult struct {
gophercloud.Result
}
// Extract returns a pointer to a ValidatedTemplate object and is called after a
// Validate operation.
func (r ValidateResult) Extract() (*ValidatedTemplate, error) {
if r.Err != nil {
return nil, r.Err
}
var res ValidatedTemplate
if err := mapstructure.Decode(r.Body, &res); err != nil {
return nil, err
}
return &res, nil
}