simplified GetParameters; include logs in Monitor Model
This commit is contained in:
@@ -15,7 +15,12 @@ namespace UptimeSharp
|
||||
/// <returns></returns>
|
||||
public List<Monitor> Get()
|
||||
{
|
||||
return Get<Get>("getMonitors").Items;
|
||||
GetParameters parameters = new GetParameters()
|
||||
{
|
||||
ShowAlerts = true
|
||||
};
|
||||
|
||||
return Get<Get>("getMonitors", parameters.Convert()).Items;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +33,8 @@ namespace UptimeSharp
|
||||
{
|
||||
GetParameters parameters = new GetParameters()
|
||||
{
|
||||
Monitors = new int[] { monitorId }
|
||||
Monitors = new int[] { monitorId },
|
||||
ShowAlerts = true
|
||||
};
|
||||
|
||||
return Get<Get>("getMonitors", parameters.Convert()).Items[0];
|
||||
@@ -44,7 +50,8 @@ namespace UptimeSharp
|
||||
{
|
||||
GetParameters parameters = new GetParameters()
|
||||
{
|
||||
Monitors = monitors
|
||||
Monitors = monitors,
|
||||
ShowAlerts = true
|
||||
};
|
||||
|
||||
return Get<Get>("getMonitors", parameters.Convert()).Items;
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace UptimeSharp.Models
|
||||
/// The name.
|
||||
/// </value>
|
||||
[DataMember(Name = "type")]
|
||||
public Type Type { get; set; }
|
||||
public AlertType Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the alert value.
|
||||
@@ -41,7 +41,7 @@ namespace UptimeSharp.Models
|
||||
/// <summary>
|
||||
/// The type of the alert contact notified.
|
||||
/// </summary>
|
||||
public enum Type
|
||||
public enum AlertType
|
||||
{
|
||||
/// <summary>
|
||||
/// SMS
|
||||
@@ -50,7 +50,7 @@ namespace UptimeSharp.Models
|
||||
/// <summary>
|
||||
/// E-Mail
|
||||
/// </summary>
|
||||
EMail = 2,
|
||||
Email = 2,
|
||||
/// <summary>
|
||||
/// Twitter DM
|
||||
/// </summary>
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace UptimeSharp.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// The Log Model
|
||||
/// </summary>
|
||||
[DataContract]
|
||||
public class Log
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the log type.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The type.
|
||||
/// </value>
|
||||
[DataMember(Name = "type")]
|
||||
public LogType Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the date time, when the log action appeared.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The date.
|
||||
/// </value>
|
||||
[DataMember(Name = "datetime")]
|
||||
public DateTime Date { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the alerts, which were notified when the log action appeared.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The alert contacts.
|
||||
/// </value>
|
||||
[DataMember(Name = "alertcontact")]
|
||||
public List<Alert> Alerts { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The type of the log entry.
|
||||
/// </summary>
|
||||
public enum LogType
|
||||
{
|
||||
/// <summary>
|
||||
/// Down
|
||||
/// </summary>
|
||||
Down = 1,
|
||||
/// <summary>
|
||||
/// Up
|
||||
/// </summary>
|
||||
Up = 2,
|
||||
/// <summary>
|
||||
/// Started
|
||||
/// </summary>
|
||||
Started = 98,
|
||||
/// <summary>
|
||||
/// Paused
|
||||
/// </summary>
|
||||
Paused = 99
|
||||
}
|
||||
}
|
||||
@@ -155,6 +155,24 @@ namespace UptimeSharp.Models
|
||||
/// </value>
|
||||
[DataMember(Name = "subtype")]
|
||||
public Subtype Subtype { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the alerts.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The alert contacts.
|
||||
/// </value>
|
||||
[DataMember(Name = "alertcontact")]
|
||||
public List<Alert> Alerts { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the log.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The log with dates and associated alert contacts.
|
||||
/// </value>
|
||||
[DataMember(Name = "log")]
|
||||
public List<Log> Log { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -31,15 +31,7 @@ namespace UptimeSharp.Models
|
||||
/// <value>
|
||||
/// The log bool.
|
||||
/// </value>
|
||||
public bool? ShowLogs { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Defines if the notified alert contacts of each notification will be returned
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The alert contacts bool.
|
||||
/// </value>
|
||||
public bool? ShowAlertContacts { get; set; }
|
||||
public bool? ShowLog { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Defines if the alert contacts set for the monitor to be returned
|
||||
@@ -47,15 +39,7 @@ namespace UptimeSharp.Models
|
||||
/// <value>
|
||||
/// The alert contacts bool.
|
||||
/// </value>
|
||||
public bool? ShowMonitorAlertContacts { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Defines if the user's timezone should be returned
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The alert contacts bool.
|
||||
/// </value>
|
||||
public bool? ShowTimezone { get; set; }
|
||||
public bool? ShowAlerts { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -74,21 +58,16 @@ namespace UptimeSharp.Models
|
||||
{
|
||||
parameters.Add(Utilities.CreateParam("customUptimeRatio", String.Join("-", CustomUptimeRatio)));
|
||||
}
|
||||
if (ShowLogs.HasValue)
|
||||
if (ShowLog.HasValue)
|
||||
{
|
||||
parameters.Add(Utilities.CreateParam("logs", ShowLogs));
|
||||
string showLog = (bool)ShowLog ? "1" : "0";
|
||||
parameters.Add(Utilities.CreateParam("logs", showLog));
|
||||
parameters.Add(Utilities.CreateParam("alertContacts", showLog));
|
||||
parameters.Add(Utilities.CreateParam("showTimezone", showLog));
|
||||
}
|
||||
if (ShowAlertContacts.HasValue)
|
||||
if (ShowAlerts.HasValue)
|
||||
{
|
||||
parameters.Add(Utilities.CreateParam("alertContacts", ShowAlertContacts));
|
||||
}
|
||||
if (ShowMonitorAlertContacts.HasValue)
|
||||
{
|
||||
parameters.Add(Utilities.CreateParam("showMonitorAlertContacts", ShowMonitorAlertContacts));
|
||||
}
|
||||
if (ShowTimezone.HasValue)
|
||||
{
|
||||
parameters.Add(Utilities.CreateParam("showTimezone", ShowTimezone));
|
||||
parameters.Add(Utilities.CreateParam("showMonitorAlertContacts", (bool)ShowAlerts ? "1" : "0"));
|
||||
}
|
||||
|
||||
return parameters;
|
||||
|
||||
@@ -54,6 +54,8 @@
|
||||
<Compile Include="APIException.cs" />
|
||||
<Compile Include="Components\Get.cs" />
|
||||
<Compile Include="JsonDeserializer.cs" />
|
||||
<Compile Include="Models\Alert.cs" />
|
||||
<Compile Include="Models\Log.cs" />
|
||||
<Compile Include="Models\Monitor.cs" />
|
||||
<Compile Include="Models\Parameters\GetParameters.cs" />
|
||||
<Compile Include="Models\Response\Get.cs" />
|
||||
|
||||
Reference in New Issue
Block a user