网络

Vpc对象内容为:

{
        "Name": "network-llllldddddd",                # 网络名字
        "Id": "d8cfcbaf-f400-412a-8d89-4dc58f4aa00b", # 网络id
        "CidrBlock": "10.0.0.0/9",                    # 网络cidr
        "IsDefault": false,                           # 是否默认优选VPC,取值为true/false
        "Description": "fxxk",                        # 描述
        "CreateAt": "2017-12-20T03:29:14Z",           # 创建时间,UTC时间
        "UpdateAt": "2017-12-20T03:29:14Z"            # 更新时间,UTC时间
        "EnableHostnameDns": false,                   # 是否开通本vpc内云服务器默认Dns托管域
        "DefaultHostedZoneId": "",                  # 本vpc内云服务器默认Dns正向解析域Id,未开通则没有值
        "DefaultInverseHostedZoneId": ""            # 本vpc内云服务器默认Dns反向解析域Id,未开通则没有值
}

1. 创建网络 CreateVpc

接口方法:POST

请求示例:

https://open.cn-east-1.163yun.com/vpc?Version=2017-11-30&Action=CreateVpc
-d '{
    "Name": "david",
    "CidrBlock": "192.168.0.0/16"
}'

url 参数:

参数是否必选说明
VersionAPI 版本号
ActionCreateVpc,新建VPC

body 参数:

参数是否必选说明
Name必选网络名,2-32位字母、数字、下划线或中划线组成,以字母开头
CidrBlock必选网络cidr,对普通用户取值范围为: 192.168.0.0/16,172.16.0.0/12,10.0.0.0/9的子集,内部要连通私有云机房网用户所选的网段必须为10.177.0.0/16的子集,VPC服务本身并没有区分是否内部用户
IsDefault可选是否默认vpc,可选值为true或者false,不填则默认为false
Description可选vpc描述,长度不超过256个字符
EnableHostnameDns可选是否开通本vpc内云服务器默认Dns托管域,该值所有用户都能看到,但是该功能通过白名单开放使用,私有云全开放,公有云限制

}

响应示例:

{
    "Vpc": {
        "Name": "david",
        "Id": "9667d067-7608-435c-9fce-27484213c0af",
        "CidrBlock": "192.168.0.0/16",
        "IsDefault": false,
        "Description": null,
        "CreateAt": "2018-10-23T04:24:30Z",
        "UpdateAt": "2018-10-23T04:24:30Z",
        "EnableHostnameDns": false,
        "DefaultHostedZoneId": "",
        "DefaultInverseHostedZoneId": ""
    },
    "RequestId": "2670540c-ab4c-4c35-b908-d7f8b6237e61"
}

常见错误:

IsDefault传值错误 400 BadRequest:
{
    "Code": "InvalidParameterValue",
    "Message": "IsDefault is invalid",
    "RequestId": "a332779b-0a52-41b2-b507-34208c6573d3",
    "Result": ""
}

cidr范围不合法 400 BadRequest:
{
    "Code": "InvalidParameterValue",
    "Message": "Cidr is invalid",
    "RequestId": "f1b07c8f-610a-420c-a416-486276dcc137",
    "Result": ""
}

名字重复或者不合法:400 BadRequest
{
    "Code": "InvalidParameterValue",
    "Message": "Name is invalid",
    "RequestId": "38f556f5-3d8a-4822-98a8-834d5d5327f1",
    "Result": ""
}
底层资源不够或者网络不通:500 Internal Server Error
{
    "Code": "InternalServerError",
    "Message": "Need retry",
    "RequestId": "25997886-d55b-488f-8b6c-0da420c52a39",
    "Result": {
        "code": 500,
        "detail": "Internal Server Error"
    }
}

2. 删除网络DeleteVpc

接口方法:GET

请求示例:

https://open.cn-east-1.163yun.com/vpc?Version=2017-11-30&Action=DeleteVpc&Id=bf6b3bd0-0716-4f4d-aaa6-a5bf65629b5e

url 参数:

参数是否必选说明
VersionAPI 版本号
ActionDeleteVpc,删除 VPC
Id必选要删除的网络id

响应示例:

{
    "Vpc": {
        "Name": "luodanAPISubnet2",
        "Id": "bf6b3bd0-0716-4f4d-aaa6-a5bf65629b5e",
        "CidrBlock": "192.168.0.0/16",
        "IsDefault": false,
        "Description": null,
        "CreateAt": "2018-10-22T09:23:23Z",
        "UpdateAt": "2018-10-22T09:23:23Z",
        "EnableHostnameDns": false,
        "DefaultHostedZoneId": "",
        "DefaultInverseHostedZoneId": ""
    },
    "RequestId": "1f49e06a-fffa-45b2-b7b4-d48dc19388d6"
}

