blob: dbf40eb36276ef8db5bef4b081d5fe555a9ddf6f [file] [log] [blame]
Jamie Hannaford4721abc2014-09-16 16:29:04 +02001package apiversions
2
3import (
4 "github.com/mitchellh/mapstructure"
5 "github.com/rackspace/gophercloud"
6)
7
8type APIVersion struct {
9 Status string `mapstructure:"status" json:"status"`
10 ID string `mapstructure:"id" json:"id"`
11}
12
13func ExtractAPIVersions(page gophercloud.Page) ([]APIVersion, error) {
14 var resp struct {
15 Versions []APIVersion `mapstructure:"versions"`
16 }
17
18 err := mapstructure.Decode(page.(gophercloud.LinkedPage).Body, &resp)
19 if err != nil {
20 return nil, err
21 }
22
23 return resp.Versions, nil
24}
25
26type APIVersionResource struct {
27 Name string `mapstructure:"name" json:"name"`
28 Collection string `mapstructure:"collection" json:"collection"`
29}
30
31func ExtractVersionResources(page gophercloud.Page) ([]APIVersionResource, error) {
32 var resp struct {
33 APIVersionResources []APIVersionResource `mapstructure:"resources"`
34 }
35
36 err := mapstructure.Decode(page.(gophercloud.LinkedPage).Body, &resp)
37 if err != nil {
38 return nil, err
39 }
40
41 return resp.APIVersionResources, nil
42}