Attach Tag to Resources
Headers
Authorization: OAuth the-session-uuidBody
{
"params": {
"resourceUuids": [
"bcd0e0f674aa47298dcbdc0efeffb55d"
]
},
"systemTags": [],
"userTags": []
}In the above example, the systemTags and userTags fields can be omitted. They are listed to show that these two fields can be included in the body.
Curl Example
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"resourceUuids":["80ed93103b624518ab0e642c6611bc0f"]}}' http://localhost:8080/zstack/v1/tags/05811acb63e34f4c9c62b19a8eb4090b/resourcesParameter List
| Name | Type | Location | Description | Allowed Values | Starting Version |
|---|---|---|---|---|---|
| tagUuid | String | url | Tag UUID | 3.2.0 | |
| resourceUuids | List | body (contained in the params structure) | Resource UUID | 3.2.0 | |
| tokens (optional) | Map | body (contained in the params structure) | Keys and values stored through the tag | 3.2.0 | |
| systemTags (optional) | List | body | 3.2.0 | ||
| userTags (optional) | List | body | 3.2.0 |
API Response
After a successful API call, success is returned as true. The number of successfully cloned VMs is returned by numberOfClonedVm. In actual operations, due to resource constraints, partial success and partial failure may occur. The clone failure reason for each VM is stored in the error field in inventories.
Response example
{
"results": [
{
"inventory": {
"tagPatternUuid": "f9060711c8453a2580f840d7aa1c5485",
"uuid": "b2f817b3400232018956a4d2d198edc4",
"resourceType": "DiskOfferingVO",
"tag": "for-large-DB",
"type": "User",
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM"
},
"success": true
}
]
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| success | boolean | 3.2.0 | |
| error | ErrorCode | Error code. If not null, the operation failed. This field is null when the operation succeeds. For details, see error | 3.2.0 |
| results | List | For details, see results | 3.2.0 |
error
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | The error code number, a globally unique identifier for the error, e.g., SYS.1000, HOST.1001 | 3.2.0 |
| description | String | A brief description of the error | 3.2.0 |
| details | String | The detailed error information | 3.2.0 |
| elaboration | String | Reserved field. Defaults to null | 3.2.0 |
| opaque | LinkedHashMap | Reserved field. Defaults to null | 3.2.0 |
| cause | ErrorCode | The root error, the cause of the current error. This field is null if there is no root error | 3.2.0 |
results
| Name | Type | Description | Starting Version |
|---|---|---|---|
| success | boolean | 3.2.0 | |
| error | ErrorCode | For details, see error | 3.2.0 |
| inventory | UserTagInventory | For details, see inventory | 3.2.0 |
error
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | The error code number, a globally unique identifier for the error, e.g., SYS.1000, HOST.1001 | 3.2.0 |
| description | String | A brief description of the error | 3.2.0 |
| details | String | The detailed error information | 3.2.0 |
| elaboration | String | Reserved field. Defaults to null | 3.2.0 |
| opaque | LinkedHashMap | Reserved field. Defaults to null | 3.2.0 |
| cause | ErrorCode | The root error, the cause of the current error. This field is null if there is no root error | 3.2.0 |
inventory
| Name | Type | Description | Starting Version |
|---|---|---|---|
| tagPatternUuid | String | 3.2.0 | |
| uuid | String | The resource UUID, uniquely identifying this resource | 3.2.0 |
| resourceUuid | String | 3.2.0 | |
| resourceType | String | 3.2.0 | |
| tag | String | 3.2.0 | |
| type | String | 3.2.0 | |
| createDate | Timestamp | Creation time | 3.2.0 |
| lastOpDate | Timestamp | Last modification time | 3.2.0 |
| tagPattern | TagPatternInventory | For details, see tagPattern | 3.2.0 |
tagPattern
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID, uniquely identifying this resource | 3.2.0 |
| name | String | Resource name | 3.2.0 |
| value | String | 3.2.0 | |
| description | String | Detailed description of the resource | 3.2.0 |
| color | String | 3.2.0 | |
| createDate | Timestamp | Creation time | 3.2.0 |
| lastOpDate | Timestamp | Last modification time | 3.2.0 |
| type | TagPatternType | For details, see type | 3.2.0 |
type
| Name | Type | Description | Starting Version |
|---|---|---|---|
| name | String | Resource name | 3.2.0 |
| ordinal | int | 3.2.0 |
SDK Examples
Java SDK
AttachTagToResourcesAction action = new AttachTagToResourcesAction();
action.tagUuid = "6369948f4523457b87c311c550aa3e16";
action.resourceUuids = asList("ae2fdc6bbd254fcba9c36ac174c87a31");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
AttachTagToResourcesAction.Result res = action.call();Python SDK
AttachTagToResourcesAction action = AttachTagToResourcesAction()
action.tagUuid = "1e9bee8a666340fe86599fa03962af90"
action.resourceUuids = [a4bb584d6c50401c98b7535dca839ba0]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
AttachTagToResourcesAction.Result res = action.call()