(contents: &str, source: &str)
| 273 | } |
| 274 | |
| 275 | fn 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 | |
| 306 | fn load_embedded_api_registries() -> Result<HashMap<String, ApiCapability>> { |
| 307 | let registry = crate::registry::embedded_registry(); |
no outgoing calls
no test coverage detected