1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/*
* OpenAI API
*
* The OpenAI REST API. Please see https://platform.openai.com/docs/api-reference for more details.
*
* The version of the OpenAPI document: 2.3.0
*
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
/// Upload : The Upload object can accept byte chunks in the form of Parts.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct Upload {
/// The Upload unique identifier, which can be referenced in API endpoints.
#[serde(rename = "id")]
pub id: String,
/// The Unix timestamp (in seconds) for when the Upload was created.
#[serde(rename = "created_at")]
pub created_at: i32,
/// The name of the file to be uploaded.
#[serde(rename = "filename")]
pub filename: String,
/// The intended number of bytes to be uploaded.
#[serde(rename = "bytes")]
pub bytes: i32,
/// The intended purpose of the file. [Please refer here](/docs/api-reference/files/object#files/object-purpose) for acceptable values.
#[serde(rename = "purpose")]
pub purpose: String,
/// The status of the Upload.
#[serde(rename = "status")]
pub status: Status,
/// The Unix timestamp (in seconds) for when the Upload will expire.
#[serde(rename = "expires_at")]
pub expires_at: i32,
/// The object type, which is always \"upload\".
#[serde(rename = "object", skip_serializing_if = "Option::is_none")]
pub object: Option<Object>,
/// The ready File object after the Upload is completed.
#[serde(rename = "file", skip_serializing_if = "Option::is_none")]
pub file: Option<Box<models::OpenAiFile>>,
}
impl Upload {
/// The Upload object can accept byte chunks in the form of Parts.
pub fn new(
id: String,
created_at: i32,
filename: String,
bytes: i32,
purpose: String,
status: Status,
expires_at: i32,
) -> Upload {
Upload {
id,
created_at,
filename,
bytes,
purpose,
status,
expires_at,
object: None,
file: None,
}
}
}
/// The status of the Upload.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Status {
#[serde(rename = "pending")]
Pending,
#[serde(rename = "completed")]
Completed,
#[serde(rename = "cancelled")]
Cancelled,
#[serde(rename = "expired")]
Expired,
}
impl Default for Status {
fn default() -> Status {
Self::Pending
}
}
/// The object type, which is always \"upload\".
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Object {
#[serde(rename = "upload")]
Upload,
}
impl Default for Object {
fn default() -> Object {
Self::Upload
}
}
impl std::fmt::Display for Upload {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match serde_json::to_string(self) {
Ok(s) => write!(f, "{}", s),
Err(_) => Err(std::fmt::Error),
}
}
}