github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/waf-premium/v1/policies/Update.go (about) 1 package policies 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 UpdateOpts struct { 10 // Policy name 11 Name string `json:"name"` 12 // Policy action 13 Action *PolicyAction `json:"action"` 14 // Policy option 15 Options *PolicyOption `json:"options"` 16 // Feature-based anti-crawler protection mode. 17 // The default protection mode is Log only. 18 RobotAction *PolicyAction `json:"robot_action"` 19 // Protection level 20 Level int `json:"level"` 21 // Detection mode in the precise protection rule 22 FullDetection *bool `json:"full_detection"` 23 } 24 25 func Update(client *golangsdk.ServiceClient, id string, opts UpdateOpts) (*Policy, error) { 26 b, err := build.RequestBody(opts, "") 27 if err != nil { 28 return nil, err 29 } 30 31 // PUT /v1/{project_id}/waf/policy/{policy_id} 32 raw, err := client.Patch(client.ServiceURL("waf", "policy", id), b, nil, &golangsdk.RequestOpts{ 33 OkCodes: []int{200}, 34 MoreHeaders: map[string]string{"Content-Type": "application/json;charset=utf8"}, 35 }) 36 if err != nil { 37 return nil, err 38 } 39 40 var res Policy 41 return &res, extract.Into(raw.Body, &res) 42 }