Reference For: developers

API: datastores

Operations of the datastores tag of the native REST API.

Datastore files: folders, listing, streamed upload and download (also at /folder, the vSphere-compatible datastore endpoint)

GET /folder/{path}

GET /folder/<path>?dcPath=&dsName=: downloads a file (vSphere datastore HTTP access; bearer, session cookie, or vmware_cgi_ticket; Range gives 206).

Parameters

NameInTypeRequiredDescription
pathpathstringyesFile path below the datastore root, each segment percent-encoded
dcPathquerystring or nullDatacenter name or inventory path (DC1, folder/DC1); may be omitted when the datastore name is unique.
dsNamequerystring or nullDatastore name.

Responses

StatusDescriptionSchema
200OK
206Partial content (the requested range)
401Not authenticated, or the session is restricted (error.mfa_required, error.password_rotation_required)ErrorBody
404Not found (or not visible to the caller)ErrorBody

PUT /folder/{path}

PUT /folder/<path>?dcPath=&dsName=: uploads a file, streamed (replacing one that is not a VM disk, as vSphere does): 201 for a new file, 200 for a replaced one.

Parameters

NameInTypeRequiredDescription
pathpathstringyesDatastore path of the file ([datastore] folder/file, URL-encoded)
dcPathquerystring or nullDatacenter name or inventory path (DC1, folder/DC1); may be omitted when the datastore name is unique.
dsNamequerystring or nullDatastore name.

Request body

application/octet-stream: array of integer (int32)

Responses

StatusDescriptionSchema
200OK
201Created
412Failed precondition; the error body says whichErrorBody
413Payload too large (error.datastore_upload_too_large, args.limit)ErrorBody

DELETE /folder/{path}

DELETE /folder/<path>?dcPath=&dsName=: deletes a file or folder.

Parameters

NameInTypeRequiredDescription
pathpathstringyesDatastore path of the file ([datastore] folder/file, URL-encoded)
dcPathquerystring or nullDatacenter name or inventory path (DC1, folder/DC1); may be omitted when the datastore name is unique.
dsNamequerystring or nullDatastore name.

Responses

StatusDescriptionSchema
204Done; no body
404Not found (or not visible to the caller)ErrorBody
412Failed precondition; the error body says whichErrorBody

DELETE /v1/datastores/{id}

Removes a datastore from every host that mounts it and from the inventory (Datastore.Delete on the datastore and Host.Config.Storage on each host). The files stay on the storage. Refused while a virtual machine has a disk on it (error.datastore_file_in_use).

CLI
kyvernon datastore remove <id>

Parameters

NameInTypeRequiredDescription
idpathstringyesId of the datastore (datastore-N)

Responses

StatusDescriptionSchema
204Done; no body
403Permission denied; args.privilege names the missing privilegeErrorBody
404Not found (or not visible to the caller)ErrorBody
412Failed precondition; the error body says whichErrorBody

GET /v1/datastores/{id}/files

Lists a folder of a datastore.

CLI
kyvernon datastore ls <id> [path]

Parameters

NameInTypeRequiredDescription
idpathstringyesId of the datastore (datastore-N)
pathquerystringPath below the datastore root (iso/ubuntu.iso); empty for the root.

Responses

StatusDescriptionSchema
200OKDatastoreListing
404Not found (or not visible to the caller)ErrorBody
503Temporarily unavailable (not the leader, or the service is off)ErrorBody

DELETE /v1/datastores/{id}/files

Deletes a file or a folder with its content. Disks of virtual machines, and folders holding them, are refused (FAILED_PRECONDITION, error.datastore_file_in_use).

CLI
kyvernon datastore rm <id> <path>

Parameters

NameInTypeRequiredDescription
idpathstringyesId of the datastore (datastore-N)
pathquerystringPath below the datastore root (iso/ubuntu.iso); empty for the root.

Responses

StatusDescriptionSchema
204Done; no body
404Not found (or not visible to the caller)ErrorBody
412Failed precondition; the error body says whichErrorBody

GET /v1/datastores/{id}/files/content

Downloads a file (streamed; Range: bytes=a-b gives 206).

CLI
kyvernon datastore download <id> <path>

Parameters

NameInTypeRequiredDescription
idpathstringyesId of the datastore (datastore-N)
pathquerystringPath below the datastore root (iso/ubuntu.iso); empty for the root.

Responses

StatusDescriptionSchema
200OK
206Partial content (the requested range)
404Not found (or not visible to the caller)ErrorBody
416Range not satisfiableErrorBody

PUT /v1/datastores/{id}/files/content

Uploads a file (streamed request body; written to a temporary file and renamed into place when complete).

CLI
kyvernon datastore upload <id> <file>

Parameters

NameInTypeRequiredDescription
idpathstringyesId of the datastore (datastore-N)
pathquerystringyesPath of the new file below the datastore root.
overwritequerybooleanReplace an existing file (never a disk of a virtual machine).

Request body

application/octet-stream: array of integer (int32)

Responses

StatusDescriptionSchema
200OK
201Created
409Conflict: the object exists, or expectedVersion is staleErrorBody
413Payload too large (error.datastore_upload_too_large, args.limit)ErrorBody

POST /v1/datastores/{id}/files/copy

Copies a file on a datastore (POST /v1/datastores/{id}/files/copy, SOAP CopyDatastoreFile_Task). Synchronous; same-host only. Privilege Datastore.FileManagement on source and destination.

