子网

子网对象内容:

 {
            "Name": "luodanAPISubnet",                      # 子网名
            "VpcId": "f7f6fb3f-bd5c-4b4d-acb6-e2355af4f1ee", # 子网所属vpcId
            "CidrBlock": "192.168.0.0/19",                  # 子网地址cidr
            "ZoneId": "cn-east-1b",                         # 子网可用区信息
            "Id": "22116cb0-7590-4693-961a-abd0480efa10",   # 子网id
            "RouteTableId": "ae280ece-e9c9-4476-8415-e4eab52793f2", # 子网绑定的路由表id
            "Description": "hehehhaha",        # 子网描述
            "AvailableIpCount":33,                 # 子网可用IP数量
            "CreateAt": "2017-08-11T03:46:28Z", # 创建时间,UTC时间
            "UpdateAt": "2017-12-12T10:23:30Z"  # 更新时间,UTC时间
 }

1. 创建子网CreateSubnet

接口方法:POST

请求示例:

https://open.cn-east-1.163yun.com/vpc?Version=2017-11-30&Action=CreateSubnet
-d'{
    "VpcId": "9667d067-7608-435c-9fce-27484213c0af",
    "Name": "subnet_api",
    "CidrBlock": "192.168.200.0/24",
    "ZoneId": "cn-east-1b"
}

url 参数:

参数是否必选说明
VersionAPI 版本号
ActionCreateSubnet,新建子网

body 参数:

参数是否必填说明
VpcId必选网络id
Description可选子网描述
Name必选子网名字
CidrBlock必选子网cidr
ZoneId必选子网可用区
RouteTableId可选子网要绑定的路由表id,如果没有提交该字段,则默认绑定系统路由表

响应示例:

{
    "RequestId": "b119496a-16ba-4f85-8faa-c9c3283fe49a",
    "Subnet": {
        "Name": "subnet_api",
        "VpcId": "9667d067-7608-435c-9fce-27484213c0af",
        "CidrBlock": "192.168.200.0/24",
        "ZoneId": "cn-east-1b",
        "Id": "ef9d3019-706e-465e-86cf-4e396decf433",
        "RouteTableId": "12ac96cb-023d-4b8e-8d26-c3b27d58ca29",
        "Description": null,
        "CreateAt": "2018-10-23T05:25:20Z",
        "UpdateAt": "2018-10-23T05:25:20Z",
        "AvailableIpCount": 253
    }
}

2. 删除子网DeleteSubnet

接口方法:GET

请求示例:

https://open.cn-east-1.163yun.com/vpc?Version=2017-11-30&Action=DeleteSubnet&Id="ef9d3019-706e-465e-86cf-4e396decf433

url 参数:

参数是否必选说明
VersionAPI 版本号
ActionDeleteSubnet,删除子网
Id必选要删除的子网的ID

响应示例:

{
    "RequestId": "1d297a89-431e-4c0a-bf51-fb65c2d92883",
    "Subnet": {
        "Name": "subnet_api",
        "VpcId": "9667d067-7608-435c-9fce-27484213c0af",
        "CidrBlock": "192.168.200.0/24",
        "ZoneId": "cn-east-1b",
        "Id": "ef9d3019-706e-465e-86cf-4e396decf433",
        "RouteTableId": "12ac96cb-023d-4b8e-8d26-c3b27d58ca29",
        "Description": null,
        "CreateAt": "2018-10-23T05:25:20Z",
        "UpdateAt": "2018-10-23T05:25:20Z",
        "AvailableIpCount": 253
    }
}

常见错误:

该租户没有这个子网 404NotFound
{
    "Code": "InvalidParameterValue",
    "Message": "Subnet id is invalid",
    "RequestId": "6e160217-31bc-4da5-a2c3-978e3f1ba3ed",
    "Result": ""
}
缺少必须参数 400BadRequest
{
    "Code": "MissingParameter",
    "Message": "Empty necessary param",
    "RequestId": "41ad2ffa-095b-4285-a89e-4946078a8912",
    "Result": "Required String parameter 'Id' is not present"
}

3. 获取列表ListSubnet

接口方法:GET

请求示例:

