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

Method enroll

atomic-cli/src/commands/identity/agent/create.rs:278–311  ·  view source on GitHub ↗

Enroll the agent key and certificate with the server. Returns `Ok(false)` when the server does not implement agent identities yet — an older deployment is a reason to say so and carry on with a locally valid certificate, not to fail after the key already exists.

(
        &self,
        delegator: &Identity,
        agent: &Identity,
        certificate: &serde_json::Value,
        server_url: &str,
    )

Source from the content-addressed store, hash-verified

276 /// yet — an older deployment is a reason to say so and carry on with a
277 /// locally valid certificate, not to fail after the key already exists.
278 async fn enroll(
279 &self,
280 delegator: &Identity,
281 agent: &Identity,
282 certificate: &serde_json::Value,
283 server_url: &str,
284 ) -> CliResult<bool> {
285 let (client, _) =
286 crate::commands::client::build_apex_client_as(delegator, self.server.as_deref())
287 .await?;
288
289 let request = EnrollAgentRequest {
290 name: agent.name.clone(),
291 email: agent.email.clone(),
292 public_key: agent.public_key_base32(),
293 certificate: certificate.clone(),
294 };
295
296 match client.enroll_agent(&request).await {
297 Ok(_) => Ok(true),
298 Err(e) if is_unsupported(&e) => {
299 print_warning(&format!(
300 "{server_url} does not support agent identities yet — the certificate is \
301 valid locally but the server will not accept this key.\n \
302 Enroll it once the server is upgraded: atomic identity delegation push"
303 ));
304 Ok(false)
305 }
306 Err(e) => Err(CliError::RemoteError {
307 message: format!("Failed to enroll agent: {e}"),
308 url: Some(server_url.to_string()),
309 }),
310 }
311 }
312
313 fn report(
314 &self,

Callers 1

executeMethod · 0.80

Calls 6

build_apex_client_asFunction · 0.85
is_unsupportedFunction · 0.85
print_warningFunction · 0.85
public_key_base32Method · 0.80
enroll_agentMethod · 0.80
cloneMethod · 0.45

Tested by

no test coverage detected