github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/networking/v2/extensions/security/rules/doc.go (about) 1 /* 2 Package rules provides information and interaction with Security Group Rules 3 for the OpenStack Networking service. 4 5 Example to List Security Groups Rules 6 7 listOpts := rules.ListOpts{ 8 Protocol: "tcp", 9 } 10 11 allPages, err := rules.List(networkClient, listOpts).AllPages() 12 if err != nil { 13 panic(err) 14 } 15 16 allRules, err := rules.ExtractRules(allPages) 17 if err != nil { 18 panic(err) 19 } 20 21 for _, rule := range allRules { 22 fmt.Printf("%+v\n", rule) 23 } 24 25 Example to Create a Security Group Rule 26 27 createOpts := rules.CreateOpts{ 28 Direction: "ingress", 29 PortRangeMin: 80, 30 EtherType: rules.EtherType4, 31 PortRangeMax: 80, 32 Protocol: "tcp", 33 RemoteGroupID: "85cc3048-abc3-43cc-89b3-377341426ac5", 34 SecGroupID: "a7734e61-b545-452d-a3cd-0189cbd9747a", 35 } 36 37 rule, err := rules.Create(networkClient, createOpts).Extract() 38 if err != nil { 39 panic(err) 40 } 41 42 Example to Delete a Security Group Rule 43 44 ruleID := "37d94f8a-d136-465c-ae46-144f0d8ef141" 45 err := rules.Delete(networkClient, ruleID).ExtractErr() 46 if err != nil { 47 panic(err) 48 } 49 */ 50 package rules