Update a firewall rule
Deprecated
client.Firewall.Rules.Update(ctx, ruleID, params) (*FirewallRule, error)
PUT/zones/{zone_id}/firewall/rules/{rule_id}
Updates an existing firewall rule.
Security
API Token
The preferred authorization scheme for interacting with the Cloudflare API. Create a token.
Example:
API Email + API Key
The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.
Example:
The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.
Example:
Accepted Permissions (at least one required)
Update a firewall rule
package main
import (
"context"
"fmt"
"github.com/cloudflare/cloudflare-go"
"github.com/cloudflare/cloudflare-go/filters"
"github.com/cloudflare/cloudflare-go/firewall"
"github.com/cloudflare/cloudflare-go/option"
)
func main() {
client := cloudflare.NewClient(
option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
)
firewallRule, err := client.Firewall.Rules.Update(
context.TODO(),
"372e67954025e0ba6aaa6d586b9e0b60",
firewall.RuleUpdateParams{
ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
Action: cloudflare.F(firewall.RuleUpdateParamsAction{
}),
Filter: cloudflare.F(filters.FirewallFilterParam{
}),
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", firewallRule.ID)
}
{
"errors": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"messages": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"result": {
"id": "372e67954025e0ba6aaa6d586b9e0b60",
"action": "block",
"description": "Blocks traffic identified during investigation for MIR-31",
"filter": {
"id": "372e67954025e0ba6aaa6d586b9e0b61",
"description": "Restrict access from these browsers on this address range.",
"expression": "(http.request.uri.path ~ \".*wp-login.php\" or http.request.uri.path ~ \".*xmlrpc.php\") and ip.addr ne 172.16.22.155",
"paused": false,
"ref": "FIL-100"
},
"paused": false,
"priority": 50,
"products": [
"waf"
],
"ref": "MIR-31"
},
"success": true
}Returns Examples
{
"errors": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"messages": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"result": {
"id": "372e67954025e0ba6aaa6d586b9e0b60",
"action": "block",
"description": "Blocks traffic identified during investigation for MIR-31",
"filter": {
"id": "372e67954025e0ba6aaa6d586b9e0b61",
"description": "Restrict access from these browsers on this address range.",
"expression": "(http.request.uri.path ~ \".*wp-login.php\" or http.request.uri.path ~ \".*xmlrpc.php\") and ip.addr ne 172.16.22.155",
"paused": false,
"ref": "FIL-100"
},
"paused": false,
"priority": 50,
"products": [
"waf"
],
"ref": "MIR-31"
},
"success": true
}