CLI
kyvernon datastore cp <id> <source> <destination>

Parameters

NameInTypeRequiredDescription
idpathstringyesId of the datastore (datastore-N)

Request body

application/json: CopyMoveFileRequest

NameTypeRequiredDescription
destinationDatastoreIdstring or nullDestination datastore (datastore-N). Defaults to the path datastore.
destinationPathstringyesDestination path below the destination datastore root.
overwritebooleanReplace an existing destination file.
sourcePathstringyesSource path below the path datastore root.

Responses

StatusDescriptionSchema
201Created
400Invalid argument; the error body names the fieldErrorBody
404Not found (or not visible to the caller)ErrorBody
409Conflict: the object exists, or expectedVersion is staleErrorBody
412Failed precondition; the error body says whichErrorBody

POST /v1/datastores/{id}/files/move

Moves or renames a file on a datastore (POST /v1/datastores/{id}/files/move, SOAP MoveDatastoreFile_Task). Synchronous; same-host only. Privilege Datastore.FileManagement on source and destination.

CLI
kyvernon datastore mv <id> <source> <destination>

Parameters

NameInTypeRequiredDescription
idpathstringyesId of the datastore (datastore-N)

Request body

application/json: CopyMoveFileRequest

NameTypeRequiredDescription
destinationDatastoreIdstring or nullDestination datastore (datastore-N). Defaults to the path datastore.
destinationPathstringyesDestination path below the destination datastore root.
overwritebooleanReplace an existing destination file.
sourcePathstringyesSource path below the path datastore root.

Responses

StatusDescriptionSchema
204Done; no body
400Invalid argument; the error body names the fieldErrorBody
404Not found (or not visible to the caller)ErrorBody
409Conflict: the object exists, or expectedVersion is staleErrorBody
412Failed precondition; the error body says whichErrorBody

POST /v1/datastores/{id}/folders

Creates a folder on a datastore (ALREADY_EXISTS when the path exists).

CLI
kyvernon datastore mkdir <id> <path>

Parameters

NameInTypeRequiredDescription
idpathstringyesId of the datastore (datastore-N)

Request body

application/json: MakeFolderRequest

NameTypeRequiredDescription
createParentsbooleanCreate missing parent folders too.
pathstringyesPath of the new folder below the datastore root.

Responses

StatusDescriptionSchema
201Created
409Conflict: the object exists, or expectedVersion is staleErrorBody

GET /v1/datastores/{id}/orphan-disks

Reports the disk images on a datastore that nothing references: no virtual machine, template or snapshot names them, and they are neither an overlay nor the backing image of a disk that is referenced, nor a content-library file. Report only: nothing is deleted. Images uploaded to make disks from are listed too; check before removing.

CLI
kyvernon datastore orphans <id>

Parameters

NameInTypeRequiredDescription
idpathstringyesId of the datastore (datastore-N)
minAgeSecondsqueryinteger (int64) or nullLeave out files changed within this many seconds (default 300): a task may be making them right now.

Responses

StatusDescriptionSchema
200OKOrphanDiskReport
404Not found (or not visible to the caller)ErrorBody
503Temporarily unavailable (not the leader, or the service is off)ErrorBody

POST /v1/datastores/{id}/refresh

Measures the datastore on a connected host that mounts it and stores its size and free space (System.Read on the datastore). The leader also does this every five minutes. Needs a host whose agent has the datastore-capacity capability (error.datastore_no_host otherwise).

CLI
kyvernon datastore refresh <id>

Parameters

NameInTypeRequiredDescription
idpathstringyesDatastore id (datastore-N).

Responses

StatusDescriptionSchema
200OKDatastoreCapacityView
403Permission denied; args.privilege names the missing privilegeErrorBody
404Not found (or not visible to the caller)ErrorBody
503Temporarily unavailable (not the leader, or the service is off)ErrorBody

POST /v1/hosts/{id}/datastores/{dsId}/mount

Mounts an existing NFS or iSCSI datastore on one more host, or again after an unmount (Host.Config.Storage on the host). A local datastore belongs to its host and cannot be mounted elsewhere (error.datastore.not_shareable).

CLI
kyvernon host mount-datastore <id> <ds-id>

Parameters

NameInTypeRequiredDescription
idpathstringyesId of the host (host-N)
dsIdpathstringyesId of the datastore on the host (datastore-N)

Responses

StatusDescriptionSchema
204Done; no body
403Permission denied; args.privilege names the missing privilegeErrorBody
404Not found (or not visible to the caller)ErrorBody
412Failed precondition; the error body says whichErrorBody

POST /v1/hosts/{id}/datastores/{dsId}/unmount

Unmounts a datastore on one host (Host.Config.Storage on the host). The datastore and its files stay; the host no longer offers it. Refused while a virtual machine placed on that host has a disk on it (error.datastore_file_in_use).

CLI
kyvernon host unmount-datastore <id> <ds-id>

Parameters

NameInTypeRequiredDescription
idpathstringyesId of the host (host-N)
dsIdpathstringyesId of the datastore on the host (datastore-N)

Responses

StatusDescriptionSchema
204Done; no body
403Permission denied; args.privilege names the missing privilegeErrorBody
404Not found (or not visible to the caller)ErrorBody
412Failed precondition; the error body says whichErrorBody

Version 0.1.