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

Method download_attestation

atomic-remote/src/http/queries.rs:340–376  ·  view source on GitHub ↗

Download an attestation from the remote server. # Arguments `hash` - The base32-encoded hash of the attestation. # Returns The raw attestation bytes.

(&self, hash: &str)

Source from the content-addressed store, hash-verified

338 ///
339 /// The raw attestation bytes.
340 pub async fn download_attestation(&self, hash: &str) -> RemoteResult<Bytes> {
341 let url = format!("{}?attest={}", self.base_url, hash);
342 debug!("GET attest: {}", url);
343
344 let response = self
345 .client
346 .get(&url)
347 .send()
348 .await
349 .map_err(|e| RemoteError::connection_failed(&url, e))?;
350
351 crate::check_min_version_header(response.headers());
352 let status = response.status();
353
354 match status {
355 StatusCode::OK => {
356 let data = response
357 .bytes()
358 .await
359 .map_err(|e| RemoteError::connection_failed(&url, e))?;
360 debug!("Downloaded attestation {} ({} bytes)", hash, data.len());
361 Ok(data)
362 }
363 StatusCode::NOT_FOUND => Err(RemoteError::protocol(format!(
364 "Attestation not found: {}",
365 hash
366 ))),
367 StatusCode::UNAUTHORIZED | StatusCode::FORBIDDEN => {
368 let msg = response.text().await.unwrap_or_default();
369 Err(RemoteError::auth_failed(&url, msg))
370 }
371 _ => {
372 let msg = response.text().await.unwrap_or_default();
373 Err(RemoteError::http(status.as_u16(), msg))
374 }
375 }
376 }
377
378 /// List all views on the remote repository.
379 ///

Callers

nothing calls this directly

Calls 5

check_min_version_headerFunction · 0.85
textMethod · 0.80
getMethod · 0.65
statusMethod · 0.45
bytesMethod · 0.45

Tested by

no test coverage detected