跳转至

获取地区限制

1. 接口描述

接口请求路径:GET /prod-api/acdn/cloudfrontRest/getRegionalRestrictions/{distributionId}

getRegionalRestrictions 用于查询指定海外 ACDN 分发的地理限制配置(黑名单 / 白名单 / 无限制)及国家/地区列表。

Token 获取方式见 密钥鉴权

2. 输入参数

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

参数名称 必选 类型 描述
distributionId Long Path 参数。分发主键 ID
示例值:38

3. 示例

示例1 查询地区限制

输入示例

GET /prod-api/acdn/cloudfrontRest/getRegionalRestrictions/38

代码调用

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

import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;

public class GetRegionalRestrictionsTest {

    public static void main(String[] args) throws Exception {
        String distributionId = "38";
        String url = "https://{登录域名}/prod-api/acdn/cloudfrontRest/getRegionalRestrictions/" + distributionId;
        String token = "eyJhbGciOiJIUzUxMiJ9.xxxxxx";

        try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
            HttpGet httpGet = new HttpGet(url);
            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"
)

func main() {
    distributionId := "38"
    url := "https://{登录域名}/prod-api/acdn/cloudfrontRest/getRegionalRestrictions/" + distributionId
    token := "eyJhbGciOiJIUzUxMiJ9.xxxxxx"

    req, err := http.NewRequest(http.MethodGet, url, 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))
}

输出示例

{
  "msg": "操作成功",
  "code": 200,
  "data": {
    "restrictionType": "whitelist",
    "quantity": 1,
    "items": [
      "AE"
    ]
  }
}

4. 输出参数

参数名称 类型 描述
code Integer 状态码。示例值:200
msg String 提示信息。示例值:操作成功
data Object 地区限制数据
data.restrictionType String 限制类型,支持以下值:
blacklist:黑名单
whitelist:白名单
none:无
示例值:whitelist
data.quantity Integer 国家/地区数量。示例值:1
data.items Array of String 国家/地区代码列表(ISO 3166-1 alpha-2)
示例值:["AE"]

5. 错误码

HTTP 状态码 / 业务提示 描述
200 成功
401 未鉴权或 Token 无效
403 无权限
id不能为空! 未传入 distributionId