Upload an attestation to the remote server. Attestations are graph-level audit nodes that capture metadata about a set of changes (cost, tokens, model usage, duration). They are stored separately from changes and don't modify the content graph. # Arguments `hash` - The base32-encoded hash of the attestation. `data` - The raw serialized attestation bytes (.attest format).
(&self, hash: &str, data: Bytes)
| 193 | /// * `hash` - The base32-encoded hash of the attestation. |
| 194 | /// * `data` - The raw serialized attestation bytes (.attest format). |
| 195 | pub async fn upload_attestation(&self, hash: &str, data: Bytes) -> RemoteResult<()> { |
| 196 | let url = format!("{}?attest={}", self.base_url, hash); |
| 197 | debug!("POST attest: {} ({} bytes)", url, data.len()); |
| 198 | |
| 199 | let response = self |
| 200 | .client |
| 201 | .post(&url) |
| 202 | .header(CONTENT_TYPE, "application/octet-stream") |
| 203 | .body(data) |
| 204 | .send() |
| 205 | .await |
| 206 | .map_err(|e| RemoteError::connection_failed(&url, e))?; |
| 207 | |
| 208 | crate::check_min_version_header(response.headers()); |
| 209 | let status = response.status(); |
| 210 | |
| 211 | match status { |
| 212 | StatusCode::OK => { |
| 213 | debug!("Successfully uploaded attestation {}", hash); |
| 214 | Ok(()) |
| 215 | } |
| 216 | StatusCode::NOT_FOUND => Err(RemoteError::repo_not_found(&url)), |
| 217 | StatusCode::UNAUTHORIZED | StatusCode::FORBIDDEN => { |
| 218 | let msg = response.text().await.unwrap_or_default(); |
| 219 | Err(RemoteError::auth_failed(&url, msg)) |
| 220 | } |
| 221 | StatusCode::BAD_REQUEST => { |
| 222 | let msg = response.text().await.unwrap_or_default(); |
| 223 | Err(RemoteError::protocol(format!( |
| 224 | "Failed to upload attestation: {}", |
| 225 | msg |
| 226 | ))) |
| 227 | } |
| 228 | _ => { |
| 229 | let msg = response.text().await.unwrap_or_default(); |
| 230 | Err(RemoteError::http(status.as_u16(), msg)) |
| 231 | } |
| 232 | } |
| 233 | } |
| 234 | |
| 235 | /// Upload a provenance graph to the remote server. |
| 236 | /// |