blob: 60775dd2fbc198ed41e19d0d4e69ef2a4b08a39a [file] [log] [blame]
Jamie Hannaford936a5472015-02-10 14:38:28 +01001package instances
2
3import (
4 "github.com/racker/perigee"
5 "github.com/rackspace/gophercloud"
6)
7
8func GetDefaultConfig(client *gophercloud.ServiceClient, id string) ConfigResult {
9 var res ConfigResult
10
11 resp, err := perigee.Request("GET", configURL(client, id), perigee.Options{
12 MoreHeaders: client.AuthenticatedHeaders(),
13 Results: &res.Body,
14 OkCodes: []int{200},
15 })
16
17 res.Header = resp.HttpResponse.Header
18 res.Err = err
19
20 return res
21}
Jamie Hannafordf77fc102015-02-10 14:56:02 +010022
23func AssociateWithConfigGroup(client *gophercloud.ServiceClient, instanceID, configGroupID string) UpdateResult {
24 reqBody := map[string]string{
25 "configuration": configGroupID,
26 }
27
28 var res UpdateResult
29
30 resp, err := perigee.Request("PUT", resourceURL(client, instanceID), perigee.Options{
31 MoreHeaders: client.AuthenticatedHeaders(),
32 ReqBody: map[string]map[string]string{"instance": reqBody},
33 OkCodes: []int{202},
34 })
35
36 res.Header = resp.HttpResponse.Header
37 res.Err = err
38
39 return res
40}