Loading
close

安全组

time 更新时间:2022-10-28 12:16:36

安全组

列举安全组

功能介绍

‎列举网络安全组

URI

GET /v2.0/security-groups

请求消息

参数 参数类型 是否必选 描述
project_id string 指定项目ID进行查询。

响应消息

参数 参数类型 描述
security-groups array 列表组对象。
created_at string 安全组的创建时间 (UTC ISO8601 格式)。
description string 用户描述
id string 安全组的ID。
name string 安全组的名称。
project_id string 安全组所属的project id。
revision_number integer 安全组的版本号。
security_group_rules array 安全组包含的规则列表。
stateful boolean 安全组是否为有状态。
tenant_id string 安全组所属的tenant id。
updated_at string 安全组最近更新的时间(UTC ISO8601格式)。

请求示例

GET http://{endpoint}/v2.0/security-groups

正常响应示例

{
    "security_groups":[
       {
        "created_at": "2021-02-24T09:06:32Z",
        "description": "",
        "id": "de80111e-4ddb-4b58-a295-0b32e9a4f963",
        "name": "test",
        "project_id": "8dac1bf1c3a24be18809f82e1f9a845d",
        "revision_number": 1,
        "security_group_rules": [
            {
                "created_at": "2021-02-24T09:06:32Z",
                "description": null,
                "direction": "egress",
                "ethertype": "IPv4",
                "id": "231354cc-c516-47fd-9cc5-c20aab9b0e6c",
                "port_range_max": null,
                "port_range_min": null,
                "project_id": "8dac1bf1c3a24be18809f82e1f9a845d",
                "protocol": null,
                "remote_group_id": null,
                "remote_ip_prefix": null,
                "revision_number": 1,
                "security_group_id": "de80111e-4ddb-4b58-a295-0b32e9a4f963",
                "tenant_id": "8dac1bf1c3a24be18809f82e1f9a845d",
                "updated_at": "2021-02-24T09:06:32Z"
            },
            {
                "created_at": "2021-02-24T09:06:32Z",
                "description": null,
                "direction": "egress",
                "ethertype": "IPv6",
                "id": "2455c213-22ec-4d8d-b668-483cf8f831b3",
                "port_range_max": null,
                "port_range_min": null,
                "project_id": "8dac1bf1c3a24be18809f82e1f9a845d",
                "protocol": null,
                "remote_group_id": null,
                "remote_ip_prefix": null,
                "revision_number": 1,
                "security_group_id": "de80111e-4ddb-4b58-a295-0b32e9a4f963",
                "tenant_id": "8dac1bf1c3a24be18809f82e1f9a845d",
                "updated_at": "2021-02-24T09:06:32Z"
            }
        ], 
        "stateful": true,
        "tenant_id": "8dac1bf1c3a24be18809f82e1f9a845d",
        "updated_at": "2021-02-24T09:06:32Z"
       }
    ]  
}

正常响应代码

200

错误码

400,401,403,404,409,413

创建安全组

功能介绍

‎创建一个安全组

URI

POST /v2.0/security-groups

请求消息

参数 参数类型 是否必选 Description
security-group object
description string 用户描述。
name string 安全组的名称。
stateful boolean 安全组是否为有状态。
tenant_id string 所属租户ID。

响应消息

参数 参数类型 描述
security-group object 安全组对象。
created_at string 安全组的创建时间 (UTC ISO8601 格式)。
description string 用户描述。
id string 安全组的ID。
name satring 安全组的名称。
project_id string 安全组所属的project id。
revision_number integer 安全组的版本号。
security_group_rules array 安全组包含的规则列表。
stateful boolean 安全组是否为有状态。
tenant_id string 安全组所属的tenant id。
updated_at string 安全组最近更新的时间(UTC ISO8601格式)。

请求示例

POST http://{endpoint}/v2.0/security-groups
{
    "security_group": {
        "name": "test",
        "stateful": true,
        "tenant_id":"8dac1bf1c3a24be18809f82e1f9a845d"
    }
}

正常响应示例

