获取刷新缓存记录¶
1. 接口描述¶
接口请求路径:POST /prod-api/cdn/layer7/cache/getCacheRecordList
getCacheRecordList 用于分页查询 URL 预热、URL 刷新、目录刷新的任务记录。
Token 获取方式见 密钥鉴权。
2. 输入参数¶
以下请求参数列表仅列出了接口请求参数和部分公共参数,完整公共参数列表见 公共请求参数。
| 参数名称 | 必选 | 类型 | 描述 |
|---|---|---|---|
| type | 是 | String | 任务类型。取值:1(URL 预热)、2(URL 刷新)、3(目录刷新)示例值: 2 |
| pageNum | 是 | Integer | 当前页数 示例值: 1 |
| pageSize | 是 | Integer | 每页显示条目个数 示例值: 10 |
| params.beginTime | 是 | String | 开始时间,格式 yyyy-MM-dd HH:mm:ss示例值: 2023-08-14 00:00:00 |
| params.endTime | 是 | String | 结束时间,格式 yyyy-MM-dd HH:mm:ss示例值: 2023-08-21 23:59:59 |
| search | 否 | String | 搜索关键字 |
| searchHeader | 否 | Object | 筛选条件 |
3. 示例¶
示例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 替换为实际值。
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": "查询成功"
}
4. 输出参数¶
| 参数名称 | 类型 | 描述 |
|---|---|---|
| code | Integer | 状态码。示例值:200 |
| msg | String | 提示信息。示例值:查询成功 |
| total | Integer | 记录总条数。示例值:6 |
| rows | Array | 当前页记录列表 |
| rows[].id | Integer | 记录 ID。示例值:53 |
| rows[].value | String | 刷新/预热的 URL 或目录。示例值:https://zb.demo.com/tcpt.hk6 |
| rows[].ctime | Integer | 创建时间(Unix 时间戳)。示例值:1685950268 |
| rows[].total | Integer | 任务节点总数。示例值:1 |
| rows[].success | Integer | 成功节点数。示例值:1 |
5. 错误码¶
| HTTP 状态码 / 业务提示 | 描述 |
|---|---|
| 200 | 成功 |
| 401 | 未鉴权或 Token 无效 |
| 403 | 无权限 |