跳转至

编辑源站组

1. 接口描述

接口请求路径:POST /prod-api/cdn/layer7/origin/modifyOriginGroup

modifyOriginGroup 用于新增或编辑源站组及其源站记录。

Token 获取方式见 密钥鉴权

2. 输入参数

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

参数名称 必选 类型 描述
originGroupId Integer 源站组 ID。编辑已有组时传入;新建时按业务约定传值
示例值:1338
originGroupName String 组名。仅支持字母、数字、下划线、中划线:a-zA-Z0-9_-
示例值:1_1_1_1
originRecords [OriginRecords] 源站记录列表,不能为空
domainId Integer 域名 ID(可选)

3. 示例

示例1 编辑源站组

输入示例

{
  "originGroupId": 1338,
  "originGroupName": "1_1_1_1",
  "originRecords": [
    {
      "recordId": 1493,
      "record": "1.1.1.1",
      "weight": null
    }
  ]
}

代码调用

请将 {登录域名}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 ModifyOriginGroupTest {

    public static void main(String[] args) throws Exception {
        String url = "https://{登录域名}/prod-api/cdn/layer7/origin/modifyOriginGroup";
        String token = "eyJhbGciOiJIUzUxMiJ9.xxxxxx";

        String requestBody = "{"
                + "\"originGroupId\":1338,"
                + "\"originGroupName\":\"1_1_1_1\","
                + "\"originRecords\":[{\"recordId\":1493,\"record\":\"1.1.1.1\",\"weight\":null}]"
                + "}";

        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/origin/modifyOriginGroup"
    token := "eyJhbGciOiJIUzUxMiJ9.xxxxxx"

    requestBody := []byte(`{
  "originGroupId": 1338,
  "originGroupName": "1_1_1_1",
  "originRecords": [
    {
      "recordId": 1493,
      "record": "1.1.1.1",
      "weight": null
    }
  ]
}`)

    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": {
    "domainId": null,
    "originGroupId": 1338,
    "originGroupName": "1_1_1_1",
    "originRecords": [
      {
        "recordId": 1493,
        "record": "1.1.1.1",
        "weight": null
      }
    ]
  }
}

4. 输出参数

参数名称 类型 描述
code Integer 状态码。示例值:200
msg String 提示信息。示例值:成功
data ModifyOriginGroupResult 编辑后的源站组信息

5. 错误码

HTTP 状态码 / 业务提示 描述
200 成功
401 未鉴权或 Token 无效
403 无权限
源站组不能为空 originRecords 为空或未传
源站组名只能为a-z, A-Z, 0-9, _, - originGroupName 含非法字符
源站组权重只能为1-100 已填写权重时,权重须在 1–100

6. 数据模型

OriginRecords

源站记录(请求)。

参数名称 必选 类型 描述
record String 源站地址。暂不支持 IP 与域名共存
示例值:1.1.1.1
recordId Integer 源站记录 ID。编辑已有记录时传入
示例值:1493
weight Integer 权重。若任一记录填写了权重,则所有记录均需填写,范围 1–100

ModifyOriginGroupResult

编辑结果。

参数名称 类型 描述
domainId Integer 域名 ID,可能为 null
originGroupId Integer 源站组 ID。示例值:1338
originGroupName String 组名。示例值:1_1_1_1
originRecords [OriginRecords] 源站记录列表