From 0750b9fe10c169ab204d0b6c57e577625fbf360f Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Wed, 25 Mar 2026 10:46:57 -0400 Subject: [PATCH] that worked! --- .../src/requests/create_alert/create_alert.rs | 64 ++++++++++++++++++- 1 file changed, 61 insertions(+), 3 deletions(-) diff --git a/crates/api_clients/rootly_client/src/requests/create_alert/create_alert.rs b/crates/api_clients/rootly_client/src/requests/create_alert/create_alert.rs index 2e763d1134..b448ce7ed1 100644 --- a/crates/api_clients/rootly_client/src/requests/create_alert/create_alert.rs +++ b/crates/api_clients/rootly_client/src/requests/create_alert/create_alert.rs @@ -40,9 +40,16 @@ pub struct CreateAlertArgs { /// Optional external URL for linking to an external system. pub external_url: Option, - /// Optional alert urgency ID. + /// Optional alert urgency ID (get IDs from GET /v1/alert_urgencies). pub alert_urgency_id: Option, + /// Who to notify. One of: "User", "Group", "EscalationPolicy", "Service". + /// Requires On-Call to be enabled. + pub notification_target_type: Option, + + /// The ID of the notification target (user ID, group ID, escalation policy ID, or service ID). + pub notification_target_id: Option, + /// Optional labels as key-value pairs. pub labels: Option>, @@ -96,8 +103,8 @@ pub async fn create_alert(args: CreateAlertArgs) -> Result AnyhowResult<()> { + let api_key = test_api_key()?; + + // IDs from our Rootly org (GET /v1/alert_urgencies, GET /v1/escalation_policies) + let high_urgency_id = "62fde143-1258-4639-9ee6-1400ebf7308d"; // "High" + let sre_escalation_policy_id = "d1f176a9-edb8-48f3-a2df-c505835498e5"; // "SRE (Site Reliability Engineering) Team" + + let result = create_alert(CreateAlertArgs { + api_key, + source: "artcraft".to_string(), + summary: "[TEST] SEV-1: Critical production issue — paging test".to_string(), + description: Some( + "This is a test SEV-1 alert to verify paging works. \ + If you received this page, the Rootly integration is working correctly. \ + Please acknowledge and resolve.".to_string() + ), + status: Some("triggered".to_string()), + service_ids: None, + group_ids: None, + environment_ids: None, + external_id: None, + external_url: None, + alert_urgency_id: Some(high_urgency_id.to_string()), + notification_target_type: Some("EscalationPolicy".to_string()), + notification_target_id: Some(sre_escalation_policy_id.to_string()), + labels: Some(vec![ + ("severity".to_string(), "sev-1".to_string()), + ("environment".to_string(), "production".to_string()), + ("test".to_string(), "true".to_string()), + ]), + deduplication_key: None, + }).await?; + + println!("Alert ID: {}", result.id); + println!("Short ID: {:?}", result.short_id); + println!("Status: {:?}", result.status); + println!("Source: {:?}", result.source); + assert!(!result.id.is_empty()); + Ok(()) + } }