コンテンツにスキップ

PUTの例

複数のルールを更新する

この例では、単一のAPI呼び出しを使用して複数のファイアウォールルールを更新します。

JSONオブジェクト配列(-dフラグ)に最大25のルールを含めてバッチとして更新できます。バッチはトランザクションとして処理されます。

リクエスト
curl --request PUT \
"https://api.cloudflare.com/client/v4/zones/{zone_id}/firewall/rules" \
--header "X-Auth-Email: <EMAIL>" \
--header "X-Auth-Key: <API_KEY>" \
--header "Content-Type: application/json" \
--data '[
{
"id": "<RULE_ID>",
"paused": false,
"description": "チャレンジサイト",
"action": "challenge",
"priority": null,
"filter": {
"id": "<FILTER_ID>",
"expression": "not http.request.uri.path matches \"^/api/.*$\"",
"paused": false,
"description": "not /api"
}
}
]'
レスポンス
{
"result": [
{
"id": "<RULE_ID>",
"paused": false,
"description": "チャレンジサイト",
"action": "challenge",
"priority": null,
"filter": {
"id": "<FILTER_ID>",
"expression": "not http.request.uri.path matches \"^/api/.*$\"",
"paused": false,
"description": "not /api"
}
}
],
"success": true,
"errors": [],
"messages": []
}

単一のルールを更新する

この例では、IDが{rule_id}のファイアウォールルールを更新します。

リクエストボディには以下のフィールドを含める必要があります:

  • id
  • action
  • filter.id

他のすべてのフィールドはオプションです。

リクエスト
curl --request PUT \
"https://api.cloudflare.com/client/v4/zones/{zone_id}/firewall/rules/{rule_id}" \
--header "X-Auth-Email: <EMAIL>" \
--header "X-Auth-Key: <API_KEY>" \
--header "Content-Type: application/json" \
--data '{
"id": "<RULE_ID>",
"paused": false,
"description": "オフィスのIPv6からのログインをチャレンジしない",
"action": "allow",
"priority": null,
"filter": {
"id": "<FILTER_ID>",
"expression": "ip.src in {2400:cb00::/32 2803:f800::/32 2c0f:f248::/32 2a06:98c0::/29} and (http.request.uri.path ~ \"^.*/wp-login.php$\" or http.request.uri.path ~ \"^.*/xmlrpc.php$\")",
"paused": false,
"description": "オフィスからのログイン"
}
}'
レスポンス
{
"result": {
"id": "<RULE_ID>",
"paused": false,
"description": "オフィスのIPv6からのログインをチャレンジしない",
"action": "allow",
"priority": null,
"filter": {
"id": "<FILTER_ID>",
"expression": "ip.src in {2400:cb00::/32 2803:f800::/32 2c0f:f248::/32 2a06:98c0::/29} and (http.request.uri.path ~ \"^.*/wp-login.php$\" or http.request.uri.path ~ \"^.*/xmlrpc.php$\")",
"paused": false,
"description": "オフィスからのログイン"
}
},
"success": true,
"errors": [],
"messages": []
}