目标组接口

1. 创建目标组

POST https://open.cn-east-1.163yun.com/nlb?Action=CreateTargetGroup&Version=2017-12-05

示例

请求:

POST /nlb?Action=CreateTargetGroup&Version=2017-12-05

HEADER:
    Content-type: application/json
    X-Product-Id: ${tenantId}

BODY:
{
    "Name": "g4",
    "InstanceId": "679fa686-eb2a-402d-9fc1-23c90c6bf637",
    "Instances":[
        {
         "Id":"5ff9f89e-62d2-4c14-b99d-91587995a02a", 
         "Name":"xx1",
         "Address":"1.1.1.1",
         "Port":8080,
         "TopAz": "dongguan1.pubvpc1"
        }
    ],
    "Monitor": {
        "Protocol": "tcp",
        "Rise": 2,
        "Fall": 3,
        "Period": 5000,
        "Timeout": 2000
    }
}

响应:

{
    "InstanceId": "c679fa686-eb2a-402d-9fc1-23c90c6bf637",
    "Name": "g4",
    "Instances":[
        {
         "Id":"11111111111111111xxxxxxxxxx", 
         "Name":"xx1",
         "Address":"1.1.1.1",
         "Port":8080,
         }
    ],
    "Monitor": {
        "Protocol": "tcp",
        "Rise": 2,
        "Fall": 3,
        "Period": 5000,
        "Timeout": 2000,
        "Url": "/"
    },
    "UseSamePort": 1,
    "TargetGroupId": "eb13e1ac-7566-44da-82ea-1acb264234f9"
}

参数说明

  • http body
参数参数描述是否必选类型范围参数说明
InstanceId实例IDuuidV4--
Name目标组名字string长度不大于32只能由大小写字母和数字组成
Instances->Id云主机uuiduuidV4--
Instances->Name云主机名字string由数字字母以及"-"和"_"组成长度超过64会被截断
Instances->Address云主机Ipstring--
Instances->Port云主机端口number1-65535-
Instances->Weight云主机权重number1-100-
Instances->TopAz云主机可用区string-空字串
Instances->BackUp备用主机number0/11处于备份状态,只有其余非备份的机器都处于异常状态才会转发流量;0处于正常状态(默认值)
Monitor健康检查规则string--
Monitor->period周期number5000-300000单位毫秒,默认值5000
Monitor->timeout超时时间number2000-60000单位毫秒,默认值2000
Monitor->rise正常状态所需次数number2-10默认值2
Monitor->fall异常状态所需次数number2-10默认值3
Monitor->protocol协议stringhttp/tcp目前仅支持两种
Monitor->url健康检查路径string以/开头,数字和字母结尾,默认为/最长为127
Monitor->port健康检查端口number1-65535-
Monitor->rstatus状态码string限制为’2xx’, ‘3xx’, ‘4xx’, 以“,”分隔-
UseSamePort集群所有后端使用相同端口标志number1/00

结果说明

参数参数描述类型范围参数说明
InstanceId实例IDuuidV4--
Name目标组名字string长度不大于32只能由大小写字母和数字组成
TargetGroupId目标组IduuidV4--
Instances->Id云主机uuiduuidV4--
Instances->Name云主机名字string由数字字母以及"-"和"_"组成长度超过64会被截断
Instances->Address云主机Ipstring--
Instances->Port云主机端口number1-65535-
Instances->Weight云主机权重number1-100-
Instances->TopAz云主机可用区string--
Instances->BackUp备用主机number0/11处于备份状态,只有其余非备份的机器都处于异常状态才会转发流量;0处于正常状态(默认值)
Monitor健康检查json-
Monitor->Protocol检查协议stringhttp/tcp目前仅支持http和tcp,其它协议后期开放
Monitor->Fall失败阈值number2-10默认值为:3
Monitor->Rise健康阈值number2-10默认值为: 2
Monitor->Url健康检查urlstringstring以/开头,数字和字母结尾,最长127个字符,默认为/,仅仅在http检查协议时使用
Monitor->Period健康检查间隔number5000-300000默认5000, 单位毫秒
Monitor->Rstatus健康检查期望返回码string限制为'2xx', '3xx', '4xx', 以“,”分隔,仅仅在http时有效, 没有配置时,返回2xx和3xx代表健康
Monitor->Timeout超时时间number2000-60000默认2000,单位毫秒
UseSamePort集群所有后端使用相同端口标志number1/01表示所有服务器是否使用相同端口

