MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / fetch_policy_with_client

Function fetch_policy_with_client

crates/openshell-core/src/grpc_client.rs:577–598  ·  view source on GitHub ↗

Fetch sandbox policy using an existing client connection.

(
    client: &mut OpenShellClient<AuthedChannel>,
    sandbox_id: &str,
)

Source from the content-addressed store, hash-verified

575
576/// Fetch sandbox policy using an existing client connection.
577async fn fetch_policy_with_client(
578 client: &mut OpenShellClient<AuthedChannel>,
579 sandbox_id: &str,
580) -> Result<Option<ProtoSandboxPolicy>> {
581 let response = client
582 .get_sandbox_config(GetSandboxConfigRequest {
583 sandbox_id: sandbox_id.to_string(),
584 })
585 .await
586 .into_diagnostic()?;
587
588 let inner = response.into_inner();
589
590 // version 0 with no policy means the sandbox was created without one.
591 if inner.version == 0 && inner.policy.is_none() {
592 return Ok(None);
593 }
594
595 Ok(Some(inner.policy.ok_or_else(|| {
596 miette::miette!("Server returned non-zero version but empty policy")
597 })?))
598}
599
600/// Sync a locally-discovered policy using an existing client connection.
601async fn sync_policy_with_client(

Callers 2

fetch_policyFunction · 0.85
discover_and_sync_policyFunction · 0.85

Calls 1

get_sandbox_configMethod · 0.45

Tested by

no test coverage detected