github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/waf-premium/v1/rules/CreateAntiTamper.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 CreateAntiTamperOpts struct { 10 // Protected website. It can be obtained by calling the ListHost API 11 // in cloud mode (the value of the hostname field in the response body). 12 Hostname string `json:"hostname" required:"true"` 13 // URL protected by the web tamper protection rule. 14 // The value must be in the standard URL format, for example, /admin 15 Url string `json:"url" required:"true"` 16 // Rule description. 17 Description string `json:"description"` 18 } 19 20 // CreateAntiTamper will create a web tamper protection rule on the values in CreateAntiTamperOpts. 21 func CreateAntiTamper(client *golangsdk.ServiceClient, policyId string, opts CreateAntiTamperOpts) (*AntiTamperRule, error) { 22 b, err := build.RequestBody(opts, "") 23 if err != nil { 24 return nil, err 25 } 26 27 // POST /v1/{project_id}/waf/policy/{policy_id}/antitamper 28 raw, err := client.Post(client.ServiceURL("waf", "policy", policyId, "antitamper"), b, 29 nil, &golangsdk.RequestOpts{ 30 OkCodes: []int{200}, 31 MoreHeaders: map[string]string{"Content-Type": "application/json;charset=utf8"}, 32 }) 33 if err != nil { 34 return nil, err 35 } 36 37 var res AntiTamperRule 38 err = extract.Into(raw.Body, &res) 39 return &res, err 40 } 41 42 type AntiTamperRule struct { 43 // Rule ID. 44 ID string `json:"id"` 45 // Policy ID. 46 PolicyId string `json:"policyid"` 47 // Time the rule is created. The value is a 13-digit timestamp in ms. 48 CreatedAt int64 `json:"timestamp"` 49 // Rule description. 50 Description string `json:"description"` 51 // Rule status. The value can be: 52 // 0: The rule is disabled. 53 // 1: The rule is enabled. 54 // Rule description. 55 Status *int `json:"status"` 56 // The domain name of the website protected with the web tamper protection rule. 57 // The domain name is in the format of xxx.xxx.com, such as www.example.com. 58 Hostname string `json:"hostname"` 59 // URL for the web tamper protection rule. 60 Url string `json:"url"` 61 }