Show network rule history.
(server: &str, name: &str, tls: &TlsOptions)
| 7725 | |
| 7726 | /// Show network rule history. |
| 7727 | pub async fn sandbox_draft_history(server: &str, name: &str, tls: &TlsOptions) -> Result<()> { |
| 7728 | let mut client = grpc_client(server, tls).await?; |
| 7729 | |
| 7730 | let response = client |
| 7731 | .get_draft_history(GetDraftHistoryRequest { |
| 7732 | name: name.to_string(), |
| 7733 | }) |
| 7734 | .await |
| 7735 | .into_diagnostic()?; |
| 7736 | |
| 7737 | let inner = response.into_inner(); |
| 7738 | |
| 7739 | if inner.entries.is_empty() { |
| 7740 | println!("No rule history for sandbox '{name}'"); |
| 7741 | return Ok(()); |
| 7742 | } |
| 7743 | |
| 7744 | println!("{}", "Rule History:".cyan().bold()); |
| 7745 | println!(); |
| 7746 | |
| 7747 | for entry in &inner.entries { |
| 7748 | let event_colored = match entry.event_type.as_str() { |
| 7749 | "proposed" => entry.event_type.yellow().to_string(), |
| 7750 | "approved" => entry.event_type.green().to_string(), |
| 7751 | "rejected" => entry.event_type.red().to_string(), |
| 7752 | _ => entry.event_type.clone(), |
| 7753 | }; |
| 7754 | |
| 7755 | println!( |
| 7756 | " {} {} [{}] {}", |
| 7757 | format_timestamp_ms(entry.timestamp_ms).dimmed(), |
| 7758 | event_colored, |
| 7759 | entry.chunk_id.get(..8).unwrap_or(&entry.chunk_id), |
| 7760 | entry.description, |
| 7761 | ); |
| 7762 | } |
| 7763 | |
| 7764 | Ok(()) |
| 7765 | } |
| 7766 | |
| 7767 | /// Format a `NetworkPolicyRule`'s endpoints as a compact string. |
| 7768 | fn format_endpoints(rule: &openshell_core::proto::NetworkPolicyRule) -> String { |
no test coverage detected