Attach Tag to Resources

POST/zstack/v1/tags/{tagUuid}/resources

Headers

Authorization: OAuth the-session-uuid

Body

{
  "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/resources

Parameter List

NameTypeLocationDescriptionAllowed ValuesStarting Version
tagUuidStringurlTag UUID 3.2.0
resourceUuidsListbody (contained in the params structure)Resource UUID 3.2.0
tokens (optional)Mapbody (contained in the params structure)Keys and values stored through the tag 3.2.0
systemTags (optional)Listbody  3.2.0
userTags (optional)Listbody  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
    }
  ]
}
NameTypeDescriptionStarting Version
successboolean 3.2.0
errorErrorCodeError code. If not null, the operation failed. This field is null when the operation succeeds. For details, see error3.2.0
resultsListFor details, see results3.2.0

error

NameTypeDescriptionStarting Version
codeStringThe error code number, a globally unique identifier for the error, e.g., SYS.1000, HOST.10013.2.0
descriptionStringA brief description of the error3.2.0
detailsStringThe detailed error information3.2.0
elaborationStringReserved field. Defaults to null3.2.0
opaqueLinkedHashMapReserved field. Defaults to null3.2.0
causeErrorCodeThe root error, the cause of the current error. This field is null if there is no root error3.2.0

results

NameTypeDescriptionStarting Version
successboolean 3.2.0
errorErrorCodeFor details, see error3.2.0
inventoryUserTagInventoryFor details, see inventory3.2.0

error

NameTypeDescriptionStarting Version
codeStringThe error code number, a globally unique identifier for the error, e.g., SYS.1000, HOST.10013.2.0
descriptionStringA brief description of the error3.2.0
detailsStringThe detailed error information3.2.0
elaborationStringReserved field. Defaults to null3.2.0
opaqueLinkedHashMapReserved field. Defaults to null3.2.0
causeErrorCodeThe root error, the cause of the current error. This field is null if there is no root error3.2.0

inventory

NameTypeDescriptionStarting Version
tagPatternUuidString 3.2.0
uuidStringThe resource UUID, uniquely identifying this resource3.2.0
resourceUuidString 3.2.0
resourceTypeString 3.2.0
tagString 3.2.0
typeString 3.2.0
createDateTimestampCreation time3.2.0
lastOpDateTimestampLast modification time3.2.0
tagPatternTagPatternInventoryFor details, see tagPattern3.2.0

tagPattern

NameTypeDescriptionStarting Version
uuidStringThe resource UUID, uniquely identifying this resource3.2.0
nameStringResource name3.2.0
valueString 3.2.0
descriptionStringDetailed description of the resource3.2.0
colorString 3.2.0
createDateTimestampCreation time3.2.0
lastOpDateTimestampLast modification time3.2.0
typeTagPatternTypeFor details, see type3.2.0

type

NameTypeDescriptionStarting Version
nameStringResource name3.2.0
ordinalint 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()