waf_rules.go 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. // Copyright 2019 Yunion
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package compute
  15. import (
  16. "yunion.io/x/cloudmux/pkg/cloudprovider"
  17. "yunion.io/x/jsonutils"
  18. "yunion.io/x/onecloud/pkg/apis"
  19. )
  20. const (
  21. WAF_RULE_STATUS_AVAILABLE = "available"
  22. WAF_RULE_STATUS_DELETING = "deleting"
  23. WAF_RULE_STATUS_CREATING = "creating"
  24. WAF_RULE_STATUS_CREATE_FAILED = "create_failed"
  25. WAF_RULE_STATUS_DELETE_FAILED = "delete_failed"
  26. WAF_RULE_STATUS_UPDATING = "updating"
  27. WAF_RULE_STATUS_UPDATE_FAILED = "update_failed"
  28. WAF_RULE_STATUS_UNKNOWN = "unknown"
  29. )
  30. type WafRuleListInput struct {
  31. apis.EnabledStatusStandaloneResourceListInput
  32. apis.ExternalizedResourceBaseListInput
  33. // WAF实例Id
  34. WafInstanceId string `json:"waf_instance_id"`
  35. // WAF规则组Id
  36. WafRuleGroupId string `json:"waf_rule_group_id"`
  37. Type string `json:"type"`
  38. }
  39. type WafRuleCreateInput struct {
  40. apis.EnabledStatusStandaloneResourceCreateInput
  41. // WAF实例Id
  42. WafInstanceId string `json:"waf_instance_id"`
  43. // 规则类型
  44. Type string `json:"type"`
  45. // 规则表达式
  46. Expression string `json:"expression"`
  47. // 规则配置
  48. Config jsonutils.JSONObject `json:"config"`
  49. // 优先级,不可重复
  50. // Azure优先级范围1-100
  51. Priority int `json:"priority"`
  52. // 匹配后默认行为
  53. Action *cloudprovider.DefaultAction `json:"action"`
  54. // enmu: and, or, not
  55. StatementCondition string `json:"statement_condition"`
  56. // swagger:ignore
  57. // WAF规则组Id
  58. WafRuleGroupId string `json:"waf_rule_group_id"`
  59. // 条件表达式
  60. Statements []cloudprovider.SWafStatement `json:"statements"`
  61. }
  62. type WafRuleDetails struct {
  63. apis.EnabledStatusStandaloneResourceDetails
  64. SWafRule
  65. Statements []cloudprovider.SWafStatement `json:"statements"`
  66. }
  67. type WafRuleUpdateInput struct {
  68. apis.EnabledStatusStandaloneResourceBaseUpdateInput
  69. // 规则表达式
  70. Expression string `json:"expression"`
  71. // 规则配置
  72. Config jsonutils.JSONObject `json:"config"`
  73. // 匹配后默认行为
  74. Action *cloudprovider.DefaultAction `json:"action"`
  75. // 优先级
  76. Priority *int `json:"priority"`
  77. // 条件表达式
  78. Statements []cloudprovider.SWafStatement `json:"statements"`
  79. }
  80. type WafRuleEnableInput struct {
  81. apis.PerformEnableInput
  82. }
  83. type WafRuleDisableInput struct {
  84. apis.PerformDisableInput
  85. }