blob: 353df7563cc28f22436b2f531d33e74c9555373f [file] [log] [blame]
Jon Perritt816d2a02014-03-11 20:49:46 -05001package gophercloud
2
3import (
4 "github.com/mitchellh/mapstructure"
5)
6
7//The default generic openstack api
8var OpenstackApi = map[string]interface{}{
Mohammed Naser15f7ac72014-06-07 18:00:16 -04009 "Name": "nova",
Jon Perritt816d2a02014-03-11 20:49:46 -050010 "UrlChoice": PublicURL,
11}
12
13// Api for use with rackspace
14var RackspaceApi = map[string]interface{}{
15 "Name": "cloudServersOpenStack",
16 "VersionId": "2",
17 "UrlChoice": PublicURL,
18}
19
20//Populates an ApiCriteria struct with the api values
21//from one of the api maps
22func PopulateApi(variant string) (ApiCriteria, error) {
23 var Api ApiCriteria
24 var variantMap map[string]interface{}
25
26 switch variant {
27 case "":
28 variantMap = OpenstackApi
29
30 case "openstack":
31 variantMap = OpenstackApi
32
33 case "rackspace":
34 variantMap = RackspaceApi
35 }
36
37 err := mapstructure.Decode(variantMap, &Api)
38 if err != nil {
39 return Api, err
40 }
41 return Api, err
42}