github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/waf-premium/v1/rules/UpdateKnownAttackSource.go (about)

     1  package rules
     2  
     3  import (
     4  	"github.com/opentelekomcloud/gophertelekomcloud"
     5  	"github.com/opentelekomcloud/gophertelekomcloud/internal/build"
     6  	"github.com/opentelekomcloud/gophertelekomcloud/internal/extract"
     7  )
     8  
     9  type UpdateKnownAttackSourceOpts struct {
    10  	// Block duration, in seconds.
    11  	// If prefix long is selected for the rule type, the value for block_time ranges from 301 to 1800.
    12  	// If prefix short is selected for the rule type, the value for block_time ranges from 0 to 300.
    13  	BlockTime *int `json:"block_time" required:"true"`
    14  	// Rule description
    15  	Description string `json:"description"`
    16  }
    17  
    18  // UpdateKnownAttackSource is used update a known attack source rule.
    19  func UpdateKnownAttackSource(client *golangsdk.ServiceClient, policyId, ruleId string, opts UpdateKnownAttackSourceOpts) (*KnownAttackSourceRule, error) {
    20  	b, err := build.RequestBody(opts, "")
    21  	if err != nil {
    22  		return nil, err
    23  	}
    24  
    25  	// PUT /v1/{project_id}/waf/policy/{policy_id}/punishment/{rule_id}
    26  	raw, err := client.Put(client.ServiceURL("waf", "policy", policyId, "punishment", ruleId), b, nil, &golangsdk.RequestOpts{
    27  		OkCodes:     []int{200},
    28  		MoreHeaders: map[string]string{"Content-Type": "application/json;charset=utf8"},
    29  	})
    30  	if err != nil {
    31  		return nil, err
    32  	}
    33  	var res KnownAttackSourceRule
    34  	return &res, extract.Into(raw.Body, &res)
    35  }