File Manager Move Datastore File Task

File Manager Move Datastore File Task

Moves the source file or folder to the destination.

If the destination file does not exist, it is created. If the destination file exists, the force parameter determines whether to overwrite it with the source or not. If the source path is a folder, then the destination path must not exist; the destination cannot be overwritten even with a force flag in that case. Folder moves are recursive, treating all files and disks to move as binary.

If source (or destination) name is specified as a URL, then the corresponding datacenter parameter may be omitted.

If any intermediate level folder specified by the source and destination does not exist, a FileNotFound fault is thrown.

If a file of a virtual machine is moved, it may corrupt that virtual machine. If a file of a virtual machine is overwritten on the destination datastore as a result of the force parameter, it may corrupt that virtual machine.

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

If source and destination resolve to the same file system location, the call has no effect.

It is important to note that this operation will provide transactional guarantees only for a file. No guarantees are provided for folder moves. If the intent is to move a virtual machine registered in the inventory, with transactional guarantees, please refer to RelocateVM_Task. If the intent is to rename a virtual machine registered in the inventory, please refer to Rename_Task.

Datastore.FileManagement privilege is required on both source and destination datastores.

Request
URI
POST
https://{vcenter-host}/sdk/vim25/{release}/FileManager/{moId}/MoveDatastoreFile_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 8.0.2.0 APIs.


Request Body
MoveDatastoreFileRequestType of type(s) application/json
Required
{
    "sourceName": "string",
    "sourceDatacenter": {
        "type": "string",
        "value": "string"
    },
    "destinationName": "string",
    "destinationDatacenter": {
        "type": "string",
        "value": "string"
    },
    "force": false
}
string
sourceName
Required

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

sourceDatacenter
Optional

Reference to an instance of the Datacenter managed object.

string
destinationName
Required

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

destinationDatacenter
Optional

Reference to an instance of the Datacenter managed object.

boolean
force
Optional

If true, overwrite any identically named file at the destination. If not specified, it is assumed to be false.

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
This response body class contains all of the following: MoRefExtensibleManagedObject
{
    "_typeName": "string",
    "type": "string",
    "value": "string"
}

500

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

FileNotFound: if the file or folder specified by sourceName is not found, or, any intermediate level folder specified by the destinationName is not found.

CannotAccessFile: if the source file or folder cannot be moved because of insufficient permissions.

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

FileAlreadyExists: if a file with the given name already exists at the destination, and the force flag is false. For folders, if the destination exists, this fault is thrown regardless.

NoDiskSpace: if there is not enough space available on the destination datastore.

FileFault: if there is a generic file error

Returns VimFault of type(s) application/json
This response body class contains all of the following: MethodFault
{
    "_typeName": "string",
    "faultCause": "MethodFault Object",
    "faultMessage": [
        {
            "_typeName": "string",
            "key": "string",
            "arg": [
                {
                    "_typeName": "string",
                    "key": "string",
                    "value": {
                        "_typeName": "string"
                    }
                }
            ],
            "message": "string"
        }
    ]
}