use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct UploadCreateRequest {
pub bytes: i64,
pub filename: String,
pub mime_type: String,
pub purpose: String,
}
impl UploadCreateRequest {
pub fn new(
bytes: i64,
filename: impl Into<String>,
mime_type: impl Into<String>,
purpose: impl Into<String>,
) -> Self {
Self {
bytes,
filename: filename.into(),
mime_type: mime_type.into(),
purpose: purpose.into(),
}
}
}
#[derive(Debug, Clone, Serialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct UploadCompleteRequest {
pub part_ids: Vec<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub md5: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
#[non_exhaustive]
pub enum UploadStatus {
#[serde(rename = "pending")]
Pending,
#[serde(rename = "completed")]
Completed,
#[serde(rename = "cancelled")]
Cancelled,
#[serde(rename = "expired")]
Expired,
}
#[derive(Debug, Clone, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct Upload {
pub id: String,
pub object: String,
pub bytes: i64,
pub filename: String,
pub purpose: String,
pub status: UploadStatus,
pub created_at: i64,
#[serde(default)]
pub expires_at: Option<i64>,
#[serde(default)]
pub file: Option<serde_json::Value>,
}