查询函数配置¶
1. 接口描述¶
接口请求路径:POST /prod-api/cdn/layer7/function/describeFunctions
describeFunctions 用于按 functionName 或 functionId 查询域名下的函数配置。不传 functionName 时,返回该域名下全部函数列表。
Token 获取方式见 密钥鉴权。
2. 输入参数¶
以下请求参数列表仅列出了接口请求参数和部分公共参数,完整公共参数列表见 公共请求参数。
| 参数名称 | 必选 | 类型 | 描述 |
|---|---|---|---|
| domainId | 是 | Integer | 域名 ID 示例值: 215 |
| functionName | 否 | String | 函数名称。取值:IPWhitelist、http3、tls_version 等;不传则返回全部示例值: IPWhitelist |
| functionId | 否 | Integer | 函数 ID,按 ID 精确查询 |
3. 示例¶
示例1 查询 IP 白名单¶
输入示例¶
代码调用¶
请将 {登录域名}、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 DescribeFunctionsTest {
public static void main(String[] args) throws Exception {
String url = "https://{登录域名}/prod-api/cdn/layer7/function/describeFunctions";
String token = "eyJhbGciOiJIUzUxMiJ9.xxxxxx";
String requestBody = "{"
+ "\"domainId\":215,"
+ "\"functionName\":\"IPWhitelist\""
+ "}";
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/function/describeFunctions"
token := "eyJhbGciOiJIUzUxMiJ9.xxxxxx"
requestBody := []byte(`{
"domainId": 215,
"functionName": "IPWhitelist"
}`)
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))
}
输出示例¶
{
"msg": "成功",
"code": 200,
"data": [
{
"functionArgs": [
{ "argName": "values", "argValue": "[\"1.1.1.1\",\"22.2.2.2\"]" }
],
"functionName": "IPWhitelist",
"functionId": 77
},
{
"functionArgs": [
{ "argName": "status", "argValue": 0 }
],
"functionName": "http3"
},
{
"functionArgs": [
{ "argName": "status", "argValue": 0 }
],
"functionName": "tls_version"
}
]
}
其他常用请求示例:
查询 HTTP/3
查询全部函数(不传 functionName)
4. 输出参数¶
| 参数名称 | 类型 | 描述 |
|---|---|---|
| code | Integer | 状态码。示例值:200 |
| msg | String | 提示信息。示例值:成功 |
| data | [FunctionVO] | 函数配置列表 |
5. functionName 与 functionArgs 对照¶
根据返回中的 functionName,读取对应的 functionArgs:
functionName |
含义 | argName |
argValue 类型 |
说明 |
|---|---|---|---|---|
IPWhitelist |
IP 白名单 | values |
字符串 | IP 列表的 JSON 字符串,如 "[\"1.1.1.1\",\"22.2.2.2\"]"。更新时见 更新函数 |
http3 |
HTTP/3 | status |
整数 | 0:开启;1:关闭 |
tls_version |
TLS 版本 | status |
整数 | 0:开启 TLS 1.0 / 1.1 / 1.2;1:开启 TLS 1.2 / 1.3 |
同一域名下,上述函数各仅一条配置(functionId 在更新时如需指定可一并返回)。
6. 错误码¶
| HTTP 状态码 / 业务提示 | 描述 |
|---|---|
| 200 | 成功 |
| 401 | 未鉴权或 Token 无效 |
| 403 | 无权限 |
7. 数据模型¶
FunctionVO¶
函数配置项。
| 参数名称 | 类型 | 描述 |
|---|---|---|
| functionName | String | 函数名称。示例值:IPWhitelist |
| functionId | Integer | 函数 ID,更新时可传入 更新函数。示例值:77 |
| functionArgs | [FunctionArgVO] | 函数参数列表,字段含义见上方对照表 |
FunctionArgVO¶
函数参数。
| 参数名称 | 类型 | 描述 |
|---|---|---|
| argName | String | 参数名。示例值:values、status |
| argValue | String / Integer | 参数值,类型随 functionName 变化 |