Jon Perritt | f799b94 | 2015-02-09 11:23:28 -0700 | [diff] [blame] | 1 | package stacktemplates |
| 2 | |
| 3 | import ( |
Pratik Mallya | 827c03e | 2015-09-17 00:10:47 -0500 | [diff] [blame] | 4 | "encoding/json" |
Jon Perritt | 3c16647 | 2016-02-25 03:07:41 -0600 | [diff] [blame] | 5 | |
Jon Perritt | 27249f4 | 2016-02-18 10:35:59 -0600 | [diff] [blame] | 6 | "github.com/gophercloud/gophercloud" |
Jon Perritt | f799b94 | 2015-02-09 11:23:28 -0700 | [diff] [blame] | 7 | ) |
| 8 | |
Jon Perritt | 8ade432 | 2015-02-09 11:34:59 -0700 | [diff] [blame] | 9 | // GetResult represents the result of a Get operation. |
Jon Perritt | f799b94 | 2015-02-09 11:23:28 -0700 | [diff] [blame] | 10 | type GetResult struct { |
| 11 | gophercloud.Result |
| 12 | } |
| 13 | |
Pratik Mallya | 827c03e | 2015-09-17 00:10:47 -0500 | [diff] [blame] | 14 | // Extract returns the JSON template and is called after a Get operation. |
| 15 | func (r GetResult) Extract() ([]byte, error) { |
Jon Perritt | f799b94 | 2015-02-09 11:23:28 -0700 | [diff] [blame] | 16 | if r.Err != nil { |
| 17 | return nil, r.Err |
| 18 | } |
Pratik Mallya | 827c03e | 2015-09-17 00:10:47 -0500 | [diff] [blame] | 19 | template, err := json.MarshalIndent(r.Body, "", " ") |
| 20 | if err != nil { |
Jon Perritt | f799b94 | 2015-02-09 11:23:28 -0700 | [diff] [blame] | 21 | return nil, err |
| 22 | } |
Pratik Mallya | 827c03e | 2015-09-17 00:10:47 -0500 | [diff] [blame] | 23 | return template, nil |
Jon Perritt | f799b94 | 2015-02-09 11:23:28 -0700 | [diff] [blame] | 24 | } |
| 25 | |
Jon Perritt | 8ade432 | 2015-02-09 11:34:59 -0700 | [diff] [blame] | 26 | // ValidatedTemplate represents the parsed object returned from a Validate request. |
Jon Perritt | f799b94 | 2015-02-09 11:23:28 -0700 | [diff] [blame] | 27 | type ValidatedTemplate struct { |
Jon Perritt | 3c16647 | 2016-02-25 03:07:41 -0600 | [diff] [blame] | 28 | Description string `json:"Description"` |
| 29 | Parameters map[string]interface{} `json:"Parameters"` |
| 30 | ParameterGroups map[string]interface{} `json:"ParameterGroups"` |
Jon Perritt | f799b94 | 2015-02-09 11:23:28 -0700 | [diff] [blame] | 31 | } |
| 32 | |
Jon Perritt | 8ade432 | 2015-02-09 11:34:59 -0700 | [diff] [blame] | 33 | // ValidateResult represents the result of a Validate operation. |
Jon Perritt | f799b94 | 2015-02-09 11:23:28 -0700 | [diff] [blame] | 34 | type ValidateResult struct { |
| 35 | gophercloud.Result |
| 36 | } |
| 37 | |
Jon Perritt | 8ade432 | 2015-02-09 11:34:59 -0700 | [diff] [blame] | 38 | // Extract returns a pointer to a ValidatedTemplate object and is called after a |
| 39 | // Validate operation. |
Jon Perritt | f799b94 | 2015-02-09 11:23:28 -0700 | [diff] [blame] | 40 | func (r ValidateResult) Extract() (*ValidatedTemplate, error) { |
Jon Perritt | 3c16647 | 2016-02-25 03:07:41 -0600 | [diff] [blame] | 41 | var s *ValidatedTemplate |
| 42 | err := r.ExtractInto(&s) |
| 43 | return s, err |
Jon Perritt | f799b94 | 2015-02-09 11:23:28 -0700 | [diff] [blame] | 44 | } |