openai_types/uploads/
manual.rs1use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Clone, Serialize)]
7#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
8pub struct UploadCreateRequest {
9 pub bytes: i64,
11
12 pub filename: String,
14
15 pub mime_type: String,
17
18 pub purpose: String,
20}
21
22impl UploadCreateRequest {
23 pub fn new(
24 bytes: i64,
25 filename: impl Into<String>,
26 mime_type: impl Into<String>,
27 purpose: impl Into<String>,
28 ) -> Self {
29 Self {
30 bytes,
31 filename: filename.into(),
32 mime_type: mime_type.into(),
33 purpose: purpose.into(),
34 }
35 }
36}
37
38#[derive(Debug, Clone, Serialize)]
40#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
41pub struct UploadCompleteRequest {
42 pub part_ids: Vec<String>,
43 #[serde(skip_serializing_if = "Option::is_none")]
44 pub md5: Option<String>,
45}
46
47#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
49#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
50#[non_exhaustive]
51pub enum UploadStatus {
52 #[serde(rename = "pending")]
53 Pending,
54 #[serde(rename = "completed")]
55 Completed,
56 #[serde(rename = "cancelled")]
57 Cancelled,
58 #[serde(rename = "expired")]
59 Expired,
60}
61
62#[derive(Debug, Clone, Deserialize)]
64#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
65pub struct Upload {
66 pub id: String,
67 pub object: String,
68 pub bytes: i64,
69 pub filename: String,
70 pub purpose: String,
71 pub status: UploadStatus,
72 pub created_at: i64,
73 #[serde(default)]
74 pub expires_at: Option<i64>,
75 #[serde(default)]
76 pub file: Option<serde_json::Value>,
77}