feat: add sharing endpoints — share, link, revoke, public access
This commit is contained in:
@@ -40,3 +40,21 @@ pub struct RegisterLibraryPathRequest {
|
||||
pub struct UpdateMetadataRequest {
|
||||
pub data: std::collections::HashMap<String, serde_json::Value>,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize, utoipa::ToSchema)]
|
||||
pub struct ShareResourceRequest {
|
||||
pub shareable_type: String,
|
||||
pub shareable_id: uuid::Uuid,
|
||||
pub target_type: String,
|
||||
pub target_id: uuid::Uuid,
|
||||
pub role_id: uuid::Uuid,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize, utoipa::ToSchema)]
|
||||
pub struct GenerateShareLinkRequest {
|
||||
pub shareable_type: String,
|
||||
pub shareable_id: uuid::Uuid,
|
||||
pub access_level: Option<String>,
|
||||
pub expires_in_hours: Option<u64>,
|
||||
pub max_uses: Option<u32>,
|
||||
}
|
||||
|
||||
@@ -132,3 +132,67 @@ pub struct IngestResponse {
|
||||
pub asset: AssetResponse,
|
||||
pub session_id: Uuid,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Serialize, utoipa::ToSchema)]
|
||||
pub struct ShareScopeResponse {
|
||||
pub scope_id: Uuid,
|
||||
pub scope_type: String,
|
||||
pub shareable_type: String,
|
||||
pub shareable_id: Uuid,
|
||||
pub created_at: DateTime<Utc>,
|
||||
}
|
||||
|
||||
impl ShareScopeResponse {
|
||||
pub fn from_domain(scope: &domain::entities::ShareScope) -> Self {
|
||||
Self {
|
||||
scope_id: *scope.scope_id.as_uuid(),
|
||||
scope_type: format!("{:?}", scope.scope_type),
|
||||
shareable_type: format!("{:?}", scope.shareable_type),
|
||||
shareable_id: *scope.shareable_id.as_uuid(),
|
||||
created_at: *scope.created_at.as_datetime(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Serialize, utoipa::ToSchema)]
|
||||
pub struct ShareLinkResponse {
|
||||
pub scope_id: Uuid,
|
||||
pub token: String,
|
||||
pub access_level: String,
|
||||
pub expires_at: Option<DateTime<Utc>>,
|
||||
pub max_uses: Option<u32>,
|
||||
}
|
||||
|
||||
impl ShareLinkResponse {
|
||||
pub fn from_domain(link: &domain::entities::ShareLink) -> Self {
|
||||
Self {
|
||||
scope_id: *link.scope_id.as_uuid(),
|
||||
token: link.token.clone(),
|
||||
access_level: format!("{:?}", link.access_level),
|
||||
expires_at: link.expires_at.as_ref().map(|d| *d.as_datetime()),
|
||||
max_uses: link.max_uses,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Serialize, utoipa::ToSchema)]
|
||||
pub struct SharedResourceResponse {
|
||||
pub scope_id: Uuid,
|
||||
pub shareable_type: String,
|
||||
pub shareable_id: Uuid,
|
||||
pub access_level: String,
|
||||
}
|
||||
|
||||
impl SharedResourceResponse {
|
||||
pub fn from_domain(
|
||||
scope: &domain::entities::ShareScope,
|
||||
access_level: domain::entities::LinkAccessLevel,
|
||||
) -> Self {
|
||||
Self {
|
||||
scope_id: *scope.scope_id.as_uuid(),
|
||||
shareable_type: format!("{:?}", scope.shareable_type),
|
||||
shareable_id: *scope.shareable_id.as_uuid(),
|
||||
access_level: format!("{:?}", access_level),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user