blob: 5cfa2da6eb1ec912bf4c1eda93d80461c4fd23dd [file] [log] [blame]
Torrent Glenn12bc4df2014-02-03 13:26:41 -08001package 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",
Torrent Glenn12bc4df2014-02-03 13:26:41 -080010 "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
21//Populates an ApiCriteria struct with the api values
22//from one of the api maps
23func PopulateApi(variant string) (ApiCriteria, error){
24 var Api ApiCriteria
25 var variantMap map[string]interface{}
26
27 switch variant {
28 case "":
29 variantMap = OpenstackApi
30
31 case "openstack":
32 variantMap = OpenstackApi
33
34 case "rackspace":
35 variantMap = RackspaceApi
36 }
37
38 err := mapstructure.Decode(variantMap,&Api)
39 if err != nil{
40 return Api,err
41 }
42 return Api, err
43}