Complete provider names by querying the active gateway.
(_prefix: &OsStr)
| 55 | |
| 56 | /// Complete provider names by querying the active gateway. |
| 57 | pub fn complete_provider_names(_prefix: &OsStr) -> Vec<CompletionCandidate> { |
| 58 | blocking_complete(async { |
| 59 | let (endpoint, gateway_name) = resolve_active_gateway()?; |
| 60 | let mut client = completion_grpc_client(&endpoint, &gateway_name).await?; |
| 61 | let response = client |
| 62 | .list_providers(ListProvidersRequest { |
| 63 | limit: 200, |
| 64 | offset: 0, |
| 65 | }) |
| 66 | .await |
| 67 | .ok()?; |
| 68 | Some( |
| 69 | response |
| 70 | .into_inner() |
| 71 | .providers |
| 72 | .into_iter() |
| 73 | .map(|p| CompletionCandidate::new(p.object_name())) |
| 74 | .collect(), |
| 75 | ) |
| 76 | }) |
| 77 | } |
| 78 | |
| 79 | fn resolve_active_gateway() -> Option<(String, String)> { |
| 80 | let name = std::env::var("OPENSHELL_GATEWAY") |