github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/waf-premium/v1/rules/UpdatePrivacy.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 UpdatePrivacyOpts struct {
    10  	// URL to which the rule applies.
    11  	Url string `json:"url" required:"true"`
    12  	// Masked field
    13  	// Enumeration values:
    14  	// params
    15  	// cookie
    16  	// header
    17  	// form
    18  	Category string `json:"category" required:"true"`
    19  	// Name of the masked field
    20  	Name string `json:"index" required:"true"`
    21  	// Rule description
    22  	Description string `json:"description"`
    23  }
    24  
    25  // UpdatePrivacy is used to update the data masking rule list.
    26  func UpdatePrivacy(client *golangsdk.ServiceClient, policyId, ruleId string, opts UpdatePrivacyOpts) (*PrivacyRule, 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}/privacy/{rule_id}
    33  	raw, err := client.Put(client.ServiceURL("waf", "policy", policyId, "privacy", 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 PrivacyRule
    41  	return &res, extract.Into(raw.Body, &res)
    42  }