安全组实例

1. 加入安全组 JoinSecurityGroup

接口方法:POST

请求示例:

https://open.cn-east-1.163yun.com/vpc?Version=2017-11-30&Action=JoinSecurityGroup
-d'{
    "InstanceType": "NVM",
    "SecurityGroupIds": [
        "4ef4db49-8a61-4f1a-8390-cd39f87ef6ee"
    ],
    "InstanceId": "fc8fc80a-8469-4f61-a094-bd42258150e9"
}'

url 参数:

参数是否必选说明
VersionAPI 版本号
ActionJoinSecurityGroup,实例加入到安全组

body 参数:

参数是否必填说明
InstanceType必选服务名
SecurityGroupIds必选要移入的安全组id列表
InstanceId必选要操作的实例id

}

响应示例:

{
    "SecurityGroupIds": [
        "4ef4db49-8a61-4f1a-8390-cd39f87ef6ee",
        "cd2290b8-989c-491f-baee-4ee392b32eaf"
    ],
    "RequestId": "1fd2e798-4c27-436c-bcae-8fb1a49d7afd"
}

常见错误:


安全组id无效 400 BadRequest
{
    "Code": "InvalidParameterValue",
    "Message": "Security group id is invalid",
    "RequestId": "da1ab2e9-3b8f-4b2c-b5c8-aa54c70c0644",
    "Result": ""
}

当前实例已经在五个安全组里,不再支持移入 400 BadRequest
{
    "Code": "InvalidParameterValue",
    "Message": "Vpc instance in security group count is over quota",
    "RequestId": "acc7a417-1a3e-48fc-8928-3b74740d5401",
    "Result": ""
}
按请求移入之后,实例安全组数量将会超过五个 400 BadRequest
{
    "Code": "InvalidParameterValue",
    "Message": "The number of instance security group is more than quota",
    "RequestId": "acc7a417-1a3e-48fc-8928-3b74740d5401",
    "Result": ""
}


2. 移出安全组LeaveSecurityGroup

接口方法:POST

请求示例:

https://open.cn-east-1.163yun.com/vpc?Version=2017-11-30&Action=LeaveSecurityGroup
-d'{
    "InstanceType": "NVM",
    "SecurityGroupIds": [
        "4ef4db49-8a61-4f1a-8390-cd39f87ef6ee"
    ],
    "InstanceId": "fc8fc80a-8469-4f61-a094-bd42258150e9"
}'

url 参数:

参数是否必选说明
VersionAPI 版本号
ActionLeaveSecurityGroup,实例移出安全组

body 参数:

参数是否必填说明
InstanceType必选服务名
SecurityGroupIds必选要移出的安全组id列表
InstanceId必选要操作的实例id

响应示例:

{
    "SecurityGroupIds": [
        "cd2290b8-989c-491f-baee-4ee392b32eaf"
    ],
    "RequestId": "ec1437b2-348f-4fd1-ba16-ece23ea91475"
}

常见错误:

当前实例只在一个安全组里,不再支持移出 400 BadRequest
{
    "Code": "InvalidParameterValue",
    "Message": "The number of instance security group can not support move out",
    "RequestId": "acc7a417-1a3e-48fc-8928-3b74740d5401",
    "Result": ""
}

3. GetInstanceCount 获取一个SecurityGroup下所有实例的总数

接口方法:GET

请求示例:

https://open.cn-east-1.163yun.com/vpc?Version=2017-11-30&Action=GetInstanceCount&Id=cd2290b8-989c-491f-baee-4ee392b32eaf

url 参数:

参数是否必选说明
VersionAPI 版本号
ActionGetInstanceCount,获取安全组内实例数
Id必选安全组的id

响应示例:

{
    "InstanceCount": 4,
    "RequestId": "864479a9-9c74-4e4e-a822-df2478158f5c"
}

4. ListSecurityGroupInstance 获取某安全组中的实例

接口方法:GET

请求示例:

https://open.cn-east-1.163yun.com/vpc?Version=2017-11-30&Action=ListSecurityGroupInstance&Id=cd2290b8-989c-491f-baee-4ee392b32eaf

url 参数:

参数是否必选说明
VersionAPI 版本号
ActionListSecurityGroupInstance,列出当前安全组内的实例
Id必选安全组id
Limit可选返回个数,不填默认20
Offset可选总偏移量,不填默认0
KeyWord可选搜索参数,可选,匹配范围为:serviceName实例类型,InstanceId实例id

响应示例:

{
    "Count": 4,
    "Offset": 0,
    "RequestId": "0abf2621-b587-40f7-88fb-c63278c9c206",
    "Instances": [
        {
            "InstanceId": "fc8fc80a-8469-4f61-a094-bd42258150e9",
            "InstanceType": "NVM"
        },
        {
            "InstanceId": "14492",
            "InstanceType": "RDS"
        },
        {
            "InstanceId": "0d42f69a-3f91-4a37-98e1-0d484ca9594c",
            "InstanceType": "NCR"
        },
        {
            "InstanceId": "21820",
            "InstanceType": "MongoDB"
        }
    ],
    "Limit": 20
}

5. ListInstanceSecurityGroups 获取实例所加入的安全组列表

接口方法:GET

请求示例:

https://open.cn-east-1.163yun.com/vpc?Version=2017-11-30&Action=ListInstanceSecurityGroups&InstanceId=fc8fc80a-8469-4f61-a094-bd42258150e9&InstanceType=NVM

url 参数:

参数是否必选说明
VersionAPI 版本号
ActionListInstanceSecurityGroups,查询实例加入的安全组
InstanceId必选实例id
InstanceType必选实例类型
Limit可选返回个数,不填默认20
Offset可选总偏移量,不填默认0
KeyWord可选搜索参数,可选,匹配范围为: 安全组id,Name安全组名字,Description安全组描述

响应示例:

{
    "Count": 1,
    "Offset": 0,
    "RequestId": "d294ab56-a5a3-4aef-b2fd-319428709b6f",
    "SecurityGroups": [
        {
            "Description": "default",
            "Id": "cd2290b8-989c-491f-baee-4ee392b32eaf",
            "VpcId": "a007fc18-2b71-4aa7-b50f-c1becbdf1e7a",
            "Name": "default",
            "SecurityGroupType": "System",
            "IsDefault": true,
            "CreateAt": "2018-08-02T02:27:05Z",
            "UpdateAt": "2018-08-02T02:27:05Z"
        }
    ],
    "Limit": 20
}