From fc7ea237b654527bf12f246c4485524f34e35da3 Mon Sep 17 00:00:00 2001 From: ceee Date: Sun, 25 Aug 2013 16:24:52 +0200 Subject: [PATCH] update naming convention for public methods --- UptimeSharp.Tests/AlertsTest.cs | 8 +++--- UptimeSharp/Components/Alert.cs | 15 ++++++++++- UptimeSharp/Components/Monitor.cs | 45 ++++++++++++++++++++----------- 3 files changed, 47 insertions(+), 21 deletions(-) diff --git a/UptimeSharp.Tests/AlertsTest.cs b/UptimeSharp.Tests/AlertsTest.cs index d806a9a..815a2ee 100644 --- a/UptimeSharp.Tests/AlertsTest.cs +++ b/UptimeSharp.Tests/AlertsTest.cs @@ -24,7 +24,7 @@ namespace UptimeSharp.Tests [TearDown] public void Teardown() { - List alerts = client.RetrieveAlerts(); + List alerts = client.GetAlerts(); alerts.ForEach(alert => client.DeleteAlert(alert)); } @@ -77,11 +77,11 @@ namespace UptimeSharp.Tests "Response should be true for adding a new alert (bocar 4)" ); - List alerts = client.RetrieveAlerts(); + List alerts = client.GetAlerts(); Assert.GreaterOrEqual(alerts.ToArray().Length, 2, "Alerts length should be at least 2", alerts); - List specificAlerts = client.RetrieveAlerts(new int[] { alerts[0].ID, alerts[1].ID }); + List specificAlerts = client.GetAlerts(new int[] { alerts[0].ID, alerts[1].ID }); Assert.AreEqual(2, specificAlerts.ToArray().Length, "Specific alerts length should be 2", specificAlerts); } @@ -89,7 +89,7 @@ namespace UptimeSharp.Tests private Alert GetOriginAlert(string value) { - List alerts = client.RetrieveAlerts(); + List alerts = client.GetAlerts(); Alert origin = null; alerts.ForEach(alert => diff --git a/UptimeSharp/Components/Alert.cs b/UptimeSharp/Components/Alert.cs index b13ffdd..958996d 100644 --- a/UptimeSharp/Components/Alert.cs +++ b/UptimeSharp/Components/Alert.cs @@ -15,7 +15,7 @@ namespace UptimeSharp /// /// Retrieve specified alert contacts by supplying IDs for them. /// - public List RetrieveAlerts(int[] alertIDs = null) + public List GetAlerts(int[] alertIDs = null) { Parameter alerts = Parameter("alertcontacts", alertIDs != null ? string.Join("-", alertIDs) : null); @@ -23,6 +23,19 @@ namespace UptimeSharp } + /// + /// Retrieves an alert from UptimeRobot + /// + /// The alertID. + /// + public Alert GetAlert(int alertID) + { + List alerts = GetAlerts(new int[] { alertID }); + + return alerts.ToArray().Length > 0 ? alerts[0] : null; + } + + /// /// Adds an alert. /// mobile/SMS alert contacts are not supported yet, see: http://www.uptimerobot.com/api.asp#methods diff --git a/UptimeSharp/Components/Monitor.cs b/UptimeSharp/Components/Monitor.cs index 3161bb6..31c6d5b 100644 --- a/UptimeSharp/Components/Monitor.cs +++ b/UptimeSharp/Components/Monitor.cs @@ -17,8 +17,10 @@ namespace UptimeSharp /// The custom uptime ratio. /// if set to true [show log]. /// if set to true [show alerts]. - /// - public List Retrieve(int[] monitors = null, float[] customUptimeRatio = null, bool showLog = false, bool showAlerts = true) + /// + /// Monitor List + /// + public List GetMonitors(int[] monitors = null, float[] customUptimeRatio = null, bool showLog = false, bool showAlerts = true) { RetrieveParameters parameters = new RetrieveParameters() { @@ -36,10 +38,17 @@ namespace UptimeSharp /// Retrieves a monitor from UptimeRobot /// /// a specific monitor ID - /// - public Monitor Retrieve(int monitorId) + /// The custom uptime ratio. + /// if set to true [show log]. + /// if set to true [show alerts]. + /// + /// The Monitor + /// + public Monitor GetMonitor(int monitorId, float[] customUptimeRatio = null, bool showLog = false, bool showAlerts = true) { - return Retrieve(new int[] { monitorId })[0]; + List monitors = GetMonitors(new int[] { monitorId }, customUptimeRatio, showLog, showAlerts); + + return monitors.ToArray().Length > 0 ? monitors[0] : null; } @@ -47,8 +56,10 @@ namespace UptimeSharp /// Deletes a monitor /// /// a specific monitor ID - /// success state - public bool Delete(int monitorId) + /// + /// Success state + /// + public bool DeleteMonitor(int monitorId) { return Get("deleteMonitor", Parameter("monitorID", monitorId)).Status; } @@ -58,10 +69,12 @@ namespace UptimeSharp /// Deletes a monitor /// /// The monitor. - /// success state - public bool Delete(Monitor monitor) + /// + /// Success state + /// + public bool DeleteMonitor(Monitor monitor) { - return Delete(monitor.ID); + return DeleteMonitor(monitor.ID); } @@ -79,11 +92,11 @@ namespace UptimeSharp /// The HTTP password. /// The HTTP username. /// - /// success state + /// Success state /// - public bool Add(string name, string uri, Type type = Type.HTTP, Subtype subtype = Subtype.Unknown, - int? port = null, string keywordValue = null, KeywordType keywordType = KeywordType.Unknown, - int[] alerts = null, string HTTPPassword = null, string HTTPUsername = null) + public bool AddMonitor(string name, string uri, Type type = Type.HTTP, Subtype subtype = Subtype.Unknown, + int? port = null, string keywordValue = null, KeywordType keywordType = KeywordType.Unknown, + int[] alerts = null, string HTTPPassword = null, string HTTPUsername = null) { MonitorParameters parameters = new MonitorParameters() @@ -109,9 +122,9 @@ namespace UptimeSharp /// /// The monitor. /// - /// success state + /// Success state /// - public bool Modify(Monitor monitor) + public bool ModifyMonitor(Monitor monitor) { List alerts = null;