File: doc.go

package info (click to toggle)
golang-github-gophercloud-gophercloud 0.0~git20180917.45f1c769-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 7,768 kB
  • sloc: sh: 98; makefile: 14
file content (65 lines) | stat: -rw-r--r-- 1,527 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
Package networks contains functionality for working with Neutron network
resources. A network is an isolated virtual layer-2 broadcast domain that is
typically reserved for the tenant who created it (unless you configure the
network to be shared). Tenants can create multiple networks until the
thresholds per-tenant quota is reached.

In the v2.0 Networking API, the network is the main entity. Ports and subnets
are always associated with a network.

Example to List Networks

	listOpts := networks.ListOpts{
		TenantID: "a99e9b4e620e4db09a2dfb6e42a01e66",
	}

	allPages, err := networks.List(networkClient, listOpts).AllPages()
	if err != nil {
		panic(err)
	}

	allNetworks, err := networks.ExtractNetworks(allPages)
	if err != nil {
		panic(err)
	}

	for _, network := range allNetworks {
		fmt.Printf("%+v", network)
	}

Example to Create a Network

	iTrue := true
	createOpts := networks.CreateOpts{
		Name:         "network_1",
		AdminStateUp: &iTrue,
	}

	network, err := networks.Create(networkClient, createOpts).Extract()
	if err != nil {
		panic(err)
	}

Example to Update a Network

	networkID := "484cda0e-106f-4f4b-bb3f-d413710bbe78"

	updateOpts := networks.UpdateOpts{
		Name: "new_name",
	}

	network, err := networks.Update(networkClient, networkID, updateOpts).Extract()
	if err != nil {
		panic(err)
	}

Example to Delete a Network

	networkID := "484cda0e-106f-4f4b-bb3f-d413710bbe78"
	err := networks.Delete(networkClient, networkID).ExtractErr()
	if err != nil {
		panic(err)
	}
*/
package networks