blob: e27445d2e371a81e88798633b3cdf2c5fe2f4387 [file] [log] [blame]
Jamie Hannaforda7f671a2014-09-11 10:25:08 +02001package networks
2
Jamie Hannaford01e14922014-09-11 15:23:49 +02003import (
4 "github.com/racker/perigee"
5 "github.com/rackspace/gophercloud"
6)
7
Jamie Hannaforda7f671a2014-09-11 10:25:08 +02008// User-defined options sent to the API when creating or updating a network.
9type NetworkOpts struct {
10 // The administrative state of the network, which is up (true) or down (false).
11 AdminStateUp bool `json:"admin_state_up"`
12 // The network name (optional)
13 Name string `json:"name"`
14 // Indicates whether this network is shared across all tenants. By default,
15 // only administrative users can change this value.
16 Shared bool `json:"shared"`
17 // Admin-only. The UUID of the tenant that will own the network. This tenant
18 // can be different from the tenant that makes the create network request.
19 // However, only administrative users can specify a tenant ID other than their
20 // own. You cannot change this value through authorization policies.
21 TenantID string `json:"tenant_id"`
22}
Jamie Hannaford01e14922014-09-11 15:23:49 +020023
24func APIVersions(c *gophercloud.ServiceClient) (*APIVersionsList, error) {
Jamie Hannaford01e14922014-09-11 15:23:49 +020025 var resp APIVersionsList
Jamie Hannafordf14d4562014-09-11 17:46:18 +020026 _, err := perigee.Request("GET", APIVersionsURL(c), perigee.Options{
27 MoreHeaders: c.Provider.AuthenticatedHeaders(),
28 Results: &resp,
29 OkCodes: []int{200},
30 })
31 if err != nil {
32 return nil, err
33 }
34
35 return &resp, nil
36}
37
38func APIInfo(c *gophercloud.ServiceClient, v string) (*APIInfoList, error) {
39 var resp APIInfoList
40 _, err := perigee.Request("GET", APIInfoURL(c, v), perigee.Options{
Jamie Hannaford01e14922014-09-11 15:23:49 +020041 MoreHeaders: c.Provider.AuthenticatedHeaders(),
42 Results: &resp,
43 OkCodes: []int{200},
44 })
45 if err != nil {
46 return nil, err
47 }
48
49 return &resp, nil
50}
Jamie Hannaford12bc2472014-09-15 12:14:31 +020051
52func GetExtension(c *gophercloud.ServiceClient, name string) (*Extension, error) {
53 var ext Extension
54 _, err := perigee.Request("GET", ExtensionURL(c, name), perigee.Options{
55 MoreHeaders: c.Provider.AuthenticatedHeaders(),
56 Results: &struct {
57 Extension *Extension `json:"extension"`
58 }{&ext},
59 OkCodes: []int{200},
60 })
61
62 if err != nil {
63 return nil, err
64 }
65 return &ext, nil
66}
Jamie Hannafordd01a3c72014-09-15 12:51:00 +020067
68func Get(c *gophercloud.ServiceClient, id string) (*Network, error) {
69 var n Network
70 _, err := perigee.Request("GET", NetworkURL(c, id), perigee.Options{
71 MoreHeaders: c.Provider.AuthenticatedHeaders(),
72 Results: &struct {
73 Network *Network `json:"network"`
74 }{&n},
75 OkCodes: []int{200},
76 })
77 if err != nil {
78 return nil, err
79 }
80 return &n, nil
81}