跳转到内容
本站为社区维护的非官方中文翻译,与 Cloudflare, Inc. 无关联。本站不提供账户登录,请勿在任何非官方站点输入您的 Cloudflare 账户信息。官方文档:developers.cloudflare.com

可编程流量防护

最后更新 查看 MarkdownAgent 设置

使用 Cloudflare API配置可编程流量防护。

API 调用示例请参阅常见 API 调用。

端点

若要获取完整端点,请将下方列出的可编程流量防护 API 端点附加到 Cloudflare API 基础 URL:

https://api.cloudflare.com/client/v4

{account_id} 参数是帐户 ID(十六进制字符串)。你可以在 Cloudflare 控制面板中找到此值。

以下各节中的表格总结了可用操作。

程序版本

每个上传的程序都从版本 1 开始。使用 PATCH 请求更新程序时,会在同一程序 ID 下创建新版本。程序响应会在 version 字段中包含当前版本。

每条规则都固定到特定的程序版本,该版本显示在规则的 program_version 字段中。创建规则时若未指定 program_version,则会固定到程序的当前版本。更新程序不会更新引用该程序的现有规则。

若要将现有规则切换到程序的另一个成功版本,请向规则端点发送 PATCH 请求,并指定目标 program_version。示例请参阅更新规则。

程序操作

操作 方法和端点 / 描述
列出程序

GET accounts/{account_id}/magic/programmable_flow_protection/configs/programs

获取帐户中的所有可编程流量防护程序。
上传程序

POST accounts/{account_id}/magic/programmable_flow_protection/configs/programs

向帐户上传新程序。可包含可选的 X-Program-Name 请求头,以指定便于阅读的程序名称。如果省略,API 会生成 UUID 作为程序名称。
获取程序

GET accounts/{account_id}/magic/programmable_flow_protection/configs/programs/{program_id}

获取现有程序的详细信息。
更新程序

PATCH accounts/{account_id}/magic/programmable_flow_protection/configs/programs/{program_id}

更新现有程序。
删除程序

DELETE accounts/{account_id}/magic/programmable_flow_protection/configs/programs/{program_id}

从帐户中删除现有程序。
删除所有程序

DELETE accounts/{account_id}/magic/programmable_flow_protection/configs/programs

删除帐户中的所有现有程序。

规则操作

操作 方法和端点 / 描述
列出规则

GET accounts/{account_id}/magic/programmable_flow_protection/configs/rules

获取帐户中的所有可编程流量防护规则。
创建规则

POST accounts/{account_id}/magic/programmable_flow_protection/configs/rules

在帐户中创建新规则。
获取规则

GET accounts/{account_id}/magic/programmable_flow_protection/configs/rules/{rule_id}

获取现有规则的详细信息。
更新规则

PATCH accounts/{account_id}/magic/programmable_flow_protection/configs/rules/{rule_id}

更新帐户中的现有规则。
删除规则

DELETE accounts/{account_id}/magic/programmable_flow_protection/configs/rules/{rule_id}

从帐户中删除现有规则。
删除所有规则

DELETE accounts/{account_id}/magic/programmable_flow_protection/configs/rules

删除帐户中的所有现有规则。

调试操作

操作 方法和端点 / 描述
使用 PCAP 调试

POST accounts/{account_id}/magic/programmable_flow_protection/configs/programs/{program_id}/pcap

对 PCAP 文件运行程序,并返回附带程序判定结果的 PCAP。

分页

返回项目列表的 API 操作使用分页。有关可用分页查询参数的更多信息,请参阅分页。

这篇文档对您有帮助吗?