blob: bca959b9c12daafd9920d1425d68e6a370c318a2 [file] [log] [blame]
Jon Perrittf799b942015-02-09 11:23:28 -07001package stacktemplates
2
3import (
Pratik Mallya827c03e2015-09-17 00:10:47 -05004 "encoding/json"
Jon Perritt3c166472016-02-25 03:07:41 -06005
Jon Perritt27249f42016-02-18 10:35:59 -06006 "github.com/gophercloud/gophercloud"
Jon Perrittf799b942015-02-09 11:23:28 -07007)
8
Jon Perritt8ade4322015-02-09 11:34:59 -07009// GetResult represents the result of a Get operation.
Jon Perrittf799b942015-02-09 11:23:28 -070010type GetResult struct {
11 gophercloud.Result
12}
13
Pratik Mallya827c03e2015-09-17 00:10:47 -050014// Extract returns the JSON template and is called after a Get operation.
15func (r GetResult) Extract() ([]byte, error) {
Jon Perrittf799b942015-02-09 11:23:28 -070016 if r.Err != nil {
17 return nil, r.Err
18 }
Pratik Mallya827c03e2015-09-17 00:10:47 -050019 template, err := json.MarshalIndent(r.Body, "", " ")
20 if err != nil {
Jon Perrittf799b942015-02-09 11:23:28 -070021 return nil, err
22 }
Pratik Mallya827c03e2015-09-17 00:10:47 -050023 return template, nil
Jon Perrittf799b942015-02-09 11:23:28 -070024}
25
Jon Perritt8ade4322015-02-09 11:34:59 -070026// ValidatedTemplate represents the parsed object returned from a Validate request.
Jon Perrittf799b942015-02-09 11:23:28 -070027type ValidatedTemplate struct {
Jon Perritt3c166472016-02-25 03:07:41 -060028 Description string `json:"Description"`
29 Parameters map[string]interface{} `json:"Parameters"`
30 ParameterGroups map[string]interface{} `json:"ParameterGroups"`
Jon Perrittf799b942015-02-09 11:23:28 -070031}
32
Jon Perritt8ade4322015-02-09 11:34:59 -070033// ValidateResult represents the result of a Validate operation.
Jon Perrittf799b942015-02-09 11:23:28 -070034type ValidateResult struct {
35 gophercloud.Result
36}
37
Jon Perritt8ade4322015-02-09 11:34:59 -070038// Extract returns a pointer to a ValidatedTemplate object and is called after a
39// Validate operation.
Jon Perrittf799b942015-02-09 11:23:28 -070040func (r ValidateResult) Extract() (*ValidatedTemplate, error) {
Jon Perritt3c166472016-02-25 03:07:41 -060041 var s *ValidatedTemplate
42 err := r.ExtractInto(&s)
43 return s, err
Jon Perrittf799b942015-02-09 11:23:28 -070044}