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

Method put_view_manifest

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

Declare a view's identity and change log on the remote. POSTs the manifest text (header `name\tscope\tparent\tstate` plus the change log, one base32 hash per line). The server applies it declaratively: creates the view with the declared scope/parent if absent, fast-forwards its log, and verifies the resulting merkle equals the declared state. Every referenced change must already be on the server

(&self, view: &str, manifest_text: String)

Source from the content-addressed store, hash-verified

119 /// String-level like the rest of this client: serialization lives in
120 /// `atomic-repository`.
121 pub async fn put_view_manifest(&self, view: &str, manifest_text: String) -> RemoteResult<()> {
122 let url = format!("{}?view-manifest={}", self.base_url, view);
123 debug!(
124 "POST view-manifest: {} ({} bytes)",
125 url,
126 manifest_text.len()
127 );
128
129 let response = self
130 .client
131 .post(&url)
132 .header(CONTENT_TYPE, "text/plain")
133 .body(manifest_text)
134 .send()
135 .await
136 .map_err(|e| RemoteError::connection_failed(&url, e))?;
137
138 crate::check_min_version_header(response.headers());
139 let status = response.status();
140
141 match status {
142 StatusCode::OK => {
143 debug!("Successfully declared view manifest for {}", view);
144 Ok(())
145 }
146 StatusCode::NOT_FOUND => Err(RemoteError::repo_not_found(&url)),
147 StatusCode::CONFLICT => {
148 // Divergence / identity mismatch / state mismatch.
149 let msg = response.text().await.unwrap_or_default();
150 Err(RemoteError::protocol(msg))
151 }
152 StatusCode::UNAUTHORIZED | StatusCode::FORBIDDEN => {
153 let msg = response.text().await.unwrap_or_default();
154 Err(RemoteError::auth_failed(&url, msg))
155 }
156 StatusCode::BAD_REQUEST => {
157 let msg = response.text().await.unwrap_or_default();
158 if msg.contains("missing") && msg.contains("change") {
159 Err(RemoteError::missing_deps(vec![]))
160 } else {
161 Err(RemoteError::http(status.as_u16(), msg))
162 }
163 }
164 _ => {
165 let msg = response.text().await.unwrap_or_default();
166 Err(RemoteError::http(status.as_u16(), msg))
167 }
168 }
169 }
170
171 /// Upload a tag (short format).
172 ///

Callers 1

run_asyncMethod · 0.80

Calls 6

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

Tested by

no test coverage detected