文档目录

SNMP相关接口

创建SNMP代理(CreateSnmpAgent)

API请求

URLs
POST zstack/v1/snmp/agent
Headers
Authorization: OAuth the-session-uuid
Body
{
  "params": {
    "version": "v3",
    "userName": "zstack",
    "authAlgorithm": "SHA512",
    "authPassword": "auth_password",
    "privacyAlgorithm": "DES",
    "privacyPassword": "priv_password",
    "port": 161
  },
  "systemTags": [],
  "userTags": []
}
Note: 上述示例中systemTagsuserTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"version":"v3","userName":"zstack","authAlgorithm":"SHA512","authPassword":"auth_password","privacyAlgorithm":"DES","privacyPassword":"priv_password","port":161}}' http://localhost:8080/zstack/v1/snmp/agent
参数列表
名字 类型 位置 描述 可选值 起始版本
version String body(包含在params结构中) SNMP代理使用协议版本
  • v2c
  • v3
4.7.21
readCommunity (可选) String body(包含在params结构中) 读团体字(version为v2c时使用) 4.7.21
userName (可选) String body(包含在params结构中) 用户名(version为v3时使用) 4.7.21
authAlgorithm (可选) String body(包含在params结构中) 认证算法
  • MD5
  • SHA
  • SHA224
  • SHA256
  • SHA384
  • SHA512
4.7.21
authPassword (可选) String body(包含在params结构中) 认证密码 4.7.21
privacyAlgorithm (可选) String body(包含在params结构中) 隐私算法
  • DES
  • AES128
  • AES192
  • AES256
  • 3DES
4.7.21
privacyPassword (可选) String body(包含在params结构中) 隐私密码 4.7.21
port int body(包含在params结构中) 端口 4.7.21
resourceUuid (可选) String body(包含在params结构中) 资源UUID 4.7.21
tagUuids (可选) List body(包含在params结构中) 标签UUID列表 4.7.21
systemTags (可选) List body 系统标签 4.7.21
userTags (可选) List body 用户标签 4.7.21

API返回

返回示例
{
  "inventory": {
    "uuid": "6dac2a94d44c3216acc13286a50416aa",
    "version": "v3",
    "userName": "zstack",
    "authAlgorithm": "SHA512",
    "authPassword": "auth_password",
    "privacyAlgorithm": "DES",
    "privacyPassword": "priv_password",
    "port": 161,
    "status": "Enable",
    "securityLevel": "authPriv"
  }
}
名字 类型 描述 起始版本
success boolean 4.7.21
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 4.7.21
inventory SnmpAgentInventory 详情参考inventory 4.7.21
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 4.7.21
description String 错误的概要描述 4.7.21
details String 错误的详细信息 4.7.21
elaboration String 保留字段,默认为null 4.7.21
opaque LinkedHashMap 保留字段,默认为null 4.7.21
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 4.7.21
#inventory
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 4.7.21
version String SNMP代理使用协议版本 4.7.21
readCommunity String 读团体字(version为v2c时使用) 4.7.21
userName String 用户名(version为v3时使用) 4.7.21
authAlgorithm String 认证算法 4.7.21
authPassword String 认证密码 4.7.21
privacyAlgorithm String 隐私算法 4.7.21
privacyPassword String 隐私密码 4.7.21
port int 端口 4.7.21
status String SNMP代理是否启用 4.7.21
securityLevel String 安全等级 4.7.21
createDate Timestamp 创建时间 4.7.21
lastOpDate Timestamp 最后一次修改时间 4.7.21

SDK示例

Java SDK
CreateSnmpAgentAction action = new CreateSnmpAgentAction();
action.version = "v3";
action.userName = "zstack";
action.authAlgorithm = "SHA512";
action.authPassword = "auth_password";
action.privacyAlgorithm = "DES";
action.privacyPassword = "priv_password";
action.port = 161;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateSnmpAgentAction.Result res = action.call();
Python SDK
CreateSnmpAgentAction action = CreateSnmpAgentAction()
action.version = "v3"
action.userName = "zstack"
action.authAlgorithm = "SHA512"
action.authPassword = "auth_password"
action.privacyAlgorithm = "DES"
action.privacyPassword = "priv_password"
action.port = 161
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreateSnmpAgentAction.Result res = action.call()

查询SNMP代理(QuerySnmpAgent)

API请求

