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

Method enroll

atomic-cli/src/commands/identity/agent/create.rs:271–304  ·  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

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