curl -D responseHeader -H "Content-Type: application/json" –H "Accept: application/json -H "x-zerto-session: 9UDQD6RG7YF33QJLWQXGJV8C453N277NA22P7FSNWVZCJTWCBRHQ" https://127.0.0.1:9669/v1/alerts |
curl -D responseHeader -H "Content-Type: application/json" –H "Accept: application/json -H "x-zerto-session: 9UDQD6RG7YF33QJLWQXGJV8C453N277NA22P7FSNWVZCJTWCBRHQ" https://127.0.0.1:9669/v1/alerts/d00ea07a-9317-4ab6-a609-0a5fcbb04680/dismiss -d "" |
/* * Example - get all alerts, filtering is not used */ private void GetAlerts() { Console.WriteLine("\nRequest the list of alerts:"); Console.WriteLine("============================"); string apiAddress = m_baseAddress + "alerts"; string result = ExecuteHttpGet(apiAddress, m_format, m_sessionId); List<AlertApi> events = (List<AlertApi>)DeserializeObjectFromJson(result, typeof(List<AlertApi>)); Console.WriteLine("Found " + alerts.Count + " alerts."); // Go Over all alerts fetching them one by one for (int i = 0;i < alerts.Count;i++) { Console.WriteLine((i+1) + ". " + alerts[i].Description); } } |
/* * Example - dismiss all the 'warning' level alerts that are not already dismissed */ private void DismissAllAlerts() { Console.WriteLine("\nDismiss all alerts that are warning level and not dismissed."); Console.WriteLine("==================================================="); // Do Get fetch all alerts with certain filter string apiAddress = m_baseAddress + "alerts?isDismissed=false&level=Error"; string result = ExecuteHttpGet(apiAddress, m_format, m_sessionId); // Deserialize response into zerto api object List<AlertApi> alerts = (List<AlertApi>)DeserializeObjectFromJson(result, typeof(List<AlertApi>)); Console.WriteLine("Found " + alerts.Count + " alerts matching filter."); int count = 0; // Go Over all alerts fetch and dismiss them one by one foreach (var alert in alerts) { try { Console.WriteLine("Dismiss alert : " + alert.Description); string apiAlertAddress = m_baseAddress + "alerts/" + alert.Link.Identifier + "/dismiss"; ExecuteHttpPost(apiAlertAddress, m_format, m_sessionId, null); count++; } catch (Exception e) { Console.WriteLine("error " + e.Message + "."); } Console.WriteLine("Dismissed " + count + " alerts."); } } |