stately_arrow/response.rs
1//! Response types for stately-arrow API endpoints.
2
3use std::collections::HashMap;
4
5use serde::{Deserialize, Serialize};
6
7/// Summary of items available in a connector.
8///
9/// The variant indicates what type of items were found based on the connector
10/// type and search context.
11#[non_exhaustive]
12#[derive(Debug, Clone, Serialize, Deserialize, utoipa::ToResponse, utoipa::ToSchema)]
13#[serde(tag = "type", content = "summary", rename_all = "snake_case")]
14#[schema(rename_all = "snake_case")]
15pub enum ListSummary {
16 /// List of database names (for database connectors at root level).
17 Databases(Vec<String>),
18 /// List of tables with metadata (for database connectors within a database).
19 Tables(Vec<TableSummary>),
20 /// List of path prefixes (for object store connectors at root level).
21 Paths(Vec<String>),
22 /// List of files with metadata (for object store connectors within a path).
23 Files(Vec<TableSummary>),
24}
25
26/// Response containing details from multiple connectors.
27#[derive(Debug, Clone, Serialize, Deserialize, utoipa::ToSchema, utoipa::ToResponse)]
28pub struct ConnectionDetailsResponse {
29 /// Map of connector IDs to their listing results.
30 pub connections: HashMap<String, ListSummary>,
31}
32
33/// Summary information about a table or file.
34#[derive(Debug, Clone, Serialize, Deserialize, utoipa::ToResponse, utoipa::ToSchema)]
35pub struct TableSummary {
36 /// Table or file name/path.
37 pub name: String,
38 /// Number of rows (if known).
39 pub rows: Option<u64>,
40 /// Size in bytes (if known).
41 pub size_bytes: Option<u64>,
42}