github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/compute/v2/extensions/defsecrules/doc.go (about) 1 /* 2 Package defsecrules enables management of default security group rules. 3 4 Default security group rules are rules that are managed in the "default" 5 security group. 6 7 This is only applicable in environments running nova-network. This package will 8 not work if the OpenStack environment is running the OpenStack Networking 9 (Neutron) service. 10 11 Example of Listing Default Security Group Rules 12 13 allPages, err := defsecrules.List(computeClient).AllPages() 14 if err != nil { 15 panic(err) 16 } 17 18 allDefaultRules, err := defsecrules.ExtractDefaultRules(allPages) 19 if err != nil { 20 panic(err) 21 } 22 23 for _, df := range allDefaultRules { 24 fmt.Printf("%+v\n", df) 25 } 26 27 Example of Retrieving a Default Security Group Rule 28 29 rule, err := defsecrules.Get(computeClient, "rule-id").Extract() 30 if err != nil { 31 panic(err) 32 } 33 34 Example of Creating a Default Security Group Rule 35 36 createOpts := defsecrules.CreateOpts{ 37 IPProtocol: "TCP", 38 FromPort: 80, 39 ToPort: 80, 40 CIDR: "10.10.12.0/24", 41 } 42 43 rule, err := defsecrules.Create(computeClient, createOpts).Extract() 44 if err != nil { 45 panic(err) 46 } 47 48 Example of Deleting a Default Security Group Rule 49 50 err := defsecrules.Delete(computeClient, "rule-id").ExtractErr() 51 if err != nil { 52 panic(err) 53 } 54 */ 55 package defsecrules