常见错误:

网络不属于该租户 400 BadRequest
{
    "Code": "InvalidParameterValue",
    "Message": "Network does not exist",
    "RequestId": "b7e5b9b2-382a-4600-beb2-79ae25f0e00d",
    "Result": ""
}

默认网络不允许使用该操作 400 BadRequest
{
    "Code": "InvalidParameterValue",
    "Message": "Network is default and can not be operated",
    "RequestId": "e267b141-f564-40f4-b6f7-8f9d3519fc9f",
    "Result": ""
}
网络中仍然有资源,不允许该操作400 BadRequest
{
    "Code": "InvalidParameterValue",
    "Message": "Vpc network resource exists",
    "RequestId": "f1b07c8f-610a-420c-a416-486276dcc137",
    "Result": ""
}

3. 设置网络信息 SetVpc

接口方法:POST

请求示例:

https://open.cn-east-1.163yun.com/vpc?Version=2017-11-30&Action=SetVpc
-d'{
    "Id": "9667d067-7608-435c-9fce-27484213c0af",
    "Description": "This is an API test."
}'

url 参数:

参数是否必选说明
VersionAPI 版本号
ActionSetVpc,设置 VPC

body 参数:

参数是否必填说明
Id必选网络id
Name可选新设置的网络名,不填则不修改
Description可选设置的新的网络描述,不填则不修改
IsDefault可选设置的网络是否为默认VPC,该值要么不填,要么只能为true
EnableHostnameDns可选是否开通本vpc内云服务器默认Dns托管域,该值返回值不作白名单区分,所有用户都能看到,但是该功能通过白名单开放使用,私有云全开放,公有云白名单限制。该值要么不填,要么只能为true

响应示例:

{
    "Vpc": {
        "Name": "david",
        "Id": "9667d067-7608-435c-9fce-27484213c0af",
        "CidrBlock": "192.168.0.0/16",
        "IsDefault": false,
        "Description": "This is an API test.",
        "CreateAt": "2018-10-23T04:24:30Z",
        "UpdateAt": "2018-10-23T04:25:18Z",
        "EnableHostnameDns": false,
        "DefaultHostedZoneId": "",
        "DefaultInverseHostedZoneId": ""
    },
    "RequestId": "f82f460a-2dd2-450b-8358-3e1f191e2d8d"
}

常见错误:

网络Id无效 400 BadRequest
{
    "Code": "InvalidParameterValue",
    "Message": "Network id is invalid",
    "RequestId": "781ae483-0b0b-4302-b2c2-a49e6fbb3076",
    "Result": ""
}

IsDefault的值不为true 400 BadRequest:
{
    "Code":"InvalidParameterValue",
    "Message":"IsDefault is invalid",
    "RequestId":"b34f6e20-d254-4a37-ade9-0c44d3d9d0fb",
    "Result":""
}

默认网络不允许set操作  400 BadRequest:
{
    "Code": "InvalidParameterValue",
    "Message": "Network is default and can not be operated",
    "RequestId": "f45305a2-13e3-45a5-8e00-bd1f8ba851b2",
    "Result": ""
}
名字不合法,重名等 400 BadRequest
{
    "Code": "InvalidParameterValue",
    "Message": "Name is invalid",
    "RequestId": "ae4c0a0c-7f69-4850-9aec-c257967467f3",
    "Result": ""
}

4.获取单个网络详情GetVpc

接口方法:GET

请求示例:

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

url 参数:

参数是否必选说明
VersionAPI 版本号
ActionGetVpc,获取单个 vpc 详情信息
Id必选要获取的网络id

响应示例:

{
    "Vpc": {
        "Name": "MyVPC",
        "Id": "a007fc18-2b71-4aa7-b50f-c1becbdf1e7a",
        "CidrBlock": "192.168.0.0/16",
        "IsDefault": true,
        "Description": null,
        "CreateAt": "2018-08-02T02:27:05Z",
        "UpdateAt": "2018-09-17T02:16:37Z",
        "EnableHostnameDns": false,
        "DefaultHostedZoneId": "",
        "DefaultInverseHostedZoneId": ""
    },
    "RequestId": "a6655db0-4b60-4e56-9ace-a29d423c48de"
}

常见错误:

经典网络不允许该操作
{
    "Code": "InvalidParameterValue",
    "Message": "Network is classic and can not be operated"
    "RequestId": "ae4c0a0c-7f69-4850-9aec-c257967467f3",
    "Result": ""
}
网络不属于该租户 400 BadRequest
{
    "Code": "InvalidParameterValue",
    "Message": "Network does not exist",
    "RequestId": "b7e5b9b2-382a-4600-beb2-79ae25f0e00d",
    "Result": ""
}

