Adding get monitor
diff --git a/rackspace/lb/v1/monitors/results.go b/rackspace/lb/v1/monitors/results.go
index 666f504..29149d8 100644
--- a/rackspace/lb/v1/monitors/results.go
+++ b/rackspace/lb/v1/monitors/results.go
@@ -1,6 +1,10 @@
package monitors
-import "github.com/rackspace/gophercloud"
+import (
+ "github.com/mitchellh/mapstructure"
+
+ "github.com/rackspace/gophercloud"
+)
// Type represents the type of Monitor.
type Type string
@@ -12,32 +16,20 @@
HTTPS Type = "HTTPS"
)
-// ConnectMonitor represents a CONNECT monitor which performs a basic connection
-// to each node on its defined port to ensure that the service is listening
-// properly. The connect monitor is the most basic type of health check and
-// does no post-processing or protocol specific health checks.
-type ConnectMonitor struct {
- // Number of permissible monitor failures before removing a node from
- // rotation.
- AttemptLimit int `mapstructure:"attemptsBeforeDeactivation"`
-
- // The minimum number of seconds to wait before executing the health monitor.
- Delay int
-
- // Maximum number of seconds to wait for a connection to be established
- // before timing out.
- Timeout int
-
- // Type of the health monitor.
- Type Type
-}
-
-// HTTPMonitor represents a HTTP monitor type, which is generally considered a
-// more intelligent and powerful type than CONNECT. It is capable of processing
-// a HTTP or HTTPS response to determine the condition of a node. It supports
-// the same basic properties as CONNECT and includes additional attributes that
-// are used to evaluate the HTTP response.
-type HTTPMonitor struct {
+// Monitor represents a health monitor API resource. A monitor comes in three
+// forms: CONNECT, HTTP or HTTPS.
+//
+// A CONNECT monitor establishes a basic connection to each node on its defined
+// port to ensure that the service is listening properly. The connect monitor
+// is the most basic type of health check and does no post-processing or
+// protocol specific health checks.
+//
+// HTTP and HTTPS health monitors are generally considered more intelligent and
+// powerful than CONNECT. It is capable of processing a HTTP or HTTPS response
+// to determine the condition of a node. It supports the same basic properties
+// as CONNECT and includes additional attributes that are used to evaluate the
+// HTTP response.
+type Monitor struct {
// Number of permissible monitor failures before removing a node from
// rotation.
AttemptLimit int `mapstructure:"attemptsBeforeDeactivation"`
@@ -67,10 +59,27 @@
StatusRegex string
}
-// HTTPSMonitor the HTTPS equivalent of HTTPMonitor
-type HTTPSMonitor HTTPMonitor
-
// UpdateResult represents the result of an Update operation.
type UpdateResult struct {
gophercloud.ErrResult
}
+
+// GetResult represents the result of a Get operation.
+type GetResult struct {
+ gophercloud.Result
+}
+
+// Extract interprets any GetResult as a Monitor.
+func (r GetResult) Extract() (*Monitor, error) {
+ if r.Err != nil {
+ return nil, r.Err
+ }
+
+ var response struct {
+ M Monitor `mapstructure:"healthMonitor"`
+ }
+
+ err := mapstructure.Decode(r.Body, &response)
+
+ return &response.M, err
+}