返回码

  • 200 创建成功
  • 400 参数错误
  • 403 权限错误
  • 500 内部错误

2. 修改目标组

POST https://open.cn-east-1.163yun.com/nlb?Action=UpdateTargetGroup&Version=2017-12-05

示例

请求:
POST https://open.cn-east-1.163yun.com/nlb?Action=UpdateTargetGroup&Version=2017-12-05

HEADER:
    Content-type: application/json
    

BODY:

{
    "InstanceId": "1049cd9a-3122-4ec1-b484-dd9f6d80e46b",
    "Instances": [
        {
            "Id": "7ba2a391-5acb-4602-832c-14c808f1cde4",
            "Name": "newvpc-5",
            "Address": "10.177.1.7",
            "Port": 8080,
            "TopAz": "dongguan1.pubvpc1"
        }
    ],
    "Monitor": {
        "Protocol": "tcp",
        "Rise": 2,
        "Fall": 3,
        "Period": 5000,
        "Timeout": 2000
    },
    "UseSamePort": 0,
    "TargetGroupId": "eb13e1ac-7566-44da-82ea-1acb264234f9"
}


响应:

无

参数说明

  • http body
参数参数描述是否必选类型范围参数说明
InstanceId实例IDuuidV4--
TargetGroupId目标组IduuidV4--
Instances->Id云主机uuiduuidV4--
Instances->Name云主机名字string长度超过64会被截断由数字字母以及"-"和"_"组成
Instances->Address云主机Ipstring--
Instances->Port云主机端口number1-655350
Instances->Weight云主机权重number1-100100
Instances->TopAz云主机可用区string--
Monitor健康检查规则string--
Monitor->period周期number5000-300000单位毫秒,默认值5000
Monitor->timeout超时时间number2000-60000单位毫秒,默认值2000
Monitor->rise正常状态所需次数number2-10默认值2
Monitor->fall异常状态所需次数number2-10默认值3
Monitor->protocol协议stringhttp/tcp目前仅支持两种
Monitor->url健康检查路径string以/开头,数字和字母结尾,默认为/最长为127
Monitor->port健康检查端口number1-65535-
Monitor->rstatus状态码string限制为’2xx’, ‘3xx’, ‘4xx’, 以“,”分隔-
UseSamePort集群全部机器使用相同端口number1/00

结果说明

返回码

  • 200 修改成功
  • 400 参数错误
  • 404 目标不存在
  • 403 权限错误
  • 500 内部错误

3. 删除目标组

GET https://open.cn-east-1.163yun.com/nlb?Action=DeleteTargetGroup&InstanceId=&Id=&Version=2017-12-05

示例

请求:
GET https://open.cn-east-1.163yun.com/nlb?Action=DeleteTargetGroup&InstanceId=&TargetGroupId=&Version=2017-12-05

HEADER:
    Content-type: application/json
    

响应:
    无

参数说明

  • http body
参数参数描述是否必选类型范围默认值
InstanceId实例IDstring--
TargetGroupId目标组Idstring--

结果说明

返回码

  • 204 修改成功
  • 404 资源不存在
  • 403 权限错误
  • 500 内部错误

4. 批量注册目标组实例

POST /nlb?Action=RegisterTGInstance=&Version=2017-12-05

示例

请求:
POST /nlb?Action=RegisterTGInstance&Version=2017-12-05

