github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/waf_hw/v1/policies/results.go (about)

     1  package policies
     2  
     3  import (
     4  	"github.com/huaweicloud/golangsdk"
     5  )
     6  
     7  // Policy contains the infomateion of the policy.
     8  type Policy struct {
     9  	Id            string       `json:"id"`
    10  	Name          string       `json:"name"`
    11  	Action        Action       `json:"action"`
    12  	Options       PolicyOption `json:"options"`
    13  	Level         int          `json:"level"`
    14  	FullDetection bool         `json:"full_detection"`
    15  	BindHosts     []BindHost   `json:"bind_host"`
    16  }
    17  
    18  //Action contains actions after the attack is detected
    19  type Action struct {
    20  	Category         string `json:"category,omitempty"`
    21  	FollowedActionId string `json:"followed_action_id,omitempty"`
    22  }
    23  
    24  // PolicyOption contains the protection rule of a policy
    25  type PolicyOption struct {
    26  	Webattack      bool `json:"webattack,omitempty"`
    27  	Common         bool `json:"common,omitempty"`
    28  	Crawler        bool `json:"crawler,omitempty"`
    29  	CrawlerEngine  bool `json:"crawler_engine,omitempty"`
    30  	CrawlerScanner bool `json:"crawler_scanner,omitempty"`
    31  	CrawlerScript  bool `json:"crawler_script,omitempty"`
    32  	CrawlerOther   bool `json:"crawler_other,omitempty"`
    33  	Webshell       bool `json:"webshell,omitempty"`
    34  	Cc             bool `json:"cc,omitempty"`
    35  	Custom         bool `json:"custom,omitempty"`
    36  	Whiteblackip   bool `json:"whiteblackip,omitempty"`
    37  	Ignore         bool `json:"ignore,omitempty"`
    38  	Privacy        bool `json:"privacy,omitempty"`
    39  	Antitamper     bool `json:"antitamper,omitempty"`
    40  }
    41  
    42  // BindHost the hosts bound to this policy.
    43  type BindHost struct {
    44  	Id       string `json:"id,omitempty"`
    45  	Hostname string `json:"hostname,omitempty"`
    46  	WafType  string `json:"waf_type,omitempty"`
    47  	Mode     string `json:"mode,omitempty"`
    48  }
    49  
    50  type commonResult struct {
    51  	golangsdk.Result
    52  }
    53  
    54  // Extract is a function that accepts a result and extracts a policy.
    55  func (r commonResult) Extract() (*Policy, error) {
    56  	var response Policy
    57  	err := r.ExtractInto(&response)
    58  	return &response, err
    59  }
    60  
    61  // CreateResult represents the result of a create operation. Call its Extract
    62  // method to interpret it as a Policy.
    63  type CreateResult struct {
    64  	commonResult
    65  }
    66  
    67  // UpdateResult represents the result of a update operation. Call its Extract
    68  // method to interpret it as a Policy.
    69  type UpdateResult struct {
    70  	commonResult
    71  }
    72  
    73  // GetResult represents the result of a get operation. Call its Extract
    74  // method to interpret it as a Policy.
    75  type GetResult struct {
    76  	commonResult
    77  }
    78  
    79  // DeleteResult represents the result of a delete operation. Call its ExtractErr
    80  // method to determine if the request succeeded or failed.
    81  type DeleteResult struct {
    82  	golangsdk.ErrResult
    83  }
    84  
    85  // ListPolicyRst
    86  type ListPolicyRst struct {
    87  	// total policy count.
    88  	Total int `json:"total"`
    89  	// the policy list
    90  	Items []Policy `json:"items"`
    91  }