https://open.cn-east-1.163yun.com/vpc?Version=2017-11-30&Action=ListSubnet&VpcId=a007fc18-2b71-4aa7-b50f-c1becbdf1e7a

url 参数:

参数是否必选说明
VersionAPI 版本号
ActionListSubnet,获取子网列表
Limit可选返回个数,不填默认20
Offset可选总偏移量,不填默认0
KeyWord可选模糊搜索参数,可选,匹配范围为:name,networkId,cidr,description
VpcId必选网络id

响应示例:

{
    "Count": 1,
    "Offset": 0,
    "RequestId": "7d3eb792-e6bd-4e88-b3f6-0fd4b77d8e65",
    "Subnets": [
        {
            "Name": "mysubnet2",
            "VpcId": "a007fc18-2b71-4aa7-b50f-c1becbdf1e7a",
            "CidrBlock": "192.168.99.0/24",
            "ZoneId": "cn-east-1b",
            "Id": "0def8457-ce0d-4b4d-91d0-83d93ce9d110",
            "RouteTableId": "6236f2a8-d125-436e-9670-10a7b69bb177",
            "Description": null,
            "CreateAt": "2018-08-08T06:46:50Z",
            "UpdateAt": "2018-08-08T06:46:50Z",
            "AvailableIpCount": 236
        }
    ],
    "Limit": 20
}

4. 获取单个子网详情GetSubnet

接口方法:GET

请求示例:

https://open.cn-east-1.163yun.com/vpc?Version=2017-11-30&Action=GetSubnet&Id=0def8457-ce0d-4b4d-91d0-83d93ce9d110

url 参数:

参数是否必选说明
VersionAPI 版本号
ActionGetSubnet,获取指定子网的详细信息
Id必选要获取的子网id

响应示例:

{
    "RequestId": "08e79a18-7ebc-43d8-a579-b7ad2f7793e1",
    "Subnet": {
        "Name": "mysubnet2",
        "VpcId": "a007fc18-2b71-4aa7-b50f-c1becbdf1e7a",
        "CidrBlock": "192.168.99.0/24",
        "ZoneId": "cn-east-1b",
        "Id": "0def8457-ce0d-4b4d-91d0-83d93ce9d110",
        "RouteTableId": "6236f2a8-d125-436e-9670-10a7b69bb177",
        "Description": null,
        "CreateAt": "2018-08-08T06:46:50Z",
        "UpdateAt": "2018-08-08T06:46:50Z",
        "AvailableIpCount": 236
    }
}

常见错误:

该租户没有这个子网 404 NotFound
{
    "Code": "InvalidParameterValue",
    "Message": "Subnet id is invalid",
    "RequestId": "7d9cded6-ce4b-4992-8df4-5d094f25d944",
    "Result": ""
}
缺少必须参数
{
    "Code": "MissingParameter",
    "Message": "Empty necessary param",
    "RequestId": "41ad2ffa-095b-4285-a89e-4946078a8912",
    "Result": "Required String parameter 'Id' is not present"
}

5. 设置子网名字 SetSubnet

接口方法:POST

请求示例:

https://open.cn-east-1.163yun.com/vpc?Version=2017-11-30&Action=SetSubnet
-d'{
    "Id": "0def8457-ce0d-4b4d-91d0-83d93ce9d110",
    "Name": "Newname"
}'

url 参数

参数是否必选说明
VersionAPI 版本号
ActionSetSubnet,修改子网信息

body 参数

参数是否必选说明
Id子网 Id
Name子网名称

响应示例:

{
    "RequestId": "973db2fb-d8dd-4824-8c60-6afac7e7c8b4",
    "Subnet": {
        "Name": "Newname",
        "VpcId": "a007fc18-2b71-4aa7-b50f-c1becbdf1e7a",
        "CidrBlock": "192.168.99.0/24",
        "ZoneId": "cn-east-1b",
        "Id": "0def8457-ce0d-4b4d-91d0-83d93ce9d110",
        "RouteTableId": "6236f2a8-d125-436e-9670-10a7b69bb177",
        "Description": null,
        "CreateAt": "2018-08-08T06:46:50Z",
        "UpdateAt": "2018-08-08T06:46:50Z",
        "AvailableIpCount": 236
    }
}