URLs
GET zstack/v1/snmp/agent
GET zstack/v1/snmp/agent/{uuid}
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/snmp/agent
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/snmp/agent/18c89b48e653385f83db6ecffb48763f

可查询字段

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

API返回

返回示例
{
  "inventories": [
    {
      "uuid": "f0ef8d847b573c6b86565e1d9111723b",
      "version": "v3",
      "userName": "zstack",
      "authAlgorithm": "SHA512",
      "authPassword": "auth_password",
      "privacyAlgorithm": "DES",
      "privacyPassword": "priv_password",
      "port": 161,
      "status": "Enable",
      "securityLevel": "authPriv"
    }
  ]
}
名字 类型 描述 起始版本
success boolean 4.7.21
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 4.7.21
inventories List 详情参考inventories 4.7.21
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 4.7.21
description String 错误的概要描述 4.7.21
details String 错误的详细信息 4.7.21
elaboration String 保留字段,默认为null 4.7.21
opaque LinkedHashMap 保留字段,默认为null 4.7.21
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 4.7.21
#inventories
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 4.7.21
version String SNMP代理使用协议版本 4.7.21
readCommunity String 读团体字(version为v2c时使用) 4.7.21
userName String 用户名(version为v3时使用) 4.7.21
authAlgorithm String 认证算法 4.7.21
authPassword String 认证密码 4.7.21
privacyAlgorithm String 隐私算法 4.7.21
privacyPassword String 隐私密码 4.7.21
port int 端口 4.7.21
status String SNMP代理是否启用 4.7.21
securityLevel String 安全等级 4.7.21
createDate Timestamp 创建时间 4.7.21
lastOpDate Timestamp 最后一次修改时间 4.7.21

SDK示例

Java SDK
QuerySnmpAgentAction action = new QuerySnmpAgentAction();
action.conditions = asList();
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QuerySnmpAgentAction.Result res = action.call();
Python SDK
QuerySnmpAgentAction action = QuerySnmpAgentAction()
action.conditions = []
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QuerySnmpAgentAction.Result res = action.call()

启动SNMP代理(StartSnmpAgent)

API请求

URLs
PUT zstack/v1/snmp/agent/actions
Headers
Authorization: OAuth the-session-uuid
Body
{
  "startSnmpAgent": {
    "uuid": "2e5ce17390a843da991411d27b67d775"
  },
  "systemTags": [],
  "userTags": []
}
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"startSnmpAgent":{"uuid":"955799e296a94e4aa2ce063a5b1ea4b8"}}' http://localhost:8080/zstack/v1/snmp/agent/actions
名字 类型 位置 描述 可选值 起始版本
uuid String body(包含在startSnmpAgent结构中) 资源的UUID,唯一标示该资源 4.7.21
systemTags (可选) List body 系统标签 4.7.21
userTags (可选) List body 用户标签 4.7.21

API返回

返回示例
{
  "inventory": {
    "uuid": "eef797ff89d84305b51cc3edcb597909",
    "version": "v3",
    "userName": "zstack",
    "authAlgorithm": "SHA",
    "authPassword": "authPassword",
    "privacyAlgorithm": "AES128",
    "privacyPassword": "privPassword",
    "port": 162
  }
}
名字 类型 描述 起始版本
success boolean 4.7.21
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 4.7.21
inventory SnmpAgentInventory 详情参考inventory 4.7.21
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 4.7.21
description String 错误的概要描述 4.7.21
details String 错误的详细信息 4.7.21
elaboration String 保留字段,默认为null 4.7.21
opaque LinkedHashMap 保留字段,默认为null 4.7.21
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 4.7.21
#inventory
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 4.7.21
version String SNMP代理使用协议版本 4.7.21
readCommunity String 读团体字(version为v2c时使用) 4.7.21
userName String 用户名(version为v3时使用) 4.7.21
authAlgorithm String 认证算法 4.7.21
authPassword String 认证密码 4.7.21
privacyAlgorithm String 隐私算法 4.7.21
privacyPassword String 隐私密码 4.7.21
port int 端口 4.7.21
status String SNMP代理是否启用 4.7.21
securityLevel String 安全等级 4.7.21
createDate Timestamp 创建时间 4.7.21
lastOpDate Timestamp 最后一次修改时间 4.7.21

SDK示例

