comments
diff --git a/openstack/orchestration/v1/stackresources/fixtures.go b/openstack/orchestration/v1/stackresources/fixtures.go
index 18a8de5..003abf3 100644
--- a/openstack/orchestration/v1/stackresources/fixtures.go
+++ b/openstack/orchestration/v1/stackresources/fixtures.go
@@ -11,6 +11,7 @@
fake "github.com/rackspace/gophercloud/testhelper/client"
)
+// FindExpected represents the expected object from a Find request.
var FindExpected = []Resource{
Resource{
Name: "hello_world",
@@ -34,6 +35,7 @@
},
}
+// FindOutput represents the response body from a Find request.
const FindOutput = `
{
"resources": [
@@ -74,6 +76,7 @@
})
}
+// ListExpected represents the expected object from a List request.
var ListExpected = []Resource{
Resource{
Name: "hello_world",
@@ -97,6 +100,7 @@
},
}
+// ListOutput represents the response body from a List request.
const ListOutput = `{
"resources": [
{
@@ -142,6 +146,7 @@
})
}
+// GetExpected represents the expected object from a Get request.
var GetExpected = &Resource{
Name: "wordpress_instance",
Links: []gophercloud.Link{
@@ -163,6 +168,7 @@
Type: "OS::Nova::Server",
}
+// GetOutput represents the response body from a Get request.
const GetOutput = `
{
"resource": {
@@ -202,11 +208,13 @@
})
}
+// MetadataExpected represents the expected object from a Metadata request.
var MetadataExpected = map[string]string{
"number": "7",
"animal": "auk",
}
+// MetadataOutput represents the response body from a Metadata request.
const MetadataOutput = `
{
"metadata": {
@@ -229,6 +237,7 @@
})
}
+// ListTypesExpected represents the expected object from a ListTypes request.
var ListTypesExpected = []string{
"OS::Nova::Server",
"OS::Heat::RandomString",
@@ -240,6 +249,7 @@
"OS::Nova::KeyPair",
}
+// ListTypesOutput represents the response body from a ListTypes request.
const ListTypesOutput = `
{
"resource_types": [
@@ -268,6 +278,7 @@
})
}
+// GetSchemaExpected represents the expected object from a Schema request.
var GetSchemaExpected = &TypeSchema{
Attributes: map[string]interface{}{
"an_attribute": map[string]interface{}{
@@ -285,6 +296,7 @@
ResourceType: "OS::Heat::AResourceName",
}
+// GetSchemaOutput represents the response body from a Schema request.
const GetSchemaOutput = `
{
"attributes": {
@@ -317,6 +329,7 @@
})
}
+// GetTemplateExpected represents the expected object from a Template request.
var GetTemplateExpected = &TypeTemplate{
HeatTemplateFormatVersion: "2012-12-12",
Outputs: map[string]interface{}{
@@ -368,6 +381,7 @@
},
}
+// GetTemplateOutput represents the response body from a Template request.
const GetTemplateOutput = `
{
"HeatTemplateFormatVersion": "2012-12-12",
diff --git a/openstack/orchestration/v1/stackresources/results.go b/openstack/orchestration/v1/stackresources/results.go
index 4a0de8e..13f5dd2 100644
--- a/openstack/orchestration/v1/stackresources/results.go
+++ b/openstack/orchestration/v1/stackresources/results.go
@@ -8,6 +8,7 @@
"github.com/rackspace/gophercloud/pagination"
)
+// Resource represents a stack resource.
type Resource struct {
Links []gophercloud.Link `mapstructure:"links"`
LogicalID string `mapstructure:"logical_resource_id"`
@@ -20,10 +21,13 @@
UpdatedTime time.Time `mapstructure:"-"`
}
+// FindResult represents the result of a Find operation.
type FindResult struct {
gophercloud.Result
}
+// Extract returns a slice of Resource objects and is called after a
+// Find operation.
func (r FindResult) Extract() ([]Resource, error) {
if r.Err != nil {
return nil, r.Err
@@ -106,10 +110,13 @@
return response.Resources, err
}
+// GetResult represents the result of a Get operation.
type GetResult struct {
gophercloud.Result
}
+// Extract returns a pointer to a Resource object and is called after a
+// Get operation.
func (r GetResult) Extract() (*Resource, error) {
if r.Err != nil {
return nil, r.Err
@@ -136,10 +143,13 @@
return res.Res, nil
}
+// MetadataResult represents the result of a Metadata operation.
type MetadataResult struct {
gophercloud.Result
}
+// Extract returns a map object and is called after a
+// Metadata operation.
func (r MetadataResult) Extract() (map[string]string, error) {
if r.Err != nil {
return nil, r.Err
@@ -182,16 +192,20 @@
return response.ResourceTypes, err
}
+// TypeSchema represents a stack resource schema.
type TypeSchema struct {
Attributes map[string]interface{} `mapstructure:"attributes"`
Properties map[string]interface{} `mapstrucutre:"properties"`
ResourceType string `mapstructure:"resource_type"`
}
+// SchemaResult represents the result of a Schema operation.
type SchemaResult struct {
gophercloud.Result
}
+// Extract returns a pointer to a TypeSchema object and is called after a
+// Schema operation.
func (r SchemaResult) Extract() (*TypeSchema, error) {
if r.Err != nil {
return nil, r.Err
@@ -206,6 +220,7 @@
return &res, nil
}
+// TypeTemplate represents a stack resource template.
type TypeTemplate struct {
HeatTemplateFormatVersion string
Outputs map[string]interface{}
@@ -213,10 +228,13 @@
Resources map[string]interface{}
}
+// TemplateResult represents the result of a Template operation.
type TemplateResult struct {
gophercloud.Result
}
+// Extract returns a pointer to a TypeTemplate object and is called after a
+// Template operation.
func (r TemplateResult) Extract() (*TypeTemplate, error) {
if r.Err != nil {
return nil, r.Err