更新USB设备(UpdateUsbDevice)

API请求

URLs
PUT zstack/v1/usb-device/usb-devices/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{
  "updateUsbDevice": {
    "name": "usb",
    "description": "this is a usb device",
    "state": "Enabled"
  },
  "systemTags": [],
  "userTags": []
}
Note: 上述示例中systemTagsuserTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"updateUsbDevice":{"name":"usb","description":"this is a usb device","state":"Enabled"}}' \
http://localhost:8080/zstack/v1/usb-device/usb-devices/9d1ab4950ce933edabbaf8e73ca7e879/actions
参数列表
名字 类型 位置 描述 可选值 起始版本
uuid String url 资源的UUID,唯一标示该资源 2.2
name (可选) String body(包含在updateUsbDevice结构中) 资源名称 2.2
description (可选) String body(包含在updateUsbDevice结构中) 资源的详细描述 2.2
state (可选) String body(包含在updateUsbDevice结构中) USB设备状态
  • Enabled
  • Disabled
2.2
systemTags (可选) List body 系统标签 2.2
userTags (可选) List body 用户标签 2.2

API返回

返回示例
{
  "inventory": {
    "uuid": "2695f7ce0bda4587bbabbbfaad080554",
    "description": "test usb",
    "hostUuid": "4261ceb358ce473fa62c137c1ba8d3ef",
    "vmInstanceUuid": "4c059c5e0a834d86984d3141d8ec42cb",
    "state": "Disabled",
    "idVendor": "10de",
    "idProduct": "0e0f",
    "iManufacturer": "SanDisk",
    "iProduct": "USB Storage",
    "iSerial": "000000000001",
    "usbVersion": "3.0",
    "attachType": "PassThrough"
  }
}
名字 类型 描述 起始版本
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 2.2
inventory UsbDeviceInventory 详情参考inventory 2.2
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 2.2
description String 错误的概要描述 2.2
details String 错误的详细信息 2.2
elaboration String 保留字段,默认为null 2.2
opaque LinkedHashMap 保留字段,默认为null 2.2
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 2.2
#inventory
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 2.2
name String 资源名称 2.2
description String 资源的详细描述 2.2
hostUuid String 物理机UUID 2.2
vmInstanceUuid String 云主机UUID 2.2
busNum String 总线号 2.2
devNum String 设备号 2.2
idVendor String VendorID 2.2
idProduct String ProductID 2.2
iManufacturer String 生产商 2.2
iProduct String 设备类型 2.2
iSerial String 序列号 2.2
usbVersion String USB版本 2.2
attachType String 加载方式 3.6.0
createDate Timestamp 创建时间 2.2
lastOpDate Timestamp 最后一次修改时间 2.2
state UsbDeviceState 详情参考state 2.2
#state
名字 类型 描述 起始版本
name String 资源名称 2.2
ordinal int 2.2

SDK示例

Java SDK
UpdateUsbDeviceAction action = new UpdateUsbDeviceAction();
action.uuid = "86d05b807cfa47a7969745f0ffe8ee4b";
action.name = "usb";
action.description = "this is a usb device";
action.state = "Enabled";
action.sessionId = "86600ceaed5642ad810828129fe0e4a0";
UpdateUsbDeviceAction.Result res = action.call();
Python SDK
UpdateUsbDeviceAction action = UpdateUsbDeviceAction()
action.uuid = "f16940abc205404bb17b00367f5b6a8d"
action.name = "usb"
action.description = "this is a usb device"
action.state = "Enabled"
action.sessionId = "a65b10bd9a164d33a42d8bacfab5acd6"
UpdateUsbDeviceAction.Result res = action.call()