{
    "security_group": {
        "created_at": "2021-02-24T09:06:32Z",
        "description": "",
        "id": "de80111e-4ddb-4b58-a295-0b32e9a4f963",
        "name": "test",
        "project_id": "8dac1bf1c3a24be18809f82e1f9a845d",
        "revision_number": 1,
        "security_group_rules": [
            {
                "created_at": "2021-02-24T09:06:32Z",
                "description": null,
                "direction": "egress",
                "ethertype": "IPv4",
                "id": "231354cc-c516-47fd-9cc5-c20aab9b0e6c",
                "port_range_max": null,
                "port_range_min": null,
                "project_id": "8dac1bf1c3a24be18809f82e1f9a845d",
                "protocol": null,
                "remote_group_id": null,
                "remote_ip_prefix": null,
                "revision_number": 1,
                "security_group_id": "de80111e-4ddb-4b58-a295-0b32e9a4f963",
                "tenant_id": "8dac1bf1c3a24be18809f82e1f9a845d",
                "updated_at": "2021-02-24T09:06:32Z"
            },
            {
                "created_at": "2021-02-24T09:06:32Z",
                "description": null,
                "direction": "egress",
                "ethertype": "IPv6",
                "id": "2455c213-22ec-4d8d-b668-483cf8f831b3",
                "port_range_max": null,
                "port_range_min": null,
                "project_id": "8dac1bf1c3a24be18809f82e1f9a845d",
                "protocol": null,
                "remote_group_id": null,
                "remote_ip_prefix": null,
                "revision_number": 1,
                "security_group_id": "de80111e-4ddb-4b58-a295-0b32e9a4f963",
                "tenant_id": "8dac1bf1c3a24be18809f82e1f9a845d",
                "updated_at": "2021-02-24T09:06:32Z"
            }
        ],
        "stateful": true,
        "tenant_id": "8dac1bf1c3a24be18809f82e1f9a845d",
        "updated_at": "2021-02-24T09:06:32Z"
    }
}

正常响应代码

201

错误码

400,401,403,404,409,413

获取安全组

功能介绍

‎获取一个安全组的详情

URI

GET /v2.0/security-groups/{security-group-id}

参数 是否必选 描述
security-group-id 安全组 的ID

请求消息

响应消息

参数 参数类型 描述
security-group object 安全组对象。
created_at string 安全组的创建时间 (UTC ISO8601 格式)。
description string 用户描述。
id string 安全组的ID。
name satring 安全组的名称。
project_id string 安全组所属的project id。
revision_number integer 安全组的版本号。
security_group_rules array 安全组包含的规则列表。
stateful boolean 安全组是否为有状态。
tenant_id string 安全组所属的tenant id。
updated_at string 安全组最近更新的时间(UTC ISO8601 格式)。

请求示例

GET http://{endpoint}/v2.0/ports/01a9c14a-d4bb-4b28-a5c8-fd0458b8c94e

正常响应示例

{
    "security_group": {
        "created_at": "2021-02-24T09:06:32Z",
        "description": "",
        "id": "de80111e-4ddb-4b58-a295-0b32e9a4f963",
        "name": "test",
        "project_id": "8dac1bf1c3a24be18809f82e1f9a845d",
        "revision_number": 1,
        "security_group_rules": [
            {
                "created_at": "2021-02-24T09:06:32Z",
                "description": null,
                "direction": "egress",
                "ethertype": "IPv4",
                "id": "231354cc-c516-47fd-9cc5-c20aab9b0e6c",
                "port_range_max": null,
                "port_range_min": null,
                "project_id": "8dac1bf1c3a24be18809f82e1f9a845d",
                "protocol": null,
                "remote_group_id": null,
                "remote_ip_prefix": null,
                "revision_number": 1,
                "security_group_id": "de80111e-4ddb-4b58-a295-0b32e9a4f963",
                "tenant_id": "8dac1bf1c3a24be18809f82e1f9a845d",
                "updated_at": "2021-02-24T09:06:32Z"
            },
            {
                "created_at": "2021-02-24T09:06:32Z",
                "description": null,
                "direction": "egress",
                "ethertype": "IPv6",
                "id": "2455c213-22ec-4d8d-b668-483cf8f831b3",
                "port_range_max": null,
                "port_range_min": null,
                "project_id": "8dac1bf1c3a24be18809f82e1f9a845d",
                "protocol": null,
                "remote_group_id": null,
                "remote_ip_prefix": null,
                "revision_number": 1,
                "security_group_id": "de80111e-4ddb-4b58-a295-0b32e9a4f963",
                "tenant_id": "8dac1bf1c3a24be18809f82e1f9a845d",
                "updated_at": "2021-02-24T09:06:32Z"
            }
        ],
        "stateful": true,
        "tenant_id": "8dac1bf1c3a24be18809f82e1f9a845d",
        "updated_at": "2021-02-24T09:06:32Z"
    }
}

