pub struct PaperlessClient {
pub request_full_permissions: bool,
pub request_full_content: bool,
/* private fields */
}Expand description
Client to interact with Paperless.
Fields§
§request_full_permissions: boolWhether to request full permissions data for items.
request_full_content: boolWhether to always request the full document content.
Implementations§
Source§impl PaperlessClient
impl PaperlessClient
Sourcepub fn new(
base_url: &str,
token: &str,
headers: Option<&HashMap<String, String>>,
) -> Result<Self, String>
pub fn new( base_url: &str, token: &str, headers: Option<&HashMap<String, String>>, ) -> Result<Self, String>
Create a new Paperless client.
§Arguments
base_url- The base URL of the Paperless API.token- The authentication token for the Paperless API.headers- Optional additional headers to include in requests.
Sourcepub fn new_with_client(
base_url: &str,
token: &str,
headers: Option<&HashMap<String, String>>,
client_builder: ClientBuilder,
) -> Result<Self, String>
pub fn new_with_client( base_url: &str, token: &str, headers: Option<&HashMap<String, String>>, client_builder: ClientBuilder, ) -> Result<Self, String>
Create a new Paperless client.
Provide a reqwest::ClientBuilder to customize the HTTP client,
such as adding custom headers or disabling compression.
§Arguments
base_url- The base URL of the Paperless API.token- The authentication token for the Paperless API.headers- Optional additional headers to include in requests.client_builder-reqwest::ClientBuilderto use for creating the HTTP client.
Sourcepub fn with_full_permissions(self, req: bool) -> Self
pub fn with_full_permissions(self, req: bool) -> Self
Sets whether to request full permissions data for items during refresh.
If not enabled only simple permission data is loaded.
See ItemPermissions for more details.
pub fn with_full_content(self, full_content: bool) -> Self
Sourcepub async fn refresh_all(&mut self) -> Result<(), Error>
pub async fn refresh_all(&mut self) -> Result<(), Error>
Refresh and cache all metadata.
Only updates the cache for this instance, cloned instances will not see the changes.
Sourcepub async fn refresh(
&mut self,
data: impl IntoIterator<Item = RefreshMetaData>,
) -> Result<(), Error>
pub async fn refresh( &mut self, data: impl IntoIterator<Item = RefreshMetaData>, ) -> Result<(), Error>
Refresh and cache the selected metadata.
Only updates the cache for this instance, cloned instances will not see the changes.
§Arguments
data- The metadata to refresh.full_permissions- Whether to use request full permissions data for the items being refreshed.
Sourcepub async fn query_documents(
&self,
query: DocumentQueryBuilder,
) -> Result<Vec<Document>, Error>
pub async fn query_documents( &self, query: DocumentQueryBuilder, ) -> Result<Vec<Document>, Error>
Query documents using the given DocumentQueryBuilder.
Get all documents with any of the given tags.
Sourcepub async fn get_document_by_id(
&self,
id: DocumentId,
) -> Result<Document, Error>
pub async fn get_document_by_id( &self, id: DocumentId, ) -> Result<Document, Error>
Get a document by its ID.
Sourcepub async fn get_task_status(
&self,
task_id: Option<&TaskId>,
task_name: Option<&str>,
acknowledged: Option<bool>,
) -> Result<Vec<Task>, Error>
pub async fn get_task_status( &self, task_id: Option<&TaskId>, task_name: Option<&str>, acknowledged: Option<bool>, ) -> Result<Vec<Task>, Error>
Get all tasks with optional filtering by ID, name, or acknowledged status.
Sourcepub fn get_workflows(
&self,
) -> impl Future<Output = Result<Vec<Workflow>, Error>>
pub fn get_workflows( &self, ) -> impl Future<Output = Result<Vec<Workflow>, Error>>
Get all workflows.
Sourcepub fn get_saved_views(
&self,
) -> impl Future<Output = Result<Vec<SavedView>, Error>>
pub fn get_saved_views( &self, ) -> impl Future<Output = Result<Vec<SavedView>, Error>>
Get all saved views.
Sourcepub fn get_statistics(&self) -> impl Future<Output = Result<Statistics, Error>>
pub fn get_statistics(&self) -> impl Future<Output = Result<Statistics, Error>>
Get server statistics.
Sourcepub fn get_status(&self) -> impl Future<Output = Result<ServerStatus, Error>>
pub fn get_status(&self) -> impl Future<Output = Result<ServerStatus, Error>>
Get server status.
Sourcepub async fn create<T: Item>(
&self,
new_item: &T::CreateDto,
) -> Result<T::BaseType, Error>
pub async fn create<T: Item>( &self, new_item: &T::CreateDto, ) -> Result<T::BaseType, Error>
Create a new item in Paperless.
All structs which implement CreateDtoObject can be used as new_item.
Returns the created item.
Sourcepub async fn update<T: Item>(
&self,
id: T::Id,
update: &T::UpdateDto,
) -> Result<T::BaseType, Error>
pub async fn update<T: Item>( &self, id: T::Id, update: &T::UpdateDto, ) -> Result<T::BaseType, Error>
Updates an existing item in Paperless.
All structs which implement UpdateDtoObject can be used as item.
Sourcepub async fn delete<T: Item>(&self, id: T::Id) -> Result<(), Error>
pub async fn delete<T: Item>(&self, id: T::Id) -> Result<(), Error>
Deletes an existing item in Paperless.
Sourcepub async fn upload_document(
&self,
file_path: &Path,
filename: &str,
) -> Result<TaskId, Error>
pub async fn upload_document( &self, file_path: &Path, filename: &str, ) -> Result<TaskId, Error>
Upload a document to Paperless.
Returns the task ID on success.
Get the tags cache.
Sourcepub fn storage_paths(&self) -> &HashMap<StoragePathId, StoragePath>
pub fn storage_paths(&self) -> &HashMap<StoragePathId, StoragePath>
Get the storage paths cache.
Sourcepub fn find_tag_by_name(&self, name: &str) -> Option<&Tag>
pub fn find_tag_by_name(&self, name: &str) -> Option<&Tag>
Find a tag by its name.
Sourcepub fn document_types(&self) -> &HashMap<DocumentTypeId, DocumentType>
pub fn document_types(&self) -> &HashMap<DocumentTypeId, DocumentType>
Get the document types cache.
Sourcepub fn find_document_type_by_name(&self, name: &str) -> Option<&DocumentType>
pub fn find_document_type_by_name(&self, name: &str) -> Option<&DocumentType>
Find a document type by its name.
Sourcepub fn correspondents(&self) -> &HashMap<CorrespondentId, Correspondent>
pub fn correspondents(&self) -> &HashMap<CorrespondentId, Correspondent>
Get the correspondents cache.
Sourcepub fn custom_fields(&self) -> &HashMap<CustomFieldId, CustomField>
pub fn custom_fields(&self) -> &HashMap<CustomFieldId, CustomField>
Get the custom fields cache.
Sourcepub fn find_custom_field_by_name(&self, name: &str) -> Option<&CustomField>
pub fn find_custom_field_by_name(&self, name: &str) -> Option<&CustomField>
Find a custom field by its name.
Trait Implementations§
Source§impl Clone for PaperlessClient
impl Clone for PaperlessClient
Source§fn clone(&self) -> PaperlessClient
fn clone(&self) -> PaperlessClient
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more