hotdata 0.7.0

Powerful data platform API for datasets, queries, and analytics.
Documentation
/*
 * 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,
        }
    }
}