正常响应代码

200

错误码

400,401,403,404,409,413

更新安全组

功能介绍

‎更新一个指定安全组

URI

PUT /v2.0/security-groups/{security-group-id}

参数 是否必选 描述
security-group-id 安全组的ID

请求消息

参数 参数类型 是否必选 描述
security-group object 安全组对象。
description string 用户描述。
stateful boolean 安全组是否为有状态。
name string 安全组的名称。

响应消息

参数 参数类型 描述
security-group object 安全组对象。
created_at string 安全组的创建时间 (UTC ISO8601 格式)。
description string 用户描述。
id string 安全组的ID。
name satring 安全组的名称。
project_id string 安全组所属的project id。
revision_number integer 安全组的版本号。
security_group_rules array 安全组包含的规则列表。
stateful boolean 安全组是否为有状态。
tenant_id string 安全组所属的tenant id。
updated_at string 安全组最近更新的时间(UTC ISO8601格式)。

请求示例

PUT http://{endpoint}/v2.0/security-groups/de80111e-4ddb-4b58-a295-0b32e9a4f963
{
    "security_group": {
        "name": "test2"
    }
}

正常响应示例

{
    "security_group": {
        "created_at": "2021-02-24T09:06:32Z",
        "description": "",
        "id": "de80111e-4ddb-4b58-a295-0b32e9a4f963",
        "name": "test2",
        "project_id": "8dac1bf1c3a24be18809f82e1f9a845d",
        "revision_number": 1,
        "security_group_rules": [
            {
                "created_at": "2021-02-24T09:06:32Z",
                "description": null,
                "direction": "egress",
                "ethertype": "IPv4",
                "id": "231354cc-c516-47fd-9cc5-c20aab9b0e6c",
                "port_range_max": null,
                "port_range_min": null,
                "project_id": "8dac1bf1c3a24be18809f82e1f9a845d",
                "protocol": null,
                "remote_group_id": null,
                "remote_ip_prefix": null,
                "revision_number": 1,
                "security_group_id": "de80111e-4ddb-4b58-a295-0b32e9a4f963",
                "tenant_id": "8dac1bf1c3a24be18809f82e1f9a845d",
                "updated_at": "2021-02-24T09:06:32Z"
            },
            {
                "created_at": "2021-02-24T09:06:32Z",
                "description": null,
                "direction": "egress",
                "ethertype": "IPv6",
                "id": "2455c213-22ec-4d8d-b668-483cf8f831b3",
                "port_range_max": null,
                "port_range_min": null,
                "project_id": "8dac1bf1c3a24be18809f82e1f9a845d",
                "protocol": null,
                "remote_group_id": null,
                "remote_ip_prefix": null,
                "revision_number": 1,
                "security_group_id": "de80111e-4ddb-4b58-a295-0b32e9a4f963",
                "tenant_id": "8dac1bf1c3a24be18809f82e1f9a845d",
                "updated_at": "2021-02-24T09:06:32Z"
            }
        ],
        "stateful": true,
        "tenant_id": "8dac1bf1c3a24be18809f82e1f9a845d",
        "updated_at": "2021-02-24T10:06:32Z"
    }
}

正常响应代码

200

错误码

400,401,403,404,409,413

删除安全组

功能介绍

‎删除一个指定安全组

URI

DELETE /v2.0/security-groups/{security-group-id}

参数 是否必选 描述
security-group-id 安全组的ID

请求消息

请求示例

DELETE http://{endpoint}/v2.0/security-groups/de80111e-4ddb-4b58-a295-0b32e9a4f963

正常响应代码

204

错误码

400,401,403,404,409,413

列举安全组规则

功能介绍

‎列举所有安全组规则

URI

GET /v2.0/security-group-rules

请求消息

响应消息

