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

Function parse_api_registry

crates/openshell-prover/src/credentials.rs:275–304  ·  view source on GitHub ↗
(contents: &str, source: &str)

Source from the content-addressed store, hash-verified

273}
274
275fn parse_api_registry(contents: &str, source: &str) -> Result<ApiCapability> {
276 let raw: ApiRegistryDef = serde_yml::from_str(contents)
277 .into_diagnostic()
278 .wrap_err_with(|| format!("parsing API registry {source}"))?;
279
280 let scope_capabilities = raw
281 .scope_capabilities
282 .into_iter()
283 .map(|(scope, actions)| {
284 let actions = actions
285 .into_iter()
286 .map(|a| ApiAction {
287 method: a.method,
288 path: a.path,
289 action: a.action,
290 })
291 .collect();
292 (scope, actions)
293 })
294 .collect();
295
296 Ok(ApiCapability {
297 api: raw.api,
298 host: raw.host,
299 port: raw.port,
300 credential_type: raw.credential_type,
301 scope_capabilities,
302 action_risk: raw.action_risk,
303 })
304}
305
306fn load_embedded_api_registries() -> Result<HashMap<String, ApiCapability>> {
307 let registry = crate::registry::embedded_registry();

Callers 2

Calls

no outgoing calls

Tested by

no test coverage detected