Skip to main content

ApiV4Client

Struct ApiV4Client 

Source
pub struct ApiV4Client {
    pub base_url: String,
    pub http_client: Client,
    pub token: Option<String>,
}
Expand description

API v4 client structure

Fields§

§base_url: String

Base URL for the Cloudreve instance

§http_client: Client

HTTP client for making requests

§token: Option<String>

Authentication token

Implementations§

Source§

impl ApiV4Client

WebDAV account management methods

Source

pub async fn list_dav_accounts( &self, page_size: u32, next_page_token: Option<&str>, ) -> Result<DavAccountsResponse, Error>

List WebDAV accounts

Source

pub async fn create_dav_account( &self, request: &CreateDavAccountRequest, ) -> Result<DavAccount, Error>

Create a new WebDAV account

Source

pub async fn update_dav_account( &self, id: &str, request: &CreateDavAccountRequest, ) -> Result<DavAccount, Error>

Update a WebDAV account

Source

pub async fn delete_dav_account(&self, id: &str) -> Result<(), Error>

Delete a WebDAV account

Source§

impl ApiV4Client

File management methods

Source

pub async fn upload_file( &self, request: &UploadRequest<'_>, ) -> Result<File, Error>

Source

pub async fn list_files( &self, request: &ListFilesRequest<'_>, ) -> Result<ListResponse, Error>

Lists files in a directory with full response including metadata

Returns a complete ListResponse containing:

  • files: Vector of files/folders in the directory
  • parent: Information about the parent directory
  • pagination: Pagination information (page, total_items, etc.)
  • storage_policy: Preferred storage policy for uploads to this directory
  • props: Navigator capabilities and settings
§Arguments
  • request - ListFilesRequest with path and optional pagination params
Source

pub async fn get_file_info(&self, file_path: &str) -> Result<File, Error>

Source

pub async fn get_file_stat(&self, file_path: &str) -> Result<FileStat, Error>

Source

pub async fn move_file( &self, request: &MoveFileRequest<'_>, ) -> Result<(), Error>

Source

pub async fn copy_file( &self, request: &CopyFileRequest<'_>, ) -> Result<(), Error>

Source

pub async fn rename_file( &self, request: &RenameFileRequest<'_>, ) -> Result<File, Error>

Source

pub async fn delete_file(&self, file_path: &str) -> Result<(), Error>

Source

pub async fn create_directory(&self, path: &str) -> Result<(), Error>

Source

pub async fn set_file_permission( &self, request: &SetFilePermissionRequest<'_>, ) -> Result<(), Error>

Source

pub async fn delete_file_permission(&self, path: &str) -> Result<(), Error>

Source

pub async fn create_upload_session( &self, request: &CreateUploadSessionRequest<'_>, ) -> Result<UploadSessionResponse, Error>

Source

pub async fn upload_file_chunk( &self, session_id: &str, index: u32, chunk_data: &[u8], ) -> Result<(), Error>

Source

pub async fn delete_upload_session( &self, path: &str, session_id: &str, ) -> Result<(), Error>

Source

pub async fn get_thumbnail_url( &self, path: &str, width: Option<u32>, height: Option<u32>, ) -> Result<String, Error>

Source

pub async fn get_file_content(&self, path: &str) -> Result<String, Error>

Source

pub async fn update_file_content( &self, request: &UpdateFileContentRequest<'_>, ) -> Result<(), Error>

Source

pub async fn create_viewer_session( &self, request: &CreateViewerSessionRequest<'_>, ) -> Result<ViewerSessionResponse, Error>

Source

pub async fn create_file( &self, request: &CreateFileRequest<'_>, ) -> Result<File, Error>

Source

pub async fn rename_multiple( &self, request: &RenameMultipleRequest<'_>, ) -> Result<(), Error>

Source

pub async fn move_copy_files( &self, request: &MoveCopyFileRequest<'_>, ) -> Result<(), Error>

Source

pub async fn create_download_url( &self, request: &CreateDownloadUrlRequest<'_>, ) -> Result<DownloadUrlResponse, Error>

Source

pub async fn restore_from_trash( &self, request: &RestoreFileRequest<'_>, ) -> Result<(), Error>

Source

pub async fn force_unlock(&self, path: &str) -> Result<(), Error>

Source

pub async fn patch_metadata( &self, path: &str, request: &UpdateMetadataRequest, ) -> Result<(), Error>

Source

pub async fn mount_storage_policy( &self, path: &str, request: &MountStoragePolicyRequest, ) -> Result<(), Error>

Source

pub async fn update_view_settings( &self, path: &str, request: &UpdateViewRequest, ) -> Result<(), Error>

Source

pub async fn get_file_activities( &self, path: &str, page: Option<u32>, page_size: Option<u32>, ) -> Result<FileActivitiesResponse, Error>

Source

pub async fn get_file_info_extended( &self, request: &GetFileInfoRequest<'_>, ) -> Result<File, Error>

Source

pub async fn get_archive_list( &self, request: &GetArchiveListRequest<'_>, ) -> Result<ArchiveListResponse, Error>

Source§

impl ApiV4Client

Source

pub async fn prepare_login( &self, email: &str, ) -> Result<LoginPreparation, Error>

Source

pub async fn prepare_openid_signin( &self, request: &OpenIdPrepareRequest<'_>, ) -> Result<String, Error>

Source

pub async fn finish_openid_signin( &self, request: &OpenIdFinishRequest<'_>, ) -> Result<LoginResponse, Error>

Source

pub async fn prepare_passkey_signin( &self, ) -> Result<PasskeySignInPreparation, Error>

Source

pub async fn finish_passkey_signin( &self, request: &PasskeySignInRequest<'_>, ) -> Result<LoginResponse, Error>

Source

pub async fn login( &self, request: &LoginRequest<'_>, ) -> Result<LoginData, Error>

Source

pub async fn finish_2fa_login( &self, request: &TwoFactorLoginRequest<'_>, ) -> Result<LoginData, Error>

Source

pub async fn refresh_token( &self, request: &RefreshTokenRequest<'_>, ) -> Result<Token, Error>

Source

pub async fn logout(&self) -> Result<(), Error>

Source§

impl ApiV4Client

Share management methods

Source

pub async fn report_abuse( &self, share_id: &str, reason: &str, ) -> Result<(), Error>

Source§

impl ApiV4Client

Source

pub async fn get_version(&self) -> Result<VersionInfo, Error>

Get API version information

Source

pub async fn ping(&self) -> Result<String, Error>

Ping the server and get server version

Source

pub async fn get_site_config( &self, section: SiteConfigSection, ) -> Result<SiteConfig, Error>

Source

pub async fn get_site_config_str( &self, section: &str, ) -> Result<SiteConfig, Error>

Get site config by section string (for backward compatibility)

Source

pub async fn report_site_abuse( &self, request: &AbuseReportRequest<'_>, ) -> Result<(), Error>

Source

pub async fn get_captcha(&self) -> Result<CaptchaResponse, Error>

Source

pub async fn check_captcha_requirement(&self) -> Result<bool, Error>

Check if CAPTCHA is required for login

Source§

impl ApiV4Client

Source

pub async fn register( &self, request: &RegisterRequest<'_>, ) -> Result<User, Error>

Source

pub async fn get_user_capacity(&self) -> Result<Quota, Error>

Source

pub async fn search_users( &self, request: &SearchUserRequest<'_>, ) -> Result<Vec<User>, Error>

Source

pub async fn get_credit_changes( &self, page: Option<u32>, page_size: Option<u32>, ) -> Result<Vec<CreditChangeRecord>, Error>

Source

pub async fn get_payment_records( &self, page: Option<u32>, page_size: Option<u32>, ) -> Result<Vec<PaymentRecord>, Error>

Source

pub async fn update_user_setting( &self, setting: &UpdateUserSettingRequest<'_>, ) -> Result<(), Error>

Source

pub async fn get_user_setting(&self) -> Result<UserSettings, Error>

Source

pub async fn enable_two_factor(&self) -> Result<TwoFactorSetup, Error>

Source

pub async fn verify_two_factor( &self, request: &TwoFactorVerify, ) -> Result<(), Error>

Source

pub async fn disable_two_factor(&self) -> Result<(), Error>

Source

pub async fn get_user_avatar(&self, user_id: &str) -> Result<String, Error>

Source

pub async fn get_user_info(&self, user_id: &str) -> Result<User, Error>

Source

pub async fn get_user_shares( &self, user_id: &str, page: Option<u32>, page_size: Option<u32>, ) -> Result<Vec<ShareLink>, Error>

Source

pub async fn update_profile( &self, request: &UpdateProfileRequest<'_>, ) -> Result<User, Error>

Source

pub async fn change_password( &self, old_password: &str, new_password: &str, ) -> Result<(), Error>

Source

pub async fn get_quota(&self) -> Result<Quota, Error>

Source

pub async fn get_settings(&self) -> Result<UserSettings, Error>

Source

pub async fn update_settings( &self, settings: &UserSettings, ) -> Result<UserSettings, Error>

Source

pub async fn get_storage_policies(&self) -> Result<Vec<StoragePolicy>, Error>

Source§

impl ApiV4Client

Source

pub async fn create_download( &self, request: &CreateDownloadRequest<'_>, ) -> Result<Vec<Task>, Error>

Source

pub async fn select_download_files( &self, task_id: &str, request: &SelectDownloadFilesRequest<'_>, ) -> Result<Vec<Task>, Error>

Source

pub async fn cancel_download_task(&self, task_id: &str) -> Result<(), Error>

Source

pub async fn list_workflow_tasks( &self, page_size: i32, category: &str, ) -> Result<TaskListResponse, Error>

Source

pub async fn get_task_progress(&self, task_id: &str) -> Result<Progress, Error>

Source

pub async fn create_archive( &self, request: &CreateArchiveRequest<'_>, ) -> Result<TaskResponse, Error>

Source

pub async fn extract_archive( &self, request: &ExtractArchiveRequest<'_>, ) -> Result<TaskResponse, Error>

Source

pub async fn relocate( &self, request: &RelocateRequest<'_>, ) -> Result<TaskResponse, Error>

Source

pub async fn import( &self, request: &ImportRequest<'_>, ) -> Result<TaskResponse, Error>

Source§

impl ApiV4Client

Source

pub fn new(base_url: &str) -> Self

Creates a new API v4 client

Source

pub fn set_token(&mut self, token: String)

Sets the authentication token

Source

pub fn clear_token(&mut self)

Clears the authentication token

Source

pub async fn get<T>(&self, endpoint: &str) -> Result<T, Error>

Makes a GET request to the API

Source

pub async fn post<T>( &self, endpoint: &str, body: &impl Serialize, ) -> Result<T, Error>

Makes a POST request to the API

Source

pub async fn put<T>( &self, endpoint: &str, body: &impl Serialize, ) -> Result<T, Error>

Makes a PUT request to the API

Source

pub async fn patch<T>( &self, endpoint: &str, body: &impl Serialize, ) -> Result<T, Error>

Source

pub async fn delete<T>(&self, endpoint: &str) -> Result<T, Error>

Makes a DELETE request to the API

Source

pub async fn delete_with_body<T>( &self, endpoint: &str, body: &impl Serialize, ) -> Result<T, Error>

Makes a DELETE request with JSON body to the API

Trait Implementations§

Source§

impl Clone for ApiV4Client

Source§

fn clone(&self) -> ApiV4Client

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ApiV4Client

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more