diff --git a/src/corelib/Providers/Rackspace/Objects/Monitoring/CheckConfiguration.cs b/src/corelib/Providers/Rackspace/Objects/Monitoring/CheckConfiguration.cs
index f3c65db5e..a6480f09c 100644
--- a/src/corelib/Providers/Rackspace/Objects/Monitoring/CheckConfiguration.cs
+++ b/src/corelib/Providers/Rackspace/Objects/Monitoring/CheckConfiguration.cs
@@ -191,6 +191,11 @@ public CheckTypeId CheckTypeId
/// Gets a object describing the detailed properties specific
/// to this type of check.
///
+ ///
+ /// The exact type returned by this property depends on the
+ /// for the current check. For additional information about the predefined check types,
+ /// see .
+ ///
public CheckDetails Details
{
get
diff --git a/src/corelib/Providers/Rackspace/Objects/Monitoring/CheckDetails.cs b/src/corelib/Providers/Rackspace/Objects/Monitoring/CheckDetails.cs
index ed6ac4e4c..a06976781 100644
--- a/src/corelib/Providers/Rackspace/Objects/Monitoring/CheckDetails.cs
+++ b/src/corelib/Providers/Rackspace/Objects/Monitoring/CheckDetails.cs
@@ -1,6 +1,7 @@
namespace net.openstack.Providers.Rackspace.Objects.Monitoring
{
using System;
+ using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
@@ -13,6 +14,40 @@
[JsonObject(MemberSerialization.OptIn)]
public abstract class CheckDetails
{
+ ///
+ /// Provides factory methods for deserializing a instance from
+ /// a according to the of the associated
+ /// check.
+ ///
+ private static readonly Dictionary> DetailsFactories =
+ new Dictionary>
+ {
+ // remote checks
+ { CheckTypeId.RemoteDns, obj => obj.ToObject() },
+ { CheckTypeId.RemoteFtpBanner, obj => obj.ToObject() },
+ { CheckTypeId.RemoteHttp, obj => obj.ToObject() },
+ { CheckTypeId.RemoteImapBanner, obj => obj.ToObject() },
+ { CheckTypeId.RemoteMssqlBanner, obj => obj.ToObject() },
+ { CheckTypeId.RemoteMysqlBanner, obj => obj.ToObject() },
+ { CheckTypeId.RemotePing, obj => obj.ToObject() },
+ { CheckTypeId.RemotePop3Banner, obj => obj.ToObject() },
+ { CheckTypeId.RemotePostgresqlBanner, obj => obj.ToObject() },
+ { CheckTypeId.RemoteSmtpBanner, obj => obj.ToObject() },
+ { CheckTypeId.RemoteSmtp, obj => obj.ToObject() },
+ { CheckTypeId.RemoteSsh, obj => obj.ToObject() },
+ { CheckTypeId.RemoteTcp, obj => obj.ToObject() },
+ { CheckTypeId.RemoteTelnetBanner, obj => obj.ToObject() },
+
+ // agent checks
+ { CheckTypeId.AgentFilesystem, obj => obj.ToObject() },
+ { CheckTypeId.AgentMemory, obj => obj.ToObject() },
+ { CheckTypeId.AgentLoadAverage, obj => obj.ToObject() },
+ { CheckTypeId.AgentCpu, obj => obj.ToObject() },
+ { CheckTypeId.AgentDisk, obj => obj.ToObject() },
+ { CheckTypeId.AgentNetwork, obj => obj.ToObject() },
+ { CheckTypeId.AgentPlugin, obj => obj.ToObject() },
+ };
+
///
/// Deserializes a JSON object to a instance of the proper type.
///
@@ -31,36 +66,11 @@ public static CheckDetails FromJObject(CheckTypeId checkTypeId, JObject obj)
if (obj == null)
throw new ArgumentNullException("obj");
- if (checkTypeId == CheckTypeId.RemoteDns)
- return obj.ToObject();
- else if (checkTypeId == CheckTypeId.RemoteFtpBanner)
- return obj.ToObject();
- else if (checkTypeId == CheckTypeId.RemoteHttp)
- return obj.ToObject();
- else if (checkTypeId == CheckTypeId.RemoteImapBanner)
- return obj.ToObject();
- else if (checkTypeId == CheckTypeId.RemoteMssqlBanner)
- return obj.ToObject();
- else if (checkTypeId == CheckTypeId.RemoteMysqlBanner)
- return obj.ToObject();
- else if (checkTypeId == CheckTypeId.RemotePing)
- return obj.ToObject();
- else if (checkTypeId == CheckTypeId.RemotePop3Banner)
- return obj.ToObject();
- else if (checkTypeId == CheckTypeId.RemotePostgresqlBanner)
- return obj.ToObject();
- else if (checkTypeId == CheckTypeId.RemoteSmtpBanner)
- return obj.ToObject();
- else if (checkTypeId == CheckTypeId.RemoteSmtp)
- return obj.ToObject();
- else if (checkTypeId == CheckTypeId.RemoteSsh)
- return obj.ToObject();
- else if (checkTypeId == CheckTypeId.RemoteTcp)
- return obj.ToObject();
- else if (checkTypeId == CheckTypeId.RemoteTelnetBanner)
- return obj.ToObject();
- else
- return obj.ToObject();
+ Func factory;
+ if (DetailsFactories.TryGetValue(checkTypeId, out factory))
+ return factory(obj);
+
+ return obj.ToObject();
}
///
diff --git a/src/corelib/Providers/Rackspace/Objects/Monitoring/CheckTypeId.cs b/src/corelib/Providers/Rackspace/Objects/Monitoring/CheckTypeId.cs
index 3de4f36ee..c051b41c3 100644
--- a/src/corelib/Providers/Rackspace/Objects/Monitoring/CheckTypeId.cs
+++ b/src/corelib/Providers/Rackspace/Objects/Monitoring/CheckTypeId.cs
@@ -51,6 +51,7 @@ public CheckTypeId(string id)
///
/// Gets a representing a remote DNS check.
///
+ ///
public static CheckTypeId RemoteDns
{
get
@@ -62,6 +63,7 @@ public static CheckTypeId RemoteDns
///
/// Gets a representing a remote FTP banner check.
///
+ ///
public static CheckTypeId RemoteFtpBanner
{
get
@@ -73,6 +75,7 @@ public static CheckTypeId RemoteFtpBanner
///
/// Gets a representing a remote HTTP check.
///
+ ///
public static CheckTypeId RemoteHttp
{
get
@@ -84,6 +87,7 @@ public static CheckTypeId RemoteHttp
///
/// Gets a representing a remote IMAP check.
///
+ ///
public static CheckTypeId RemoteImapBanner
{
get
@@ -95,6 +99,7 @@ public static CheckTypeId RemoteImapBanner
///
/// Gets a representing a remote SQL Server check.
///
+ ///
public static CheckTypeId RemoteMssqlBanner
{
get
@@ -106,6 +111,7 @@ public static CheckTypeId RemoteMssqlBanner
///
/// Gets a representing a remote MySQL check.
///
+ ///
public static CheckTypeId RemoteMysqlBanner
{
get
@@ -117,6 +123,7 @@ public static CheckTypeId RemoteMysqlBanner
///
/// Gets a representing a remote PING check.
///
+ ///
public static CheckTypeId RemotePing
{
get
@@ -128,6 +135,7 @@ public static CheckTypeId RemotePing
///
/// Gets a representing a remote POP3 check.
///
+ ///
public static CheckTypeId RemotePop3Banner
{
get
@@ -139,6 +147,7 @@ public static CheckTypeId RemotePop3Banner
///
/// Gets a representing a remote PostgreSQL check.
///
+ ///
public static CheckTypeId RemotePostgresqlBanner
{
get
@@ -150,6 +159,7 @@ public static CheckTypeId RemotePostgresqlBanner
///
/// Gets a representing a remote SMTP banner check.
///
+ ///
public static CheckTypeId RemoteSmtpBanner
{
get
@@ -161,6 +171,7 @@ public static CheckTypeId RemoteSmtpBanner
///
/// Gets a representing a remote SMTP check.
///
+ ///
public static CheckTypeId RemoteSmtp
{
get
@@ -172,6 +183,7 @@ public static CheckTypeId RemoteSmtp
///
/// Gets a representing a remote SSH check.
///
+ ///
public static CheckTypeId RemoteSsh
{
get
@@ -183,6 +195,7 @@ public static CheckTypeId RemoteSsh
///
/// Gets a representing a remote TCP check.
///
+ ///
public static CheckTypeId RemoteTcp
{
get
@@ -194,6 +207,7 @@ public static CheckTypeId RemoteTcp
///
/// Gets a representing a remote telnet banner check.
///
+ ///
public static CheckTypeId RemoteTelnetBanner
{
get
@@ -205,6 +219,7 @@ public static CheckTypeId RemoteTelnetBanner
///
/// Gets a representing an agent filesystem check.
///
+ ///
public static CheckTypeId AgentFilesystem
{
get
@@ -216,6 +231,7 @@ public static CheckTypeId AgentFilesystem
///
/// Gets a representing an agent memory check.
///
+ ///
public static CheckTypeId AgentMemory
{
get
@@ -227,6 +243,7 @@ public static CheckTypeId AgentMemory
///
/// Gets a representing an agent load average check.
///
+ ///
public static CheckTypeId AgentLoadAverage
{
get
@@ -238,6 +255,7 @@ public static CheckTypeId AgentLoadAverage
///
/// Gets a representing an agent CPU check.
///
+ ///
public static CheckTypeId AgentCpu
{
get
@@ -249,6 +267,7 @@ public static CheckTypeId AgentCpu
///
/// Gets a representing an agent disk check.
///
+ ///
public static CheckTypeId AgentDisk
{
get
@@ -260,6 +279,7 @@ public static CheckTypeId AgentDisk
///
/// Gets a representing an agent network check.
///
+ ///
public static CheckTypeId AgentNetwork
{
get
@@ -271,6 +291,7 @@ public static CheckTypeId AgentNetwork
///
/// Gets a representing an agent plug-in check.
///
+ ///
public static CheckTypeId AgentPlugin
{
get
diff --git a/src/corelib/Providers/Rackspace/Objects/Monitoring/CpuCheckDetails.cs b/src/corelib/Providers/Rackspace/Objects/Monitoring/CpuCheckDetails.cs
new file mode 100644
index 000000000..9c2265d64
--- /dev/null
+++ b/src/corelib/Providers/Rackspace/Objects/Monitoring/CpuCheckDetails.cs
@@ -0,0 +1,31 @@
+namespace net.openstack.Providers.Rackspace.Objects.Monitoring
+{
+ using Newtonsoft.Json;
+
+ ///
+ /// This class represents the detailed configuration parameters for a
+ /// check.
+ ///
+ ///
+ ///
+ ///
+ [JsonObject(MemberSerialization.OptIn)]
+ public class CpuCheckDetails : CheckDetails
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public CpuCheckDetails()
+ {
+ }
+
+ ///
+ ///
+ /// This class only supports checks.
+ ///
+ protected internal override bool SupportsCheckType(CheckTypeId checkTypeId)
+ {
+ return checkTypeId == CheckTypeId.AgentCpu;
+ }
+ }
+}
diff --git a/src/corelib/Providers/Rackspace/Objects/Monitoring/DiskCheckDetails.cs b/src/corelib/Providers/Rackspace/Objects/Monitoring/DiskCheckDetails.cs
new file mode 100644
index 000000000..def919da9
--- /dev/null
+++ b/src/corelib/Providers/Rackspace/Objects/Monitoring/DiskCheckDetails.cs
@@ -0,0 +1,68 @@
+namespace net.openstack.Providers.Rackspace.Objects.Monitoring
+{
+ using System;
+ using Newtonsoft.Json;
+
+ ///
+ /// This class represents the detailed configuration parameters for a
+ /// check.
+ ///
+ ///
+ ///
+ ///
+ [JsonObject(MemberSerialization.OptIn)]
+ public class DiskCheckDetails : CheckDetails
+ {
+ ///
+ /// This is the backing field for the property.
+ ///
+ [JsonProperty("target")]
+ private string _target;
+
+ ///
+ /// Initializes a new instance of the class
+ /// during JSON deserialization.
+ ///
+ [JsonConstructor]
+ protected DiskCheckDetails()
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the class
+ /// with the specified target.
+ ///
+ /// The disk to check.
+ /// If is .
+ /// If is empty.
+ public DiskCheckDetails(string target)
+ {
+ if (target == null)
+ throw new ArgumentNullException("target");
+ if (string.IsNullOrEmpty(target))
+ throw new ArgumentException("target cannot be empty");
+
+ _target = target;
+ }
+
+ ///
+ /// Gets the disk to check.
+ ///
+ public string Target
+ {
+ get
+ {
+ return _target;
+ }
+ }
+
+ ///
+ ///
+ /// This class only supports checks.
+ ///
+ protected internal override bool SupportsCheckType(CheckTypeId checkTypeId)
+ {
+ return checkTypeId == CheckTypeId.AgentDisk;
+ }
+ }
+}
diff --git a/src/corelib/Providers/Rackspace/Objects/Monitoring/FilesystemCheckDetails.cs b/src/corelib/Providers/Rackspace/Objects/Monitoring/FilesystemCheckDetails.cs
new file mode 100644
index 000000000..ad452a981
--- /dev/null
+++ b/src/corelib/Providers/Rackspace/Objects/Monitoring/FilesystemCheckDetails.cs
@@ -0,0 +1,68 @@
+namespace net.openstack.Providers.Rackspace.Objects.Monitoring
+{
+ using System;
+ using Newtonsoft.Json;
+
+ ///
+ /// This class represents the detailed configuration parameters for a
+ /// check.
+ ///
+ ///
+ ///
+ ///
+ [JsonObject(MemberSerialization.OptIn)]
+ public class FilesystemCheckDetails : CheckDetails
+ {
+ ///
+ /// This is the backing field for the property.
+ ///
+ [JsonProperty("target")]
+ private string _target;
+
+ ///
+ /// Initializes a new instance of the class
+ /// during JSON deserialization.
+ ///
+ [JsonConstructor]
+ protected FilesystemCheckDetails()
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the class
+ /// with the specified target.
+ ///
+ /// The mount point to check.
+ /// If is .
+ /// If is empty.
+ public FilesystemCheckDetails(string target)
+ {
+ if (target == null)
+ throw new ArgumentNullException("target");
+ if (string.IsNullOrEmpty(target))
+ throw new ArgumentException("target cannot be empty");
+
+ _target = target;
+ }
+
+ ///
+ /// Gets the mount point to check.
+ ///
+ public string Target
+ {
+ get
+ {
+ return _target;
+ }
+ }
+
+ ///
+ ///
+ /// This class only supports checks.
+ ///
+ protected internal override bool SupportsCheckType(CheckTypeId checkTypeId)
+ {
+ return checkTypeId == CheckTypeId.AgentFilesystem;
+ }
+ }
+}
diff --git a/src/corelib/Providers/Rackspace/Objects/Monitoring/LoadAverageCheckDetails.cs b/src/corelib/Providers/Rackspace/Objects/Monitoring/LoadAverageCheckDetails.cs
new file mode 100644
index 000000000..c55ecaac2
--- /dev/null
+++ b/src/corelib/Providers/Rackspace/Objects/Monitoring/LoadAverageCheckDetails.cs
@@ -0,0 +1,35 @@
+namespace net.openstack.Providers.Rackspace.Objects.Monitoring
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Text;
+ using Newtonsoft.Json;
+
+ ///
+ /// This class represents the detailed configuration parameters for a
+ /// check.
+ ///
+ ///
+ ///
+ ///
+ [JsonObject(MemberSerialization.OptIn)]
+ public class LoadAverageCheckDetails : CheckDetails
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public LoadAverageCheckDetails()
+ {
+ }
+
+ ///
+ ///
+ /// This class only supports checks.
+ ///
+ protected internal override bool SupportsCheckType(CheckTypeId checkTypeId)
+ {
+ return checkTypeId == CheckTypeId.AgentLoadAverage;
+ }
+ }
+}
diff --git a/src/corelib/Providers/Rackspace/Objects/Monitoring/MemoryCheckDetails.cs b/src/corelib/Providers/Rackspace/Objects/Monitoring/MemoryCheckDetails.cs
new file mode 100644
index 000000000..950e93cca
--- /dev/null
+++ b/src/corelib/Providers/Rackspace/Objects/Monitoring/MemoryCheckDetails.cs
@@ -0,0 +1,31 @@
+namespace net.openstack.Providers.Rackspace.Objects.Monitoring
+{
+ using Newtonsoft.Json;
+
+ ///
+ /// This class represents the detailed configuration parameters for a
+ /// check.
+ ///
+ ///
+ ///
+ ///
+ [JsonObject(MemberSerialization.OptIn)]
+ public class MemoryCheckDetails : CheckDetails
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public MemoryCheckDetails()
+ {
+ }
+
+ ///
+ ///
+ /// This class only supports checks.
+ ///
+ protected internal override bool SupportsCheckType(CheckTypeId checkTypeId)
+ {
+ return checkTypeId == CheckTypeId.AgentMemory;
+ }
+ }
+}
diff --git a/src/corelib/Providers/Rackspace/Objects/Monitoring/NetworkCheckDetails.cs b/src/corelib/Providers/Rackspace/Objects/Monitoring/NetworkCheckDetails.cs
new file mode 100644
index 000000000..481369104
--- /dev/null
+++ b/src/corelib/Providers/Rackspace/Objects/Monitoring/NetworkCheckDetails.cs
@@ -0,0 +1,68 @@
+namespace net.openstack.Providers.Rackspace.Objects.Monitoring
+{
+ using System;
+ using Newtonsoft.Json;
+
+ ///
+ /// This class represents the detailed configuration parameters for a
+ /// check.
+ ///
+ ///
+ ///
+ ///
+ [JsonObject(MemberSerialization.OptIn)]
+ public class NetworkCheckDetails : CheckDetails
+ {
+ ///
+ /// This is the backing field for the property.
+ ///
+ [JsonProperty("target")]
+ private string _target;
+
+ ///
+ /// Initializes a new instance of the class
+ /// during JSON deserialization.
+ ///
+ [JsonConstructor]
+ protected NetworkCheckDetails()
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the class
+ /// with the specified target.
+ ///
+ /// The network device to check.
+ /// If is .
+ /// If is empty.
+ public NetworkCheckDetails(string target)
+ {
+ if (target == null)
+ throw new ArgumentNullException("target");
+ if (string.IsNullOrEmpty(target))
+ throw new ArgumentException("target cannot be empty");
+
+ _target = target;
+ }
+
+ ///
+ /// Gets the network device to check.
+ ///
+ public string Target
+ {
+ get
+ {
+ return _target;
+ }
+ }
+
+ ///
+ ///
+ /// This class only supports checks.
+ ///
+ protected internal override bool SupportsCheckType(CheckTypeId checkTypeId)
+ {
+ return checkTypeId == CheckTypeId.AgentNetwork;
+ }
+ }
+}
diff --git a/src/corelib/Providers/Rackspace/Objects/Monitoring/PluginCheckDetails.cs b/src/corelib/Providers/Rackspace/Objects/Monitoring/PluginCheckDetails.cs
new file mode 100644
index 000000000..010584be7
--- /dev/null
+++ b/src/corelib/Providers/Rackspace/Objects/Monitoring/PluginCheckDetails.cs
@@ -0,0 +1,121 @@
+namespace net.openstack.Providers.Rackspace.Objects.Monitoring
+{
+ using System;
+ using System.Collections.ObjectModel;
+ using System.Linq;
+ using Newtonsoft.Json;
+
+ ///
+ /// This class represents the detailed configuration parameters for a
+ /// check.
+ ///
+ ///
+ ///
+ ///
+ [JsonObject(MemberSerialization.OptIn)]
+ public class PluginCheckDetails : CheckDetails
+ {
+ ///
+ /// This is the backing field for the property.
+ ///
+ [JsonProperty("file")]
+ private string _file;
+
+ ///
+ /// This is the backing field for the property.
+ ///
+ [JsonProperty("args", DefaultValueHandling = DefaultValueHandling.Ignore)]
+ private string[] _arguments;
+
+ ///
+ /// This is the backing field for the property.
+ ///
+ [JsonProperty("timeout", DefaultValueHandling = DefaultValueHandling.Ignore)]
+ private int? _timeout;
+
+ ///
+ /// Initializes a new instance of the class
+ /// during JSON deserialization.
+ ///
+ [JsonConstructor]
+ protected PluginCheckDetails()
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the class
+ /// with the specified values.
+ ///
+ /// The name of the plugin file.
+ /// A collection of command line arguments which are passed to the plugin. If this argument is , no command line arguments are passed to the plugin.
+ /// The plugin execution timeout. If this value is , the plugin execution timeout is unspecified.
+ /// If is .
+ ///
+ /// If is empty.
+ /// -or-
+ /// If contains any or empty values.
+ ///
+ /// If is less than .
+ public PluginCheckDetails(string file, string[] arguments, TimeSpan? timeout)
+ {
+ if (file == null)
+ throw new ArgumentNullException("file");
+ if (arguments != null && arguments.Any(string.IsNullOrEmpty))
+ throw new ArgumentException("arguments cannot contain any null or empty values", "arguments");
+ if (timeout < TimeSpan.Zero)
+ throw new ArgumentOutOfRangeException("timeout cannot be negative");
+
+ _file = file;
+ _arguments = (string[])arguments.Clone();
+ _timeout = timeout != null ? (int?)timeout.Value.TotalMilliseconds : null;
+ }
+
+ ///
+ /// Gets the name of the plugin file.
+ ///
+ public string File
+ {
+ get
+ {
+ return _file;
+ }
+ }
+
+ ///
+ /// Gets a collection of command line arguments passed to the plugin.
+ ///
+ public ReadOnlyCollection Arguments
+ {
+ get
+ {
+ if (_arguments == null)
+ return null;
+
+ return new ReadOnlyCollection(_arguments);
+ }
+ }
+
+ ///
+ /// Gets the plugin execution timeout.
+ ///
+ public TimeSpan? Timeout
+ {
+ get
+ {
+ if (_timeout == null)
+ return null;
+
+ return TimeSpan.FromMilliseconds(_timeout.Value);
+ }
+ }
+
+ ///
+ ///
+ /// This class only supports checks.
+ ///
+ protected internal override bool SupportsCheckType(CheckTypeId checkTypeId)
+ {
+ return checkTypeId == CheckTypeId.AgentPlugin;
+ }
+ }
+}
diff --git a/src/corelib/corelib.v3.5.csproj b/src/corelib/corelib.v3.5.csproj
index c139d26e0..1ff256543 100644
--- a/src/corelib/corelib.v3.5.csproj
+++ b/src/corelib/corelib.v3.5.csproj
@@ -391,11 +391,13 @@
+
+
@@ -403,6 +405,7 @@
+
@@ -411,7 +414,9 @@
+
+
@@ -423,6 +428,7 @@
+
@@ -444,6 +450,7 @@
+
diff --git a/src/corelib/corelib.v4.0.csproj b/src/corelib/corelib.v4.0.csproj
index e47c9d8b1..0e63cd109 100644
--- a/src/corelib/corelib.v4.0.csproj
+++ b/src/corelib/corelib.v4.0.csproj
@@ -414,11 +414,13 @@
+
+
@@ -426,6 +428,7 @@
+
@@ -434,7 +437,9 @@
+
+
@@ -446,6 +451,7 @@
+
@@ -467,6 +473,7 @@
+