Fix api interfaces for orchestration resources

Some of the interfaces don't correspond well to the values
expected by the requests and returned by api.
diff --git a/openstack/orchestration/v1/stackresources/fixtures.go b/openstack/orchestration/v1/stackresources/fixtures.go
index c3c3d3f..2273ba7 100644
--- a/openstack/orchestration/v1/stackresources/fixtures.go
+++ b/openstack/orchestration/v1/stackresources/fixtures.go
@@ -28,10 +28,13 @@
 		LogicalID:    "hello_world",
 		StatusReason: "state changed",
 		UpdatedTime:  time.Date(2015, 2, 5, 21, 33, 11, 0, time.UTC),
+		CreationTime: time.Date(2015, 2, 5, 21, 33, 10, 0, time.UTC),
 		RequiredBy:   []interface{}{},
 		Status:       "CREATE_IN_PROGRESS",
 		PhysicalID:   "49181cd6-169a-4130-9455-31185bbfc5bf",
 		Type:         "OS::Nova::Server",
+		Attributes:   map[string]interface{}{"SXSW": "atx"},
+		Description:  "Some resource",
 	},
 }
 
@@ -40,6 +43,8 @@
 {
   "resources": [
   {
+  	"description": "Some resource",
+  	"attributes": {"SXSW": "atx"},
     "resource_name": "hello_world",
     "links": [
       {
@@ -54,6 +59,7 @@
     "logical_resource_id": "hello_world",
     "resource_status_reason": "state changed",
     "updated_time": "2015-02-05T21:33:11",
+	"creation_time": "2015-02-05T21:33:10",
     "required_by": [],
     "resource_status": "CREATE_IN_PROGRESS",
     "physical_resource_id": "49181cd6-169a-4130-9455-31185bbfc5bf",
@@ -93,10 +99,13 @@
 		LogicalID:    "hello_world",
 		StatusReason: "state changed",
 		UpdatedTime:  time.Date(2015, 2, 5, 21, 33, 11, 0, time.UTC),
+		CreationTime: time.Date(2015, 2, 5, 21, 33, 10, 0, time.UTC),
 		RequiredBy:   []interface{}{},
 		Status:       "CREATE_IN_PROGRESS",
 		PhysicalID:   "49181cd6-169a-4130-9455-31185bbfc5bf",
 		Type:         "OS::Nova::Server",
+		Attributes:   map[string]interface{}{"SXSW": "atx"},
+		Description:  "Some resource",
 	},
 }
 
@@ -121,7 +130,10 @@
     "required_by": [],
     "resource_status": "CREATE_IN_PROGRESS",
     "physical_resource_id": "49181cd6-169a-4130-9455-31185bbfc5bf",
-    "resource_type": "OS::Nova::Server"
+	"creation_time": "2015-02-05T21:33:10",
+    "resource_type": "OS::Nova::Server",
+	"attributes": {"SXSW": "atx"},
+	"description": "Some resource"
   }
 ]
 }`
@@ -162,6 +174,7 @@
 		},
 	},
 	LogicalID:    "wordpress_instance",
+	Attributes:   map[string]interface{}{"SXSW": "atx"},
 	StatusReason: "state changed",
 	UpdatedTime:  time.Date(2014, 12, 10, 18, 34, 35, 0, time.UTC),
 	RequiredBy:   []interface{}{},
@@ -174,6 +187,8 @@
 const GetOutput = `
 {
   "resource": {
+    "description": "Some resource",
+    "attributes": {"SXSW": "atx"},
     "resource_name": "wordpress_instance",
     "description": "",
     "links": [
@@ -240,7 +255,7 @@
 }
 
 // ListTypesExpected represents the expected object from a ListTypes request.
-var ListTypesExpected = []string{
+var ListTypesExpected = resourceTypes{
 	"OS::Nova::Server",
 	"OS::Heat::RandomString",
 	"OS::Swift::Container",
@@ -251,6 +266,18 @@
 	"OS::Nova::KeyPair",
 }
 
+// same as above, but sorted
+var SortedListTypesExpected = resourceTypes{
+	"OS::Cinder::VolumeAttachment",
+	"OS::Heat::RandomString",
+	"OS::Nova::FloatingIP",
+	"OS::Nova::FloatingIPAssociation",
+	"OS::Nova::KeyPair",
+	"OS::Nova::Server",
+	"OS::Swift::Container",
+	"OS::Trove::Instance",
+}
+
 // ListTypesOutput represents the response body from a ListTypes request.
 const ListTypesOutput = `
 {
@@ -296,6 +323,11 @@
 		},
 	},
 	ResourceType: "OS::Heat::AResourceName",
+	SupportStatus: map[string]interface{}{
+		"message": "A status message",
+		"status":  "SUPPORTED",
+		"version": "2014.1",
+	},
 }
 
 // GetSchemaOutput represents the response body from a Schema request.
@@ -314,7 +346,12 @@
       "description": "A resource description."
     }
   },
-  "resource_type": "OS::Heat::AResourceName"
+  "resource_type": "OS::Heat::AResourceName",
+  "support_status": {
+	"message": "A status message",
+	"status": "SUPPORTED",
+	"version": "2014.1"
+  }
 }`
 
 // HandleGetSchemaSuccessfully creates an HTTP handler at `/resource_types/OS::Heat::AResourceName`
@@ -332,56 +369,7 @@
 }
 
 // GetTemplateExpected represents the expected object from a Template request.
-var GetTemplateExpected = &TypeTemplate{
-	HeatTemplateFormatVersion: "2012-12-12",
-	Outputs: map[string]interface{}{
-		"private_key": map[string]interface{}{
-			"Description": "The private key if it has been saved.",
-			"Value":       "{\"Fn::GetAtt\": [\"KeyPair\", \"private_key\"]}",
-		},
-		"public_key": map[string]interface{}{
-			"Description": "The public key.",
-			"Value":       "{\"Fn::GetAtt\": [\"KeyPair\", \"public_key\"]}",
-		},
-	},
-	Parameters: map[string]interface{}{
-		"name": map[string]interface{}{
-			"Description": "The name of the key pair.",
-			"Type":        "String",
-		},
-		"public_key": map[string]interface{}{
-			"Description": "The optional public key. This allows users to supply the public key from a pre-existing key pair. If not supplied, a new key pair will be generated.",
-			"Type":        "String",
-		},
-		"save_private_key": map[string]interface{}{
-			"AllowedValues": []string{
-				"True",
-				"true",
-				"False",
-				"false",
-			},
-			"Default":     false,
-			"Description": "True if the system should remember a generated private key; False otherwise.",
-			"Type":        "String",
-		},
-	},
-	Resources: map[string]interface{}{
-		"KeyPair": map[string]interface{}{
-			"Properties": map[string]interface{}{
-				"name": map[string]interface{}{
-					"Ref": "name",
-				},
-				"public_key": map[string]interface{}{
-					"Ref": "public_key",
-				},
-				"save_private_key": map[string]interface{}{
-					"Ref": "save_private_key",
-				},
-			},
-			"Type": "OS::Nova::KeyPair",
-		},
-	},
-}
+var GetTemplateExpected = "{\n  \"HeatTemplateFormatVersion\": \"2012-12-12\",\n  \"Outputs\": {\n    \"private_key\": {\n      \"Description\": \"The private key if it has been saved.\",\n      \"Value\": \"{\\\"Fn::GetAtt\\\": [\\\"KeyPair\\\", \\\"private_key\\\"]}\"\n    },\n    \"public_key\": {\n      \"Description\": \"The public key.\",\n      \"Value\": \"{\\\"Fn::GetAtt\\\": [\\\"KeyPair\\\", \\\"public_key\\\"]}\"\n    }\n  },\n  \"Parameters\": {\n    \"name\": {\n      \"Description\": \"The name of the key pair.\",\n      \"Type\": \"String\"\n    },\n    \"public_key\": {\n      \"Description\": \"The optional public key. This allows users to supply the public key from a pre-existing key pair. If not supplied, a new key pair will be generated.\",\n      \"Type\": \"String\"\n    },\n    \"save_private_key\": {\n      \"AllowedValues\": [\n        \"True\",\n        \"true\",\n        \"False\",\n        \"false\"\n      ],\n      \"Default\": false,\n      \"Description\": \"True if the system should remember a generated private key; False otherwise.\",\n      \"Type\": \"String\"\n    }\n  },\n  \"Resources\": {\n    \"KeyPair\": {\n      \"Properties\": {\n        \"name\": {\n          \"Ref\": \"name\"\n        },\n        \"public_key\": {\n          \"Ref\": \"public_key\"\n        },\n        \"save_private_key\": {\n          \"Ref\": \"save_private_key\"\n        }\n      },\n      \"Type\": \"OS::Nova::KeyPair\"\n    }\n  }\n}"
 
 // GetTemplateOutput represents the response body from a Template request.
 const GetTemplateOutput = `
diff --git a/openstack/orchestration/v1/stackresources/requests_test.go b/openstack/orchestration/v1/stackresources/requests_test.go
index f137878..e5045a7 100644
--- a/openstack/orchestration/v1/stackresources/requests_test.go
+++ b/openstack/orchestration/v1/stackresources/requests_test.go
@@ -1,6 +1,7 @@
 package stackresources
 
 import (
+	"sort"
 	"testing"
 
 	"github.com/rackspace/gophercloud/pagination"
@@ -75,6 +76,9 @@
 		th.AssertNoErr(t, err)
 
 		th.CheckDeepEquals(t, ListTypesExpected, actual)
+		// test if sorting works
+		sort.Sort(actual)
+		th.CheckDeepEquals(t, SortedListTypesExpected, actual)
 
 		return true, nil
 	})
@@ -103,5 +107,5 @@
 	th.AssertNoErr(t, err)
 
 	expected := GetTemplateExpected
-	th.AssertDeepEquals(t, expected, actual)
+	th.AssertDeepEquals(t, expected, string(actual))
 }
diff --git a/openstack/orchestration/v1/stackresources/results.go b/openstack/orchestration/v1/stackresources/results.go
index df79d58..51c3c0c 100644
--- a/openstack/orchestration/v1/stackresources/results.go
+++ b/openstack/orchestration/v1/stackresources/results.go
@@ -1,6 +1,7 @@
 package stackresources
 
 import (
+	"encoding/json"
 	"fmt"
 	"reflect"
 	"time"
@@ -12,15 +13,18 @@
 
 // Resource represents a stack resource.
 type Resource struct {
-	Links        []gophercloud.Link `mapstructure:"links"`
-	LogicalID    string             `mapstructure:"logical_resource_id"`
-	Name         string             `mapstructure:"resource_name"`
-	PhysicalID   string             `mapstructure:"physical_resource_id"`
-	RequiredBy   []interface{}      `mapstructure:"required_by"`
-	Status       string             `mapstructure:"resource_status"`
-	StatusReason string             `mapstructure:"resource_status_reason"`
-	Type         string             `mapstructure:"resource_type"`
-	UpdatedTime  time.Time          `mapstructure:"-"`
+	Attributes   map[string]interface{} `mapstructure:"attributes"`
+	CreationTime time.Time              `mapstructure:"-"`
+	Description  string                 `mapstructure:"description"`
+	Links        []gophercloud.Link     `mapstructure:"links"`
+	LogicalID    string                 `mapstructure:"logical_resource_id"`
+	Name         string                 `mapstructure:"resource_name"`
+	PhysicalID   string                 `mapstructure:"physical_resource_id"`
+	RequiredBy   []interface{}          `mapstructure:"required_by"`
+	Status       string                 `mapstructure:"resource_status"`
+	StatusReason string                 `mapstructure:"resource_status_reason"`
+	Type         string                 `mapstructure:"resource_type"`
+	UpdatedTime  time.Time              `mapstructure:"-"`
 }
 
 // FindResult represents the result of a Find operation.
@@ -54,6 +58,13 @@
 			}
 			res.Res[i].UpdatedTime = t
 		}
+		if date, ok := resource["creation_time"]; ok && date != nil {
+			t, err := time.Parse(gophercloud.STACK_TIME_FMT, date.(string))
+			if err != nil {
+				return nil, err
+			}
+			res.Res[i].CreationTime = t
+		}
 	}
 
 	return res.Res, nil
@@ -75,18 +86,6 @@
 	return len(resources) == 0, nil
 }
 
-// LastMarker returns the last container name in a ListResult.
-func (r ResourcePage) LastMarker() (string, error) {
-	resources, err := ExtractResources(r)
-	if err != nil {
-		return "", err
-	}
-	if len(resources) == 0 {
-		return "", nil
-	}
-	return resources[len(resources)-1].PhysicalID, nil
-}
-
 // ExtractResources interprets the results of a single page from a List() call, producing a slice of Resource entities.
 func ExtractResources(page pagination.Page) ([]Resource, error) {
 	casted := page.(ResourcePage).Body
@@ -94,8 +93,9 @@
 	var response struct {
 		Resources []Resource `mapstructure:"resources"`
 	}
-	err := mapstructure.Decode(casted, &response)
-
+	if err := mapstructure.Decode(casted, &response); err != nil {
+		return nil, err
+	}
 	var resources []interface{}
 	switch casted.(type) {
 	case map[string]interface{}:
@@ -115,9 +115,16 @@
 			}
 			response.Resources[i].UpdatedTime = t
 		}
+		if date, ok := resource["creation_time"]; ok && date != nil {
+			t, err := time.Parse(gophercloud.STACK_TIME_FMT, date.(string))
+			if err != nil {
+				return nil, err
+			}
+			response.Resources[i].CreationTime = t
+		}
 	}
 
-	return response.Resources, err
+	return response.Resources, nil
 }
 
 // GetResult represents the result of a Get operation.
@@ -149,6 +156,13 @@
 		}
 		res.Res.UpdatedTime = t
 	}
+	if date, ok := resource["creation_time"]; ok && date != nil {
+		t, err := time.Parse(gophercloud.STACK_TIME_FMT, date.(string))
+		if err != nil {
+			return nil, err
+		}
+		res.Res.CreationTime = t
+	}
 
 	return res.Res, nil
 }
@@ -192,21 +206,42 @@
 	return len(rts) == 0, nil
 }
 
+// resourceTypes represents the type that holds the result of ExtractResourceTypes.
+// We define methods on this type to sort it before output
+type resourceTypes []string
+
+func (r resourceTypes) Len() int {
+	return len(r)
+}
+
+func (r resourceTypes) Swap(i, j int) {
+	r[i], r[j] = r[j], r[i]
+}
+
+func (r resourceTypes) Less(i, j int) bool {
+	return r[i] < r[j]
+}
+
 // ExtractResourceTypes extracts and returns resource types.
-func ExtractResourceTypes(page pagination.Page) ([]string, error) {
+func ExtractResourceTypes(page pagination.Page) (resourceTypes, error) {
+	casted := page.(ResourceTypePage).Body
+
 	var response struct {
-		ResourceTypes []string `mapstructure:"resource_types"`
+		ResourceTypes resourceTypes `mapstructure:"resource_types"`
 	}
 
-	err := mapstructure.Decode(page.(ResourceTypePage).Body, &response)
-	return response.ResourceTypes, err
+	if err := mapstructure.Decode(casted, &response); err != nil {
+		return nil, err
+	}
+	return response.ResourceTypes, nil
 }
 
 // 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"`
+	Attributes    map[string]interface{} `mapstructure:"attributes"`
+	Properties    map[string]interface{} `mapstrucutre:"properties"`
+	ResourceType  string                 `mapstructure:"resource_type"`
+	SupportStatus map[string]interface{} `mapstructure:"support_status"`
 }
 
 // SchemaResult represents the result of a Schema operation.
@@ -230,31 +265,20 @@
 	return &res, nil
 }
 
-// TypeTemplate represents a stack resource template.
-type TypeTemplate struct {
-	HeatTemplateFormatVersion string
-	Outputs                   map[string]interface{}
-	Parameters                map[string]interface{}
-	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
+// Extract returns the template and is called after a
 // Template operation.
-func (r TemplateResult) Extract() (*TypeTemplate, error) {
+func (r TemplateResult) Extract() ([]byte, error) {
 	if r.Err != nil {
 		return nil, r.Err
 	}
-
-	var res TypeTemplate
-
-	if err := mapstructure.Decode(r.Body, &res); err != nil {
+	template, err := json.MarshalIndent(r.Body, "", "  ")
+	if err != nil {
 		return nil, err
 	}
-
-	return &res, nil
+	return template, nil
 }