Jamie Hannaford | 276a032 | 2014-11-06 14:26:12 +0100 | [diff] [blame] | 1 | package throttle |
| 2 | |
| 3 | import ( |
| 4 | "github.com/mitchellh/mapstructure" |
| 5 | "github.com/rackspace/gophercloud" |
| 6 | ) |
| 7 | |
| 8 | // SSLTermConfig represents the SSL configuration for a particular load balancer. |
| 9 | type SSLTermConfig struct { |
| 10 | // The port on which the SSL termination load balancer listens for secure |
| 11 | // traffic. The value must be unique to the existing LB protocol/port |
| 12 | // combination |
| 13 | SecurePort int `mapstructure:"securePort"` |
| 14 | |
| 15 | // The private key for the SSL certificate which is validated and verified |
| 16 | // against the provided certificates. |
| 17 | PrivateKey string `mapstructure:"privatekey"` |
| 18 | |
| 19 | // The certificate used for SSL termination, which is validated and verified |
| 20 | // against the key and intermediate certificate if provided. |
| 21 | Certificate string |
| 22 | |
| 23 | // The intermediate certificate (for the user). The intermediate certificate |
| 24 | // is validated and verified against the key and certificate credentials |
| 25 | // provided. A user may only provide this value when accompanied by a |
| 26 | // Certificate, PrivateKey, and SecurePort. It may not be added or updated as |
| 27 | // a single attribute in a future operation. |
| 28 | IntCertificate string `mapstructure:"intermediatecertificate"` |
| 29 | |
| 30 | // Determines if the load balancer is enabled to terminate SSL traffic or not. |
| 31 | // If this is set to false, the load balancer retains its specified SSL |
| 32 | // attributes but does not terminate SSL traffic. |
| 33 | Enabled bool |
| 34 | |
| 35 | // Determines if the load balancer can only accept secure traffic. If set to |
| 36 | // true, the load balancer will not accept non-secure traffic. |
| 37 | SecureTrafficOnly bool |
| 38 | } |
| 39 | |
| 40 | // DeleteResult represents the result of a delete operation. |
| 41 | type DeleteResult struct { |
| 42 | gophercloud.ErrResult |
| 43 | } |
| 44 | |
| 45 | // UpdateResult represents the result of an update operation. |
| 46 | type UpdateResult struct { |
| 47 | gophercloud.ErrResult |
| 48 | } |
| 49 | |
| 50 | // GetResult represents the result of a get operation. |
| 51 | type GetResult struct { |
| 52 | gophercloud.Result |
| 53 | } |
| 54 | |
| 55 | // Extract interprets a GetResult as a SSLTermConfig struct, if possible. |
| 56 | func (r GetResult) Extract() (*SSLTermConfig, error) { |
| 57 | if r.Err != nil { |
| 58 | return nil, r.Err |
| 59 | } |
| 60 | |
| 61 | var response struct { |
| 62 | SSL SSLTermConfig `mapstructure:"sslTermination"` |
| 63 | } |
| 64 | |
| 65 | err := mapstructure.Decode(r.Body, &response) |
| 66 | |
| 67 | return &response.SSL, err |
| 68 | } |