pub struct Client { /* private fields */ }
Expand description
A low level Client for the hydrus API. It provides basic abstraction over the REST api.
Implementations§
Source§impl Client
impl Client
Sourcepub fn builder() -> ClientBuilder
pub fn builder() -> ClientBuilder
Returns a builder for the client
Sourcepub fn new<S: AsRef<str>>(url: S, access_key: S) -> Self
pub fn new<S: AsRef<str>>(url: S, access_key: S) -> Self
Creates a new client to start requests against the hydrus api.
Sourcepub async fn api_version(&self) -> Result<ApiVersionResponse>
pub async fn api_version(&self) -> Result<ApiVersionResponse>
Returns the current API version. It’s being incremented every time the API changes.
Sourcepub async fn session_key(&self) -> Result<SessionKeyResponse>
pub async fn session_key(&self) -> Result<SessionKeyResponse>
Creates a new session key
Sourcepub async fn verify_access_key(&self) -> Result<VerifyAccessKeyResponse>
pub async fn verify_access_key(&self) -> Result<VerifyAccessKeyResponse>
Verifies if the access key is valid and returns some information about its permissions
Sourcepub async fn get_services(&self) -> Result<GetServicesResponse>
pub async fn get_services(&self) -> Result<GetServicesResponse>
Returns the list of tag and file services of the client
Sourcepub async fn add_file<S: ToString + Debug>(
&self,
path: S,
) -> Result<AddFileResponse>
pub async fn add_file<S: ToString + Debug>( &self, path: S, ) -> Result<AddFileResponse>
Adds a file to hydrus
Sourcepub async fn add_binary_file(&self, data: Vec<u8>) -> Result<AddFileResponse>
pub async fn add_binary_file(&self, data: Vec<u8>) -> Result<AddFileResponse>
Adds a file from binary data to hydrus
Sourcepub async fn delete_files(
&self,
files: FileSelection,
service: FileServiceSelection,
reason: Option<String>,
) -> Result<()>
pub async fn delete_files( &self, files: FileSelection, service: FileServiceSelection, reason: Option<String>, ) -> Result<()>
Moves files with matching hashes to the trash
Sourcepub async fn undelete_files(
&self,
files: FileSelection,
service: FileServiceSelection,
) -> Result<()>
pub async fn undelete_files( &self, files: FileSelection, service: FileServiceSelection, ) -> Result<()>
Pulls files out of the trash by hash
Sourcepub async fn archive_files(
&self,
files: FileSelection,
service: FileServiceSelection,
) -> Result<()>
pub async fn archive_files( &self, files: FileSelection, service: FileServiceSelection, ) -> Result<()>
Moves files from the inbox into the archive
Sourcepub async fn unarchive_files(
&self,
files: FileSelection,
service: FileServiceSelection,
) -> Result<()>
pub async fn unarchive_files( &self, files: FileSelection, service: FileServiceSelection, ) -> Result<()>
Moves files from the archive into the inbox
Returns the list of tags as the client would see them in a human friendly order
Adds tags to files with the given hashes
Searches for tags by name
Sourcepub async fn search_files(
&self,
query: Vec<SearchQueryEntry>,
options: FileSearchOptions,
) -> Result<SearchFilesResponse>
pub async fn search_files( &self, query: Vec<SearchQueryEntry>, options: FileSearchOptions, ) -> Result<SearchFilesResponse>
Searches for files
Sourcepub async fn search_file_hashes(
&self,
query: Vec<SearchQueryEntry>,
options: FileSearchOptions,
) -> Result<SearchFileHashesResponse>
pub async fn search_file_hashes( &self, query: Vec<SearchQueryEntry>, options: FileSearchOptions, ) -> Result<SearchFileHashesResponse>
Searches for file hashes
Sourcepub async fn get_file_metadata<M: FileMetadataType>(
&self,
file_ids: Vec<u64>,
hashes: Vec<String>,
) -> Result<FileMetadataResponse<M>>
pub async fn get_file_metadata<M: FileMetadataType>( &self, file_ids: Vec<u64>, hashes: Vec<String>, ) -> Result<FileMetadataResponse<M>>
Returns the metadata for a given list of file_ids or hashes
Sourcepub async fn get_file_metadata_by_identifier<M: FileMetadataType>(
&self,
id: FileIdentifier,
) -> Result<M::Response>
pub async fn get_file_metadata_by_identifier<M: FileMetadataType>( &self, id: FileIdentifier, ) -> Result<M::Response>
Returns the metadata for a single file identifier
Sourcepub async fn get_file(&self, id: FileIdentifier) -> Result<FileRecord>
pub async fn get_file(&self, id: FileIdentifier) -> Result<FileRecord>
Returns the bytes of a file from hydrus
Sourcepub async fn get_url_files<S: AsRef<str> + Debug>(
&self,
url: S,
) -> Result<GetUrlFilesResponse>
pub async fn get_url_files<S: AsRef<str> + Debug>( &self, url: S, ) -> Result<GetUrlFilesResponse>
Returns all files associated with the given url
Sourcepub async fn get_url_info<S: AsRef<str> + Debug>(
&self,
url: S,
) -> Result<GetUrlInfoResponse>
pub async fn get_url_info<S: AsRef<str> + Debug>( &self, url: S, ) -> Result<GetUrlInfoResponse>
Returns information about the given url
Sourcepub async fn add_url(&self, request: AddUrlRequest) -> Result<AddUrlResponse>
pub async fn add_url(&self, request: AddUrlRequest) -> Result<AddUrlResponse>
Adds an url to hydrus, optionally with additional tags and a destination page
Sourcepub async fn associate_urls(
&self,
urls: Vec<String>,
hashes: Vec<String>,
) -> Result<()>
pub async fn associate_urls( &self, urls: Vec<String>, hashes: Vec<String>, ) -> Result<()>
Associates urls with the given file hashes
Sourcepub async fn disassociate_urls(
&self,
urls: Vec<String>,
hashes: Vec<String>,
) -> Result<()>
pub async fn disassociate_urls( &self, urls: Vec<String>, hashes: Vec<String>, ) -> Result<()>
Disassociates urls with the given file hashes
Sourcepub async fn set_notes(
&self,
id: FileIdentifier,
notes: HashMap<String, String>,
) -> Result<()>
pub async fn set_notes( &self, id: FileIdentifier, notes: HashMap<String, String>, ) -> Result<()>
Sets the notes for the file
Sourcepub async fn delete_notes(
&self,
id: FileIdentifier,
note_names: Vec<String>,
) -> Result<()>
pub async fn delete_notes( &self, id: FileIdentifier, note_names: Vec<String>, ) -> Result<()>
Deletes the notes of a file
Sourcepub async fn get_pages(&self) -> Result<GetPagesResponse>
pub async fn get_pages(&self) -> Result<GetPagesResponse>
Returns all pages of the client
Sourcepub async fn get_page_info<S: AsRef<str> + Debug>(
&self,
page_key: S,
) -> Result<GetPageInfoResponse>
pub async fn get_page_info<S: AsRef<str> + Debug>( &self, page_key: S, ) -> Result<GetPageInfoResponse>
Returns information about a single page
Sourcepub async fn focus_page<S: ToString + Debug>(&self, page_key: S) -> Result<()>
pub async fn focus_page<S: ToString + Debug>(&self, page_key: S) -> Result<()>
Focuses a page in the client
Sourcepub async fn add_files_to_page<S: ToString + Debug>(
&self,
page_key: S,
file_ids: Vec<u64>,
hashes: Vec<String>,
) -> Result<()>
pub async fn add_files_to_page<S: ToString + Debug>( &self, page_key: S, file_ids: Vec<u64>, hashes: Vec<String>, ) -> Result<()>
Adds files to a page
Returns all cookies for the given domain
Sets some cookies for some websites.
Each entry needs to be in the format [<name>, <value>, <domain>, <path>, <expires>]
with the types [String, String, String, String, u64]