Java SDK
StartSnmpAgentAction action = new StartSnmpAgentAction();
action.uuid = "a74555a81a4244bb9ce0f8f2b5691ac5";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
StartSnmpAgentAction.Result res = action.call();
Python SDK
StartSnmpAgentAction action = StartSnmpAgentAction()
action.uuid = "56f7b7cc6f764c55bf4016cc2257f456"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
StartSnmpAgentAction.Result res = action.call()

停止SNMP代理(StopSnmpAgent)

API请求

URLs
PUT zstack/v1/snmp/agent/actions
Headers
Authorization: OAuth the-session-uuid
Body
{
  "stopSnmpAgent": {
    "uuid": "253c4449901c49f9928d2d7fd2119715"
  },
  "systemTags": [],
  "userTags": []
}

上述示例中systemTagsuserTags字段可以省略。列出是为了表示body中可以包含这两个字段。

Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"stopSnmpAgent":{"uuid":"d3dcbba6129e497480af319ee4e42749"}}' http://localhost:8080/zstack/v1/snmp/agent/actions
参数列表
名字 类型 位置 描述 可选值 起始版本
uuid String body(包含在stopSnmpAgent结构中) 资源的UUID,唯一标示该资源 4.7.21
systemTags (可选) List body 系统标签 4.7.21
userTags (可选) List body 用户标签 4.7.21

API返回

返回示例
{
  "inventory": {
    "uuid": "b32ac27ffdd03e7ea7857d318d5cfdd8",
    "version": "v3",
    "userName": "zstack",
    "authAlgorithm": "SHA512",
    "authPassword": "auth_password",
    "privacyAlgorithm": "DES",
    "privacyPassword": "priv_password",
    "port": 161,
    "status": "Enable",
    "securityLevel": "authPriv"
  }
}
名字 类型 描述 起始版本
success boolean 4.7.21
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 4.7.21
inventory SnmpAgentInventory 详情参考inventory 4.7.21
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 4.7.21
description String 错误的概要描述 4.7.21
details String 错误的详细信息 4.7.21
elaboration String 保留字段,默认为null 4.7.21
opaque LinkedHashMap 保留字段,默认为null 4.7.21
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 4.7.21
#inventory
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 4.7.21
version String SNMP代理使用协议版本 4.7.21
readCommunity String 读团体字(version为v2c时使用) 4.7.21
userName String 用户名(version为v3时使用) 4.7.21
authAlgorithm String 认证算法 4.7.21
authPassword String 认证密码 4.7.21
privacyAlgorithm String 隐私算法 4.7.21
privacyPassword String 隐私密码 4.7.21
port int 端口 4.7.21
status String SNMP代理是否启用 4.7.21
securityLevel String 安全等级 4.7.21
createDate Timestamp 创建时间 4.7.21
lastOpDate Timestamp 最后一次修改时间 4.7.21

SDK示例

Java SDK
StopSnmpAgentAction action = new StopSnmpAgentAction();
action.uuid = "5b470e397e794dff84efa29375d9cef8";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
StopSnmpAgentAction.Result res = action.call();
Python SDK
StopSnmpAgentAction action = StopSnmpAgentAction()
action.uuid = "e48db055707445d3b70e8e52f7ee0ca3"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
StopSnmpAgentAction.Result res = action.call()

更新SNMP代理(UpdateSnmpAgent)

API请求

URLs
PUT zstack/v1/snmp/agent/actions
Headers
Authorization: OAuth the-session-uuid
Body
{
  "updateSnmpAgent": {
    "version": "v2c",
    "readCommunity": "zstack",
    "port": 1161
  },
  "systemTags": [],
  "userTags": []
}

上述示例中systemTagsuserTags字段可以省略。列出是为了表示body中可以包含这两个字段。

Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"updateSnmpAgent":{"version":"v2c","readCommunity":"zstack","port":1161}}' http://localhost:8080/zstack/v1/snmp/agent/actions
参数列表
名字 类型 位置 描述 可选值 起始版本
uuid String body(包含在updateSnmpAgent结构中) 资源的UUID,唯一标示该资源 4.7.21
version String body(包含在updateSnmpAgent结构中) SNMP代理使用协议版本
  • v2c
  • v3
4.7.21
readCommunity (可选) String body(包含在updateSnmpAgent结构中) 读团体字(version为v2c时使用) 4.7.21
userName (可选) String body(包含在updateSnmpAgent结构中) 用户名(version为v3时使用) 4.7.21
authAlgorithm (可选) String body(包含在updateSnmpAgent结构中) 认证算法
  • MD5
  • SHA
  • SHA224
  • SHA256
  • SHA384
  • SHA512
