MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / upload_attestation

Method upload_attestation

atomic-remote/src/http/upload.rs:298–336  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

296 /// * `hash` - The base32-encoded hash of the attestation.
297 /// * `data` - The raw serialized attestation bytes (.attest format).
298 pub async fn upload_attestation(&self, hash: &str, data: Bytes) -> RemoteResult<()> {
299 let url = format!("{}?attest={}", self.base_url, hash);
300 debug!("POST attest: {} ({} bytes)", url, data.len());
301
302 let response = self
303 .client
304 .post(&url)
305 .header(CONTENT_TYPE, "application/octet-stream")
306 .body(data)
307 .send()
308 .await
309 .map_err(|e| RemoteError::connection_failed(&url, e))?;
310
311 crate::check_min_version_header(response.headers());
312 let status = response.status();
313
314 match status {
315 StatusCode::OK => {
316 debug!("Successfully uploaded attestation {}", hash);
317 Ok(())
318 }
319 StatusCode::NOT_FOUND => Err(RemoteError::repo_not_found(&url)),
320 StatusCode::UNAUTHORIZED | StatusCode::FORBIDDEN => {
321 let msg = response.text().await.unwrap_or_default();
322 Err(RemoteError::auth_failed(&url, msg))
323 }
324 StatusCode::BAD_REQUEST => {
325 let msg = response.text().await.unwrap_or_default();
326 Err(RemoteError::protocol(format!(
327 "Failed to upload attestation: {}",
328 msg
329 )))
330 }
331 _ => {
332 let msg = response.text().await.unwrap_or_default();
333 Err(RemoteError::http(status.as_u16(), msg))
334 }
335 }
336 }
337
338 /// Upload a provenance graph to the remote server.
339 ///

Callers 1

run_asyncMethod · 0.80

Calls 5

check_min_version_headerFunction · 0.85
postMethod · 0.80
textMethod · 0.80
headerMethod · 0.45
statusMethod · 0.45

Tested by

no test coverage detected