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 (58 lines) | stat: -rw-r--r-- 1,172 bytes parent folder | download | duplicates (6)
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
/*
Package groups provides information and interaction with Security Groups
for the OpenStack Networking service.

Example to List Security Groups

	listOpts := groups.ListOpts{
		TenantID: "966b3c7d36a24facaf20b7e458bf2192",
	}

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

	allGroups, err := groups.ExtractGroups(allPages)
	if err != nil {
		panic(err)
	}

	for _, group := range allGroups {
		fmt.Printf("%+v\n", group)
	}

Example to Create a Security Group

	createOpts := groups.CreateOpts{
		Name:        "group_name",
		Description: "A Security Group",
	}

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

Example to Update a Security Group

	groupID := "37d94f8a-d136-465c-ae46-144f0d8ef141"

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

	group, err := groups.Update(networkClient, groupID, updateOpts).Extract()
	if err != nil {
		panic(err)
	}

Example to Delete a Security Group

	groupID := "37d94f8a-d136-465c-ae46-144f0d8ef141"
	err := groups.Delete(networkClient, groupID).ExtractErr()
	if err != nil {
		panic(err)
	}
*/
package groups