自定义属性相关接口
创建自定义属性键(CreateResourceAttributeKey)
API请求
URLs
POST zstack/v1/resource-attributesHeaders
Authorization: OAuth the-session-uuidBody
{
"params": {
"name": "Operations personnel"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"name":"Operations personnel"}}' \
http://localhost:8080/zstack/v1/resource-attributes参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| name | String | body(包含在params结构中) |
自定义属性键名称 | 4.10.16 | |
| description (可选) | String | body(包含在params结构中) |
资源的详细描述 | 4.10.16 | |
| resourceTypes (可选) | List | body(包含在params结构中) |
该属性支持的资源类型列表, 默认支持所有可支持的属性 | 4.10.16 | |
| constraints (可选) | List | body(包含在params结构中) |
属性限制列表 | 4.10.16 | |
| resourceUuid (可选) | String | body(包含在params结构中) |
资源 UUID | 4.10.16 | |
| tagUuids (可选) | List | body(包含在params结构中) |
标签 UUID 列表 | 4.10.16 | |
| systemTags (可选) | List | body | 系统标签 | 4.10.16 | |
| userTags (可选) | List | body | 用户标签 | 4.10.16 |
API返回
返回示例
{
"inventory": {
"uuid": "ff03a2b491023030bf58b1b35ea9cd00",
"name": "OperationsPersonnel",
"description": "Kinny",
"resourceTypes": [
"VmInstanceVO"
],
"createDate": "Nov 14, 2017 2:20:57 PM",
"lastOpDate": "Nov 14, 2017 2:20:57 PM",
"constraints": [
{
"id": 1,
"keyUuid": "ff03a2b491023030bf58b1b35ea9cd00",
"type": "option",
"parameter": "Kinny",
"createDate": "Nov 14, 2017 2:20:57 PM",
"lastOpDate": "Nov 14, 2017 2:20:57 PM"
}
]
}
}#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 自定义属性键 UUID | 4.10.16 |
| name | String | 自定义属性键名称 | 4.10.16 |
| description | String | 资源的详细描述 | 4.10.16 |
| createDate | Timestamp | 创建时间 | 4.10.16 |
| lastOpDate | Timestamp | 最后一次修改时间 | 4.10.16 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| ode | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 0.6 |
| description | String | 错误的概要描述 | 0.6 |
| details | String | 错误的详细信息 | 0.6 |
| elaboration | String | 保留字段,默认为null | 0.6 |
| opaque | LinkedHashMap | 保留字段,默认为null | 0.6 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 0.6 |
SDK示例
Java SDK
CreateResourceAttributeKeyAction action = new CreateResourceAttributeKeyAction();
action.name = "Operations personnel";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateResourceAttributeKeyAction.Result res = action.call();Python SDK
action = CreateResourceAttributeKeyAction()
action.name = "Operations personnel"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()删除自定义属性键(DeleteResourceAttributeKey)
API请求
URLs
DELETE zstack/v1/resource-attributes/{uuid}Headers
Authorization: OAuth the-session-uuidCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X DELETE http://localhost:8080/zstack/v1/resource-attributes/ff03a2b491023030bf58b1b35ea9cd00?deleteMode=Permissive参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | 自定义属性键 UUID | 4.10.16 | |
| deleteMode (可选) | String | query | 删除模式(Permissive / Enforcing,Permissive) | 4.10.16 | |
| systemTags (可选) | List | query | 系统标签 | 4.10.16 | |
| userTags (可选) | List | query | 用户标签 | 4.10.16 |
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
DeleteResourceAttributeKeyAction action = new DeleteResourceAttributeKeyAction();
action.uuid = "ff03a2b491023030bf58b1b35ea9cd00";
action.deleteMode = "Permissive";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DeleteResourceAttributeKeyAction.Result res = action.call();Python SDK
action = DeleteResourceAttributeKeyAction()
action.uuid = "ff03a2b491023030bf58b1b35ea9cd00"
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()更新自定义属性键(UpdateResourceAttributeKey)
API请求
URLs
PUT zstack/v1/resource-attributes/{uuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"updateResourceAttributeKey": {
"description": "test"
},
"systemTags": [],
"userTags": []
}
Note: 上述示例中
systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"updateResourceAttributeKey":{"description":"test"}}' \
http://localhost:8080/zstack/v1/resource-attributes/ff03a2b491023030bf58b1b35ea9cd00/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | 自定义属性键 UUID | 4.10.16 | |
| name (可选) | String | body(包含在updateResourceAttributeKey结构中) |
键名称 | 4.10.16 | |
| description (可选) | String | body(包含在updateResourceAttributeKey结构中) |
资源的详细描述 | 4.10.16 | |
| resourceTypes (可选) | List | body(包含在updateResourceAttributeKey结构中) |
该属性支持的资源类型列表 | 4.10.16 | |
| createConstraints (可选) | List | body(包含在updateResourceAttributeKey结构中) |
新创建的限制 | 4.10.16 | |
| updateConstraints (可选) | List | body(包含在updateResourceAttributeKey结构中) |
更新的限制 | 4.10.16 | |
| deleteConstraintIds (可选) | List | body(包含在updateResourceAttributeKey结构中) |
删除的限制的 ID 列表 | 4.10.16 | |
| systemTags (可选) | List | body | 系统标签 | 4.10.16 | |
| userTags (可选) | List | body | 用户标签 | 4.10.16 |
API返回
返回示例
{
"inventory": {
"uuid": "ff03a2b491023030bf58b1b35ea9cd00",
"name": "OperationsPersonnel",
"description": "Kinny",
"resourceTypes": [
"VmInstanceVO"
],
"createDate": "Nov 14, 2017 2:20:57 PM",
"lastOpDate": "Nov 14, 2017 2:20:57 PM",
"constraints": [
{
"id": 1,
"keyUuid": "ff03a2b491023030bf58b1b35ea9cd00",
"type": "option",
"parameter": "Kinny",
"createDate": "Nov 14, 2017 2:20:57 PM",
"lastOpDate": "Nov 14, 2017 2:20:57 PM"
}
]
}
}#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 自定义属性键 UUID | 4.10.16 |
| name | String | 自定义属性键名称 | 4.10.16 |
| description | String | 资源的详细描述 | 4.10.16 |
| createDate | Timestamp | 创建时间 | 4.10.16 |
| lastOpDate | Timestamp | 最后一次修改时间 | 4.10.16 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| ode | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 0.6 |
| description | String | 错误的概要描述 | 0.6 |
| details | String | 错误的详细信息 | 0.6 |
| elaboration | String | 保留字段,默认为null | 0.6 |
| opaque | LinkedHashMap | 保留字段,默认为null | 0.6 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 0.6 |
SDK示例
Java SDK
UpdateResourceAttributeKeyAction action = new UpdateResourceAttributeKeyAction();
action.uuid = "ff03a2b491023030bf58b1b35ea9cd00";
action.description = "test";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateResourceAttributeKeyAction.Result res = action.call();Python SDK
action = UpdateResourceAttributeKeyAction()
action.uuid = "ff03a2b491023030bf58b1b35ea9cd00"
action.description = "test"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()查询自定义属性键(QueryResourceAttributeKey)
API请求
URLs
GET zstack/v1/resource-attributes/keys
GET zstack/v1/resource-attributes/keys/{uuid}Headers
Authorization: OAuth the-session-uuidCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/resource-attributes/keys?q=name=OperationsPersonnelcurl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/resource-attributes/keys/dbd98db0aeb939c38a6574e64b822b7d可查询字段
运行CLI命令行工具,输入QueryResourceAttributeKey并按Tab键查看所有可查询字段以及可跨表查询的资源名。
API返回
返回示例
{
"inventories": [
{
"uuid": "ff03a2b491023030bf58b1b35ea9cd00",
"name": "OperationsPersonnel",
"description": "Kinny",
"resourceTypes": [
"VmInstanceVO"
],
"createDate": "Nov 14, 2017 2:20:57 PM",
"lastOpDate": "Nov 14, 2017 2:20:57 PM",
"constraints": [
{
"id": 1,
"keyUuid": "ff03a2b491023030bf58b1b35ea9cd00",
"type": "option",
"parameter": "Kinny",
"createDate": "Nov 14, 2017 2:20:57 PM",
"lastOpDate": "Nov 14, 2017 2:20:57 PM"
}
]
}
]
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 查询是否成功 | 4.10.16 |
| inventories | List | 详情参考inventories | 4.10.16 |
| error | ErrorCode | 详情参考error | 4.10.16 |
#inventories
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 自定义属性键 UUID | 4.10.16 |
| name | String | 自定义属性键名称 | 4.10.16 |
| description | String | 资源的详细描述 | 4.10.16 |
| createDate | Timestamp | 创建时间 | 4.10.16 |
| lastOpDate | Timestamp | 最后一次修改时间 | 4.10.16 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| ode | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 0.6 |
| description | String | 错误的概要描述 | 0.6 |
| details | String | 错误的详细信息 | 0.6 |
| elaboration | String | 保留字段,默认为null | 0.6 |
| opaque | LinkedHashMap | 保留字段,默认为null | 0.6 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 0.6 |
SDK示例
Java SDK
QueryResourceAttributeKeyAction action = new QueryResourceAttributeKeyAction();
action.conditions = asList("name=OperationsPersonnel");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryResourceAttributeKeyAction.Result res = action.call();Python SDK
action = QueryResourceAttributeKeyAction()
action.conditions = ["name=OperationsPersonnel"]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()创建自定义属性值(CreateResourceAttributeValue)
API请求
URLs
POST zstack/v1/resource-attributes/{keyUuid}/resourcesHeaders
Authorization: OAuth the-session-uuidBody
{
"params": {
"value": "Kinny",
"resourceUuids": [
"ff01ec80fd11327cba7519b66119d900"
]
},
"systemTags": [],
"userTags": []
}Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"value":"Kinny","resourceUuids":["ff01ec80fd11327cba7519b66119d900"]}}' \
http://localhost:8080/zstack/v1/resource-attributes/ff03a2b491023030bf58b1b35ea9cd00/resources参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| keyUuid | String | url | 自定义属性键 UUID | 4.10.16 | |
| value | String | body(包含在params结构中) |
值 | 4.10.16 | |
| resourceUuids | List | body(包含在params结构中) |
资源 UUID | 4.10.16 | |
| systemTags (可选) | List | body | 系统标签 | 4.10.16 | |
| userTags (可选) | List | body | 用户标签 | 4.10.16 |
API返回
返回示例
{
"inventories": [
{
"inventory": {
"keyUuid": "ff03a2b491023030bf58b1b35ea9cd00",
"key": {
"uuid": "ff03a2b491023030bf58b1b35ea9cd00",
"name": "OperationsPersonnel",
"description": "Kinny",
"resourceTypes": [
"VmInstanceVO"
],
"createDate": "Nov 14, 2017 2:20:57 PM",
"lastOpDate": "Nov 14, 2017 2:20:57 PM",
"constraints": [
{
"id": 1,
"keyUuid": "ff03a2b491023030bf58b1b35ea9cd00",
"type": "option",
"parameter": "Kinny",
"createDate": "Nov 14, 2017 2:20:57 PM",
"lastOpDate": "Nov 14, 2017 2:20:57 PM"
}
]
},
"value": "Kinny",
"resourceUuid": "ff01ec80fd11327cba7519b66119d900",
"resourceType": "VmInstanceVO",
"createDate": "Nov 14, 2017 2:20:57 PM"
},
"success": true
}
]
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 创建是否成功 | 4.10.16 |
| inventories | List | 详情参考inventories | 4.10.16 |
| error | ErrorCode | 详情参考error | 4.10.16 |
#inventories
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| ode | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 0.6 |
| description | String | 错误的概要描述 | 0.6 |
| details | String | 错误的详细信息 | 0.6 |
| elaboration | String | 保留字段,默认为null | 0.6 |
| opaque | LinkedHashMap | 保留字段,默认为null | 0.6 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 0.6 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| keyUuid | String | 自定义属性键 UUID | 4.10.16 |
| value | String | 值 | 4.10.16 |
| resourceUuid | String | 资源 UUID | 4.10.16 |
| resourceType | String | 资源类型 | 4.10.16 |
| createDate | Timestamp | 创建时间 | 4.10.16 |
| key | ResourceAttributeKeyInventory | 详情参考key | 4.10.16 |
#key
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 自定义属性键 UUID | 4.10.16 |
| name | String | 自定义属性键名称 | 4.10.16 |
| description | String | 资源的详细描述 | 4.10.16 |
| createDate | Timestamp | 创建时间 | 4.10.16 |
| lastOpDate | Timestamp | 最后一次修改时间 | 4.10.16 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| ode | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 0.6 |
| description | String | 错误的概要描述 | 0.6 |
| details | String | 错误的详细信息 | 0.6 |
| elaboration | String | 保留字段,默认为null | 0.6 |
| opaque | LinkedHashMap | 保留字段,默认为null | 0.6 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 0.6 |
SDK示例
Java SDK
CreateResourceAttributeValueAction action = new CreateResourceAttributeValueAction();
action.keyUuid = "ff03a2b491023030bf58b1b35ea9cd00";
action.value = "Kinny";
action.resourceUuids = asList("ff01ec80fd11327cba7519b66119d900");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateResourceAttributeValueAction.Result res = action.call();Python SDK
action = CreateResourceAttributeValueAction()
action.keyUuid = "ff03a2b491023030bf58b1b35ea9cd00"
action.value = "Kinny"
action.resourceUuids = [ff01ec80fd11327cba7519b66119d900]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()删除自定义属性值(DeleteResourceAttributeValue)
API请求
URLs
DELETE zstack/v1/resource-attributes/{keyUuid}/resourcesHeaders
Authorization: OAuth the-session-uuidCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X DELETE http://localhost:8080/zstack/v1/resource-attributes/ff03a2b491023030bf58b1b35ea9cd00/resources?resourceUuids=ff01ec80fd11327cba7519b66119d900参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| keyUuid | String | url | 自定义属性键 UUID | 4.10.16 | |
| resourceUuids | List | query | 资源 UUID | 4.10.16 | |
| systemTags (可选) | List | query | 系统标签 | 4.10.16 | |
| userTags (可选) | List | query | 用户标签 | 4.10.16 |
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
DeleteResourceAttributeValueAction action = new DeleteResourceAttributeValueAction();
action.keyUuid = "ff03a2b491023030bf58b1b35ea9cd00";
action.resourceUuids = asList("ff01ec80fd11327cba7519b66119d900");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DeleteResourceAttributeValueAction.Result res = action.call();Python SDK
action = DeleteResourceAttributeValueAction()
action.keyUuid = "ff03a2b491023030bf58b1b35ea9cd00"
action.resourceUuids = [ff01ec80fd11327cba7519b66119d900]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()查询自定义属性值(QueryResourceAttributeValue)
API请求
URLs
GET zstack/v1/resource-attributesHeaders
Authorization: OAuth the-session-uuidCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/resource-attributes?q=keyUuid=ff03a2b491023030bf58b1b35ea9cd00可查询字段
运行CLI命令行工具,输入QueryResourceAttributeValue并按Tab键查看所有可查询字段以及可跨表查询的资源名。
API返回
返回示例
{
"inventories": [
{
"keyUuid": "ff03a2b491023030bf58b1b35ea9cd00",
"key": {
"uuid": "ff03a2b491023030bf58b1b35ea9cd00",
"name": "OperationsPersonnel",
"description": "Kinny",
"resourceTypes": [
"VmInstanceVO"
],
"createDate": "Nov 14, 2017 2:20:57 PM",
"lastOpDate": "Nov 14, 2017 2:20:57 PM",
"constraints": [
{
"id": 1,
"keyUuid": "ff03a2b491023030bf58b1b35ea9cd00",
"type": "option",
"parameter": "Kinny",
"createDate": "Nov 14, 2017 2:20:57 PM",
"lastOpDate": "Nov 14, 2017 2:20:57 PM"
}
]
},
"value": "Kinny",
"resourceUuid": "ff01ec80fd11327cba7519b66119d900",
"resourceType": "VmInstanceVO",
"createDate": "Nov 14, 2017 2:20:57 PM"
}
]
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 查询是否成功 | 4.10.16 |
| inventories | List | 详情参考inventories | 4.10.16 |
| error | ErrorCode | 详情参考error | 4.10.16 |
#inventories
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| keyUuid | String | 自定义属性键 UUID | 4.10.16 |
| value | String | 值 | 4.10.16 |
| resourceUuid | String | 资源 UUID | 4.10.16 |
| resourceType | String | 资源类型 | 4.10.16 |
| createDate | Timestamp | 创建时间 | 4.10.16 |
| key | ResourceAttributeKeyInventory | 详情参考key | 4.10.16 |
#key
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 自定义属性键 UUID | 4.10.16 |
| name | String | 自定义属性键名称 | 4.10.16 |
| description | String | 资源的详细描述 | 4.10.16 |
| createDate | Timestamp | 创建时间 | 4.10.16 |
| lastOpDate | Timestamp | 最后一次修改时间 | 4.10.16 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| ode | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 0.6 |
| description | String | 错误的概要描述 | 0.6 |
| details | String | 错误的详细信息 | 0.6 |
| elaboration | String | 保留字段,默认为null | 0.6 |
| opaque | LinkedHashMap | 保留字段,默认为null | 0.6 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 0.6 |
SDK示例
Java SDK
QueryResourceAttributeValueAction action = new QueryResourceAttributeValueAction();
action.conditions = asList("keyUuid=ff03a2b491023030bf58b1b35ea9cd00");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryResourceAttributeValueAction.Result res = action.call();Python SDK
action = QueryResourceAttributeValueAction()
action.conditions = ["keyUuid=ff03a2b491023030bf58b1b35ea9cd00"]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()