Create Custom Attribute Value

POST/zstack/v1/resource-attributes/{keyUuid}/resources

Headers

Authorization: OAuth the-session-uuid

Body

{
  "params": {
    "value": "Kinny",
    "resourceUuids": [
      "ff01ec80fd11327cba7519b66119d900"
    ]
  },
  "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":{"value":"Kinny","resourceUuids":["ff01ec80fd11327cba7519b66119d900"]}}' \
http://localhost:8080/zstack/v1/resource-attributes/ff03a2b491023030bf58b1b35ea9cd00/resources

Parameter List

NameTypeLocationDescriptionAllowed ValuesStarting Version
keyUuidStringurlCustom attribute key UUID 4.10.16
valueStringbody (contained in the params structure)Value 4.10.16
resourceUuidsListbody (contained in the params structure)Resource UUID 4.10.16
systemTags (optional)ListbodySystem tags 4.10.16
userTags (optional)ListbodyUser tags 4.10.16

API Response

Response example

{
  "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
    }
  ]
}
NameTypeDescriptionStarting Version
successbooleanWhether the creation succeeded4.10.16
inventoriesListFor details, see inventories4.10.16
errorErrorCodeFor details, see error4.10.16

inventories

NameTypeDescriptionStarting Version
successbooleanWhether the creation succeeded4.10.16
errorErrorCodeFor details, see error4.10.16
inventoryResourceAttributeValueInventoryFor details, see inventory4.10.16

error

NameTypeDescriptionStarting Version
odeStringThe error code number, a globally unique identifier for the error, e.g., SYS.1000, HOST.10010.6
descriptionStringA brief description of the error0.6
detailsStringThe detailed error information0.6
elaborationStringReserved field. Defaults to null0.6
opaqueLinkedHashMapReserved field. Defaults to null0.6
causeErrorCodeThe root error, the cause of the current error. This field is null if there is no root error0.6

inventory

NameTypeDescriptionStarting Version
keyUuidStringCustom attribute key UUID4.10.16
valueStringValue4.10.16
resourceUuidStringResource UUID4.10.16
resourceTypeStringResource type4.10.16
createDateTimestampCreation time4.10.16
keyResourceAttributeKeyInventoryFor details, see key4.10.16

key

NameTypeDescriptionStarting Version
uuidStringCustom attribute key UUID4.10.16
nameStringCustom attribute key name4.10.16
descriptionStringDetailed description of the resource4.10.16
createDateTimestampCreation time4.10.16
lastOpDateTimestampLast modification time4.10.16

error

NameTypeDescriptionStarting Version
odeStringThe error code number, a globally unique identifier for the error, e.g., SYS.1000, HOST.10010.6
descriptionStringA brief description of the error0.6
detailsStringThe detailed error information0.6
elaborationStringReserved field. Defaults to null0.6
opaqueLinkedHashMapReserved field. Defaults to null0.6
causeErrorCodeThe root error, the cause of the current error. This field is null if there is no root error0.6

SDK Examples

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()