objectstorage v1 and orchestration v1 struct tags
diff --git a/openstack/orchestration/v1/stacktemplates/requests.go b/openstack/orchestration/v1/stacktemplates/requests.go
index d307fad..9337cae 100644
--- a/openstack/orchestration/v1/stacktemplates/requests.go
+++ b/openstack/orchestration/v1/stacktemplates/requests.go
@@ -4,11 +4,9 @@
// Get retreives data for the given stack template.
func Get(c *gophercloud.ServiceClient, stackName, stackID string) GetResult {
- var res GetResult
- _, res.Err = c.Request("GET", getURL(c, stackName, stackID), &gophercloud.RequestOpts{
- JSONResponse: &res.Body,
- })
- return res
+ var r GetResult
+ _, r.Err = c.Get(getURL(c, stackName, stackID), &r.Body, nil)
+ return r
}
// ValidateOptsBuilder describes struct types that can be accepted by the Validate call.
@@ -19,39 +17,25 @@
// ValidateOpts specifies the template validation parameters.
type ValidateOpts struct {
- Template string
- TemplateURL string
+ Template string `json:"template" or:"TemplateURL"`
+ TemplateURL string `json:"template_url" or:"Template"`
}
// ToStackTemplateValidateMap assembles a request body based on the contents of a ValidateOpts.
func (opts ValidateOpts) ToStackTemplateValidateMap() (map[string]interface{}, error) {
- vo := make(map[string]interface{})
- if opts.Template != "" {
- vo["template"] = opts.Template
- return vo, nil
- }
- if opts.TemplateURL != "" {
- vo["template_url"] = opts.TemplateURL
- return vo, nil
- }
- err := gophercloud.ErrMissingInput{}
- err.Argument = "stacktemplates.ValidateOpts.Template/stacktemplates.ValidateOpts.TemplateURL"
- err.Info = "One of Template or TemplateURL is required."
- return nil, err
+ return gophercloud.BuildRequestBody(opts, "")
}
// Validate validates the given stack template.
func Validate(c *gophercloud.ServiceClient, opts ValidateOptsBuilder) ValidateResult {
- var res ValidateResult
-
- reqBody, err := opts.ToStackTemplateValidateMap()
+ var r ValidateResult
+ b, err := opts.ToStackTemplateValidateMap()
if err != nil {
- res.Err = err
- return res
+ r.Err = err
+ return r
}
-
- _, res.Err = c.Post(validateURL(c), reqBody, &res.Body, &gophercloud.RequestOpts{
+ _, r.Err = c.Post(validateURL(c), b, &r.Body, &gophercloud.RequestOpts{
OkCodes: []int{200},
})
- return res
+ return r
}