ApiClient

interface ApiClient

The general interface that exposes pCloud API's methods.

The class is a factory for Call objects which can be used to execute certain operations on a pCloud account.

The ApiClient is designed with reuse in mind, it's best used when created once and shared among code using it, mainly due to used connection and thread pooling.
  • Users should configure and create instances through the Builder interface.
  • Builder instances can be created via the newClientBuilder method or from an existing ApiClient instance through the newBuilder method.
  • Shared instance's configuration can be changed by using the newBuilder method that will return a pre-configured builder.
  • There is no explicit need to call shutdown, any idle threads and connections will automatically get closed once not used anymore.
  • All methods return non-null Call instances.
  • All methods are thread-safe.
  • All calls resulting in a collection of objects, return unmodifiable java.util.Collection-derived objects.
Bear in mind that shutting down a instance will also affect all instances sharing the underlying resources.

Types

Builder
Link copied to clipboard
interface Builder
A builder for configuring an creating new ApiClient instances.

Functions

apiHost
Link copied to clipboard
abstract fun apiHost(): String
authenticator
Link copied to clipboard
abstract fun authenticator(): Authenticator
cache
Link copied to clipboard
abstract fun cache(): Cache
callbackExecutor
Link copied to clipboard
abstract fun callbackExecutor(): Executor
connectionPool
Link copied to clipboard
abstract fun connectionPool(): ConnectionPool
connectTimeoutMs
Link copied to clipboard
abstract fun connectTimeoutMs(): Int
copy
Link copied to clipboard
abstract fun copy(file: RemoteEntry, toFolder: RemoteFolder): Call<out RemoteEntry>
abstract fun copy(id: String, toFolderId: Long): Call<out RemoteEntry>
abstract fun copy(file: RemoteEntry, toFolder: RemoteFolder, overwriteFiles: Boolean): Call<out RemoteEntry>
abstract fun copy(id: String, toFolderId: Long, overwriteFiles: Boolean): Call<out RemoteEntry>
Copy a specified file or folder.
copyFile
Link copied to clipboard
abstract fun copyFile(file: RemoteFile, toFolder: RemoteFolder): Call<RemoteFile>
abstract fun copyFile(fileId: Long, toFolderId: Long): Call<RemoteFile>
abstract fun copyFile(file: RemoteFile, toFolder: RemoteFolder, overwrite: Boolean): Call<RemoteFile>
abstract fun copyFile(fileId: Long, toFolderId: Long, overwrite: Boolean): Call<RemoteFile>
Copy a specified file.
copyFolder
Link copied to clipboard
abstract fun copyFolder(folder: RemoteFolder, toFolder: RemoteFolder): Call<RemoteFolder>
abstract fun copyFolder(folderId: Long, toFolderId: Long): Call<RemoteFolder>
abstract fun copyFolder(folder: RemoteFolder, toFolder: RemoteFolder, overwrite: Boolean): Call<RemoteFolder>
abstract fun copyFolder(folderId: Long, toFolderId: Long, overwrite: Boolean): Call<RemoteFolder>
Copy specified folder.
createFile
Link copied to clipboard
abstract fun createFile(folder: RemoteFolder, filename: String, data: DataSource): Call<RemoteFile>
abstract fun createFile(path: String, filename: String, data: DataSource): Call<RemoteFile>
abstract fun createFile(folderId: Long, filename: String, data: DataSource): Call<RemoteFile>
abstract fun createFile(folder: RemoteFolder, filename: String, data: DataSource, uploadOptions: UploadOptions): Call<RemoteFile>
abstract fun createFile(path: String, filename: String, data: DataSource, uploadOptions: UploadOptions): Call<RemoteFile>
abstract fun createFile(folderId: Long, filename: String, data: DataSource, uploadOptions: UploadOptions): Call<RemoteFile>
abstract fun createFile(folder: RemoteFolder, filename: String, data: DataSource, modifiedDate: Date, listener: ProgressListener): Call<RemoteFile>
abstract fun createFile(path: String, filename: String, data: DataSource, modifiedDate: Date, listener: ProgressListener): Call<RemoteFile>
abstract fun createFile(folderId: Long, filename: String, data: DataSource, modifiedDate: Date, listener: ProgressListener): Call<RemoteFile>
abstract fun createFile(folder: RemoteFolder, filename: String, data: DataSource, modifiedDate: Date, listener: ProgressListener, uploadOptions: UploadOptions): Call<RemoteFile>
abstract fun createFile(path: String, filename: String, data: DataSource, modifiedDate: Date, listener: ProgressListener, uploadOptions: UploadOptions): Call<RemoteFile>
abstract fun createFile(folderId: Long, filename: String, data: DataSource, modifiedDate: Date, listener: ProgressListener, uploadOptions: UploadOptions): Call<RemoteFile>
Create a new file.
createFileLink
Link copied to clipboard
abstract fun createFileLink(file: RemoteFile, options: DownloadOptions): Call<FileLink>
Create a download link for a file If successful, this call will return a FileLink object, which can be used to download the contents of the specified RemoteFile entry.
abstract fun createFileLink(path: String, options: DownloadOptions): Call<FileLink>
Create a download link for a file If successful, this call will return a FileLink object, which can be used to download the contents of the remote file with the specified path.
abstract fun createFileLink(fileId: Long, options: DownloadOptions): Call<FileLink>
Create a download link for a file If successful, this call will return a FileLink object, which can be used to download the contents of the remote file with the specified fileId.
createFolder
Link copied to clipboard
abstract fun createFolder(path: String): Call<RemoteFolder>
abstract fun createFolder(parentFolderId: Long, folderName: String): Call<RemoteFolder>
Create a new folder.
abstract fun createFolder(parentFolder: RemoteFolder, folderName: String): Call<RemoteFolder>
Create a folder.
delete
Link copied to clipboard
abstract fun delete(file: RemoteEntry): Call<Boolean>
abstract fun delete(id: String): Call<Boolean>
Delete a specified file or folder.
deleteFile
Link copied to clipboard
abstract fun deleteFile(file: RemoteFile): Call<Boolean>
abstract fun deleteFile(path: String): Call<Boolean>
abstract fun deleteFile(fileId: Long): Call<Boolean>
Delete a specified file.
deleteFolder
Link copied to clipboard
abstract fun deleteFolder(folder: RemoteFolder): Call<Boolean>
abstract fun deleteFolder(path: String): Call<Boolean>
abstract fun deleteFolder(folderId: Long): Call<Boolean>
abstract fun deleteFolder(folder: RemoteFolder, recursively: Boolean): Call<Boolean>
abstract fun deleteFolder(path: String, recursively: Boolean): Call<Boolean>
abstract fun deleteFolder(folderId: Long, recursively: Boolean): Call<Boolean>
Delete a specified folder recursively.
dispatcher
Link copied to clipboard
abstract fun dispatcher(): Dispatcher
download
Link copied to clipboard
abstract fun download(fileLink: FileLink): Call<BufferedSource>
Get the content of a specified file link.
abstract fun download(file: RemoteFile): Call<BufferedSource>
Get the content of a specified remote file.
abstract fun download(fileLink: FileLink, sink: DataSink): Call<Void>
abstract fun download(fileLink: FileLink, sink: DataSink, listener: ProgressListener): Call<Void>
Download a FileLink to a specified destination.
getChecksums
Link copied to clipboard
abstract fun getChecksums(filePath: String): Call<Checksums>
Get Checksums of a remote file by a given file filePath.
abstract fun getChecksums(fileId: Long): Call<Checksums>
Get Checksums of a remote file by its file id.
getUserInfo
Link copied to clipboard
abstract fun getUserInfo(): Call<UserInfo>
Get UserInfo for the current account.
listFolder
Link copied to clipboard
abstract fun listFolder(path: String): Call<RemoteFolder>
abstract fun listFolder(folderId: Long): Call<RemoteFolder>
abstract fun listFolder(path: String, recursively: Boolean): Call<RemoteFolder>
abstract fun listFolder(folderId: Long, recursively: Boolean): Call<RemoteFolder>
Load a specified folder.
loadFile
Link copied to clipboard
abstract fun loadFile(path: String): Call<RemoteFile>
abstract fun loadFile(fileId: Long): Call<RemoteFile>
Load a specific file.
loadFolder
Link copied to clipboard
abstract fun loadFolder(path: String): Call<RemoteFolder>
abstract fun loadFolder(folderId: Long): Call<RemoteFolder>
Load a specific folder.
move
Link copied to clipboard
abstract fun move(file: RemoteEntry, toFolder: RemoteFolder): Call<out RemoteEntry>
abstract fun move(id: String, toFolderId: Long): Call<out RemoteEntry>
Move a specified file or folder.
moveFile
Link copied to clipboard
abstract fun moveFile(file: RemoteFile, toFolder: RemoteFolder): Call<RemoteFile>
abstract fun moveFile(path: String, toPath: String): Call<RemoteFile>
abstract fun moveFile(fileId: Long, toFolderId: Long): Call<RemoteFile>
Move a specified file.
moveFolder
Link copied to clipboard
abstract fun moveFolder(folder: RemoteFolder, toFolder: RemoteFolder): Call<RemoteFolder>
abstract fun moveFolder(path: String, toPath: String): Call<RemoteFolder>
abstract fun moveFolder(folderId: Long, toFolderId: Long): Call<RemoteFolder>
Change a specified folder's parent.
newBuilder
Link copied to clipboard
abstract fun newBuilder(): ApiClient.Builder
Create a new shared ApiClient instance.
progressCallbackThreshold
Link copied to clipboard
abstract fun progressCallbackThreshold(): Long
readTimeoutMs
Link copied to clipboard
abstract fun readTimeoutMs(): Int
rename
Link copied to clipboard
abstract fun rename(file: RemoteEntry, newFilename: String): Call<out RemoteEntry>
abstract fun rename(id: String, newFilename: String): Call<out RemoteEntry>
Rename a specified file or folder.
renameFile
Link copied to clipboard
abstract fun renameFile(file: RemoteFile, newFilename: String): Call<RemoteFile>
abstract fun renameFile(fileId: Long, newFilename: String): Call<RemoteFile>
Rename a specified file.
renameFolder
Link copied to clipboard
abstract fun renameFolder(folder: RemoteFolder, newFolderName: String): Call<RemoteFolder>
abstract fun renameFolder(folderId: Long, newFolderName: String): Call<RemoteFolder>
Rename a specified folder.
shutdown
Link copied to clipboard
abstract fun shutdown()
Stop this instance and cleanup resources.
writeTimeoutMs
Link copied to clipboard
abstract fun writeTimeoutMs(): Int