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
/*
* Hotdata API
*
* Powerful data platform API for managed databases, queries, and analytics.
*
* The version of the OpenAPI document: 1.0.0
* Contact: developers@hotdata.dev
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
/// UploadSessionResponse : A created upload session: everything needed to upload the bytes directly to storage and later finalize the upload.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct UploadSessionResponse {
/// One-time token that authorizes finalizing this upload. Returned exactly once at create time — store it; it cannot be retrieved again.
#[serde(rename = "finalize_token")]
pub finalize_token: String,
/// Headers you must send verbatim with each `PUT`. Currently always empty; present so a future mode can require signed headers without changing the response shape.
#[serde(rename = "headers")]
pub headers: std::collections::HashMap<String, String>,
/// Upload mode: `single` (upload the whole file with one `PUT` to `url`) or `multipart` (upload each part with one `PUT` to the matching entry in `part_urls`). Modeled as a string so additional modes can be added later without breaking clients.
#[serde(rename = "mode")]
pub mode: String,
/// For a `multipart` upload (both known-size and streaming), the size in bytes to split the file into: send bytes `[(i-1) * part_size, i * part_size)` as part *i*, with the last part carrying the remainder. Slice by this value — do **not** divide the file evenly by the number of parts, which can make a non-final part smaller than the 5 MiB minimum that storage requires (the upload then fails at finalize). Absent for `single` uploads.
#[serde(
rename = "part_size",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub part_size: Option<Option<i64>>,
/// For a known-size `multipart` upload, the per-part URLs in ascending part order: `PUT` your file's part *i* (1-based) to `part_urls[i - 1]` and keep each response's `ETag`, then pass the `{part_number, e_tag}` list to finalize. Absent for `single` uploads, and also absent for a streaming (unknown-size) `multipart` upload — there, mint part URLs on demand via `POST /v1/uploads/{upload_id}/parts`.
#[serde(
rename = "part_urls",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub part_urls: Option<Option<Vec<String>>>,
/// Identifier for this upload. Pass it to the finalize endpoint and to the managed-table load endpoint once finalized.
#[serde(rename = "upload_id")]
pub upload_id: String,
/// The URL to `PUT` the raw file bytes to, for a `single` upload. Short-lived — upload promptly and finalize. Absent for `multipart` uploads (use `part_urls`).
#[serde(
rename = "url",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub url: Option<Option<String>>,
}
impl UploadSessionResponse {
/// A created upload session: everything needed to upload the bytes directly to storage and later finalize the upload.
pub fn new(
finalize_token: String,
headers: std::collections::HashMap<String, String>,
mode: String,
upload_id: String,
) -> UploadSessionResponse {
UploadSessionResponse {
finalize_token,
headers,
mode,
part_size: None,
part_urls: None,
upload_id,
url: None,
}
}
}