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

Function build_apex_client_as

atomic-cli/src/commands/client.rs:169–184  ·  view source on GitHub ↗

Build an apex-scoped [`StorageClient`] authenticating as a **named identity rather than whichever one the server profile resolves to. Agent enrollment is the reason this exists: the caller must be the human who signs the certificate, and that is not necessarily the identity bound to the profile — nor, once agents are in play, the default. Making the identity explicit keeps "who is enrolling" a de

(
    identity: &atomic_identity::Identity,
    server_override: Option<&str>,
)

Source from the content-addressed store, hash-verified

167/// explicit keeps "who is enrolling" a decision at the call site instead of a
168/// side effect of configuration.
169pub async fn build_apex_client_as(
170 identity: &atomic_identity::Identity,
171 server_override: Option<&str>,
172) -> CliResult<(StorageClient, String)> {
173 let apex_url = apex_server_url(server_override)?;
174 let bearer_token = atomic_remote::auth::token::get_token(&apex_url, identity).await?;
175 let delegation = delegation_for(identity, &apex_url);
176
177 let client =
178 StorageClient::with_delegation(&apex_url, "", &bearer_token, delegation.as_deref())
179 .map_err(|e| {
180 CliError::Internal(anyhow::anyhow!("Failed to create storage client: {}", e))
181 })?;
182
183 Ok((client, apex_url))
184}
185
186/// Build a [`StorageClient`] and return the resolved org slug alongside it.
187///

Callers 6

executeMethod · 0.85
check_revocationMethod · 0.85
revoke_everythingMethod · 0.85
publish_grantMethod · 0.85
notify_serverMethod · 0.85
enrollMethod · 0.85

Calls 3

get_tokenFunction · 0.85
delegation_forFunction · 0.85
apex_server_urlFunction · 0.70

Tested by

no test coverage detected