参数 参数类型 描述
security-group-rules array 安全组规则列表。
created_at string 安全组规则的创建时间 (UTC ISO8601格式)。
description string 用户描述。
direction string 安全组规则作用的方向,ingress或egress
ethertype string 匹配的以太网协议,必需是IPv4或IPv6。
id string 安全组规则的ID。
project_id string 安全组规则所。属的project id。
protocol string 匹配的IP协议类型,比如ICMP type。
port_range_max integer 匹配的协议端口号最大值,如果协议是ICMP,则表示ICMP code。
port_range_min integer 匹配的协议端口号最小值,如果协议是ICMP,则表示ICMP code。
remote_ip_prefix string 匹配的远端ip前缀。
remote_group_id string 匹配的远端安全组的ID,可以指定remote_group_id或者remote_ip_prefix。
revision_number integer 安全组规则的版本号。
security_group_id string 关联的安全组ID。
normalized_cidr string 只读的字段,规范化cidr的值
tenant_id string 安全组规则所属的tenant id。
updated_at string 安全组规则最近更新的时间(UTC ISO8601格式)。

请求示例

GET http://{endpoint}/v2.0/security-group-rules

正常响应示例

{
"security_group_rules": [
  {
    "created_at": "2021-02-22T03:23:55Z",
    "description": null,
    "direction": "egress",
    "ethertype": "IPv4",
    "id": "00c1068e-0110-4cf2-8856-0e20268562fd",
    "port_range_max": null,
    "port_range_min": null,
    "project_id": "6e3cf7a9d62a4faf8162cacfc94126a9",
    "protocol": null,
    "remote_group_id": null,
    "remote_ip_prefix": null,
    "revision_number": 1,
    "normalized_cidr": null,
    "security_group_id": "61884e28-ca98-4e76-b0f3-6d5b3536bd7b",
    "tenant_id": "6e3cf7a9d62a4faf8162cacfc94126a9",
    "updated_at": "2021-02-22T03:23:55Z"
  },
  {
   "created_at": "2021-02-25T03:07:27Z",
    "description": "",
    "direction": "ingress",
    "ethertype": "IPv4",
    "id": "0184bfe7-f838-476f-ad19-6891215583f5",
    "port_range_max": 65535,
    "port_range_min": 1,
    "project_id": "e9f2f863c96841e49ba4e9946ebe9087",
    "protocol": "tcp",
    "remote_group_id": null,
    "remote_ip_prefix": "0.0.0.0/0",
    "revision_number": 1,
    "normalized_cidr": null,
    "security_group_id": "a12e08af-9e8d-461c-952d-3c6fbc1bebcb",
    "tenant_id": "e9f2f863c96841e49ba4e9946ebe9087",
    "updated_at": "2021-02-25T03:07:27Z"
   }
  ]
}

正常响应代码

200

错误码

400,401,403,404,409,413

创建安全组规则

功能介绍

‎创建一个安全组规则

URI

POST /v2.0/security-group-rules

请求消息

参数 参数类型 是否必选 Description
security-group-rule object 安全组规则对象。
description string 用户描述。
direction string 安全组规则作用的方向,ingress或egress。
ethertype string 匹配的以太网协议类型,必需是IPv4或IPv6。
port_range_max integer 匹配的协议端口号最大值,如果协议是ICMP,则表示ICMP code。
port_range_min integer 匹配的协议端口号最小值,如果协议是ICMP,则表示ICMP code。
protocol string 匹配的IP协议类型,比如ICMP type。
remote_ip_prefix string 匹配的远端ip前缀。
remote_group_id string 匹配的远端安全组ID,可以指定remote_group_id或者remote_ip_prefix。
security_group_id string 关联的安全组ID。
tenant_id string 所属租户ID。

响应消息

参数 参数类型 描述
security-group-rule object 安全组规则。
created_at string 安全组规则的创建时间 (UTC ISO8601格式)。
description string 用户描述。
direction string 安全组规则作用的方向,ingress或egress。
ethertype string 匹配的以太网协议,必需是IPv4或IPv6。
id string 安全组规则的ID。
project_id string 安全组规则所属的project id。
protocol string 匹配的IP协议类型,比如ICMP type。
port_range_max integer 匹配的协议端口号最大值,如果协议是ICMP,则表示ICMP code。
port_range_min integer 匹配的协议端口号最小值,如果协议是ICMP,则表示ICMP code。
remote_ip_prefix string 匹配的远端ip前缀。
remote_group_id string 匹配的远端安全组的ID,可以指定remote_group_id或者remote_ip_prefix。
revision_number integer 安全组规则的版本号。
security_group_id string 关联的安全组ID。
normalized_cidr string 只读的字段,规范化cidr的值
tenant_id string 安全组规则所属的tenant id。
updated_at string 安全组规则最近更新的时间(UTC ISO8601格式)。