5. ListVpc

接口方法:GET

请求示例:

https://open.cn-east-1.163yun.com/vpc?Version=2017-11-30&Action=ListVpc

url 参数:

参数是否必选说明
VersionAPI 版本号
ActionListVpc,获取 vpc 列表

body 参数:

参数是否必填说明
Limit可选返回个数,不填默认20
Offset可选总偏移量,不填默认0
KeyWord可选搜索参数,可选,匹配范围为:name,networkId,cidr,description

响应示例:

{
    "Count": 3,
    "Vpcs": [
        {
            "Name": "luodanAPISubnet2",
            "Id": "bf6b3bd0-0716-4f4d-aaa6-a5bf65629b5e",
            "CidrBlock": "192.168.0.0/16",
            "IsDefault": false,
            "Description": null,
            "CreateAt": "2018-10-22T09:23:23Z",
            "UpdateAt": "2018-10-22T09:23:23Z",
            "EnableHostnameDns": false,
            "DefaultHostedZoneId": "",
            "DefaultInverseHostedZoneId": ""
        },
        {
            "Name": "MyVPC",
            "Id": "a007fc18-2b71-4aa7-b50f-c1becbdf1e7a",
            "CidrBlock": "192.168.0.0/16",
            "IsDefault": true,
            "Description": null,
            "CreateAt": "2018-08-02T02:27:05Z",
            "UpdateAt": "2018-09-17T02:16:37Z",
            "EnableHostnameDns": false,
            "DefaultHostedZoneId": "",
            "DefaultInverseHostedZoneId": ""
        },
        {
            "Name": "classic",
            "Id": "f44faa6c-311d-4b54-bdca-e2d221bef45b",
            "CidrBlock": "-",
            "IsDefault": false,
            "Description": null,
            "CreateAt": "2018-08-01T08:38:09Z",
            "UpdateAt": "2018-08-01T08:38:09Z",
            "EnableHostnameDns": false,
            "DefaultHostedZoneId": "",
            "DefaultInverseHostedZoneId": ""
        }
    ],
    "Offset": 0,
    "RequestId": "89a8195b-4ba0-49e8-af46-c2c907f6b204",
    "Limit": 20
}

常见错误

分页参数不能大于1000
{
    "Code":"InvalidParameterValue",
    "Message":"Limit should be between 1 and 1000",
    "RequestId":"5473a2c1-83d3-4159-a62d-897c033bad51",
    "Result":""
}

6. ListVpcInstance

接口方法:GET

请求示例:

https://open.cn-east-1.163yun.com/vpc?Version=2017-11-30&Action=ListVpcInstance&VpcId=9667d067-7608-435c-9fce-27484213c0af

url 参数:

参数是否必选说明
VersionAPI 版本号
ActionListVpcInstance,获取 vpc 内的实例信息
VpcId必选vpc网络id

响应示例:

{
    "KAFKA": 0,
    "NES": 0,
    "NCS": 0,
    "NCR": 0,
    "RDS": 0,
    "NLB": 0,
    "NQS": 0,
    "NVM": 0,
    "RequestId": "88b9311c-106e-4ad7-9ce3-5d314923dd5b",
    "MongoDB": 0,
    "ING": 0,
    "NAS": 0,
    "NEC_Peering": 0,
    "NMEM": 0,
    "NEC_Direct": 0
}

7. SearchVpc

按照 vpcid 列表获得一个用户当前 Region 的 vpc。

接口方法:POST

请求示例:

https://open.cn-east-1.163yun.com/vpc?Version=2017-11-30&Action=SearchVpc
-d'{
    "VpcIds": [
        "a007fc18-2b71-4aa7-b50f-c1becbdf1e7a"
    ]
}'

url 参数

参数是否必选说明
VersionAPI 版本号
ActionSearchVpc,获取 vpc 的网络信息

body 参数:

参数是否必填说明
VpcIds必选需要查询的VpcId列表,该参数内容不能为空,一次查询id数量不大于100个

响应示例:

如果传入的vpc id在该region中不存在,则不返回该vpc id的网络信息

{
    "Count": 1,
    "Vpcs": [
        {
            "Name": "MyVPC",
            "Id": "a007fc18-2b71-4aa7-b50f-c1becbdf1e7a",
            "CidrBlock": "192.168.0.0/16",
            "IsDefault": true,
            "Description": null,
            "CreateAt": "2018-08-02T02:27:05Z",
            "UpdateAt": "2018-09-17T02:16:37Z",
            "EnableHostnameDns": false,
            "DefaultHostedZoneId": "",
            "DefaultInverseHostedZoneId": ""
        }
    ],
    "RequestId": "29e1c270-f676-48de-9c20-13345a09f772"
}