github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/waf-premium/v1/rules/CreatePrivacy.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 CreatePrivacyOpts struct { 10 // URL protected by the data masking rule. 11 // The value must be in the standard URL format, for example, /admin. 12 Url string `json:"url" required:"true"` 13 // Masked field. 14 // Enumeration values: 15 // params 16 // cookie 17 // header 18 // form 19 Category string `json:"category" required:"true"` 20 // Name of the masked field. 21 Name string `json:"index" required:"true"` 22 // Rule description. 23 Description string `json:"description"` 24 } 25 26 // CreatePrivacy will create a data masking rule on the values in CreateOpts. 27 func CreatePrivacy(client *golangsdk.ServiceClient, policyId string, opts CreatePrivacyOpts) (*PrivacyRule, error) { 28 b, err := build.RequestBody(opts, "") 29 if err != nil { 30 return nil, err 31 } 32 33 // POST /v1/{project_id}/waf/policy/{policy_id}/privacy 34 raw, err := client.Post(client.ServiceURL("waf", "policy", policyId, "privacy"), b, 35 nil, &golangsdk.RequestOpts{ 36 OkCodes: []int{200}, 37 MoreHeaders: map[string]string{"Content-Type": "application/json;charset=utf8"}, 38 }) 39 if err != nil { 40 return nil, err 41 } 42 43 var res PrivacyRule 44 err = extract.Into(raw.Body, &res) 45 return &res, err 46 } 47 48 type PrivacyRule struct { 49 // Rule ID. 50 ID string `json:"id"` 51 // Policy ID. 52 PolicyId string `json:"policyid"` 53 // Time the rule is created. The value is a 13-digit timestamp in ms. 54 CreatedAt int64 `json:"timestamp"` 55 // Rule status. The value can be: 56 // 0: The rule is disabled. 57 // 1: The rule is enabled. 58 Status *int `json:"status"` 59 // URL protected by the data masking rule. 60 Url string `json:"url"` 61 // Masked field. 62 // Enumeration values: 63 // params 64 // cookie 65 // header 66 // form 67 Category string `json:"category"` 68 // Name of the masked field. 69 Name string `json:"index"` 70 // Rule description. 71 Description string `json:"description"` 72 }