查询安全组规则

GET/zstack/v1/security-groups/rules
GET/zstack/v1/security-groups/rules/{uuid}

Headers

Authorization: OAuth the-session-uuid

Curl示例

curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth 9aa7adfe564e4acda956ef90430b0f1b" \
-X GET http://localhost:8080/zstack/v1/security-groups/rules?q=endPort=22&q=state=Enabled
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth 36a86c5b46784b169fe82d7c990ae1a7" \
-X GET http://localhost:8080/zstack/v1/security-groups/rules/ae59353d95f744b5b4396e1783ddb918

可查询字段

运行CLI命令行工具,输入QuerySecurityGroupRule并按Tab键查看所有可查询字段以及可跨表查询的资源名。

API返回

返回示例

{
  "inventories": [
    {
      "uuid": "b3a99fc1548b41778258153cfd70f4b7",
      "securityGroupUuid": "629d55f78c9f4b0e8e3504b9834ca1bb",
      "type": "Ingress",
      "startPort": 22.0,
      "endPort": 22.0,
      "protocol": "TCP",
      "state": "Enabled",
      "allowedCidr": "0.0.0.0/0",
      "createDate": "Jun 7, 2017 9:20:25 PM",
      "lastOpDate": "Jun 7, 2017 9:20:25 PM"
    }
  ]
}
名字类型描述起始版本
errorErrorCode错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error0.6
inventoriesList详情参考inventories0.6

error

名字类型描述起始版本
codeString错误码号,错误的全局唯一标识,例如SYS.1000, HOST.10010.6
descriptionString错误的概要描述0.6
detailsString错误的详细信息0.6
elaborationString保留字段,默认为null0.6
opaqueLinkedHashMap保留字段,默认为null0.6
causeErrorCode根错误,引发当前错误的源错误,若无原错误,该字段为null0.6

inventories

名字类型描述起始版本
uuidString资源的UUID,唯一标示该资源0.6
securityGroupUuidString安全组UUID0.6
typeString流量类型0.6
ipVersionIntegerip协议号3.1.0
startPortInteger如果协议是TCP/UDP, 它是端口范围(port range)的起始端口号; 如果协议是ICMP, 它是ICMP类型(type)0.6
endPortInteger如果协议是TCP/UDP, 它是端口范围(port range)的结束端口号; 如果协议是ICMP, 它是ICMP类型(type)0.6
protocolString流量协议类型0.6
stateString规则的可用状态, 当前版本未实现0.6
allowedCidrString允许的CIDR,根据流量类型的不同, 允许的CIDR有不同的含义,如果流量类型是Ingress, 允许的CIDR是允许访问虚拟机网卡的源CIDR,如果流量类型是Egress, 允许的CIDR是允许从虚拟机网卡离开并到达的目的地CIDR0.6
remoteSecurityGroupUuidString 0.6
createDateTimestamp创建时间0.6
lastOpDateTimestamp最后一次修改时间0.6

SDK示例

Java SDK

QuerySecurityGroupRuleAction action = new QuerySecurityGroupRuleAction();
action.conditions = asList("endPort=22","state=Enabled");
action.sessionId = "362452e4e8a746ce981a5a54c7390445";
QuerySecurityGroupRuleAction.Result res = action.call();

Python SDK

QuerySecurityGroupRuleAction action = QuerySecurityGroupRuleAction()
action.conditions = ["endPort=22","state=Enabled"]
action.sessionId = "37e099aa344c40ca947d11dff7ec2b91"
QuerySecurityGroupRuleAction.Result res = action.call()