Samuel A. Falvo II | c007c27 | 2014-02-10 20:49:26 -0800 | [diff] [blame] | 1 | package servers |
| 2 | |
| 3 | import ( |
Jon Perritt | 9a0980e | 2015-01-14 21:29:44 -0700 | [diff] [blame] | 4 | "reflect" |
einarf | 4e5fdaf | 2015-04-16 23:14:59 +0000 | [diff] [blame] | 5 | "fmt" |
| 6 | "path" |
| 7 | "net/url" |
Jon Perritt | 9a0980e | 2015-01-14 21:29:44 -0700 | [diff] [blame] | 8 | |
Samuel A. Falvo II | e246ac0 | 2014-02-13 23:20:09 -0800 | [diff] [blame] | 9 | "github.com/mitchellh/mapstructure" |
Ash Wilson | d27e0ff | 2014-09-25 11:50:31 -0400 | [diff] [blame] | 10 | "github.com/rackspace/gophercloud" |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame] | 11 | "github.com/rackspace/gophercloud/pagination" |
Samuel A. Falvo II | c007c27 | 2014-02-10 20:49:26 -0800 | [diff] [blame] | 12 | ) |
| 13 | |
Ash Wilson | 397c78b | 2014-09-25 15:19:14 -0400 | [diff] [blame] | 14 | type serverResult struct { |
Ash Wilson | f548aad | 2014-10-20 08:35:34 -0400 | [diff] [blame] | 15 | gophercloud.Result |
Ash Wilson | 397c78b | 2014-09-25 15:19:14 -0400 | [diff] [blame] | 16 | } |
| 17 | |
| 18 | // Extract interprets any serverResult as a Server, if possible. |
| 19 | func (r serverResult) Extract() (*Server, error) { |
| 20 | if r.Err != nil { |
| 21 | return nil, r.Err |
| 22 | } |
| 23 | |
| 24 | var response struct { |
| 25 | Server Server `mapstructure:"server"` |
| 26 | } |
| 27 | |
Jon Perritt | 9a0980e | 2015-01-14 21:29:44 -0700 | [diff] [blame] | 28 | config := &mapstructure.DecoderConfig{ |
Jon Perritt | 0e19f60 | 2015-01-15 09:35:46 -0700 | [diff] [blame] | 29 | DecodeHook: toMapFromString, |
| 30 | Result: &response, |
Jon Perritt | 9a0980e | 2015-01-14 21:29:44 -0700 | [diff] [blame] | 31 | } |
| 32 | decoder, err := mapstructure.NewDecoder(config) |
| 33 | if err != nil { |
| 34 | return nil, err |
| 35 | } |
| 36 | |
| 37 | err = decoder.Decode(r.Body) |
| 38 | if err != nil { |
| 39 | return nil, err |
| 40 | } |
| 41 | |
| 42 | return &response.Server, nil |
Ash Wilson | 397c78b | 2014-09-25 15:19:14 -0400 | [diff] [blame] | 43 | } |
| 44 | |
| 45 | // CreateResult temporarily contains the response from a Create call. |
| 46 | type CreateResult struct { |
| 47 | serverResult |
| 48 | } |
| 49 | |
| 50 | // GetResult temporarily contains the response from a Get call. |
| 51 | type GetResult struct { |
| 52 | serverResult |
| 53 | } |
| 54 | |
| 55 | // UpdateResult temporarily contains the response from an Update call. |
| 56 | type UpdateResult struct { |
| 57 | serverResult |
| 58 | } |
| 59 | |
Jon Perritt | cc77da6 | 2014-11-16 13:14:21 -0700 | [diff] [blame] | 60 | // DeleteResult temporarily contains the response from a Delete call. |
Jamie Hannaford | 34732fe | 2014-10-27 11:29:36 +0100 | [diff] [blame] | 61 | type DeleteResult struct { |
Jon Perritt | ba2395e | 2014-10-27 15:23:21 -0500 | [diff] [blame] | 62 | gophercloud.ErrResult |
Jamie Hannaford | 34732fe | 2014-10-27 11:29:36 +0100 | [diff] [blame] | 63 | } |
| 64 | |
Ash Wilson | 397c78b | 2014-09-25 15:19:14 -0400 | [diff] [blame] | 65 | // RebuildResult temporarily contains the response from a Rebuild call. |
Jamie Hannaford | 01c1efe | 2014-10-16 15:08:59 +0200 | [diff] [blame] | 66 | type RebuildResult struct { |
Ash Wilson | 397c78b | 2014-09-25 15:19:14 -0400 | [diff] [blame] | 67 | serverResult |
| 68 | } |
Samuel A. Falvo II | c007c27 | 2014-02-10 20:49:26 -0800 | [diff] [blame] | 69 | |
Jamie Hannaford | 01c1efe | 2014-10-16 15:08:59 +0200 | [diff] [blame] | 70 | // ActionResult represents the result of server action operations, like reboot |
| 71 | type ActionResult struct { |
Jon Perritt | ba2395e | 2014-10-27 15:23:21 -0500 | [diff] [blame] | 72 | gophercloud.ErrResult |
Jamie Hannaford | 01c1efe | 2014-10-16 15:08:59 +0200 | [diff] [blame] | 73 | } |
| 74 | |
Alex Gaynor | 587e3e3 | 2014-11-13 10:39:09 -0800 | [diff] [blame] | 75 | // RescueResult represents the result of a server rescue operation |
Alex Gaynor | fbe61bb | 2014-11-12 13:35:03 -0800 | [diff] [blame] | 76 | type RescueResult struct { |
| 77 | ActionResult |
Alex Gaynor | 7f3b06e | 2014-11-13 09:54:03 -0800 | [diff] [blame] | 78 | } |
| 79 | |
einarf | 4e5fdaf | 2015-04-16 23:14:59 +0000 | [diff] [blame] | 80 | // CreateImageResult represents the result of an image creation operation |
| 81 | type CreateImageResult struct { |
einarf | 2fc665e | 2015-04-16 20:16:21 +0000 | [diff] [blame] | 82 | gophercloud.Result |
| 83 | } |
| 84 | |
einarf | 4e5fdaf | 2015-04-16 23:14:59 +0000 | [diff] [blame] | 85 | // ExtractImageID gets the ID of the newly created server image from the header |
| 86 | func (res CreateImageResult) ExtractImageID() (string, error) { |
| 87 | if res.Err != nil { |
| 88 | return "", res.Err |
| 89 | } |
| 90 | // Get the image id from the header |
| 91 | u, err := url.ParseRequestURI(res.Header.Get("Location")) |
| 92 | if err != nil { |
| 93 | return "", fmt.Errorf("Failed to parse the image id: %s", err.Error()) |
| 94 | } |
| 95 | imageId := path.Base(u.Path) |
| 96 | if imageId == "." || imageId == "/" { |
| 97 | return "", fmt.Errorf("Failed to parse the ID of newly created image: %s", u) |
| 98 | } |
| 99 | return imageId, nil |
| 100 | } |
| 101 | |
Jon Perritt | cc77da6 | 2014-11-16 13:14:21 -0700 | [diff] [blame] | 102 | // Extract interprets any RescueResult as an AdminPass, if possible. |
Alex Gaynor | 7f3b06e | 2014-11-13 09:54:03 -0800 | [diff] [blame] | 103 | func (r RescueResult) Extract() (string, error) { |
| 104 | if r.Err != nil { |
Alex Gaynor | 94a28aa | 2014-11-13 10:09:56 -0800 | [diff] [blame] | 105 | return "", r.Err |
Alex Gaynor | 7f3b06e | 2014-11-13 09:54:03 -0800 | [diff] [blame] | 106 | } |
| 107 | |
| 108 | var response struct { |
| 109 | AdminPass string `mapstructure:"adminPass"` |
| 110 | } |
| 111 | |
| 112 | err := mapstructure.Decode(r.Body, &response) |
Alex Gaynor | 94a28aa | 2014-11-13 10:09:56 -0800 | [diff] [blame] | 113 | return response.AdminPass, err |
Alex Gaynor | fbe61bb | 2014-11-12 13:35:03 -0800 | [diff] [blame] | 114 | } |
| 115 | |
Samuel A. Falvo II | c007c27 | 2014-02-10 20:49:26 -0800 | [diff] [blame] | 116 | // Server exposes only the standard OpenStack fields corresponding to a given server on the user's account. |
Samuel A. Falvo II | c007c27 | 2014-02-10 20:49:26 -0800 | [diff] [blame] | 117 | type Server struct { |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame] | 118 | // ID uniquely identifies this server amongst all other servers, including those not accessible to the current tenant. |
| 119 | ID string |
| 120 | |
| 121 | // TenantID identifies the tenant owning this server resource. |
| 122 | TenantID string `mapstructure:"tenant_id"` |
| 123 | |
| 124 | // UserID uniquely identifies the user account owning the tenant. |
| 125 | UserID string `mapstructure:"user_id"` |
| 126 | |
| 127 | // Name contains the human-readable name for the server. |
| 128 | Name string |
| 129 | |
| 130 | // Updated and Created contain ISO-8601 timestamps of when the state of the server last changed, and when it was created. |
| 131 | Updated string |
| 132 | Created string |
| 133 | |
| 134 | HostID string |
| 135 | |
| 136 | // Status contains the current operational status of the server, such as IN_PROGRESS or ACTIVE. |
| 137 | Status string |
| 138 | |
| 139 | // Progress ranges from 0..100. |
| 140 | // A request made against the server completes only once Progress reaches 100. |
| 141 | Progress int |
| 142 | |
| 143 | // AccessIPv4 and AccessIPv6 contain the IP addresses of the server, suitable for remote access for administration. |
Jamie Hannaford | 908e1e9 | 2014-10-27 14:41:17 +0100 | [diff] [blame] | 144 | AccessIPv4, AccessIPv6 string |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame] | 145 | |
| 146 | // Image refers to a JSON object, which itself indicates the OS image used to deploy the server. |
| 147 | Image map[string]interface{} |
| 148 | |
| 149 | // Flavor refers to a JSON object, which itself indicates the hardware configuration of the deployed server. |
| 150 | Flavor map[string]interface{} |
| 151 | |
| 152 | // Addresses includes a list of all IP addresses assigned to the server, keyed by pool. |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame] | 153 | Addresses map[string]interface{} |
| 154 | |
| 155 | // Metadata includes a list of all user-specified key-value pairs attached to the server. |
| 156 | Metadata map[string]interface{} |
| 157 | |
| 158 | // Links includes HTTP references to the itself, useful for passing along to other APIs that might want a server reference. |
| 159 | Links []interface{} |
| 160 | |
Ash Wilson | ad21c71 | 2014-09-25 10:15:22 -0400 | [diff] [blame] | 161 | // KeyName indicates which public key was injected into the server on launch. |
Ash Wilson | 69b144f | 2014-10-21 14:03:52 -0400 | [diff] [blame] | 162 | KeyName string `json:"key_name" mapstructure:"key_name"` |
Ash Wilson | ad21c71 | 2014-09-25 10:15:22 -0400 | [diff] [blame] | 163 | |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame] | 164 | // AdminPass will generally be empty (""). However, it will contain the administrative password chosen when provisioning a new server without a set AdminPass setting in the first place. |
| 165 | // Note that this is the ONLY time this field will be valid. |
Ash Wilson | 69b144f | 2014-10-21 14:03:52 -0400 | [diff] [blame] | 166 | AdminPass string `json:"adminPass" mapstructure:"adminPass"` |
Joe Topjian | 978bb50 | 2015-02-12 20:55:31 +0000 | [diff] [blame] | 167 | |
| 168 | // SecurityGroups includes the security groups that this instance has applied to it |
| 169 | SecurityGroups []map[string]interface{} `json:"security_groups" mapstructure:"security_groups"` |
Samuel A. Falvo II | c007c27 | 2014-02-10 20:49:26 -0800 | [diff] [blame] | 170 | } |
| 171 | |
Ash Wilson | 397c78b | 2014-09-25 15:19:14 -0400 | [diff] [blame] | 172 | // ServerPage abstracts the raw results of making a List() request against the API. |
| 173 | // As OpenStack extensions may freely alter the response bodies of structures returned to the client, you may only safely access the |
| 174 | // data provided through the ExtractServers call. |
| 175 | type ServerPage struct { |
| 176 | pagination.LinkedPageBase |
Ash Wilson | f57381e | 2014-09-25 13:21:34 -0400 | [diff] [blame] | 177 | } |
| 178 | |
Ash Wilson | 397c78b | 2014-09-25 15:19:14 -0400 | [diff] [blame] | 179 | // IsEmpty returns true if a page contains no Server results. |
| 180 | func (page ServerPage) IsEmpty() (bool, error) { |
| 181 | servers, err := ExtractServers(page) |
| 182 | if err != nil { |
| 183 | return true, err |
| 184 | } |
| 185 | return len(servers) == 0, nil |
| 186 | } |
| 187 | |
| 188 | // NextPageURL uses the response's embedded link reference to navigate to the next page of results. |
| 189 | func (page ServerPage) NextPageURL() (string, error) { |
Ash Wilson | 397c78b | 2014-09-25 15:19:14 -0400 | [diff] [blame] | 190 | type resp struct { |
Jamie Hannaford | a581acd | 2014-10-08 17:14:13 +0200 | [diff] [blame] | 191 | Links []gophercloud.Link `mapstructure:"servers_links"` |
Ash Wilson | d27e0ff | 2014-09-25 11:50:31 -0400 | [diff] [blame] | 192 | } |
| 193 | |
Ash Wilson | 397c78b | 2014-09-25 15:19:14 -0400 | [diff] [blame] | 194 | var r resp |
| 195 | err := mapstructure.Decode(page.Body, &r) |
| 196 | if err != nil { |
| 197 | return "", err |
Ash Wilson | d27e0ff | 2014-09-25 11:50:31 -0400 | [diff] [blame] | 198 | } |
| 199 | |
Jamie Hannaford | a581acd | 2014-10-08 17:14:13 +0200 | [diff] [blame] | 200 | return gophercloud.ExtractNextURL(r.Links) |
Ash Wilson | d27e0ff | 2014-09-25 11:50:31 -0400 | [diff] [blame] | 201 | } |
| 202 | |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame] | 203 | // ExtractServers interprets the results of a single page from a List() call, producing a slice of Server entities. |
| 204 | func ExtractServers(page pagination.Page) ([]Server, error) { |
Ash Wilson | 397c78b | 2014-09-25 15:19:14 -0400 | [diff] [blame] | 205 | casted := page.(ServerPage).Body |
Ash Wilson | 1225939 | 2014-09-17 10:50:02 -0400 | [diff] [blame] | 206 | |
| 207 | var response struct { |
| 208 | Servers []Server `mapstructure:"servers"` |
| 209 | } |
Jon Perritt | 9a0980e | 2015-01-14 21:29:44 -0700 | [diff] [blame] | 210 | |
| 211 | config := &mapstructure.DecoderConfig{ |
Jon Perritt | 0e19f60 | 2015-01-15 09:35:46 -0700 | [diff] [blame] | 212 | DecodeHook: toMapFromString, |
| 213 | Result: &response, |
Jon Perritt | 9a0980e | 2015-01-14 21:29:44 -0700 | [diff] [blame] | 214 | } |
| 215 | decoder, err := mapstructure.NewDecoder(config) |
| 216 | if err != nil { |
| 217 | return nil, err |
| 218 | } |
| 219 | |
| 220 | err = decoder.Decode(casted) |
| 221 | |
Ash Wilson | 1225939 | 2014-09-17 10:50:02 -0400 | [diff] [blame] | 222 | return response.Servers, err |
Samuel A. Falvo II | c007c27 | 2014-02-10 20:49:26 -0800 | [diff] [blame] | 223 | } |
Jon Perritt | cc77da6 | 2014-11-16 13:14:21 -0700 | [diff] [blame] | 224 | |
Jon Perritt | 78c57ce | 2014-11-20 11:07:18 -0700 | [diff] [blame] | 225 | // MetadataResult contains the result of a call for (potentially) multiple key-value pairs. |
Jon Perritt | cc77da6 | 2014-11-16 13:14:21 -0700 | [diff] [blame] | 226 | type MetadataResult struct { |
| 227 | gophercloud.Result |
| 228 | } |
| 229 | |
| 230 | // GetMetadataResult temporarily contains the response from a metadata Get call. |
| 231 | type GetMetadataResult struct { |
| 232 | MetadataResult |
| 233 | } |
| 234 | |
Jon Perritt | 789f832 | 2014-11-21 08:20:04 -0700 | [diff] [blame] | 235 | // ResetMetadataResult temporarily contains the response from a metadata Reset call. |
| 236 | type ResetMetadataResult struct { |
Jon Perritt | cc77da6 | 2014-11-16 13:14:21 -0700 | [diff] [blame] | 237 | MetadataResult |
| 238 | } |
| 239 | |
Jon Perritt | 78c57ce | 2014-11-20 11:07:18 -0700 | [diff] [blame] | 240 | // UpdateMetadataResult temporarily contains the response from a metadata Update call. |
| 241 | type UpdateMetadataResult struct { |
| 242 | MetadataResult |
Jon Perritt | cc77da6 | 2014-11-16 13:14:21 -0700 | [diff] [blame] | 243 | } |
| 244 | |
Jon Perritt | 78c57ce | 2014-11-20 11:07:18 -0700 | [diff] [blame] | 245 | // MetadatumResult contains the result of a call for individual a single key-value pair. |
| 246 | type MetadatumResult struct { |
| 247 | gophercloud.Result |
| 248 | } |
Jon Perritt | cc77da6 | 2014-11-16 13:14:21 -0700 | [diff] [blame] | 249 | |
Jon Perritt | 78c57ce | 2014-11-20 11:07:18 -0700 | [diff] [blame] | 250 | // GetMetadatumResult temporarily contains the response from a metadatum Get call. |
| 251 | type GetMetadatumResult struct { |
| 252 | MetadatumResult |
| 253 | } |
Jon Perritt | cc77da6 | 2014-11-16 13:14:21 -0700 | [diff] [blame] | 254 | |
Jon Perritt | 78c57ce | 2014-11-20 11:07:18 -0700 | [diff] [blame] | 255 | // CreateMetadatumResult temporarily contains the response from a metadatum Create call. |
| 256 | type CreateMetadatumResult struct { |
| 257 | MetadatumResult |
| 258 | } |
| 259 | |
| 260 | // DeleteMetadatumResult temporarily contains the response from a metadatum Delete call. |
| 261 | type DeleteMetadatumResult struct { |
| 262 | gophercloud.ErrResult |
Jon Perritt | cc77da6 | 2014-11-16 13:14:21 -0700 | [diff] [blame] | 263 | } |
| 264 | |
| 265 | // Extract interprets any MetadataResult as a Metadata, if possible. |
| 266 | func (r MetadataResult) Extract() (map[string]string, error) { |
| 267 | if r.Err != nil { |
| 268 | return nil, r.Err |
| 269 | } |
| 270 | |
| 271 | var response struct { |
Jon Perritt | 78c57ce | 2014-11-20 11:07:18 -0700 | [diff] [blame] | 272 | Metadata map[string]string `mapstructure:"metadata"` |
Jon Perritt | cc77da6 | 2014-11-16 13:14:21 -0700 | [diff] [blame] | 273 | } |
| 274 | |
| 275 | err := mapstructure.Decode(r.Body, &response) |
| 276 | return response.Metadata, err |
| 277 | } |
Jon Perritt | 78c57ce | 2014-11-20 11:07:18 -0700 | [diff] [blame] | 278 | |
| 279 | // Extract interprets any MetadatumResult as a Metadatum, if possible. |
| 280 | func (r MetadatumResult) Extract() (map[string]string, error) { |
| 281 | if r.Err != nil { |
| 282 | return nil, r.Err |
| 283 | } |
| 284 | |
| 285 | var response struct { |
| 286 | Metadatum map[string]string `mapstructure:"meta"` |
| 287 | } |
| 288 | |
| 289 | err := mapstructure.Decode(r.Body, &response) |
| 290 | return response.Metadatum, err |
| 291 | } |
Jon Perritt | 0e19f60 | 2015-01-15 09:35:46 -0700 | [diff] [blame] | 292 | |
| 293 | func toMapFromString(from reflect.Kind, to reflect.Kind, data interface{}) (interface{}, error) { |
| 294 | if (from == reflect.String) && (to == reflect.Map) { |
| 295 | return map[string]interface{}{}, nil |
| 296 | } |
| 297 | return data, nil |
| 298 | } |
Jon Perritt | 5cb4948 | 2015-02-19 12:19:58 -0700 | [diff] [blame] | 299 | |
| 300 | // Address represents an IP address. |
| 301 | type Address struct { |
| 302 | Version int `mapstructure:"version"` |
| 303 | Address string `mapstructure:"addr"` |
| 304 | } |
| 305 | |
Jon Perritt | 04d073c | 2015-02-19 21:46:23 -0700 | [diff] [blame] | 306 | // AddressPage abstracts the raw results of making a ListAddresses() request against the API. |
Jon Perritt | 5cb4948 | 2015-02-19 12:19:58 -0700 | [diff] [blame] | 307 | // As OpenStack extensions may freely alter the response bodies of structures returned |
| 308 | // to the client, you may only safely access the data provided through the ExtractAddresses call. |
| 309 | type AddressPage struct { |
| 310 | pagination.SinglePageBase |
| 311 | } |
| 312 | |
Jon Perritt | 04d073c | 2015-02-19 21:46:23 -0700 | [diff] [blame] | 313 | // IsEmpty returns true if an AddressPage contains no networks. |
Jon Perritt | 5cb4948 | 2015-02-19 12:19:58 -0700 | [diff] [blame] | 314 | func (r AddressPage) IsEmpty() (bool, error) { |
| 315 | addresses, err := ExtractAddresses(r) |
| 316 | if err != nil { |
| 317 | return true, err |
| 318 | } |
| 319 | return len(addresses) == 0, nil |
| 320 | } |
| 321 | |
Jon Perritt | 04d073c | 2015-02-19 21:46:23 -0700 | [diff] [blame] | 322 | // ExtractAddresses interprets the results of a single page from a ListAddresses() call, |
Jon Perritt | 5cb4948 | 2015-02-19 12:19:58 -0700 | [diff] [blame] | 323 | // producing a map of addresses. |
| 324 | func ExtractAddresses(page pagination.Page) (map[string][]Address, error) { |
| 325 | casted := page.(AddressPage).Body |
| 326 | |
| 327 | var response struct { |
| 328 | Addresses map[string][]Address `mapstructure:"addresses"` |
| 329 | } |
| 330 | |
| 331 | err := mapstructure.Decode(casted, &response) |
| 332 | if err != nil { |
| 333 | return nil, err |
| 334 | } |
| 335 | |
| 336 | return response.Addresses, err |
| 337 | } |
Jon Perritt | 04d073c | 2015-02-19 21:46:23 -0700 | [diff] [blame] | 338 | |
| 339 | // NetworkAddressPage abstracts the raw results of making a ListAddressesByNetwork() request against the API. |
| 340 | // As OpenStack extensions may freely alter the response bodies of structures returned |
| 341 | // to the client, you may only safely access the data provided through the ExtractAddresses call. |
| 342 | type NetworkAddressPage struct { |
| 343 | pagination.SinglePageBase |
| 344 | } |
| 345 | |
| 346 | // IsEmpty returns true if a NetworkAddressPage contains no addresses. |
| 347 | func (r NetworkAddressPage) IsEmpty() (bool, error) { |
| 348 | addresses, err := ExtractNetworkAddresses(r) |
| 349 | if err != nil { |
| 350 | return true, err |
| 351 | } |
| 352 | return len(addresses) == 0, nil |
| 353 | } |
| 354 | |
| 355 | // ExtractNetworkAddresses interprets the results of a single page from a ListAddressesByNetwork() call, |
Jon Perritt | b51ba9c | 2015-02-23 10:56:35 -0700 | [diff] [blame] | 356 | // producing a slice of addresses. |
| 357 | func ExtractNetworkAddresses(page pagination.Page) ([]Address, error) { |
Jon Perritt | 04d073c | 2015-02-19 21:46:23 -0700 | [diff] [blame] | 358 | casted := page.(NetworkAddressPage).Body |
| 359 | |
| 360 | var response map[string][]Address |
| 361 | err := mapstructure.Decode(casted, &response) |
| 362 | if err != nil { |
| 363 | return nil, err |
| 364 | } |
| 365 | |
Jon Perritt | b51ba9c | 2015-02-23 10:56:35 -0700 | [diff] [blame] | 366 | var key string |
| 367 | for k := range response { |
| 368 | key = k |
| 369 | } |
| 370 | |
| 371 | return response[key], err |
Jon Perritt | 04d073c | 2015-02-19 21:46:23 -0700 | [diff] [blame] | 372 | } |