librarium
librarium copied to clipboard
Palette API V1 > Spectroclusters > Updates | Snapshot
The documentation lacks details about reverting a snapshot. The method name should include keywords: revert snapshot, not UPDATE.
https://docs.spectrocloud.com/api/v1/v-1-vm-snapshot-update/
There are a lot of values in the payload that aren't actually required.
And the required keys are not mentioned, like "resourceVersion"
import requests
import json
url = "https://api.spectrocloud.com/v1/spectroclusters/:uid/vms/:vmName/snapshot/:snapshotName"
payload = json.dumps({
"apiVersion": "string",
"kind": "string",
"metadata": {
"annotations": {},
"clusterName": "string",
"creationTimestamp": "string",
"deletionGracePeriodSeconds": 0,
"deletionTimestamp": "2024-07-29T15:51:28.071Z",
"finalizers": [
"string"
],
"generateName": "string",
"generation": 0,
"labels": {},
"managedFields": [
{
"apiVersion": "string",
"fieldsType": "string",
"fieldsV1": {
"Raw": [
"string"
]
},
"manager": "string",
"operation": "string",
"subresource": "string",
"time": "2024-07-29T15:51:28.071Z"
}
],
"name": "string",
"namespace": "string",
"ownerReferences": [
{
"apiVersion": "string",
"blockOwnerDeletion": True,
"controller": True,
"kind": "string",
"name": "string",
"uid": "string"
}
],
"resourceVersion": "string",
"selfLink": "string",
"uid": "string"
},
"spec": {
"deletionPolicy": "string",
"failureDeadline": "string",
"source": {
"apiGroup": "string",
"kind": "string",
"name": "string"
}
},
"status": {
"conditions": [
{
"lastProbeTime": "string",
"lastTransitionTime": "string",
"message": "string",
"reason": "string",
"status": "string",
"type": "string"
}
],
"creationTime": "2024-07-29T15:51:28.071Z",
"error": {
"message": "string",
"time": "2024-07-29T15:51:28.071Z"
},
"indications": [
"string"
],
"phase": "string",
"readyToUse": True,
"snapshotVolumes": {
"excludedVolumes": [
"string"
],
"includedVolumes": [
"string"
]
},
"sourceUID": "string",
"virtualMachineSnapshotContentName": "string"
}
})
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'ApiKey': '<ApiKey>'
}
response = requests.request("PUT", url, headers=headers, data=payload)
print(response.text)
Actual payload:
payload = {
"metadata": {
"ownerReferences": [
{
"apiVersion": "kubevirt.io/v1",
"kind": "VirtualMachine",
"name": f"{self.vm_name}",
"uid": f"{self.vm_obj.uid}"
}
],
"namespace": f"{self.namespace}",
"name": f"{snap_obj.name}",
"resourceVersion": f"{snap_obj.resourceVersion}"
},
"spec": {
"source": {
"kind": "VirtualMachine",
"apiGroup": "kubevirt.io",
"name": f"{self.vm_name}"
}
}
}