2020-10-06 21:02:37 +08:00
|
|
|
|
package waf
|
|
|
|
|
|
|
2023-06-30 18:08:30 +08:00
|
|
|
|
import ( "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
|
|
|
|
|
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
|
2020-10-06 21:02:37 +08:00
|
|
|
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
type DeleteAction struct {
|
|
|
|
|
|
actionutils.ParentAction
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (this *DeleteAction) RunPost(params struct {
|
|
|
|
|
|
FirewallPolicyId int64
|
|
|
|
|
|
}) {
|
2020-11-17 15:41:43 +08:00
|
|
|
|
// 日志
|
2023-06-30 18:08:30 +08:00
|
|
|
|
defer this.CreateLogInfo(codes.WAFPolicy_LogDeleteWAFPolicy, params.FirewallPolicyId)
|
2020-11-17 15:41:43 +08:00
|
|
|
|
|
2020-12-17 15:50:44 +08:00
|
|
|
|
countResp, err := this.RPC().NodeClusterRPC().CountAllEnabledNodeClustersWithHTTPFirewallPolicyId(this.AdminContext(), &pb.CountAllEnabledNodeClustersWithHTTPFirewallPolicyIdRequest{HttpFirewallPolicyId: params.FirewallPolicyId})
|
2020-10-06 21:02:37 +08:00
|
|
|
|
if err != nil {
|
|
|
|
|
|
this.ErrorPage(err)
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
if countResp.Count > 0 {
|
2020-12-17 15:50:44 +08:00
|
|
|
|
this.Fail("此WAF策略正在被有些集群引用,请修改后再删除。")
|
2020-10-06 21:02:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-12-17 15:50:44 +08:00
|
|
|
|
_, err = this.RPC().HTTPFirewallPolicyRPC().DeleteHTTPFirewallPolicy(this.AdminContext(), &pb.DeleteHTTPFirewallPolicyRequest{HttpFirewallPolicyId: params.FirewallPolicyId})
|
2020-10-06 21:02:37 +08:00
|
|
|
|
if err != nil {
|
|
|
|
|
|
this.ErrorPage(err)
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.Success()
|
|
|
|
|
|
}
|