tencentcloud-edgeone
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseTencent Cloud EdgeOne (CDN + Security)
腾讯云EdgeOne(CDN + 安全)
Manage EdgeOne zones — purge cache, prefetch URLs, manage DNS records on the zone, check WAF settings.
Setup: See tencentcloud authentication. The SDK reads/TENCENTCLOUD_SECRET_IDfrom env. EdgeOne is global —TENCENTCLOUD_SECRET_KEYis fine.Region=""
管理EdgeOne区域——清除缓存、预取URL、管理区域内的DNS记录、查看WAF设置。
设置: 查看腾讯云认证。SDK从环境变量中读取/TENCENTCLOUD_SECRET_ID。EdgeOne是全局服务——设置TENCENTCLOUD_SECRET_KEY即可。Region=""
CLI (preferred)
CLI(推荐方式)
The skill ships — wraps zone discovery, purge / prefetch, task tracking, EdgeOne DNS records, and WAF inspection.
scripts/edgeone.pybash
EO=$SKILL_DIR/scripts/edgeone.py
python3 $EO zones # list zones
python3 $EO zone zone-xxxxxxxx # one zone's details
python3 $EO domains zone-xxxxxxxx # acceleration domains
python3 $EO purge zone-xxxxxxxx --urls https://hub.example.com/index.html
python3 $EO purge zone-xxxxxxxx --prefixes https://hub.example.com/assets/
python3 $EO purge zone-xxxxxxxx --hosts hub.example.com
python3 $EO purge zone-xxxxxxxx --all # nuclear
python3 $EO prefetch zone-xxxxxxxx --urls https://hub.example.com/ https://hub.example.com/chat
python3 $EO purge-tasks zone-xxxxxxxx --status processing
python3 $EO prefetch-tasks zone-xxxxxxxx
python3 $EO dns zone-xxxxxxxx # EdgeOne DNS records
python3 $EO dns-create zone-xxxxxxxx --name sub --type CNAME --content origin.example.com
python3 $EO dns-delete zone-xxxxxxxx <record-id>
python3 $EO security zone-xxxxxxxx # WAF / security cfg
python3 $EO waf zone-xxxxxxxxPurge / prefetch propagation is global but typically takes 30s–2min. Use to wait.
purge-tasks --status processing本技能附带脚本——封装了区域发现、清除/预取、任务跟踪、EdgeOne DNS记录及WAF查看功能。
scripts/edgeone.pybash
EO=$SKILL_DIR/scripts/edgeone.py
python3 $EO zones # 列出区域
python3 $EO zone zone-xxxxxxxx # 查看单个区域详情
python3 $EO domains zone-xxxxxxxx # 查看加速域名
python3 $EO purge zone-xxxxxxxx --urls https://hub.example.com/index.html
python3 $EO purge zone-xxxxxxxx --prefixes https://hub.example.com/assets/
python3 $EO purge zone-xxxxxxxx --hosts hub.example.com
python3 $EO purge zone-xxxxxxxx --all # 清除全部缓存(彻底清除)
python3 $EO prefetch zone-xxxxxxxx --urls https://hub.example.com/ https://hub.example.com/chat
python3 $EO purge-tasks zone-xxxxxxxx --status processing
python3 $EO prefetch-tasks zone-xxxxxxxx
python3 $EO dns zone-xxxxxxxx # 查看EdgeOne DNS记录
python3 $EO dns-create zone-xxxxxxxx --name sub --type CNAME --content origin.example.com
python3 $EO dns-delete zone-xxxxxxxx <record-id>
python3 $EO security zone-xxxxxxxx # 查看WAF/安全配置
python3 $EO waf zone-xxxxxxxx清除/预取操作会在全球范围生效,但通常需要30秒至2分钟。可使用命令等待操作完成。
purge-tasks --status processingWhen to Use
使用场景
- List EdgeOne zones / acceleration domains
- Purge cache after a deploy (by URL, prefix, hostname, or whole zone)
- Prefetch URLs to warm edge nodes
- Track purge / prefetch task status
- Manage EdgeOne DNS records (zones managed by EdgeOne use the TEO API, not DNSPod)
- Inspect WAF / security config
- 列出EdgeOne区域/加速域名
- 部署完成后清除缓存(按URL、前缀、主机名或整个区域)
- 预取URL以预热边缘节点
- 跟踪清除/预取任务状态
- 管理EdgeOne DNS记录(由EdgeOne管理的区域使用TEO API,而非DNSPod)
- 查看WAF/安全配置
Dependencies
依赖项
bash
pip install tencentcloud-sdk-pythonbash
pip install tencentcloud-sdk-pythonQuick start
快速开始
python
import os
from tencentcloud.common import credential
from tencentcloud.teo.v20220901 import teo_client, models
cred = credential.EnvironmentVariableCredential().get_credential()
client = teo_client.TeoClient(cred, "")python
import os
from tencentcloud.common import credential
from tencentcloud.teo.v20220901 import teo_client, models
cred = credential.EnvironmentVariableCredential().get_credential()
client = teo_client.TeoClient(cred, "")Workflows
工作流
List zones
列出区域
python
req = models.DescribeZonesRequest()
req.Limit = 100
resp = client.DescribeZones(req)
for z in resp.Zones:
print(z.ZoneId, z.ZoneName, z.Status, z.Type)Zone IDs look like. Thezone-xxxxxxxxis the apex domain (e.g.ZoneName).acedata.cloud
python
req = models.DescribeZonesRequest()
req.Limit = 100
resp = client.DescribeZones(req)
for z in resp.Zones:
print(z.ZoneId, z.ZoneName, z.Status, z.Type)区域ID格式为。zone-xxxxxxxx是顶级域名(例如ZoneName)。acedata.cloud
List acceleration domains in a zone
列出区域内的加速域名
python
req = models.DescribeAccelerationDomainsRequest()
req.ZoneId = "zone-xxxxxxxx"
req.Limit = 100
resp = client.DescribeAccelerationDomains(req)
for d in resp.AccelerationDomains:
print(d.DomainName, d.DomainStatus, d.OriginDetail.OriginType)python
req = models.DescribeAccelerationDomainsRequest()
req.ZoneId = "zone-xxxxxxxx"
req.Limit = 100
resp = client.DescribeAccelerationDomains(req)
for d in resp.AccelerationDomains:
print(d.DomainName, d.DomainStatus, d.OriginDetail.OriginType)Purge cache — by URL
按URL清除缓存
python
req = models.CreatePurgeTaskRequest()
req.ZoneId = "zone-xxxxxxxx"
req.Type = "purge_url"
req.Targets = [
"https://hub.example.com/index.html",
"https://hub.example.com/assets/main.css",
]
resp = client.CreatePurgeTask(req)
print("Task:", resp.JobId)python
req = models.CreatePurgeTaskRequest()
req.ZoneId = "zone-xxxxxxxx"
req.Type = "purge_url"
req.Targets = [
"https://hub.example.com/index.html",
"https://hub.example.com/assets/main.css",
]
resp = client.CreatePurgeTask(req)
print("任务ID:", resp.JobId)Purge by hostname (entire host)
按主机名清除缓存(整个主机)
python
req = models.CreatePurgeTaskRequest()
req.ZoneId = "zone-xxxxxxxx"
req.Type = "purge_host"
req.Targets = ["hub.example.com"]
client.CreatePurgeTask(req)python
req = models.CreatePurgeTaskRequest()
req.ZoneId = "zone-xxxxxxxx"
req.Type = "purge_host"
req.Targets = ["hub.example.com"]
client.CreatePurgeTask(req)Purge by prefix (all URLs under a path)
按前缀清除缓存(路径下所有URL)
python
req = models.CreatePurgeTaskRequest()
req.ZoneId = "zone-xxxxxxxx"
req.Type = "purge_prefix"
req.Targets = ["https://hub.example.com/assets/"]
client.CreatePurgeTask(req)python
req = models.CreatePurgeTaskRequest()
req.ZoneId = "zone-xxxxxxxx"
req.Type = "purge_prefix"
req.Targets = ["https://hub.example.com/assets/"]
client.CreatePurgeTask(req)Purge ALL cache for a zone (nuclear option)
清除区域内全部缓存(彻底清除选项)
python
undefinedpython
undefinedConfirm with the user — this re-fetches every cached object on next request,
请与用户确认——此操作会在下次请求时重新拉取所有缓存对象,
spiking origin load.
导致源站负载激增。
req = models.CreatePurgeTaskRequest()
req.ZoneId = "zone-xxxxxxxx"
req.Type = "purge_all"
client.CreatePurgeTask(req)
undefinedreq = models.CreatePurgeTaskRequest()
req.ZoneId = "zone-xxxxxxxx"
req.Type = "purge_all"
client.CreatePurgeTask(req)
undefinedPrefetch (pre-warm edges)
预取(预热边缘节点)
python
req = models.CreatePrefetchTaskRequest()
req.ZoneId = "zone-xxxxxxxx"
req.Targets = [
"https://hub.example.com/",
"https://hub.example.com/chat",
]
resp = client.CreatePrefetchTask(req)
print("Task:", resp.JobId)python
req = models.CreatePrefetchTaskRequest()
req.ZoneId = "zone-xxxxxxxx"
req.Targets = [
"https://hub.example.com/",
"https://hub.example.com/chat",
]
resp = client.CreatePrefetchTask(req)
print("任务ID:", resp.JobId)Track task status
跟踪任务状态
python
req = models.DescribePurgeTasksRequest()
req.ZoneId = "zone-xxxxxxxx"
req.Limit = 50python
req = models.DescribePurgeTasksRequest()
req.ZoneId = "zone-xxxxxxxx"
req.Limit = 50Optional: req.Filters = [{"Name": "job-id", "Values": ["<job-id>"]}]
可选:req.Filters = [{"Name": "job-id", "Values": ["<job-id>"]}]
resp = client.DescribePurgeTasks(req)
for t in resp.Tasks:
print(t.JobId, t.Type, t.Status, t.CreateTime)
resp = client.DescribePurgeTasks(req)
for t in resp.Tasks:
print(t.JobId, t.Type, t.Status, t.CreateTime)
Same shape for DescribePrefetchTasks
DescribePrefetchTasks接口返回格式与此相同
undefinedundefinedList EdgeOne DNS records on a zone
列出区域内的EdgeOne DNS记录
python
req = models.DescribeDnsRecordsRequest()
req.ZoneId = "zone-xxxxxxxx"
req.Limit = 100
resp = client.DescribeDnsRecords(req)
for r in resp.DnsRecords:
print(r.RecordId, r.Name, r.Type, r.Content)python
req = models.DescribeDnsRecordsRequest()
req.ZoneId = "zone-xxxxxxxx"
req.Limit = 100
resp = client.DescribeDnsRecords(req)
for r in resp.DnsRecords:
print(r.RecordId, r.Name, r.Type, r.Content)Create an EdgeOne DNS record
创建EdgeOne DNS记录
python
req = models.CreateDnsRecordRequest()
req.ZoneId = "zone-xxxxxxxx"
req.Name = "sub.example.com"
req.Type = "CNAME"
req.Content = "origin.example.com"
req.TTL = 600
client.CreateDnsRecord(req)python
req = models.CreateDnsRecordRequest()
req.ZoneId = "zone-xxxxxxxx"
req.Name = "sub.example.com"
req.Type = "CNAME"
req.Content = "origin.example.com"
req.TTL = 600
client.CreateDnsRecord(req)Delete an EdgeOne DNS record
删除EdgeOne DNS记录
python
req = models.DeleteDnsRecordsRequest()
req.ZoneId = "zone-xxxxxxxx"
req.RecordIds = ["<record-id>"]
client.DeleteDnsRecords(req)python
req = models.DeleteDnsRecordsRequest()
req.ZoneId = "zone-xxxxxxxx"
req.RecordIds = ["<record-id>"]
client.DeleteDnsRecords(req)Purge type cheatsheet
清除类型速查表
| Type | When to use | Caveat |
|---|---|---|
| Specific page / asset changed | Most surgical; up to 1000 URLs per call |
| A directory of assets changed ( | Treats target as a prefix match |
| Full site deployment | Affects everything on the hostname |
| Emergency / major migration | All cache for the zone — origin spike inevitable |
| 类型 | 使用场景 | 注意事项 |
|---|---|---|
| 特定页面/资源更新 | 最精准的方式;每次调用最多支持1000个URL |
| 某个目录下的资源更新( | 将目标视为前缀匹配 |
| 全站点部署 | 影响该主机名下的所有内容 |
| 紧急情况/重大迁移 | 清除区域内所有缓存——必然导致源站负载激增 |
Typical post-deploy sequence
典型部署后流程
python
undefinedpython
undefined1. Purge the hostname so users get the new bundle
1. 清除主机名缓存,确保用户获取到新的资源包
client.CreatePurgeTask(models.CreatePurgeTaskRequest(
ZoneId="zone-xxxxxxxx",
Type="purge_host",
Targets=["hub.example.com"],
))
client.CreatePurgeTask(models.CreatePurgeTaskRequest(
ZoneId="zone-xxxxxxxx",
Type="purge_host",
Targets=["hub.example.com"],
))
2. Prefetch the most-trafficked routes so edge cache is warm
2. 预取流量最高的路由,确保边缘缓存已预热
client.CreatePrefetchTask(models.CreatePrefetchTaskRequest(
ZoneId="zone-xxxxxxxx",
Targets=[
"https://hub.example.com/",
"https://hub.example.com/chat",
"https://hub.example.com/login",
],
))
client.CreatePrefetchTask(models.CreatePrefetchTaskRequest(
ZoneId="zone-xxxxxxxx",
Targets=[
"https://hub.example.com/",
"https://hub.example.com/chat",
"https://hub.example.com/login",
],
))
3. Watch for completion (typically 30s – 2min)
3. 等待操作完成(通常需要30秒 – 2分钟)
import time
while True:
resp = client.DescribePurgeTasks(models.DescribePurgeTasksRequest(
ZoneId="zone-xxxxxxxx",
Filters=[{"Name": "status", "Values": ["processing"]}],
))
if not resp.Tasks:
print("All purge tasks done.")
break
print(f"{len(resp.Tasks)} tasks still processing...")
time.sleep(15)
undefinedimport time
while True:
resp = client.DescribePurgeTasks(models.DescribePurgeTasksRequest(
ZoneId="zone-xxxxxxxx",
Filters=[{"Name": "status", "Values": ["processing"]}],
))
if not resp.Tasks:
print("所有清除任务已完成。")
break
print(f"仍有{len(resp.Tasks)}个任务在处理中...")
time.sleep(15)
undefinedImportant reminders
重要提醒
- causes origin load spike. Use only when surgical purges aren't enough.
purge_all - Prefetch isn't free — it counts against your CDN traffic quota at edge-warm time. Only prefetch URLs you're confident users will hit.
- Purge / prefetch propagation is global but takes 30s–2min. Plan deploy windows accordingly.
- EdgeOne DNS and DNSPod DNS are separate. Domains onboarded to EdgeOne with NS-mode resolve through the TEO API; CNAME-mode domains still resolve through whatever DNS you've configured (DNSPod or third-party). Use the right skill for the right zone type.
- 会导致源站负载激增。仅在精准清除无法满足需求时使用。
purge_all - 预取并非免费——预热边缘节点时会消耗CDN流量配额。仅预取确定用户会访问的URL。
- 清除/预取操作会在全球范围生效,但需要30秒至2分钟。请据此规划部署窗口。
- EdgeOne DNS与DNSPod DNS是相互独立的。以NS模式接入EdgeOne的域名通过TEO API解析;CNAME模式的域名仍通过您配置的DNS(DNSPod或第三方)解析。请根据区域类型选择合适的工具。
Console links
控制台链接
- EdgeOne console: https://console.cloud.tencent.com/edgeone
- API reference: https://www.tencentcloud.com/document/product/1145/53929