github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/waf-premium/v1/rules/CreateAntiLeakage.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 CreateAntiLeakageOpts 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, 14 // and email addresses. 15 // code: The rule blocks response pages of specified HTTP response code. 16 Category string `json:"category" required:"true"` 17 // Content corresponding to the sensitive information type. Multiple options can be set. 18 // When category is set to code, the pages that contain the following HTTP response codes 19 // will be blocked: 400, 401, 402, 403, 404, 405, 500, 501, 502, 503, 504 and 507. 20 // When category is set to sensitive, parameters phone, id_card, and email can be set. 21 Contents []string `json:"contents" required:"true"` 22 // Rule description. 23 Description string `json:"description"` 24 } 25 26 // CreateAntiLeakage will create an information leakage protection rule on the values in CreateOpts. 27 func CreateAntiLeakage(client *golangsdk.ServiceClient, policyId string, opts CreateAntiLeakageOpts) (*AntiLeakageRule, 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}/antileakage 34 raw, err := client.Post(client.ServiceURL("waf", "policy", policyId, "antileakage"), 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 AntiLeakageRule 44 err = extract.Into(raw.Body, &res) 45 return &res, err 46 } 47 48 type AntiLeakageRule struct { 49 // Rule ID. 50 ID string `json:"id"` 51 // Policy ID. 52 PolicyId string `json:"policyid"` 53 // URL to which the rule applies. 54 Url string `json:"url"` 55 // Sensitive information type in the information leakage prevention rule. 56 // sensitive: The rule masks sensitive user information, such as ID code, 57 // phone numbers, and email addresses. 58 // code: The rule blocks response pages of specified HTTP response code. 59 Category string `json:"category"` 60 // Content corresponding to the sensitive information type. 61 Contents []string `json:"contents"` 62 // Time the rule is created. The value is a 13-digit timestamp in ms. 63 CreatedAt int64 `json:"timestamp"` 64 // Rule status. The value can be: 65 // 0: The rule is disabled. 66 // 1: The rule is enabled. 67 Status *int `json:"status"` 68 // Rule description. 69 Description string `json:"description"` 70 }