ironflow_api/entities/
approval_delegation.rs1use chrono::{DateTime, Utc};
4use serde::{Deserialize, Serialize};
5use uuid::Uuid;
6use validator::Validate;
7
8use ironflow_store::entities::ApprovalDelegation;
9
10#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
12#[derive(Debug, Serialize)]
13pub struct ApprovalDelegationResponse {
14 pub id: Uuid,
16 pub from_user_id: Uuid,
18 pub to_user_id: Uuid,
20 pub valid_from: DateTime<Utc>,
22 pub valid_until: DateTime<Utc>,
24 pub workflow_filter: Option<String>,
26 pub created_at: DateTime<Utc>,
28}
29
30impl From<ApprovalDelegation> for ApprovalDelegationResponse {
31 fn from(d: ApprovalDelegation) -> Self {
32 Self {
33 id: d.id,
34 from_user_id: d.from_user_id,
35 to_user_id: d.to_user_id,
36 valid_from: d.valid_from,
37 valid_until: d.valid_until,
38 workflow_filter: d.workflow_filter,
39 created_at: d.created_at,
40 }
41 }
42}
43
44#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
49#[derive(Debug, Deserialize, Validate)]
50pub struct CreateApprovalDelegationRequest {
51 pub to_user_id: Uuid,
53 pub valid_from: Option<DateTime<Utc>>,
55 pub valid_until: DateTime<Utc>,
57 pub workflow_filter: Option<String>,
59}
60
61#[cfg_attr(feature = "openapi", derive(utoipa::IntoParams, utoipa::ToSchema))]
67#[derive(Debug, Deserialize)]
68pub struct ListApprovalDelegationsQuery {
69 pub from_user_id: Option<Uuid>,
71 pub to_user_id: Option<Uuid>,
73 pub page: Option<u32>,
75 pub per_page: Option<u32>,
77}