Class FilesResource

java.lang.Object
dev.dosya.sdk.resource.FilesResource

public final class FilesResource extends Object
Provides operations for managing files in Dosya workspaces.

This resource handles listing, retrieving, deleting, restoring, renaming, moving, copying, locking, hiding, versioning, and sharing files.

Since:
0.1.0
  • Constructor Details

    • FilesResource

      public FilesResource(@NotNull @NotNull DosyaHttpClient http)
      Creates a new FilesResource backed by the given HTTP client.
      Parameters:
      http - the HTTP client used to make API requests
  • Method Details

    • list

      @NotNull public @NotNull ListFilesResponse list(@NotNull @NotNull ListFilesParams params)
      Lists files and folders in a workspace, optionally filtered by folder, query, or status.
      Parameters:
      params - the listing parameters including workspace ID, pagination, and filters
      Returns:
      the response containing files, folders, breadcrumbs, and pagination info
      Throws:
      DosyaApiException - if the API returns an error
    • get

      @NotNull public @NotNull FileDetail get(@NotNull @NotNull String fileId)
      Retrieves detailed information about a single file.
      Parameters:
      fileId - the unique identifier of the file
      Returns:
      the file detail
      Throws:
      DosyaApiException - if the API returns an error
    • delete

      public boolean delete(@NotNull @NotNull String fileId)
      Deletes a file. Returns whether the deletion was permanent.
      Parameters:
      fileId - the unique identifier of the file to delete
      Returns:
      true if the file was permanently deleted, false if soft-deleted
      Throws:
      DosyaApiException - if the API returns an error
    • restore

      public void restore(@NotNull @NotNull String fileId)
      Restores a previously soft-deleted file.
      Parameters:
      fileId - the unique identifier of the file to restore
      Throws:
      DosyaApiException - if the API returns an error
    • rename

      @NotNull public @NotNull String rename(@NotNull @NotNull String fileId, @NotNull @NotNull String name)
      Renames a file and returns the new name.
      Parameters:
      fileId - the unique identifier of the file
      name - the new name for the file
      Returns:
      the updated file name as confirmed by the server
      Throws:
      DosyaApiException - if the API returns an error
    • move

      public void move(@NotNull @NotNull String fileId, @NotNull @NotNull String folderId)
      Moves a file into a different folder.
      Parameters:
      fileId - the unique identifier of the file to move
      folderId - the target folder ID
      Throws:
      DosyaApiException - if the API returns an error
    • copy

      @NotNull public @NotNull FileDetail copy(@NotNull @NotNull String fileId, @Nullable @Nullable String newName, @Nullable @Nullable String folderId)
      Copies a file, optionally with a new name and/or into a different folder.
      Parameters:
      fileId - the unique identifier of the file to copy
      newName - the name for the copy, or null to keep the original name
      folderId - the target folder ID for the copy, or null to keep the same folder
      Returns:
      the detail of the newly created copy
      Throws:
      DosyaApiException - if the API returns an error
    • copy

      @NotNull public @NotNull FileDetail copy(@NotNull @NotNull String fileId)
      Copies a file using the original name and folder.
      Parameters:
      fileId - the unique identifier of the file to copy
      Returns:
      the detail of the newly created copy
      Throws:
      DosyaApiException - if the API returns an error
    • lock

      public void lock(@NotNull @NotNull String fileId, @NotNull @NotNull String lockMode, @Nullable @Nullable String password)
      Locks a file with the specified lock mode and optional password.
      Parameters:
      fileId - the unique identifier of the file to lock
      lockMode - the lock mode (e.g. "password", "readonly")
      password - the password for the lock, or null if not required
      Throws:
      DosyaApiException - if the API returns an error
    • lock

      public void lock(@NotNull @NotNull String fileId, @NotNull @NotNull String lockMode)
      Locks a file with the specified lock mode without a password.
      Parameters:
      fileId - the unique identifier of the file to lock
      lockMode - the lock mode (e.g. "password", "readonly")
      Throws:
      DosyaApiException - if the API returns an error
    • unlock

      public void unlock(@NotNull @NotNull String fileId)
      Removes the lock from a file.
      Parameters:
      fileId - the unique identifier of the file to unlock
      Throws:
      DosyaApiException - if the API returns an error
    • hide

      public void hide(@NotNull @NotNull String fileId, @Nullable @Nullable String hiddenMode, @Nullable @Nullable List<String> targetIds)
      Hides a file, optionally specifying a hidden mode and target user/group IDs.
      Parameters:
      fileId - the unique identifier of the file to hide
      hiddenMode - the hidden mode, or null for the default
      targetIds - the list of user or group IDs to hide the file from, or null
      Throws:
      DosyaApiException - if the API returns an error
    • hide

      public void hide(@NotNull @NotNull String fileId)
      Hides a file using the default hidden mode.
      Parameters:
      fileId - the unique identifier of the file to hide
      Throws:
      DosyaApiException - if the API returns an error
    • listVersions

      @NotNull public @NotNull FileVersionsResponse listVersions(@NotNull @NotNull String fileId)
      Lists all versions of a file.
      Parameters:
      fileId - the unique identifier of the file
      Returns:
      the response containing the file name, current version, and version history
      Throws:
      DosyaApiException - if the API returns an error
    • restoreVersion

      @NotNull public @NotNull VersionRestoreResponse restoreVersion(@NotNull @NotNull String fileId, int versionNumber)
      Restores a file to a previous version.
      Parameters:
      fileId - the unique identifier of the file
      versionNumber - the version number to restore
      Returns:
      the response containing the new version number and the version it was restored from
      Throws:
      DosyaApiException - if the API returns an error
    • getShareLinks

      @NotNull public @NotNull List<ShareLinkDetail> getShareLinks(@NotNull @NotNull String fileId)
      Retrieves all share links associated with a file.
      Parameters:
      fileId - the unique identifier of the file
      Returns:
      the list of share link details
      Throws:
      DosyaApiException - if the API returns an error
    • createShareLink

      @NotNull public @NotNull ShareLinkDetail createShareLink(@NotNull @NotNull String fileId, @Nullable @Nullable CreateShareLinkParams params)
      Creates a new share link for a file with optional configuration.
      Parameters:
      fileId - the unique identifier of the file to share
      params - optional parameters such as expiration, password, and lock mode; may be null
      Returns:
      the created share link detail
      Throws:
      DosyaApiException - if the API returns an error
    • createShareLink

      @NotNull public @NotNull ShareLinkDetail createShareLink(@NotNull @NotNull String fileId)
      Creates a new share link for a file with default settings.
      Parameters:
      fileId - the unique identifier of the file to share
      Returns:
      the created share link detail
      Throws:
      DosyaApiException - if the API returns an error
    • shareByEmail

      public void shareByEmail(@NotNull @NotNull String fileId, @NotNull @NotNull List<String> emails, @Nullable @Nullable String message)
      Shares a file by sending email invitations to the specified recipients.
      Parameters:
      fileId - the unique identifier of the file to share
      emails - the list of recipient email addresses
      message - an optional message to include in the email, or null
      Throws:
      DosyaApiException - if the API returns an error
    • createShareBundle

      @NotNull public @NotNull ShareBundleLink createShareBundle(@NotNull @NotNull CreateShareBundleParams params)
      Creates a share bundle containing multiple files as a single shareable link.
      Parameters:
      params - the bundle parameters including file IDs and optional expiration/password
      Returns:
      the created share bundle link
      Throws:
      DosyaApiException - if the API returns an error