跳转至

查询函数列表

1. 接口描述

接口请求路径:POST /prod-api/multiCdn/function/describeCdnFunctions

describeCdnFunctions 用于分页查询当前账号下的 CDN 函数,可按函数或域名筛选。账号需具备 cdn2:DescribeAllFunctions 权限。

Token 获取方式见 密钥鉴权。

2. 输入参数

以下请求参数列表仅列出了接口请求参数和部分公共参数,完整公共参数列表见 公共请求参数。

参数名称 必选 类型 描述
pageNum 是 Integer 当前页数。示例值:1
pageSize 是 Integer 每页显示条目个数。示例值:10
functionName 否 String 函数类别。取值:cache(缓存配置)。示例值:cache
functionGrnId 否 String 函数唯一 ID,传入后只查询该函数。示例值:grn:test:multi-cdn:001:function/0a1b2c3d4e5f6789
domainGrnId 否 String 域名唯一 ID,传入后查询该域名关联的函数。示例值:grn:test:multi-cdn:001:domain/01234565d940e553de8e

3. 输出参数

参数名称 类型 描述
code Integer 状态码。示例值:200
msg String 提示信息。示例值:成功
total Integer 总条数。示例值:2
rows Array 当前页函数列表
rows[].functionGrnId String 函数唯一 ID。示例值:grn:test:multi-cdn:001:function/0a1b2c3d4e5f6789
rows[].functionName String 函数类别。取值:cache(缓存配置)。示例值:cache
rows[].name String 函数名称。示例值:图片缓存规则
rows[].remark String 备注。示例值:静态图片缓存 1 天
rows[].config Object 函数配置,字段随函数类别不同而不同。缓存配置字段见下方说明
rows[].updateTime String 更新时间,格式 yyyy-MM-dd HH:mm:ss。示例值:2026-11-01 12:00:00

config(functionName 为 cache 时)字段说明:

参数名称 类型 描述
contentType String 缓存内容类型。取值:directory(目录)、file(文件后缀)、path(全路径)。示例值:file
contentValue String 缓存内容,多个值用英文逗号分隔。示例值:jpg,png,gif
cacheTime Long 缓存时间,单位秒。示例值:86400
ignoreParams Boolean 是否忽略 URL 参数。示例值:false

4. 示例

输入示例

{
  "pageNum": 1,
  "pageSize": 10,
  "functionName": "cache"
}

代码调用

请将 {登录域名}、token 替换为实际值。

curl -X POST 'https://{登录域名}/prod-api/multiCdn/function/describeCdnFunctions' \
  -H 'Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.xxxxxx' \
  -H 'Content-Type: application/json' \
  -d '{
  "pageNum": 1,
  "pageSize": 10,
  "functionName": "cache"
}'
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 DescribeCdnFunctionsTest {

    public static void main(String[] args) throws Exception {
        String url = "https://{登录域名}/prod-api/multiCdn/function/describeCdnFunctions";
        String token = "eyJhbGciOiJIUzUxMiJ9.xxxxxx";

        String requestBody = "{"
                + "\"pageNum\":1,"
                + "\"pageSize\":10,"
                + "\"functionName\":\"cache\""
                + "}";

        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/multiCdn/function/describeCdnFunctions"
    token := "eyJhbGciOiJIUzUxMiJ9.xxxxxx"

    requestBody := []byte(`{
  "pageNum": 1,
  "pageSize": 10,
  "functionName": "cache"
}`)

    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": 1,
  "rows": [
    {
      "functionGrnId": "grn:test:multi-cdn:001:function/0a1b2c3d4e5f6789",
      "functionName": "cache",
      "name": "图片缓存规则",
      "remark": "静态图片缓存 1 天",
      "config": {
        "contentType": "file",
        "contentValue": "jpg,png,gif",
        "cacheTime": 86400,
        "ignoreParams": false
      },
      "updateTime": "2026-11-01 12:00:00"
    }
  ],
  "code": 200,
  "msg": "成功"
}

5. 错误码

HTTP 状态码 / 业务提示 描述
200 成功
401 未鉴权或 Token 无效
403 无权限