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

Method upload_attestation

atomic-remote/src/http/upload.rs:329–367  ·  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

327 /// * `hash` - The base32-encoded hash of the attestation.
328 /// * `data` - The raw serialized attestation bytes (.attest format).
329 pub async fn upload_attestation(&self, hash: &str, data: Bytes) -> RemoteResult<()> {
330 let url = format!("{}?attest={}", self.base_url, hash);
331 debug!("POST attest: {} ({} bytes)", url, data.len());
332
333 let response = self
334 .client
335 .post(&url)
336 .header(CONTENT_TYPE, "application/octet-stream")
337 .body(data)
338 .send()
339 .await
340 .map_err(|e| RemoteError::connection_failed(&url, e))?;
341
342 crate::check_min_version_header(response.headers());
343 let status = response.status();
344
345 match status {
346 StatusCode::OK => {
347 debug!("Successfully uploaded attestation {}", hash);
348 Ok(())
349 }
350 StatusCode::NOT_FOUND => Err(RemoteError::repo_not_found(&url)),
351 StatusCode::UNAUTHORIZED | StatusCode::FORBIDDEN => {
352 let msg = response.text().await.unwrap_or_default();
353 Err(RemoteError::auth_failed(&url, msg))
354 }
355 StatusCode::BAD_REQUEST => {
356 let msg = response.text().await.unwrap_or_default();
357 Err(RemoteError::protocol(format!(
358 "Failed to upload attestation: {}",
359 msg
360 )))
361 }
362 _ => {
363 let msg = response.text().await.unwrap_or_default();
364 Err(RemoteError::http(status.as_u16(), msg))
365 }
366 }
367 }
368
369 /// Upload a provenance graph to the remote server.
370 ///

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