获取刷新缓存记录¶
1. 接口描述¶
接口请求路径:POST /prod-api/cdn/layer7/cache/getCacheRecordList
getCacheRecordList 用于分页查询当前账号下的 URL 预热、URL 刷新、目录刷新任务记录,可按时间范围、URL 关键字及完成状态筛选。
Token 获取方式见 密钥鉴权。
2. 输入参数¶
以下请求参数列表仅列出了接口请求参数和部分公共参数,完整公共参数列表见 公共请求参数。
| 参数名称 | 必选 | 类型 | 描述 |
|---|---|---|---|
| type | 是 | String | 任务类型。取值:1(URL 预热)、2(URL 刷新)、3(目录刷新)。示例值:2 |
| pageNum | 是 | Integer | 当前页数。示例值:1 |
| pageSize | 是 | Integer | 每页显示条目个数。示例值:10 |
| params | 否 | TimeRange | 时间范围;不传则不按时间过滤 |
| search | 否 | String | 按 URL/目录模糊搜索 |
| searchHeader | 否 | CacheRecordFilter | 完成状态等筛选条件 |
3. 输出参数¶
| 参数名称 | 类型 | 描述 |
|---|---|---|
| code | Integer | 状态码。示例值:200 |
| msg | String | 提示信息。示例值:查询成功 |
| total | Integer | 记录总条数。示例值:6 |
| rows | [CacheRecord] | 当前页记录列表 |
4. 示例¶
示例1 查询 URL 刷新记录¶
输入示例¶
{
"type": "2",
"pageSize": 10,
"pageNum": 1,
"search": "",
"searchHeader": {},
"params": {
"beginTime": "2023-08-14 00:00:00",
"endTime": "2023-08-21 23:59:59"
}
}
代码调用¶
请将 {登录域名}、token 替换为实际值。
curl -X POST 'https://{登录域名}/prod-api/cdn/layer7/cache/getCacheRecordList' \
-H 'Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.xxxxxx' \
-H 'Content-Type: application/json' \
-d '{
"type": "2",
"pageSize": 10,
"pageNum": 1,
"search": "",
"searchHeader": {},
"params": {
"beginTime": "2023-08-14 00:00:00",
"endTime": "2023-08-21 23:59:59"
}
}'
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
public class GetCacheRecordListTest {
public static void main(String[] args) throws Exception {
String url = "https://{登录域名}/prod-api/cdn/layer7/cache/getCacheRecordList";
String token = "eyJhbGciOiJIUzUxMiJ9.xxxxxx";
String requestBody = "{"
+ "\"type\":\"2\","
+ "\"pageSize\":10,"
+ "\"pageNum\":1,"
+ "\"search\":\"\","
+ "\"searchHeader\":{},"
+ "\"params\":{"
+ "\"beginTime\":\"2023-08-14 00:00:00\","
+ "\"endTime\":\"2023-08-21 23:59:59\""
+ "}"
+ "}";
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
HttpPost httpPost = new HttpPost(url);
httpPost.setHeader("Authorization", "Bearer " + token);
httpPost.setEntity(new StringEntity(requestBody, ContentType.APPLICATION_JSON));
try (CloseableHttpResponse response = httpClient.execute(httpPost)) {
int statusCode = response.getStatusLine().getStatusCode();
String body = EntityUtils.toString(response.getEntity(), "UTF-8");
System.out.println("Status Code: " + statusCode);
System.out.println("Body: " + body);
}
}
}
}
package main
import (
"bytes"
"fmt"
"io"
"net/http"
)
func main() {
url := "https://{登录域名}/prod-api/cdn/layer7/cache/getCacheRecordList"
token := "eyJhbGciOiJIUzUxMiJ9.xxxxxx"
requestBody := []byte(`{
"type": "2",
"pageSize": 10,
"pageNum": 1,
"search": "",
"searchHeader": {},
"params": {
"beginTime": "2023-08-14 00:00:00",
"endTime": "2023-08-21 23:59:59"
}
}`)
req, err := http.NewRequest(http.MethodPost, url, bytes.NewReader(requestBody))
if err != nil {
panic(err)
}
req.Header.Set("Authorization", "Bearer "+token)
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
panic(err)
}
fmt.Println("Status Code:", resp.StatusCode)
fmt.Println("Body:", string(body))
}
输出示例¶
{
"total": 6,
"rows": [
{
"id": 53,
"value": "https://zb.demo.com/tcpt.hk6",
"ctime": 1685950268,
"total": 1,
"success": 1
}
],
"code": 200,
"msg": "查询成功"
}
5. 错误码¶
| HTTP 状态码 / 业务提示 | 描述 |
|---|---|
| 200 | 成功 |
| 401 | 未鉴权或 Token 无效 |
| 403 | 无权限 |
6. 数据模型¶
TimeRange¶
查询时间范围。
| 参数名称 | 必选 | 类型 | 描述 |
|---|---|---|---|
| beginTime | 是 | String | 开始时间,格式 yyyy-MM-dd HH:mm:ss。示例值:2023-08-14 00:00:00 |
| endTime | 是 | String | 结束时间,格式 yyyy-MM-dd HH:mm:ss。示例值:2023-08-21 23:59:59 |
CacheRecordFilter¶
完成状态筛选。
| 参数名称 | 必选 | 类型 | 描述 |
|---|---|---|---|
| status | 否 | Array of String | 完成状态。取值:2(全部节点成功)、3(存在未成功节点)。取数组首个元素生效。示例值:["2"] |
CacheRecord¶
单条刷新/预热任务记录。
| 参数名称 | 类型 | 描述 |
|---|---|---|
| id | Long | 记录 ID。示例值:53 |
| value | String | 刷新/预热的 URL 或目录。示例值:https://zb.demo.com/tcpt.hk6 |
| ctime | Long | 创建时间(Unix 秒级时间戳)。示例值:1685950268 |
| total | Long | 任务节点总数。示例值:1 |
| success | Long | 成功节点数。示例值:1 |