Skip to main content

rust_genai_types/
files.rs

1use serde::{Deserialize, Serialize};
2
3use crate::enums::{FileSource, FileState};
4use crate::http::{HttpOptions, HttpResponse};
5
6/// Status of a file that failed to process.
7#[derive(Debug, Clone, Serialize, Deserialize, Default)]
8#[serde(rename_all = "camelCase")]
9pub struct FileStatus {
10    #[serde(skip_serializing_if = "Option::is_none")]
11    pub details: Option<Vec<serde_json::Value>>,
12    #[serde(skip_serializing_if = "Option::is_none")]
13    pub message: Option<String>,
14    #[serde(skip_serializing_if = "Option::is_none")]
15    pub code: Option<i32>,
16}
17
18/// A file uploaded to the API.
19#[derive(Debug, Clone, Serialize, Deserialize, Default)]
20#[serde(rename_all = "camelCase")]
21pub struct File {
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub name: Option<String>,
24    #[serde(skip_serializing_if = "Option::is_none")]
25    pub display_name: Option<String>,
26    #[serde(skip_serializing_if = "Option::is_none")]
27    pub mime_type: Option<String>,
28    #[serde(skip_serializing_if = "Option::is_none")]
29    pub size_bytes: Option<String>,
30    #[serde(skip_serializing_if = "Option::is_none")]
31    pub create_time: Option<String>,
32    #[serde(skip_serializing_if = "Option::is_none")]
33    pub expiration_time: Option<String>,
34    #[serde(skip_serializing_if = "Option::is_none")]
35    pub update_time: Option<String>,
36    #[serde(skip_serializing_if = "Option::is_none")]
37    pub sha256_hash: Option<String>,
38    #[serde(skip_serializing_if = "Option::is_none")]
39    pub uri: Option<String>,
40    #[serde(skip_serializing_if = "Option::is_none")]
41    pub download_uri: Option<String>,
42    #[serde(skip_serializing_if = "Option::is_none")]
43    pub state: Option<FileState>,
44    #[serde(skip_serializing_if = "Option::is_none")]
45    pub source: Option<FileSource>,
46    #[serde(skip_serializing_if = "Option::is_none")]
47    pub video_metadata: Option<serde_json::Value>,
48    #[serde(skip_serializing_if = "Option::is_none")]
49    pub error: Option<FileStatus>,
50}
51
52/// List files request configuration.
53#[derive(Debug, Clone, Serialize, Deserialize, Default)]
54#[serde(rename_all = "camelCase")]
55pub struct ListFilesConfig {
56    /// Optional. HTTP request overrides (SDK only, not sent to API).
57    #[serde(skip_serializing, skip_deserializing)]
58    pub http_options: Option<HttpOptions>,
59    #[serde(skip_serializing_if = "Option::is_none")]
60    pub page_size: Option<i32>,
61    #[serde(skip_serializing_if = "Option::is_none")]
62    pub page_token: Option<String>,
63}
64
65/// Response for listing files.
66#[derive(Debug, Clone, Serialize, Deserialize, Default)]
67#[serde(rename_all = "camelCase")]
68pub struct ListFilesResponse {
69    /// Optional. Used to retain the full HTTP response.
70    #[serde(skip_serializing_if = "Option::is_none")]
71    pub sdk_http_response: Option<HttpResponse>,
72    #[serde(skip_serializing_if = "Option::is_none")]
73    pub next_page_token: Option<String>,
74    #[serde(skip_serializing_if = "Option::is_none")]
75    pub files: Option<Vec<File>>,
76}
77
78/// Create file request configuration (resumable upload start).
79#[derive(Debug, Clone, Serialize, Deserialize, Default)]
80#[serde(rename_all = "camelCase")]
81pub struct CreateFileConfig {
82    /// Optional. HTTP request overrides (SDK only, not sent to API).
83    #[serde(skip_serializing, skip_deserializing)]
84    pub http_options: Option<HttpOptions>,
85    /// Optional. If true, returns the raw HTTP response body in `sdk_http_response.body` (SDK only).
86    #[serde(skip_serializing, skip_deserializing)]
87    pub should_return_http_response: Option<bool>,
88}
89
90/// Response for creating a file (resumable upload start).
91#[derive(Debug, Clone, Serialize, Deserialize, Default)]
92#[serde(rename_all = "camelCase")]
93pub struct CreateFileResponse {
94    /// Optional. Used to retain the full HTTP response.
95    #[serde(skip_serializing_if = "Option::is_none")]
96    pub sdk_http_response: Option<HttpResponse>,
97}
98
99/// Upload file configuration.
100#[derive(Debug, Clone, Serialize, Deserialize, Default)]
101#[serde(rename_all = "camelCase")]
102pub struct UploadFileConfig {
103    /// Optional. HTTP request overrides (SDK only, not sent to API).
104    #[serde(skip_serializing, skip_deserializing)]
105    pub http_options: Option<HttpOptions>,
106    #[serde(skip_serializing_if = "Option::is_none")]
107    pub name: Option<String>,
108    #[serde(skip_serializing_if = "Option::is_none")]
109    pub mime_type: Option<String>,
110    #[serde(skip_serializing_if = "Option::is_none")]
111    pub display_name: Option<String>,
112}
113
114/// Download file configuration.
115#[derive(Debug, Clone, Serialize, Deserialize, Default)]
116#[serde(rename_all = "camelCase")]
117pub struct DownloadFileConfig {
118    /// Optional. HTTP request overrides (SDK only, not sent to API).
119    #[serde(skip_serializing, skip_deserializing)]
120    pub http_options: Option<HttpOptions>,
121}
122
123/// Get file request configuration.
124#[derive(Debug, Clone, Serialize, Deserialize, Default)]
125#[serde(rename_all = "camelCase")]
126pub struct GetFileConfig {
127    /// Optional. HTTP request overrides (SDK only, not sent to API).
128    #[serde(skip_serializing, skip_deserializing)]
129    pub http_options: Option<HttpOptions>,
130}
131
132/// Delete file request configuration.
133#[derive(Debug, Clone, Serialize, Deserialize, Default)]
134#[serde(rename_all = "camelCase")]
135pub struct DeleteFileConfig {
136    /// Optional. HTTP request overrides (SDK only, not sent to API).
137    #[serde(skip_serializing, skip_deserializing)]
138    pub http_options: Option<HttpOptions>,
139}
140
141/// Register files configuration.
142#[derive(Debug, Clone, Serialize, Deserialize, Default)]
143#[serde(rename_all = "camelCase")]
144pub struct RegisterFilesConfig {
145    /// Optional. HTTP request overrides (SDK only, not sent to API).
146    #[serde(skip_serializing, skip_deserializing)]
147    pub http_options: Option<HttpOptions>,
148    /// Optional. If true, returns the raw HTTP response body in `sdk_http_response.body` (SDK only).
149    #[serde(skip_serializing, skip_deserializing)]
150    pub should_return_http_response: Option<bool>,
151}
152
153/// Response for registering files.
154#[derive(Debug, Clone, Serialize, Deserialize, Default)]
155#[serde(rename_all = "camelCase")]
156pub struct RegisterFilesResponse {
157    /// Optional. Used to retain the full HTTP response.
158    #[serde(skip_serializing_if = "Option::is_none")]
159    pub sdk_http_response: Option<HttpResponse>,
160    /// The registered files.
161    #[serde(skip_serializing_if = "Option::is_none")]
162    pub files: Option<Vec<File>>,
163}
164
165/// Response for deleting a file.
166#[derive(Debug, Clone, Serialize, Deserialize, Default)]
167#[serde(rename_all = "camelCase")]
168pub struct DeleteFileResponse {
169    /// Optional. Used to retain the full HTTP response.
170    #[serde(skip_serializing_if = "Option::is_none")]
171    pub sdk_http_response: Option<HttpResponse>,
172}