跳转至

查询函数关联的域名

1. 接口描述

接口请求路径:GET /prod-api/multiCdn/function/describeCdnDomainByFunction

describeCdnDomainByFunction 用于查询指定函数当前关联的域名列表。

Token 获取方式见 密钥鉴权。

2. 输入参数

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

参数名称 必选 类型 描述
functionGrnId 是 String Query 参数。函数唯一 ID。示例值:grn:test:multi-cdn:001:function/0a1b2c3d4e5f6789

3. 输出参数

参数名称 类型 描述
code Integer 状态码。示例值:200
msg String 提示信息。示例值:成功
data Array of Object 函数关联的域名列表
data[].domainGrnId String 域名唯一 ID。示例值:grn:test:multi-cdn:001:domain/01234565d940e553de8e
data[].domainName String 域名。示例值:www.demo.com

4. 示例

输入示例

GET /prod-api/multiCdn/function/describeCdnDomainByFunction?functionGrnId=grn:test:multi-cdn:001:function/0a1b2c3d4e5f6789

代码调用

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

curl -X GET 'https://{登录域名}/prod-api/multiCdn/function/describeCdnDomainByFunction?functionGrnId=grn:test:multi-cdn:001:function/0a1b2c3d4e5f6789' \
  -H 'Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.xxxxxx'
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;

public class DescribeCdnDomainByFunctionTest {

    public static void main(String[] args) throws Exception {
        String token = "eyJhbGciOiJIUzUxMiJ9.xxxxxx";

        URIBuilder uriBuilder = new URIBuilder("https://{登录域名}/prod-api/multiCdn/function/describeCdnDomainByFunction");
        uriBuilder.addParameter("functionGrnId", "grn:test:multi-cdn:001:function/0a1b2c3d4e5f6789");

        try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
            HttpGet httpGet = new HttpGet(uriBuilder.build());
            httpGet.setHeader("Authorization", "Bearer " + token);

            try (CloseableHttpResponse response = httpClient.execute(httpGet)) {
                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 (
    "fmt"
    "io"
    "net/http"
    "net/url"
)

func main() {
    token := "eyJhbGciOiJIUzUxMiJ9.xxxxxx"

    u, err := url.Parse("https://{登录域名}/prod-api/multiCdn/function/describeCdnDomainByFunction")
    if err != nil {
        panic(err)
    }
    q := u.Query()
    q.Set("functionGrnId", "grn:test:multi-cdn:001:function/0a1b2c3d4e5f6789")
    u.RawQuery = q.Encode()

    req, err := http.NewRequest(http.MethodGet, u.String(), nil)
    if err != nil {
        panic(err)
    }
    req.Header.Set("Authorization", "Bearer "+token)

    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))
}

输出示例

{
  "code": 200,
  "msg": "成功",
  "data": [
    {
      "domainGrnId": "grn:test:multi-cdn:001:domain/01234565d940e553de8e",
      "domainName": "www.demo.com"
    }
  ]
}

5. 错误码

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