Rename v2_0 and add remaining boilerplate
diff --git a/openstack/networking/v2/client.go b/openstack/networking/v2/client.go
new file mode 100644
index 0000000..4b37bd1
--- /dev/null
+++ b/openstack/networking/v2/client.go
@@ -0,0 +1,96 @@
+package v2
+
+import (
+ "fmt"
+
+ identity "github.com/rackspace/gophercloud/openstack/identity/v2"
+)
+
+// Client is a structure that contains information for communicating with a provider.
+type Client struct {
+ endpoint string
+ authority identity.AuthResults
+ options identity.AuthOptions
+ token *identity.Token
+}
+
+// NewClient creates and returns a *Client.
+func NewClient(e string, a identity.AuthResults, o identity.AuthOptions) *Client {
+ return &Client{
+ endpoint: e,
+ authority: a,
+ options: o,
+ }
+}
+
+// ListNetworksURL returns the URL for listing networks available to the tenant.
+func (c *Client) ListNetworksURL() string {
+ return fmt.Sprintf("%sv2.0/networks", c.endpoint)
+}
+
+// CreateNetworkURL returns the URL for creating a network.
+func (c *Client) CreateNetworkURL() string {
+ return c.ListNetworksURL()
+}
+
+// GetNetworkURL returns the URL for showing information for the network with the given id.
+func (c *Client) GetNetworkURL(id string) string {
+ return fmt.Sprintf("%sv2.0/networks/%s", c.endpoint, id)
+}
+
+// UpdateNetworkURL returns the URL for updating information for the network with the given id.
+func (c *Client) UpdateNetworkURL(id string) string {
+ return c.GetNetworkURL(id)
+}
+
+// DeleteNetworkURL returns the URL for deleting the network with the given id.
+func (c *Client) DeleteNetworkURL(id string) string {
+ return c.GetNetworkURL(id)
+}
+
+func (c *Client) ListSubnetsURL() string {
+ return fmt.Sprintf("%sv2.0/subnets", c.endpoint)
+}
+
+func (c *Client) CreateSubnetURL() string {
+ return c.ListSubnetsURL()
+}
+
+func (c *Client) DeleteSubnetURL(id string) string {
+ return fmt.Sprintf("%sv2.0/subnets/%s", c.endpoint, id)
+}
+
+func (c *Client) GetSubnetURL(id string) string {
+ return c.DeleteSubnetURL(id)
+}
+
+func (c *Client) UpdateSubnetURL(id string) string {
+ return c.DeleteSubnetURL(id)
+}
+
+// GetHeaders is a function that gets the header for token authentication against a client's endpoint.
+// This function is exported to allow the subpackages to use it. It is not meant for public consumption.
+func (c *Client) GetHeaders() (map[string]string, error) {
+ t, err := c.getAuthToken()
+ if err != nil {
+ return map[string]string{}, err
+ }
+
+ return map[string]string{
+ "X-Auth-Token": t,
+ }, nil
+}
+
+// getAuthToken is a function that tries to retrieve an authentication token from a client's endpoint.
+func (c *Client) getAuthToken() (string, error) {
+ var err error
+
+ if c.token == nil {
+ c.token, err = identity.GetToken(c.authority)
+ if err != nil {
+ return "", err
+ }
+ }
+
+ return c.token.Id, err
+}
diff --git a/openstack/networking/v2/networks/doc.go b/openstack/networking/v2/networks/doc.go
new file mode 100644
index 0000000..83c4a6a
--- /dev/null
+++ b/openstack/networking/v2/networks/doc.go
@@ -0,0 +1 @@
+package networks
diff --git a/openstack/networking/v2/networks/errors.go b/openstack/networking/v2/networks/errors.go
new file mode 100644
index 0000000..83c4a6a
--- /dev/null
+++ b/openstack/networking/v2/networks/errors.go
@@ -0,0 +1 @@
+package networks
diff --git a/openstack/networking/v2/networks/requests.go b/openstack/networking/v2/networks/requests.go
new file mode 100644
index 0000000..b74608b
--- /dev/null
+++ b/openstack/networking/v2/networks/requests.go
@@ -0,0 +1,17 @@
+package networks
+
+// User-defined options sent to the API when creating or updating a network.
+type NetworkOpts struct {
+ // The administrative state of the network, which is up (true) or down (false).
+ AdminStateUp bool `json:"admin_state_up"`
+ // The network name (optional)
+ Name string `json:"name"`
+ // Indicates whether this network is shared across all tenants. By default,
+ // only administrative users can change this value.
+ Shared bool `json:"shared"`
+ // Admin-only. The UUID of the tenant that will own the network. This tenant
+ // can be different from the tenant that makes the create network request.
+ // However, only administrative users can specify a tenant ID other than their
+ // own. You cannot change this value through authorization policies.
+ TenantID string `json:"tenant_id"`
+}
diff --git a/openstack/networking/v2/networks/requests_test.go b/openstack/networking/v2/networks/requests_test.go
new file mode 100644
index 0000000..083ca59
--- /dev/null
+++ b/openstack/networking/v2/networks/requests_test.go
@@ -0,0 +1,17 @@
+package networks
+
+import (
+ "github.com/rackspace/gophercloud"
+ "github.com/rackspace/gophercloud/testhelper"
+)
+
+const TokenID = "123"
+
+func ServiceClient() *gophercloud.ServiceClient {
+ return &gophercloud.ServiceClient{
+ Provider: &gophercloud.ProviderClient{
+ TokenID: TokenID,
+ },
+ Endpoint: testhelper.Endpoint(),
+ }
+}
diff --git a/openstack/networking/v2/networks/results.go b/openstack/networking/v2/networks/results.go
new file mode 100644
index 0000000..dddeed7
--- /dev/null
+++ b/openstack/networking/v2/networks/results.go
@@ -0,0 +1,27 @@
+package networks
+
+// A Network represents a a virtual layer-2 broadcast domain.
+type Network struct {
+ // Id is the unique identifier for the network.
+ Id string `json:"id"`
+ // Name is the (not necessarily unique) human-readable identifier for the network.
+ Name string `json:"name"`
+ // AdminStateUp is administrative state of the network. If false, network is down.
+ AdminStateUp bool `json:"admin_state_up"`
+ // Status indicates if the network is operational. Possible values: active, down, build, error.
+ Status string `json:"status"`
+ // Subnets are IP address blocks that can be used to assign IP addresses to virtual instances.
+ Subnets []string `json:"subnets"`
+ // Shared indicates whether the network can be accessed by any tenant or not.
+ Shared bool `json:"shared"`
+ // TenantId is the owner of the network. Admins may specify TenantId other than their own.
+ TenantId string `json:"tenant_id"`
+ // RouterExternal indicates if the network is connected to an external router.
+ RouterExternal bool `json:"router:external"`
+ // ProviderPhysicalNetwork is the name of the provider physical network.
+ ProviderPhysicalNetwork string `json:"provider:physical_network"`
+ // ProviderNetworkType is the type of provider network (eg "vlan").
+ ProviderNetworkType string `json:"provider:network_type"`
+ // ProviderSegmentationId is the provider network identifier (such as the vlan id).
+ ProviderSegmentationId string `json:"provider:segmentation_id"`
+}
diff --git a/openstack/networking/v2/networks/results_test.go b/openstack/networking/v2/networks/results_test.go
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/openstack/networking/v2/networks/results_test.go
diff --git a/openstack/networking/v2/networks/urls.go b/openstack/networking/v2/networks/urls.go
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/openstack/networking/v2/networks/urls.go
diff --git a/openstack/networking/v2/networks/urls_test.go b/openstack/networking/v2/networks/urls_test.go
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/openstack/networking/v2/networks/urls_test.go