Usage

// create instance
UptimeRobotAPI api = new UptimeRobotAPI("u54091-960e132dcfaf27834836450d");

// verify account
bool verified = api.VerifyAccount();

// # Contacts

// create contact
UptimeRobotContactResponse response1 = api.CreateContact(UptimeRobotContactType.Email, "user@domain.com");
bool success1 = response1.Success; // true if successful
int contactID1 = response1.ContactID; // contact ID

// get alert contacts
List<UptimeRobotContact> contacts1 = api.GetContacts();

// get alert contact ID 123
UptimeRobotContact contact1 = api.GetContact(123);

// delete alert contact ID 123
UptimeRobotContactResponse response2 = api.DeleteContact(123);

// # Monitors

// all monitors, without custom uptime ratio, without logs and without alerts contacts
List<UptimeRobotMonitor> list1 = api.GetMonitors();
List<UptimeRobotMonitor> list2 = api.GetMonitors(false);

// all monitors, without custom uptime ratio, with logs, without alert contacts
List<UptimeRobotMonitor> list3 = api.GetMonitors(true);

// monitors 123 and 456, with custom uptime ratio (30 days), with logs, with alert contacts
List<UptimeRobotMonitor> list4 = api.GetMonitors(new int[] { 123, 456 }, 30, true, true);

// create new HTTP(S) monitor
UptimeRobotMonitorResponse response3 = api.CreateHTTPMonitor(null, null, "Monitor1", new Uri("http://www.codeplex.com/"), new int[] { 123 });
bool success2 = response3.Success;
int monitorID1 = response3.MonitorID;

// create new keyword monitor
UptimeRobotMonitorResponse response4 = api.CreateKeywordMonitor(UptimeRobotMonitorKeywordType.NotExists, "codeplex", null, null, "Monitor2", new Uri("http://www.codeplex.com/"), new int[] { 123 });

// create new ping monitor
UptimeRobotMonitorResponse response5 = api.CreatePingMonitor("Monitor3", System.Net.IPAddress.Parse("666.666.666.666"), new int[] { 123 });

// create new port monitor
UptimeRobotMonitorResponse response6 = api.CreatePortMonitor(UptimeRobotMonitorSubType.POP3, 110, null, null, "Monitor4", System.Net.IPAddress.Parse("666.666.666.666"), new int[] { 123 });

// delete monitor ID 123
UptimeRobotMonitorResponse response7 = api.DeleteMonitor(123);


Last edited Jul 19, 2012 at 7:18 PM by gbshouse, version 2

Comments

No comments yet.