blob: 968a3ec672c9ca47c5b0e9a33896edccc81ca5a1 [file] [log] [blame]
Jon Perrittf799b942015-02-09 11:23:28 -07001package stacktemplates
2
3import (
4 "github.com/mitchellh/mapstructure"
5 "github.com/rackspace/gophercloud"
6)
7
8type Template struct {
9 Description string `mapstructure:"description"`
10 HeatTemplateVersion string `mapstructure:"heat_template_version"`
11 Parameters map[string]interface{} `mapstructure:"parameters"`
12 Resources map[string]interface{} `mapstructure:"resources"`
13}
14
15type GetResult struct {
16 gophercloud.Result
17}
18
19func (r GetResult) Extract() (*Template, error) {
20 if r.Err != nil {
21 return nil, r.Err
22 }
23
24 var res Template
25 if err := mapstructure.Decode(r.Body, &res); err != nil {
26 return nil, err
27 }
28
29 return &res, nil
30}
31
32type ValidatedTemplate struct {
33 Description string
34 Parameters map[string]interface{}
35}
36
37type ValidateResult struct {
38 gophercloud.Result
39}
40
41func (r ValidateResult) Extract() (*ValidatedTemplate, error) {
42 if r.Err != nil {
43 return nil, r.Err
44 }
45
46 var res ValidatedTemplate
47 if err := mapstructure.Decode(r.Body, &res); err != nil {
48 return nil, err
49 }
50
51 return &res, nil
52}