Jamie Hannaford | 1ba046f | 2014-11-06 13:21:30 +0100 | [diff] [blame] | 1 | package throttle |
| 2 | |
| 3 | import ( |
| 4 | "github.com/mitchellh/mapstructure" |
| 5 | |
| 6 | "github.com/rackspace/gophercloud" |
| 7 | ) |
| 8 | |
| 9 | // ConnectionThrottle represents the connection throttle configuration for a |
| 10 | // particular load balancer. |
| 11 | type ConnectionThrottle struct { |
| 12 | MaxConnections int |
| 13 | } |
| 14 | |
| 15 | // CreateResult represents the result of a create operation. |
| 16 | type CreateResult struct { |
| 17 | gophercloud.ErrResult |
| 18 | } |
| 19 | |
| 20 | // DeleteResult represents the result of a delete operation. |
| 21 | type DeleteResult struct { |
| 22 | gophercloud.ErrResult |
| 23 | } |
| 24 | |
| 25 | // GetResult represents the result of a get operation. |
| 26 | type GetResult struct { |
| 27 | gophercloud.Result |
| 28 | } |
| 29 | |
| 30 | // Extract interprets a GetResult as a SP, if possible. |
| 31 | func (r GetResult) Extract() (*ConnectionThrottle, error) { |
| 32 | if r.Err != nil { |
| 33 | return nil, r.Err |
| 34 | } |
| 35 | |
| 36 | var response struct { |
| 37 | CT ConnectionThrottle `mapstructure:"connectionThrottle"` |
| 38 | } |
| 39 | |
| 40 | err := mapstructure.Decode(r.Body, &response) |
| 41 | |
| 42 | return &response.CT, err |
| 43 | } |