4.7.21
authPassword (可选) String body(包含在updateSnmpAgent结构中) 认证密码 4.7.21
privacyAlgorithm (可选) String body(包含在updateSnmpAgent结构中) 隐私算法
  • DES
  • AES128
  • AES192
  • AES256
  • 3DES
4.7.21
privacyPassword (可选) String body(包含在updateSnmpAgent结构中) 隐私密码 4.7.21
port int body(包含在updateSnmpAgent结构中) 端口 4.7.21
systemTags (可选) List body 系统标签 4.7.21
userTags (可选) List body 用户标签 4.7.21

API返回

返回示例
{
  "inventory": {
    "uuid": "cad9965ebedd495aa1f5718f31da1aa8",
    "version": "v3",
    "userName": "zstack",
    "authAlgorithm": "SHA",
    "authPassword": "authPassword",
    "privacyAlgorithm": "AES128",
    "privacyPassword": "privPassword",
    "port": 162
  }
}
名字 类型 描述 起始版本
success boolean 4.7.21
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 4.7.21
inventory SnmpAgentInventory 详情参考inventory 4.7.21
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 4.7.21
description String 错误的概要描述 4.7.21
details String 错误的详细信息 4.7.21
elaboration String 保留字段,默认为null 4.7.21
opaque LinkedHashMap 保留字段,默认为null 4.7.21
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 4.7.21
#inventory
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 4.7.21
version String SNMP代理使用协议版本 4.7.21
readCommunity String 读团体字(version为v2c时使用) 4.7.21
userName String 用户名(version为v3时使用) 4.7.21
authAlgorithm String 认证算法 4.7.21
authPassword String 认证密码 4.7.21
privacyAlgorithm String 隐私算法 4.7.21
privacyPassword String 隐私密码 4.7.21
port int 端口 4.7.21
status String SNMP代理是否启用 4.7.21
securityLevel String 安全等级 4.7.21
createDate Timestamp 创建时间 4.7.21
lastOpDate Timestamp 最后一次修改时间 4.7.21

SDK示例

Java SDK
UpdateSnmpAgentAction action = new UpdateSnmpAgentAction();
action.version = "v2c";
action.readCommunity = "zstack";
action.port = 1161;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateSnmpAgentAction.Result res = action.call();
Python SDK
UpdateSnmpAgentAction action = UpdateSnmpAgentAction()
action.version = "v2c"
action.readCommunity = "zstack"
action.port = 1161
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
UpdateSnmpAgentAction.Result res = action.call()

创建SNMP终端(CreateSNSSnmpEndpoint)

API请求

URLs
POST zstack/v1/sns/application-endpoints/snmp
Headers
Authorization: OAuth the-session-uuid
Body
{
  "params": {
    "name": "snmp endpoint",
    "platformUuid": "c453382b049c3280b69157501914870d"
  },
  "systemTags": [],
  "userTags": []
}

上述示例中systemTagsuserTags字段可以省略。列出是为了表示body中可以包含这两个字段。

Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"name":"snmp endpoint","platformUuid":"c453382b049c3280b69157501914870d"}}' http://localhost:8080/zstack/v1/sns/application-endpoints/snmp
参数列表
名字 类型 位置 描述 可选值 起始版本
name String body(包含在params结构中) 资源名称 4.7.21
description (可选) String body(包含在params结构中) 资源的详细描述 4.7.21
platformUuid (可选) String body(包含在params结构中) 应用平台UUID 4.7.21
resourceUuid (可选) String body(包含在params结构中) 资源UUID 4.7.21
tagUuids (可选) List body(包含在params结构中) 标签UUID列表 4.7.21
systemTags (可选) List body 系统标签 4.7.21
userTags (可选) List body 用户标签 4.7.21

API返回

