修改分发配置信息¶
1. 接口描述¶
接口请求路径:POST /prod-api/acdn/cloudfrontRest/updateDistributionSetting
updateDistributionSetting 用于修改海外 ACDN 分发的常规配置,包括价格级别、CNAME、证书、安全策略、HTTP 版本、IPv6 等。
Token 获取方式见 密钥鉴权。
2. 输入参数¶
以下请求参数列表仅列出了接口请求参数和部分公共参数,完整公共参数列表见 公共请求参数。
| 参数名称 | 必选 | 类型 | 描述 |
|---|---|---|---|
| distributionId | 是 | Long | 分发主键 ID 示例值: 38 |
| aliases | 否 | Array | 备用域名(CNAME)列表 |
| aliases.value | 否 | String | CNAME 值 示例值: cdn.example.com |
| comment | 否 | String | 说明 |
| defaultRootObject | 否 | String | 默认根对象 示例值: / |
| isHttpVersion | 否 | String | HTTP 版本 示例值: http2 |
| isIpv6Enabled | 否 | Boolean | 是否启用 IPv6。true 开启,false 关闭示例值: true |
| isLogging | 否 | Boolean | 是否开启标准日志。true 开启,false 关闭 |
| isCookie | 否 | Boolean | 是否记录 Cookie。true 开启,false 关闭 |
| priceClass | 否 | String | 价格级别,支持以下值:PriceClass_All:使用所有边缘站点(最佳性能)PriceClass_100:仅使用北美洲和欧洲PriceClass_200:使用北美洲、欧洲、亚洲、中东和非洲示例值: PriceClass_All |
| protocolVersionType | 否 | String | 安全策略,支持以下值:TLSv1.2_2021:TLSv1.2_2021(推荐)TLSv1.2_2019:TLSv1.2_2019TLSv1.2_2018:TLSv1.2_2018TLSv1.1_2016:TLSv1.1_2016TLSv1_2016:TLSv1_2016TLSv1:TLSv1示例值: TLSv1 |
| sslCertificateId | 否 | String | SSL 证书 ARN |
| webACLId | 否 | String | WAF Web ACL ID |
3. 示例¶
示例1 修改分发配置¶
输入示例¶
{
"sslCertificateId": "",
"comment": "",
"webACLId": "",
"aliases": [
{
"value": ""
}
],
"distributionId": 38,
"isIpv6Enabled": true,
"priceClass": "PriceClass_All",
"defaultRootObject": "/",
"isHttpVersion": "http2",
"protocolVersionType": "TLSv1"
}
代码调用¶
请将 {登录域名}、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 UpdateDistributionSettingTest {
public static void main(String[] args) throws Exception {
String url = "https://{登录域名}/prod-api/acdn/cloudfrontRest/updateDistributionSetting";
String token = "eyJhbGciOiJIUzUxMiJ9.xxxxxx";
String requestBody = "{"
+ "\"sslCertificateId\":\"\","
+ "\"comment\":\"\","
+ "\"webACLId\":\"\","
+ "\"aliases\":[{\"value\":\"\"}],"
+ "\"distributionId\":38,"
+ "\"isIpv6Enabled\":true,"
+ "\"priceClass\":\"PriceClass_All\","
+ "\"defaultRootObject\":\"/\","
+ "\"isHttpVersion\":\"http2\","
+ "\"protocolVersionType\":\"TLSv1\""
+ "}";
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/acdn/cloudfrontRest/updateDistributionSetting"
token := "eyJhbGciOiJIUzUxMiJ9.xxxxxx"
requestBody := []byte(`{
"sslCertificateId": "",
"comment": "",
"webACLId": "",
"aliases": [
{
"value": ""
}
],
"distributionId": 38,
"isIpv6Enabled": true,
"priceClass": "PriceClass_All",
"defaultRootObject": "/",
"isHttpVersion": "http2",
"protocolVersionType": "TLSv1"
}`)
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))
}
输出示例¶
4. 输出参数¶
| 参数名称 | 类型 | 描述 |
|---|---|---|
| code | Integer | 状态码。示例值:200 |
| msg | String | 提示信息。示例值:修改成功 |
5. 错误码¶
| HTTP 状态码 / 业务提示 | 描述 |
|---|---|
| 200 | 成功 |
| 401 | 未鉴权或 Token 无效 |
| 403 | 无权限 |
| id不能为空! | 未传入 distributionId |
| 修改失败 | 更新未成功 |