修改源¶
1. 接口描述¶
接口请求路径:POST /prod-api/acdn/originsRest/updateOrigins
updateOrigins 用于修改指定海外 ACDN 分发下的源配置。修改时需传入原源名称 oldOriginIdName。
Token 获取方式见 密钥鉴权。
2. 输入参数¶
以下请求参数列表仅列出了接口请求参数和部分公共参数,完整公共参数列表见 公共请求参数。
| 参数名称 | 必选 | 类型 | 描述 |
|---|---|---|---|
| distributionId | 是 | Long | 分发主键 ID 示例值: 34 |
| oldOriginIdName | 是 | String | 修改前的源名称 示例值: ztta.com |
| domainName | 是 | String | 源域名 示例值: ztta.com |
| originIdName | 是 | String | 新源名称(唯一) 示例值: ztta.com |
| protocolPolicy | 是 | String | 协议策略,支持以下值:http-only:仅 HTTPhttps-only:仅 HTTPSmatch-viewer:匹配查看器示例值: http-only |
| httpPort | 否 | Integer | HTTP 端口,默认 80示例值: 80 |
| httpsPort | 否 | Integer | HTTPS 端口,默认 443示例值: 443 |
| quantity | 否 | Integer | 最低源 SSL 协议档位,支持以下值:1:TLSv1.22:TLSv1.13:TLSv14:SSLV3示例值: 1 |
| originPath | 否 | String | 源路径 |
| customHeaders | 否 | Array | 自定义标头列表 |
| customHeaders.headerName | 否 | String | 标头名 示例值: 11 |
| customHeaders.headerValue | 否 | String | 标头值 示例值: 123.com |
| isOriginShield | 否 | Integer | 是否启用源护盾,支持以下值:0:否1:是示例值: 1 |
| originShieldRegion | 否 | String | 源护盾 AWS 区域,支持以下值:us-east-1:美国东部(弗吉尼亚北部)us-east-2:美国东部(俄亥俄)us-west-2:美国西部(俄勒冈)ap-south-1:亚太地区(孟买)ap-northeast-2:亚太地区(首尔)ap-southeast-1:亚太地区(新加坡)ap-southeast-2:亚太地区(悉尼)ap-northeast-1:亚太地区(东京)eu-central-1:欧洲(法兰克福)eu-west-1:欧洲(爱尔兰)eu-west-2:欧洲(伦敦)sa-east-1:南美洲(圣保罗)示例值: us-east-1 |
| connectionAttempts | 否 | Integer | 连接尝试次数(1–3,默认 3) 示例值: 3 |
| connectionTimeout | 否 | Integer | 连接超时(秒,1–10,默认 10) 示例值: 10 |
| originReadTimeout | 否 | Integer | 响应超时(秒,1–60,默认 30) 示例值: 30 |
| originKeepaliveTimeout | 否 | Integer | 保持连接超时(秒,1–60,默认 5) 示例值: 5 |
3. 示例¶
示例1 修改源¶
输入示例¶
{
"oldOriginIdName": "ztta.com",
"connectionAttempts": 3,
"originReadTimeout": 30,
"quantity": 1,
"httpPort": 80,
"connectionTimeout": 10,
"domainName": "ztta.com",
"distributionId": 34,
"httpsPort": 443,
"customHeaders": [
{
"headerValue": "123.com",
"headerName": "11"
}
],
"originIdName": "ztta.com",
"originPath": "",
"isOriginShield": 1,
"originKeepaliveTimeout": 5,
"originShieldRegion": "us-east-1",
"protocolPolicy": "http-only"
}
代码调用¶
请将 {登录域名}、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 UpdateOriginsTest {
public static void main(String[] args) throws Exception {
String url = "https://{登录域名}/prod-api/acdn/originsRest/updateOrigins";
String token = "eyJhbGciOiJIUzUxMiJ9.xxxxxx";
String requestBody = "{"
+ "\"oldOriginIdName\":\"ztta.com\","
+ "\"connectionAttempts\":3,"
+ "\"originReadTimeout\":30,"
+ "\"quantity\":1,"
+ "\"httpPort\":80,"
+ "\"connectionTimeout\":10,"
+ "\"domainName\":\"ztta.com\","
+ "\"distributionId\":34,"
+ "\"httpsPort\":443,"
+ "\"customHeaders\":[{\"headerValue\":\"123.com\",\"headerName\":\"11\"}],"
+ "\"originIdName\":\"ztta.com\","
+ "\"originPath\":\"\","
+ "\"isOriginShield\":1,"
+ "\"originKeepaliveTimeout\":5,"
+ "\"originShieldRegion\":\"us-east-1\","
+ "\"protocolPolicy\":\"http-only\""
+ "}";
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/originsRest/updateOrigins"
token := "eyJhbGciOiJIUzUxMiJ9.xxxxxx"
requestBody := []byte(`{
"oldOriginIdName": "ztta.com",
"connectionAttempts": 3,
"originReadTimeout": 30,
"quantity": 1,
"httpPort": 80,
"connectionTimeout": 10,
"domainName": "ztta.com",
"distributionId": 34,
"httpsPort": 443,
"customHeaders": [
{
"headerValue": "123.com",
"headerName": "11"
}
],
"originIdName": "ztta.com",
"originPath": "",
"isOriginShield": 1,
"originKeepaliveTimeout": 5,
"originShieldRegion": "us-east-1",
"protocolPolicy": "http-only"
}`)
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 | 无权限 |
| 修改失败 | 修改未成功 |