github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/networking/v2/extensions/fwaas/rules/doc.go (about) 1 /* 2 Package rules enables management and retrieval of Firewall Rules in the 3 OpenStack Networking Service. 4 5 Example to List Rules 6 7 listOpts := rules.ListOpts{ 8 Protocol: rules.ProtocolAny, 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 Rule 26 27 createOpts := rules.CreateOpts{ 28 Action: "allow", 29 Protocol: rules.ProtocolTCP, 30 Description: "ssh", 31 DestinationPort: 22, 32 DestinationIPAddress: "192.168.1.0/24", 33 } 34 35 rule, err := rules.Create(networkClient, createOpts).Extract() 36 if err != nil { 37 panic(err) 38 } 39 40 Example to Update a Rule 41 42 ruleID := "f03bd950-6c56-4f5e-a307-45967078f507" 43 newPort := 80 44 newDescription := "http" 45 46 updateOpts := rules.UpdateOpts{ 47 Description: &newDescription, 48 port: &newPort, 49 } 50 51 rule, err := rules.Update(networkClient, ruleID, updateOpts).Extract() 52 if err != nil { 53 panic(err) 54 } 55 56 Example to Delete a Rule 57 58 ruleID := "f03bd950-6c56-4f5e-a307-45967078f507" 59 err := rules.Delete(networkClient, ruleID).ExtractErr() 60 if err != nil { 61 panic(err) 62 } 63 */ 64 package rules