Add more api calls

Add api to get a list of files by identifiers.
Add api to get all namespaces stored in the repo.

Signed-off-by: Trivernis <trivernis@protonmail.com>
pull/4/head
Trivernis 2 years ago
parent a723ebab95
commit 73c98e44a2

@ -1,6 +1,6 @@
[package]
name = "mediarepo-api"
version = "0.16.1"
version = "0.17.0"
edition = "2018"
license = "gpl-3"

@ -48,10 +48,17 @@ impl FileApi {
}
/// Returns a file by identifier
#[tracing::instrument(level = "debug", skip(self))]
pub async fn get_file(&self, id: FileIdentifier) -> ApiResult<FileMetadataResponse> {
self.emit_and_get("get_file", id, Some(Duration::from_secs(2))).await
}
/// Returns metadata for a range of files
#[tracing::instrument(level = "debug", skip(self, ids))]
pub async fn get_files(&self, ids: Vec<FileIdentifier>) -> ApiResult<Vec<FileMetadataResponse>> {
self.emit_and_get("get_files", ids, Some(Duration::from_secs(10))).await
}
/// Searches for a file by a list of tags
#[tracing::instrument(level = "debug", skip(self))]
pub async fn find_files(

@ -3,7 +3,7 @@ use crate::client_api::error::ApiResult;
use crate::client_api::IPCApi;
use crate::types::files::{GetFileTagsRequest, GetFilesTagsRequest};
use crate::types::identifier::FileIdentifier;
use crate::types::tags::{ChangeFileTagsRequest, TagResponse};
use crate::types::tags::{ChangeFileTagsRequest, NamespaceResponse, TagResponse};
use async_trait::async_trait;
use bromine::context::{PoolGuard, PooledContext};
use bromine::ipc::context::Context;
@ -42,6 +42,12 @@ impl TagApi {
self.emit_and_get("all_tags", (), Some(Duration::from_secs(2))).await
}
/// Returns a list of all namespaces stored in the repo
#[tracing::instrument(level = "debug", skip(self))]
pub async fn get_all_namespaces(&self) -> ApiResult<Vec<NamespaceResponse>> {
self.emit_and_get("all_namespaces", (), Some(Duration::from_secs(2))).await
}
/// Returns a list of all tags for a file
#[tracing::instrument(level = "debug", skip(self))]
pub async fn get_tags_for_file(&self, id: FileIdentifier) -> ApiResult<Vec<TagResponse>> {

@ -8,6 +8,12 @@ pub struct TagResponse {
pub name: String,
}
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct NamespaceResponse {
pub id: i64,
pub name: String,
}
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct ChangeFileTagsRequest {
pub file_id: FileIdentifier,

Loading…
Cancel
Save