Rackspace Auto Scale: Add webhooks Get()
diff --git a/rackspace/autoscale/v1/webhooks/results.go b/rackspace/autoscale/v1/webhooks/results.go
index 410f5cb..0fa550e 100644
--- a/rackspace/autoscale/v1/webhooks/results.go
+++ b/rackspace/autoscale/v1/webhooks/results.go
@@ -11,6 +11,21 @@
gophercloud.Result
}
+// Extract interprets any webhookResult as a Webhook, if possible.
+func (r webhookResult) Extract() (*Webhook, error) {
+ if r.Err != nil {
+ return nil, r.Err
+ }
+
+ var response struct {
+ Webhook Webhook `mapstructure:"webhook"`
+ }
+
+ err := mapstructure.Decode(r.Body, &response)
+
+ return &response.Webhook, err
+}
+
// CreateResult represents the result of a create operation. Multiple webhooks
// can be created in a single call, so the result should be treated as a typical
// pagination Page. ExtractWebhooks() can be used to extract a slice of
@@ -19,6 +34,11 @@
pagination.SinglePageBase
}
+// GetResult temporarily contains the response from a Get call.
+type GetResult struct {
+ webhookResult
+}
+
// ExtractWebhooks extracts a slice of Webhooks from a CreateResult.
func (res CreateResult) ExtractWebhooks() ([]Webhook, error) {
if res.Err != nil {