返回示例
{
  "inventory": {
    "name": "example",
    "uuid": "917fe66f76b241f0843dfbd6be685fc1",
    "description": "description example",
    "type": "Email",
    "state": "Enabled",
    "platformUuid": "4eb0ceebf95b452585ebeacd647d9f35",
    "createDate": "Sep 28, 2023 4:35:44 PM",
    "lastOpDate": "Sep 28, 2023 4:35:44 PM"
  }
}
名字 类型 描述 起始版本
success boolean 4.7.21
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 4.7.21
inventory SNSApplicationEndpointInventory 详情参考inventory 4.7.21
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 4.7.21
description String 错误的概要描述 4.7.21
details String 错误的详细信息 4.7.21
elaboration String 保留字段,默认为null 4.7.21
opaque LinkedHashMap 保留字段,默认为null 4.7.21
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 4.7.21
#inventory
名字 类型 描述 起始版本
name String 资源名称 4.7.21
uuid String 资源的UUID,唯一标示该资源 4.7.21
description String 资源的详细描述 4.7.21
type String 类型 4.7.21
platformUuid String 应用平台UUID 4.7.21
createDate Timestamp 创建时间 4.7.21
lastOpDate Timestamp 最后一次修改时间 4.7.21

SDK示例

Java SDK
CreateSNSSnmpEndpointAction action = new CreateSNSSnmpEndpointAction();
action.name = "snmp endpoint";
action.platformUuid = "c453382b049c3280b69157501914870d";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateSNSSnmpEndpointAction.Result res = action.call();
Python SDK
CreateSNSSnmpEndpointAction action = CreateSNSSnmpEndpointAction()
action.name = "snmp endpoint"
action.platformUuid = "c453382b049c3280b69157501914870d"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreateSNSSnmpEndpointAction.Result res = action.call()

创建SNS SNMP平台(CreateSNSSnmpPlatform)

API请求

URLs
POST zstack/v1/sns/application-platforms/snmp
Headers
Authorization: OAuth the-session-uuid
Body
{
  "params": {
    "snmpAddress": "127.0.0.1",
    "snmpPort": 161,
    "name": "snmp platform"
  },
  "systemTags": [],
  "userTags": []
}

上述示例中systemTagsuserTags字段可以省略。列出是为了表示body中可以包含这两个字段。

Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"snmpAddress":"127.0.0.1","snmpPort":161,"name":"snmp platform"}}' http://localhost:8080/zstack/v1/sns/application-platforms/snmp
参数列表
名字 类型 位置 描述 可选值 起始版本
snmpAddress String body(包含在params结构中) SNMP服务器地址 4.7.21
snmpPort Integer body(包含在params结构中) SNMP服务器端口 4.7.21
name String body(包含在params结构中) 资源名称 4.7.21
description (可选) String body(包含在params结构中) 资源的详细描述 4.7.21
resourceUuid (可选) String body(包含在params结构中) 资源UUID 4.7.21
tagUuids (可选) List body(包含在params结构中) 标签UUID列表 4.7.21
systemTags (可选) List body 系统标签 4.7.21
userTags (可选) List body 用户标签 4.7.21

API返回

返回示例
{
  "inventory": {
    "uuid": "e13b9854866747738df3026dabae9689",
    "name": "email platform",
    "description": "example description",
    "state": "Enabled",
    "type": "Email",
    "createDate": "Sep 28, 2023 4:34:04 PM",
    "lastOpDate": "Sep 28, 2023 4:34:04 PM"
  }
}
名字 类型 描述 起始版本
success boolean 4.7.21
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 4.7.21
inventory SNSApplicationPlatformInventory 详情参考inventory 4.7.21
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 4.7.21
description String 错误的概要描述 4.7.21
details String 错误的详细信息 4.7.21
elaboration String 保留字段,默认为null 4.7.21
opaque LinkedHashMap 保留字段,默认为null 4.7.21
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 4.7.21
#inventory
名字 类型 描述 起始版本
name String 资源名称 4.7.21
uuid String 资源的UUID,唯一标示该资源 4.7.21
description String 资源的详细描述 4.7.21
type String 类型 4.7.21
createDate Timestamp 创建时间 4.7.21
lastOpDate Timestamp 最后一次修改时间 4.7.21

SDK示例

Java SDK
CreateSNSSnmpPlatformAction action = new CreateSNSSnmpPlatformAction();
action.snmpAddress = "127.0.0.1";
action.snmpPort = 161;
action.name = "snmp platform";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateSNSSnmpPlatformAction.Result res = action.call();
Python SDK
CreateSNSSnmpPlatformAction action = CreateSNSSnmpPlatformAction()
action.snmpAddress = "127.0.0.1"
action.snmpPort = 161
action.name = "snmp platform"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreateSNSSnmpPlatformAction.Result res = action.call()

查询SNS SNMP平台信息(QuerySNSSnmpPlatform)

API请求

