File Manager Delete Datastore File Task

File Manager Delete Datastore File Task

Deletes the specified file or folder from the datastore.

If a file of a virtual machine is deleted, it may corrupt that virtual machine. Folder deletes are always recursive. The datacenter parameter may be omitted if a URL is used to name the file or folder.

If the source is an extent of a virtual disk, this operation treats the extent as a file.

It is important to note that this operation will provide transactional guarantees only for a file. No guarantees are provided when deleting folders. If the intent is to delete a virtual machine registered in the inventory, please refer to Destroy_Task.

Requires Datastore.FileManagement privilege on the datastore.

Request
URI
POST
https://{api_host}/sdk/vim25/{release}/FileManager/{moId}/DeleteDatastoreFile_Task
COPY
Path Parameters
string
moId
Required

The unique identifier for the managed object to which the method attaches; the serialized managed object reference for a request has the form moType/moId, in this case FileManager/{moId}.

string
release
Required

The vSphere release schema. The current specification covers vSphere 9.0.0.0 APIs.


Request Body
DeleteDatastoreFileRequestType of type(s) application/json
Required
"DeleteDatastoreFileRequestType Object"
string
name
Required

The name of the file or folder, either a URL or a datastore path referring to the file or folder to be deleted.

datacenter
Optional

If name is a datastore path, the datacenter for that datastore path. Not needed when invoked directly on ESX. If not specified on a call to VirtualCenter, name must be a URL.

Required privileges: System.View

Authentication
This operation uses the following authentication methods.
Responses
200

This method returns a Task object with which to monitor the operation.

Returns MoRefTask of type(s) application/json
"MoRefTask Object"

500

InvalidDatastore: if the operation cannot be performed on the datastore. Typically, a specific subclass of this exception is thrown.

FileNotFound: if the file or folder specified by name is not found.

CannotDeleteFile: if the delete operation on the file or folder fails.

FileLocked: if the source file or folder is currently locked or in use.

FileFault: if there is a generic file error

Returns VimFault of type(s) application/json
This response body class contains all of the following: InlineVimFault0
"VimFault Object"

Code Samples
COPY
                    curl -X POST -H 'Authorization: <value>' -H 'Content-Type: application/json' -d '[{}]' https://{api_host}/sdk/vim25/{release}/FileManager/{moId}/DeleteDatastoreFile_Task