请求示例

POST http://{endpoint}/v2.0/security-group-rules
{
  "security_group_rule": {
    "direction": "ingress",
    "ethertype": "IPv4",
    "port_range_max": "88",
    "port_range_min": "22",
    "protocol": "tcp",
    "remote_ip_prefix": "0.0.0.0/24",
    "security_group_id": "de80111e-4ddb-4b58-a295-0b32e9a4f963"
  }
}

正常响应示例

{
  "security_group_rule": {
    "created_at": "2021-02-25T06:19:33Z",
    "description": "",
    "direction": "ingress",
    "ethertype": "IPv4",
    "id": "5dc48c92-e097-4aa4-ae9b-88550dd0170d",
    "port_range_max": 88,
    "port_range_min": 22,
    "project_id": "8dac1bf1c3a24be18809f82e1f9a845d",
    "protocol": "tcp",
    "remote_group_id": null,
    "remote_ip_prefix": "0.0.0.0/24",
    "revision_number": 1,
    "normalized_cidr": null,
    "security_group_id": "de80111e-4ddb-4b58-a295-0b32e9a4f963",
    "tenant_id": "8dac1bf1c3a24be18809f82e1f9a845d",
    "updated_at": "2021-02-25T06:19:33Z"
  }
}

正常响应代码

201

错误码

400,401,403,404,409,413

获取安全组规则

功能介绍

‎获取一个安全组规则的详情

URI

GET /v2.0/security-group-rules/{security-group-rule-id}

参数 是否必选 描述
security-group-rule-id 安全组规则的ID

请求消息

响应消息

参数 参数类型 描述
security-group-rule object 安全组规则对象。
created_at string 安全组规则的创建时间 (UTC ISO8601 form)。
description string 用户描述。
direction string 安全组规则作用的方向,ingress或egress
ethertype string 匹配的以太网协议,必需是IPv4或IPv6
id string 安全组规则的ID。
project_id string 安全组规则所属的project id。
protocol string 匹配的IP协议类型,比如ICMP type。
port_range_max integer 匹配的协议端口号最大值,如果协议是ICMP,则表示ICMP code。
port_range_min integer 匹配的协议端口号最小值,如果协议是ICMP,则表示ICMP code。
remote_ip_prefix string 匹配的远端ip前缀。
remote_group_id string 匹配的远端安全组的ID,可以指定remote_group_id或者remote_ip_prefix。
revision_number integer 安全组规则的版本号。
security_group_id string 关联的安全组ID。
normalized_cidr string 只读的字段,规范化cidr的值
tenant_id string 安全组规则所属的tenant id。
updated_at string 安全组规则最近更新的时间(UTC ISO8601格式)。

请求示例

GET http://{endpoint}/v2.0/security-group-rules/ 5dc48c92-e097-4aa4-ae9b-88550dd0170d

正常响应示例

{
  "security_group_rule": {
    "created_at": "2021-02-25T06:19:33Z",
    "description": "",
    "direction": "ingress",
    "ethertype": "IPv4",
    "id": "5dc48c92-e097-4aa4-ae9b-88550dd0170d",
    "port_range_max": 88,
    "port_range_min": 22,
    "project_id": "8dac1bf1c3a24be18809f82e1f9a845d",
    "protocol": "tcp",
    "remote_group_id": null,
    "remote_ip_prefix": "0.0.0.0/24",
    "revision_number": 1,
    "normalized_cidr": null,
    "security_group_id": "de80111e-4ddb-4b58-a295-0b32e9a4f963",
    "tenant_id": "8dac1bf1c3a24be18809f82e1f9a845d",
    "updated_at": "2021-02-25T06:19:33Z"
  }
} 

正常响应代码

200

错误码

400,401,403,404,409,413

删除安全组规则

功能介绍

‎删除一个指定安全组规则

URI

DELETE /v2.0/security-group-rules/{security-group-rule-id}

参数 是否必选 描述
security-group-rule-id 安全组的ID

请求消息

请求示例

DELETE http://{endpoint}/v2.0/security-group-rules/ 5dc48c92-e097-4aa4-ae9b-88550dd0170d

正常响应代码

204

错误码

400,401,403,404,409,413

此篇文章对你是否有帮助?
没帮助
locked-file

您暂无权限访问该产品