URLs
GET zstack/v1/sns/application-platforms/snmp
GET zstack/v1/sns/application-platforms/snmp/{uuid}
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/sns/application-platforms/snmp?q=name=snmp
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/sns/application-platforms/snmp/282706a5c66231019bf6c250304903bf

可查询字段

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

API返回

该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{
	"error": {
		"code": "SYS.1001",
		"description": "A message or a operation timeout",
		"details": "Create VM on KVM timeout after 300s"
	}
}

SDK示例

Java SDK
QuerySNSSnmpPlatformAction action = new QuerySNSSnmpPlatformAction();
action.conditions = asList("name=snmp");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QuerySNSSnmpPlatformAction.Result res = action.call();
Python SDK
QuerySNSSnmpPlatformAction action = QuerySNSSnmpPlatformAction()
action.conditions = ["name=snmp"]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QuerySNSSnmpPlatformAction.Result res = action.call()

更新SNS SNMP平台(UpdateSNSSnmpPlatform)

API请求

URLs
PUT zstack/v1/sns/application-platforms/snmp/{uuid}
Headers
Authorization: OAuth the-session-uuid
Body
{
  "updateSNSSnmpPlatform": {
    "snmpAddress": "127.0.0.1",
    "snmpPort": 161,
    "name": "snmp platform name"
  },
  "systemTags": [],
  "userTags": []
}

上述示例中systemTagsuserTags字段可以省略。列出是为了表示body中可以包含这两个字段。

Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"updateSNSSnmpPlatform":{"snmpAddress":"127.0.0.1","snmpPort":161,"name":"snmp platform name"}}' http://localhost:8080/zstack/v1/sns/application-platforms/snmp/cbd548888e9d37b594bc99c1892589ed
参数列表
名字 类型 位置 描述 可选值 起始版本
snmpAddress String body(包含在updateSNSSnmpPlatform结构中) SNMP服务器地址 4.7.21
snmpPort Integer body(包含在updateSNSSnmpPlatform结构中) SNMP服务器端口 4.7.21
uuid String url 资源的UUID,唯一标示该资源 4.7.21
name (可选) String body(包含在updateSNSSnmpPlatform结构中) 资源名称 4.7.21
description (可选) String body(包含在updateSNSSnmpPlatform结构中) 资源的详细描述 4.7.21
systemTags (可选) List body 系统标签 4.7.21
userTags (可选) List body 用户标签 4.7.21

API返回

返回示例
{
  "inventory": {
    "uuid": "38c619bf4e7a4cdaa04fcb44d85d5fc9",
    "name": "email platform",
    "description": "example description",
    "state": "Enabled",
    "type": "Email",
    "createDate": "Sep 28, 2023 4:32:51 PM",
    "lastOpDate": "Sep 28, 2023 4:32:51 PM"
  }
}
名字 类型 描述 起始版本
success boolean 4.7.21
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 4.7.21
inventory SNSApplicationPlatformInventory 详情参考inventory 4.7.21
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 4.7.21
description String 错误的概要描述 4.7.21
details String 错误的详细信息 4.7.21
elaboration String 保留字段,默认为null 4.7.21
opaque LinkedHashMap 保留字段,默认为null 4.7.21
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 4.7.21
#inventory
名字 类型 描述 起始版本
name String 资源名称 4.7.21
uuid String 资源的UUID,唯一标示该资源 4.7.21
description String 资源的详细描述 4.7.21
type String 类型 4.7.21
createDate Timestamp 创建时间 4.7.21
lastOpDate Timestamp 最后一次修改时间 4.7.21

SDK示例

Java SDK
UpdateSNSSnmpPlatformAction action = new UpdateSNSSnmpPlatformAction();
action.snmpAddress = "127.0.0.1";
action.snmpPort = 161;
action.uuid = "cbd548888e9d37b594bc99c1892589ed";
action.name = "snmp platform name";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateSNSSnmpPlatformAction.Result res = action.call();
Python SDK
UpdateSNSSnmpPlatformAction action = UpdateSNSSnmpPlatformAction()
action.snmpAddress = "127.0.0.1"
action.snmpPort = 161
action.uuid = "cbd548888e9d37b594bc99c1892589ed"
action.name = "snmp platform name"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
UpdateSNSSnmpPlatformAction.Result res = action.call()
开发手册 | 4.8.38 | ZStack Cloud · ZCF | ZStack 资源中心