github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/waf-premium/v1/rules/UpdateAntiLeakage.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 UpdateAntiLeakageOpts struct {
    10  	// URL to which the rule applies.
    11  	Url string `json:"url" required:"true"`
    12  	// Sensitive information type in the information leakage prevention rule.
    13  	// sensitive: The rule masks sensitive user information, such as ID code, phone numbers, and email addresses.
    14  	// code: The rule blocks response pages of specified HTTP response code.
    15  	Category string `json:"category" required:"true"`
    16  	// Content corresponding to the sensitive information type. Multiple options can be set.
    17  	// When category is set to code, the pages that contain the following HTTP response codes
    18  	// will be blocked: 400, 401, 402, 403, 404, 405, 500, 501, 502, 503, 504 and 507.
    19  	// When category is set to sensitive, parameters phone, id_card, and email can be set.
    20  	Contents []string `json:"contents" required:"true"`
    21  	// Rule description
    22  	Description string `json:"description"`
    23  }
    24  
    25  // UpdateAntiLeakage is used to update an information leakage prevention rule.
    26  func UpdateAntiLeakage(client *golangsdk.ServiceClient, policyId, ruleId string, opts UpdateAntiLeakageOpts) (*AntiLeakageRule, error) {
    27  	b, err := build.RequestBody(opts, "")
    28  	if err != nil {
    29  		return nil, err
    30  	}
    31  
    32  	// PUT /v1/{project_id}/waf/policy/{policy_id}/antileakage/{rule_id}
    33  	raw, err := client.Put(client.ServiceURL("waf", "policy", policyId, "antileakage", ruleId), b, nil, &golangsdk.RequestOpts{
    34  		OkCodes:     []int{200},
    35  		MoreHeaders: map[string]string{"Content-Type": "application/json;charset=utf8"},
    36  	})
    37  	if err != nil {
    38  		return nil, err
    39  	}
    40  	var res AntiLeakageRule
    41  	return &res, extract.Into(raw.Body, &res)
    42  }