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

Method upload_attestation

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

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 ///

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