|
|
@ -1,9 +1,9 @@
|
|
|
|
use crate::client_api::error::ApiResult;
|
|
|
|
use crate::client_api::error::ApiResult;
|
|
|
|
use crate::client_api::IPCApi;
|
|
|
|
use crate::client_api::IPCApi;
|
|
|
|
use crate::types::files::{
|
|
|
|
use crate::types::files::{
|
|
|
|
AddFileRequestHeader, FileBasicDataResponse, FileMetadataResponse, FileOSMetadata,
|
|
|
|
AddFileRequestHeader, FileBasicDataResponse, FileMetadataResponse, FileOSMetadata, FileStatus,
|
|
|
|
GetFileThumbnailOfSizeRequest, GetFileThumbnailsRequest, ReadFileRequest,
|
|
|
|
GetFileThumbnailOfSizeRequest, GetFileThumbnailsRequest, ReadFileRequest,
|
|
|
|
ThumbnailMetadataResponse, UpdateFileNameRequest,
|
|
|
|
ThumbnailMetadataResponse, UpdateFileNameRequest, UpdateFileStatusRequest,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
use crate::types::filtering::{FilterExpression, FindFilesRequest, SortKey};
|
|
|
|
use crate::types::filtering::{FilterExpression, FindFilesRequest, SortKey};
|
|
|
|
use crate::types::identifier::FileIdentifier;
|
|
|
|
use crate::types::identifier::FileIdentifier;
|
|
|
@ -103,6 +103,60 @@ impl FileApi {
|
|
|
|
Ok(payload.into_inner())
|
|
|
|
Ok(payload.into_inner())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Adds a file with predefined tags
|
|
|
|
|
|
|
|
#[tracing::instrument(level = "debug", skip(self, bytes))]
|
|
|
|
|
|
|
|
pub async fn add_file(
|
|
|
|
|
|
|
|
&self,
|
|
|
|
|
|
|
|
metadata: FileOSMetadata,
|
|
|
|
|
|
|
|
tags: Vec<String>,
|
|
|
|
|
|
|
|
bytes: Vec<u8>,
|
|
|
|
|
|
|
|
) -> ApiResult<FileBasicDataResponse> {
|
|
|
|
|
|
|
|
let payload = TandemPayload::new(
|
|
|
|
|
|
|
|
AddFileRequestHeader { metadata, tags },
|
|
|
|
|
|
|
|
BytePayload::new(bytes),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.emit_and_get("add_file", payload, Some(Duration::from_secs(5)))
|
|
|
|
|
|
|
|
.await
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Updates a files name
|
|
|
|
|
|
|
|
#[tracing::instrument(level = "debug", skip(self))]
|
|
|
|
|
|
|
|
pub async fn update_file_name(
|
|
|
|
|
|
|
|
&self,
|
|
|
|
|
|
|
|
file_id: FileIdentifier,
|
|
|
|
|
|
|
|
name: String,
|
|
|
|
|
|
|
|
) -> ApiResult<FileMetadataResponse> {
|
|
|
|
|
|
|
|
self.emit_and_get(
|
|
|
|
|
|
|
|
"update_file_name",
|
|
|
|
|
|
|
|
UpdateFileNameRequest { file_id, name },
|
|
|
|
|
|
|
|
Some(Duration::from_secs(1)),
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
.await
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Updates the status of a file
|
|
|
|
|
|
|
|
#[tracing::instrument(level = "debug", skip(self))]
|
|
|
|
|
|
|
|
pub async fn update_file_status(
|
|
|
|
|
|
|
|
&self,
|
|
|
|
|
|
|
|
file_id: FileIdentifier,
|
|
|
|
|
|
|
|
status: FileStatus,
|
|
|
|
|
|
|
|
) -> ApiResult<FileBasicDataResponse> {
|
|
|
|
|
|
|
|
self.emit_and_get(
|
|
|
|
|
|
|
|
"update_file_status",
|
|
|
|
|
|
|
|
UpdateFileStatusRequest { status, file_id },
|
|
|
|
|
|
|
|
Some(Duration::from_secs(1)),
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
.await
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Permanently deletes a file from the disk and database
|
|
|
|
|
|
|
|
#[tracing::instrument(level = "debug", skip(self))]
|
|
|
|
|
|
|
|
pub async fn delete_file(&self, file_id: FileIdentifier) -> ApiResult<()> {
|
|
|
|
|
|
|
|
self.emit_and_get("delete_file", file_id, Some(Duration::from_secs(10)))
|
|
|
|
|
|
|
|
.await
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Returns a list of all thumbnails of the file
|
|
|
|
/// Returns a list of all thumbnails of the file
|
|
|
|
#[tracing::instrument(level = "debug", skip(self))]
|
|
|
|
#[tracing::instrument(level = "debug", skip(self))]
|
|
|
|
pub async fn get_file_thumbnails(
|
|
|
|
pub async fn get_file_thumbnails(
|
|
|
@ -141,38 +195,6 @@ impl FileApi {
|
|
|
|
Ok((metadata.data(), bytes.into_inner()))
|
|
|
|
Ok((metadata.data(), bytes.into_inner()))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Updates a files name
|
|
|
|
|
|
|
|
#[tracing::instrument(level = "debug", skip(self))]
|
|
|
|
|
|
|
|
pub async fn update_file_name(
|
|
|
|
|
|
|
|
&self,
|
|
|
|
|
|
|
|
file_id: FileIdentifier,
|
|
|
|
|
|
|
|
name: String,
|
|
|
|
|
|
|
|
) -> ApiResult<FileMetadataResponse> {
|
|
|
|
|
|
|
|
self.emit_and_get(
|
|
|
|
|
|
|
|
"update_file_name",
|
|
|
|
|
|
|
|
UpdateFileNameRequest { file_id, name },
|
|
|
|
|
|
|
|
Some(Duration::from_secs(1)),
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
.await
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Adds a file with predefined tags
|
|
|
|
|
|
|
|
#[tracing::instrument(level = "debug", skip(self, bytes))]
|
|
|
|
|
|
|
|
pub async fn add_file(
|
|
|
|
|
|
|
|
&self,
|
|
|
|
|
|
|
|
metadata: FileOSMetadata,
|
|
|
|
|
|
|
|
tags: Vec<String>,
|
|
|
|
|
|
|
|
bytes: Vec<u8>,
|
|
|
|
|
|
|
|
) -> ApiResult<FileBasicDataResponse> {
|
|
|
|
|
|
|
|
let payload = TandemPayload::new(
|
|
|
|
|
|
|
|
AddFileRequestHeader { metadata, tags },
|
|
|
|
|
|
|
|
BytePayload::new(bytes),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.emit_and_get("add_file", payload, Some(Duration::from_secs(5)))
|
|
|
|
|
|
|
|
.await
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Deletes all thumbnails of a file to regenerate them when requested
|
|
|
|
/// Deletes all thumbnails of a file to regenerate them when requested
|
|
|
|
#[tracing::instrument(level = "debug", skip(self))]
|
|
|
|
#[tracing::instrument(level = "debug", skip(self))]
|
|
|
|
pub async fn delete_thumbnails(&self, file_id: FileIdentifier) -> ApiResult<()> {
|
|
|
|
pub async fn delete_thumbnails(&self, file_id: FileIdentifier) -> ApiResult<()> {
|
|
|
|