doc.go 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*
  2. Package l7policies provides information and interaction with L7Policies and
  3. Rules of the LBaaS v2 extension for the OpenStack Networking service.
  4. Example to Create a L7Policy
  5. createOpts := l7policies.CreateOpts{
  6. Name: "redirect-example.com",
  7. ListenerID: "023f2e34-7806-443b-bfae-16c324569a3d",
  8. Action: l7policies.ActionRedirectToURL,
  9. RedirectURL: "http://www.example.com",
  10. }
  11. l7policy, err := l7policies.Create(lbClient, createOpts).Extract()
  12. if err != nil {
  13. panic(err)
  14. }
  15. Example to List L7Policies
  16. listOpts := l7policies.ListOpts{
  17. ListenerID: "c79a4468-d788-410c-bf79-9a8ef6354852",
  18. }
  19. allPages, err := l7policies.List(lbClient, listOpts).AllPages()
  20. if err != nil {
  21. panic(err)
  22. }
  23. allL7Policies, err := l7policies.ExtractL7Policies(allPages)
  24. if err != nil {
  25. panic(err)
  26. }
  27. for _, l7policy := range allL7Policies {
  28. fmt.Printf("%+v\n", l7policy)
  29. }
  30. Example to Get a L7Policy
  31. l7policy, err := l7policies.Get(lbClient, "023f2e34-7806-443b-bfae-16c324569a3d").Extract()
  32. if err != nil {
  33. panic(err)
  34. }
  35. Example to Delete a L7Policy
  36. l7policyID := "d67d56a6-4a86-4688-a282-f46444705c64"
  37. err := l7policies.Delete(lbClient, l7policyID).ExtractErr()
  38. if err != nil {
  39. panic(err)
  40. }
  41. Example to Update a L7Policy
  42. l7policyID := "d67d56a6-4a86-4688-a282-f46444705c64"
  43. name := "new-name"
  44. updateOpts := l7policies.UpdateOpts{
  45. Name: &name,
  46. }
  47. l7policy, err := l7policies.Update(lbClient, l7policyID, updateOpts).Extract()
  48. if err != nil {
  49. panic(err)
  50. }
  51. Example to Create a Rule
  52. l7policyID := "d67d56a6-4a86-4688-a282-f46444705c64"
  53. createOpts := l7policies.CreateRuleOpts{
  54. RuleType: l7policies.TypePath,
  55. CompareType: l7policies.CompareTypeRegex,
  56. Value: "/images*",
  57. }
  58. rule, err := l7policies.CreateRule(lbClient, l7policyID, createOpts).Extract()
  59. if err != nil {
  60. panic(err)
  61. }
  62. Example to List L7 Rules
  63. l7policyID := "d67d56a6-4a86-4688-a282-f46444705c64"
  64. listOpts := l7policies.ListRulesOpts{
  65. RuleType: l7policies.TypePath,
  66. }
  67. allPages, err := l7policies.ListRules(lbClient, l7policyID, listOpts).AllPages()
  68. if err != nil {
  69. panic(err)
  70. }
  71. allRules, err := l7policies.ExtractRules(allPages)
  72. if err != nil {
  73. panic(err)
  74. }
  75. for _, rule := allRules {
  76. fmt.Printf("%+v\n", rule)
  77. }
  78. Example to Get a l7 rule
  79. l7rule, err := l7policies.GetRule(lbClient, "023f2e34-7806-443b-bfae-16c324569a3d", "53ad8ab8-40fa-11e8-a508-00224d6b7bc1").Extract()
  80. if err != nil {
  81. panic(err)
  82. }
  83. Example to Delete a l7 rule
  84. l7policyID := "d67d56a6-4a86-4688-a282-f46444705c64"
  85. ruleID := "64dba99f-8af8-4200-8882-e32a0660f23e"
  86. err := l7policies.DeleteRule(lbClient, l7policyID, ruleID).ExtractErr()
  87. if err != nil {
  88. panic(err)
  89. }
  90. Example to Update a Rule
  91. l7policyID := "d67d56a6-4a86-4688-a282-f46444705c64"
  92. ruleID := "64dba99f-8af8-4200-8882-e32a0660f23e"
  93. updateOpts := l7policies.UpdateRuleOpts{
  94. RuleType: l7policies.TypePath,
  95. CompareType: l7policies.CompareTypeRegex,
  96. Value: "/images/special*",
  97. }
  98. rule, err := l7policies.UpdateRule(lbClient, l7policyID, ruleID, updateOpts).Extract()
  99. if err != nil {
  100. panic(err)
  101. }
  102. */
  103. package l7policies