spatio_sdk/models/spatio_file.rs
1/*
2 * SpatioAPI
3 *
4 * The REST API that owns every resource in your Spatio workspace: notes, sheets, slides, tasks, calendar events, mail, chat, files, and contacts. SpatioMCP wraps this API; Spatio Desktop reads from it. You can call it directly from your own code. All requests must be authenticated with a Personal Access Token (`Authorization: Bearer pat_...`) or an OAuth 2.1 access token, and use HTTPS. Official SDKs (MIT, generated from this spec on every release): - TypeScript: https://github.com/spatio-labs/spatio-ts (`npm install @spatio-labs/spatio-ts`) - Python: https://github.com/spatio-labs/spatio-py (`pip install spatio-sdk`) - Go: https://github.com/spatio-labs/spatio-go (`go get github.com/spatio-labs/spatio-go`) This specification is generated from the platform-service Go source on every push to `main`. The spec, not hand-written documentation, is the source of truth: server stubs and SDKs are generated from it, and any drift between the spec and the running service fails CI.
5 *
6 * The version of the OpenAPI document: v1
7 * Contact: hello@spatio.app
8 * Generated by: https://openapi-generator.tech
9 */
10
11use crate::models;
12use serde::{Deserialize, Serialize};
13
14/// SpatioFile : A user file. Files belong to one connected file provider account (`accountId` + `provider`); native storage uses Spatio's block-store, external providers (Google Drive, Dropbox, etc.) round-trip through Spatio. Schema name is `SpatioFile` (not `File`) to avoid the `java.io.File` collision that breaks the Kotlin SDK generator when the schema is named `File`.
15#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
16pub struct SpatioFile {
17 #[serde(rename = "id")]
18 pub id: String,
19 #[serde(rename = "provider", skip_serializing_if = "Option::is_none")]
20 pub provider: Option<String>,
21 #[serde(rename = "accountId", skip_serializing_if = "Option::is_none")]
22 pub account_id: Option<String>,
23 #[serde(rename = "name")]
24 pub name: String,
25 /// Bytes.
26 #[serde(rename = "size")]
27 pub size: i64,
28 #[serde(rename = "mimeType")]
29 pub mime_type: String,
30 #[serde(rename = "folderId", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
31 pub folder_id: Option<Option<String>>,
32 /// Backing storage class — `r2`, `gdrive`, `dropbox`, etc. Provider-specific; treat as opaque.
33 #[serde(rename = "storageType")]
34 pub storage_type: String,
35 /// Pre-signed download URL when one is cached on the row. Use `GET /v1/files/{id}/download` for a guaranteed-fresh URL — this field can lag past expiry.
36 #[serde(rename = "downloadUrl", skip_serializing_if = "Option::is_none")]
37 pub download_url: Option<String>,
38 #[serde(rename = "metadata", skip_serializing_if = "Option::is_none")]
39 pub metadata: Option<std::collections::HashMap<String, serde_json::Value>>,
40 #[serde(rename = "createdAt")]
41 pub created_at: chrono::DateTime<chrono::FixedOffset>,
42 #[serde(rename = "updatedAt")]
43 pub updated_at: chrono::DateTime<chrono::FixedOffset>,
44}
45
46impl SpatioFile {
47 /// A user file. Files belong to one connected file provider account (`accountId` + `provider`); native storage uses Spatio's block-store, external providers (Google Drive, Dropbox, etc.) round-trip through Spatio. Schema name is `SpatioFile` (not `File`) to avoid the `java.io.File` collision that breaks the Kotlin SDK generator when the schema is named `File`.
48 pub fn new(id: String, name: String, size: i64, mime_type: String, storage_type: String, created_at: chrono::DateTime<chrono::FixedOffset>, updated_at: chrono::DateTime<chrono::FixedOffset>) -> SpatioFile {
49 SpatioFile {
50 id,
51 provider: None,
52 account_id: None,
53 name,
54 size,
55 mime_type,
56 folder_id: None,
57 storage_type,
58 download_url: None,
59 metadata: None,
60 created_at,
61 updated_at,
62 }
63 }
64}
65