HEADER:
    Content-type: application/json
    X-Product-Id: ${tenantId}

BODY:

{
    "InstanceId": "966da082-9790-405b-a016-3d71209cb012",
    "Instances":[
        {
         "Id":"b013b75a-5a28-4d2a-aeda-d09e1f3217c0", 
         "Name":"nlb-example-for-debug",
         "weight":40,
         "Port":80,
         "Address": "60.191.87.7",
         "TopAz": "cn-east-1b"         
        },
        {
         "Id":"68a6cf48-8c91-479e-9da5-fac59d3726fc", 
         "Name":"demon-test-elb",
         "weight":60,
         "Port":80,
         "Address": "115.238.125.92",
         "TopAz": "cn-east-1a"
        }
    ],
    "TargetGroupId": "c9c1bc08-dd82-4f68-be0b-84ef01a039c4"
}


响应:

无

参数说明

  • http header
参数参数描述是否必选类型说明
X-Product-Id租户IDstring定长32租户ID
  • http body
参数参数描述是否必选类型范围默认值
InstanceId实例IDstring--
TargetGroupId目标组Idstring--
Instances用户云主机array of json--
instances[]->Id云主机uuiduuidV4--
instances[]->Name云主机名字string长度超过64会被截断由数字字母以及"-"和"_"组成
instances[]->Address云主机Ipstring--
instances[]->Port云主机端口number1-655350
instances[]->Weight云主机权重number1-100100
instances[]->TopAz云主机可用区string--

结果说明

返回码

  • 200 修改成功
  • 400 参数错误
  • 500 内部错误

5. 批量注销目标组实例

POST /nlb?Action=DeregisterTGInstance&Version=2017-12-05

示例

请求:
POST /nlb?Action=DeregisterTGInstance&Version=2017-12-05

HEADER:
    Content-type: application/json
    X-Product-Id: ${tenantId}

BODY:

{
    "InstanceId": "966da082-9790-405b-a016-3d71209cb012",
    "Instances":[
        {
         "Address":"115.238.125.92",
         "Port":80
        },
        {
         "Address":"60.191.87.7",
         "Port":80
        }
    ],
    "TargetGroupId": "c9c1bc08-dd82-4f68-be0b-84ef01a039c4"
}

响应:

无

参数说明

  • http header
参数参数描述是否必选类型说明
X-Product-Id租户IDstring定长32租户ID
  • http body
参数参数描述是否必选类型范围默认值
InstanceId实例IDstring--
TargetGroupId目标组Idstring--
Instances用户云主机array of json--
instances[]->Address云主机Ipstring--
instances[]->Port云主机端口number1-655350

结果说明

返回码

  • 200 修改成功
  • 400 参数错误
  • 500 内部错误

6. 更新目标组属性

POST /nlb?Action=UpdateTGInstance&Version=2017-12-05

示例

请求:
POST /nlb?Action=UpdateTGInstance&Version=2017-12-05

HEADER:
    Content-type: application/json
    X-Product-Id: ${tenantId}

BODY:

{
    "InstanceId": "966da082-9790-405b-a016-3d71209cb012",
    "Instances":[
        {
         "Address":"115.238.125.92",
         "Port":80,
         "Weight":90
        },
        {
         "Address":"60.191.87.7",
         "Port":80,
         "Weight":100
        }
    ],
    "TargetGroupId": "c9c1bc08-dd82-4f68-be0b-84ef01a039c4"
}

响应:

无

参数说明

  • http header
参数参数描述是否必选类型说明
X-Product-Id租户IDstring定长32租户ID
  • http body
参数参数描述是否必选类型范围默认值
InstanceId实例IDstring--
TargetGroupId目标组Idstring--
Instances用户云主机array of json--
instances[]->Address云主机Ipstring--
instances[]->Port云主机端口number1-65535-
instances[]->Weight云主机权重number1-100-

结果说明

返回码

  • 200 修改成功
  • 400 参数错误
  • 500 内部错误