shardline_server/model.rs
1use std::collections::BTreeMap;
2
3use serde::{Deserialize, Serialize};
4use shardline_protocol::{RepositoryProvider, TokenScope};
5
6/// Health response returned by the HTTP server.
7#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
8pub struct HealthResponse {
9 /// Service status.
10 pub status: String,
11}
12
13/// Readiness response returned by the HTTP server.
14#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
15pub struct ReadyResponse {
16 /// Service status.
17 pub status: String,
18 /// Selected runtime role.
19 pub server_role: String,
20 /// Enabled runtime protocol frontends.
21 pub server_frontends: Vec<String>,
22 /// Selected metadata backend.
23 pub metadata_backend: String,
24 /// Selected immutable object-storage backend.
25 pub object_backend: String,
26 /// Selected reconstruction-cache backend.
27 pub cache_backend: String,
28}
29
30/// Upload result for a single chunk.
31#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
32pub struct UploadChunkResult {
33 /// Chunk hash in Xet CAS API hexadecimal ordering.
34 pub hash: String,
35 /// Byte offset inside the uploaded file.
36 pub offset: u64,
37 /// Chunk byte length.
38 pub length: u64,
39 /// Whether the upload inserted new chunk bytes.
40 pub inserted: bool,
41}
42
43/// File upload response.
44#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
45pub struct UploadFileResponse {
46 /// Uploaded file identifier.
47 pub file_id: String,
48 /// Immutable content identity for this uploaded file version.
49 pub content_hash: String,
50 /// Total uploaded byte length.
51 pub total_bytes: u64,
52 /// Server chunk size used for this upload.
53 pub chunk_size: u64,
54 /// Number of chunks inserted.
55 pub inserted_chunks: u64,
56 /// Number of chunks already present.
57 pub reused_chunks: u64,
58 /// Number of new bytes written to chunk storage.
59 pub stored_bytes: u64,
60 /// Ordered chunk upload results.
61 pub chunks: Vec<UploadChunkResult>,
62}
63
64/// Storage stats response.
65#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
66pub struct ServerStatsResponse {
67 /// Number of chunk objects stored.
68 pub chunks: u64,
69 /// Total bytes stored across chunk objects.
70 pub chunk_bytes: u64,
71 /// Number of file records stored.
72 pub files: u64,
73}
74
75/// Provider-backed CAS token issuance request.
76#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
77pub struct ProviderTokenIssueRequest {
78 /// Authenticated provider subject to authorize.
79 pub subject: String,
80 /// Repository owner or namespace.
81 pub owner: String,
82 /// Repository name.
83 pub repo: String,
84 /// Optional revision context. When omitted, the provider default revision is used.
85 pub revision: Option<String>,
86 /// Requested CAS scope.
87 pub scope: TokenScope,
88}
89
90/// Provider-backed CAS token issuance response.
91#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
92pub struct ProviderTokenIssueResponse {
93 /// Signed bearer token for subsequent CAS requests.
94 pub token: String,
95 /// Issuer embedded into the token.
96 pub issuer: String,
97 /// Subject embedded into the token.
98 pub subject: String,
99 /// Repository hosting provider.
100 pub provider: RepositoryProvider,
101 /// Repository owner or namespace.
102 pub owner: String,
103 /// Repository name.
104 pub repo: String,
105 /// Scoped revision.
106 pub revision: Option<String>,
107 /// Granted CAS scope.
108 pub scope: TokenScope,
109 /// Token expiration timestamp as Unix seconds.
110 pub expires_at_unix_seconds: u64,
111}
112
113/// Xet CAS access-token response consumed by reference clients.
114#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
115#[serde(rename_all = "camelCase")]
116pub struct XetCasTokenResponse {
117 /// CAS server endpoint base URL.
118 pub cas_url: String,
119 /// Token expiration timestamp as Unix seconds.
120 pub exp: u64,
121 /// Signed bearer token for CAS requests.
122 pub access_token: String,
123}
124
125/// Git LFS authenticate response carrying Xet custom-transfer bootstrap headers.
126#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
127pub struct GitLfsAuthenticateResponse {
128 /// CAS endpoint URL.
129 pub href: String,
130 /// Headers consumed by the Xet custom transfer adapter.
131 pub header: BTreeMap<String, String>,
132 /// Relative token lifetime in seconds.
133 pub expires_in: u64,
134}
135
136/// OCI registry bearer-token exchange response.
137#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
138pub struct OciRegistryTokenResponse {
139 /// Bearer token returned by the registry token service.
140 pub token: String,
141 /// Duplicate bearer token field used by some clients.
142 pub access_token: String,
143 /// Relative token lifetime in seconds.
144 pub expires_in: u64,
145}
146
147/// Provider webhook handling response.
148#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
149pub struct ProviderWebhookResponse {
150 /// Repository hosting provider.
151 pub provider: RepositoryProvider,
152 /// Repository owner or namespace.
153 pub owner: String,
154 /// Repository name.
155 pub repo: String,
156 /// Provider delivery identifier.
157 pub delivery_id: String,
158 /// Normalized webhook event kind.
159 pub event_kind: String,
160 /// New repository owner or namespace when the event renamed the repository.
161 #[serde(skip_serializing_if = "Option::is_none")]
162 pub new_owner: Option<String>,
163 /// New repository name when the event renamed the repository.
164 #[serde(skip_serializing_if = "Option::is_none")]
165 pub new_repo: Option<String>,
166 /// Updated revision when the event described a push.
167 #[serde(skip_serializing_if = "Option::is_none")]
168 pub revision: Option<String>,
169 /// Number of affected immutable file-version records.
170 pub affected_file_versions: u64,
171 /// Number of distinct affected chunk objects.
172 pub affected_chunks: u64,
173 /// Number of retention holds inserted or refreshed by the event.
174 pub applied_holds: u64,
175 /// Retention applied to newly created holds, when the event mutated lifecycle state.
176 #[serde(skip_serializing_if = "Option::is_none")]
177 pub retention_seconds: Option<u64>,
178}