Show network rules for a sandbox.
(
server: &str,
name: &str,
status_filter: Option<&str>,
tls: &TlsOptions,
)
| 7531 | |
| 7532 | /// Show network rules for a sandbox. |
| 7533 | pub async fn sandbox_draft_get( |
| 7534 | server: &str, |
| 7535 | name: &str, |
| 7536 | status_filter: Option<&str>, |
| 7537 | tls: &TlsOptions, |
| 7538 | ) -> Result<()> { |
| 7539 | let mut client = grpc_client(server, tls).await?; |
| 7540 | |
| 7541 | let response = client |
| 7542 | .get_draft_policy(GetDraftPolicyRequest { |
| 7543 | name: name.to_string(), |
| 7544 | status_filter: status_filter.unwrap_or("").to_string(), |
| 7545 | }) |
| 7546 | .await |
| 7547 | .into_diagnostic()?; |
| 7548 | |
| 7549 | let inner = response.into_inner(); |
| 7550 | |
| 7551 | if inner.chunks.is_empty() { |
| 7552 | println!("No network rules for sandbox '{name}'"); |
| 7553 | return Ok(()); |
| 7554 | } |
| 7555 | |
| 7556 | println!( |
| 7557 | "{} (version {}, {} chunk{})", |
| 7558 | "Network Rules:".cyan().bold(), |
| 7559 | inner.draft_version, |
| 7560 | inner.chunks.len(), |
| 7561 | if inner.chunks.len() == 1 { "" } else { "s" } |
| 7562 | ); |
| 7563 | println!(); |
| 7564 | |
| 7565 | for chunk in &inner.chunks { |
| 7566 | let status_colored = match chunk.status.as_str() { |
| 7567 | "pending" => chunk.status.yellow().to_string(), |
| 7568 | "approved" => chunk.status.green().to_string(), |
| 7569 | "rejected" => chunk.status.red().to_string(), |
| 7570 | _ => chunk.status.clone(), |
| 7571 | }; |
| 7572 | |
| 7573 | println!(" {} {}", "Chunk:".dimmed(), chunk.id); |
| 7574 | println!(" {} {}", "Status:".dimmed(), status_colored); |
| 7575 | println!(" {} {}", "Rule:".dimmed(), chunk.rule_name); |
| 7576 | if !chunk.binary.is_empty() { |
| 7577 | println!(" {} {}", "Binary:".dimmed(), chunk.binary); |
| 7578 | } |
| 7579 | println!( |
| 7580 | " {} {:.0}%", |
| 7581 | "Confidence:".dimmed(), |
| 7582 | chunk.confidence * 100.0 |
| 7583 | ); |
| 7584 | println!(" {} {}", "Rationale:".dimmed(), chunk.rationale); |
| 7585 | |
| 7586 | if !chunk.security_notes.is_empty() { |
| 7587 | println!( |
| 7588 | " {} {}", |
| 7589 | "Security:".dimmed(), |
| 7590 | chunk.security_notes.yellow() |
no test coverage detected