VM Related InterfacesKey Provider APIs

Re-encrypt Specified Keys

PUT/zstack/v1/key-providers/{providerUuid}/rekey

Headers

Authorization: OAuth the-session-uuid

Body

{
  "rekeyKeyProviderRefs": {
    "refIds": [
      1,
      2
    ],
    "rekeyAll": false
  },
  "systemTags": [],
  "userTags": []
}

In the preceding example, the systemTags and userTags fields can be omitted. They are listed to indicate that the body can include these two fields.

Curl Example

curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"rekeyKeyProviderRefs":{"refIds":[1,2],"rekeyAll":false}}' \
http://localhost:8080/zstack/v1/key-providers/ff0340e5866e385b9a86e592dd7e1900/rekey

Parameter List

NameTypeLocationDescriptionOptional ValueSince
refIds (optional)Listbody (contained in rekeyKeyProviderRefs structure)List of key reference IDs to re-encrypt 5.0.0
resourceUuids (optional)Listbody (contained in rekeyKeyProviderRefs structure)List of associated resource UUIDs. Use this with resourceType. 5.0.0
resourceType (optional)Stringbody (contained in rekeyKeyProviderRefs structure)Associated resource type. Use this with resourceUuids. 5.0.0
providerUuidStringurlKey provider UUID 5.0.0
rekeyAll (optional)booleanbody (contained in rekeyKeyProviderRefs structure)Whether to perform full re-encryption. If set to true, you cannot specify refIds or resourceType/resourceUuids. 5.0.0
systemTags (optional)ListbodySystem tags 5.0.0
userTags (optional)ListbodyUser tags 5.0.0

API Response

Response Example

{
  "totalCount": 3,
  "successCount": 1,
  "skippedCount": 1,
  "failedCount": 1,
  "providerResults": [
    {
      "providerUuid": "provider-uuid-1",
      "providerName": "provider-1",
      "totalRefCount": 3,
      "successRefCount": 1,
      "skippedRefCount": 1,
      "failedRefCount": 1,
      "skippedResources": [
        {
          "keyRefId": 11,
          "resourceType": "TpmVO",
          "resourceUuid": "ff00de2d3ab43127b1abdac68f1e7f00",
          "reason": "encrypted resource key ref[id:11, resourceType:TpmVO, resourceUuid:ff00de2d3ab43127b1abdac68f1e7f00] has empty secret ref"
        }
      ],
      "failedResources": [
        {
          "keyRefId": 12,
          "resourceType": "TpmVO",
          "resourceUuid": "ff00de2d3ab43127b1abdac68f1e7f00",
          "reason": "key-tool rekey failed: failed to decrypt wrapper DEK with KEK"
        }
      ]
    }
  ]
}
NameTypeDescriptionSince
successboolean 5.0.0
totalCountintNumber of source key providers involved in this operation (deduplicated by provider associated with resource refs)5.0.0
successCountintNumber of providers with no failed refs (including providers that only have skipped refs)5.0.0
skippedCountintNumber of providers that have skipped refs5.0.0
failedCountintNumber of providers that have failed refs5.0.0
providerResultsListResults aggregated by source key provider. Each element contains skippedResources, failedResources, and ref counts of each type for the provider.5.0.0
errorErrorCodeFor details, see error5.0.0

error

NameTypeDescriptionSince
codeStringError code, which is the globally unique identifier of the error, for example, SYS.1000 or HOST.10010.6
descriptionStringSummary description of the error0.6
detailsStringDetailed information about the error0.6
elaborationStringReserved field. The default value is null.0.6
opaqueLinkedHashMapReserved field. The default value is null.0.6
causeErrorCodeRoot error that caused the current error. If no root error exists, this field is null.0.6

SDK Example

Java SDK

RekeyKeyProviderRefsAction action = new RekeyKeyProviderRefsAction();
action.refIds = asList(1,2);
action.providerUuid = "ff0340e5866e385b9a86e592dd7e1900";
action.rekeyAll = false;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
RekeyKeyProviderRefsAction.Result res = action.call();

Python SDK

action = RekeyKeyProviderRefsAction()
action.refIds = [1, 2]
action.providerUuid = "ff0340e5866e385b9a86e592dd7e1900"
action.rekeyAll = false
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()