/* * Copyright 2012 Splunk, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"): you may * not use this file except in compliance with the License. You may obtain * a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations * under the License. */ namespace Splunk { using System; using System.Collections.Generic; /// /// Represents the set of specific Splunk input kinds. /// public class InputKind { /// /// The map of known inputs, aka relative paths. /// private static Dictionary knownRelativePaths = new Dictionary(); /// /// The kind of input. /// private string kind; /// /// The relative path from the inputs endpoint. /// private string relpath; /// /// The input class type. /// private Type inputClass; /// /// The basic, unknown input type. /// public static readonly InputKind Unknown = new InputKind("Unknown", typeof(Input)); /// /// The Monitor Input /// public static readonly InputKind Monitor = new InputKind("monitor", typeof(MonitorInput)); /// /// The Script Input /// public static readonly InputKind Script = new InputKind("script", typeof(ScriptInput)); /// /// The Raw TCP Input /// public static readonly InputKind Tcp = new InputKind("tcp/raw", typeof(TcpInput)); /// /// The Cooked TCP Input /// public static readonly InputKind TcpSplunk = new InputKind("tcp/cooked", typeof(TcpSplunkInput)); /// /// The UDP Input /// public static readonly InputKind Udp = new InputKind("udp", typeof(UdpInput)); /// /// The Windows Active Directory Input /// public static readonly InputKind WindowsActiveDirectory = new InputKind("ad", typeof(WindowsActiveDirectoryInput)); /// /// The Windows Event Log Input /// public static readonly InputKind WindowsEventLog = new InputKind( "win-event-log-collections", typeof(WindowsEventLogInput)); /// /// The Windows Performance Monitor Input /// public static readonly InputKind WindowsPerfmon = new InputKind("win-perfmon", typeof(WindowsPerfmonInput)); /// /// The Windows Registry Input /// public static readonly InputKind WindowsRegistry = new InputKind("registry", typeof(WindowsRegistryInput)); /// /// The Windows WMI Input /// public static readonly InputKind WindowsWmi = new InputKind("win-wmi-collections", typeof(WindowsWmiInput)); /// /// Initializes a new instance of the class. /// /// The relative input path /// The input class public InputKind(string relpath, Type inputClass) { this.kind = relpath; this.relpath = relpath; this.inputClass = inputClass; knownRelativePaths.Add(relpath, this); } /// /// Initializes a new instance of the class. /// /// The relative input path /// The input class /// The kind public InputKind(string relpath, Type inputClass, string kind) { this.kind = kind; this.relpath = relpath; this.inputClass = inputClass; knownRelativePaths.Add(relpath, this); } /// /// Gets the IEnumerable list of Inputs /// public static IEnumerable Values { get { yield return Unknown; yield return Monitor; yield return Script; yield return Tcp; yield return TcpSplunk; yield return Udp; yield return WindowsActiveDirectory; yield return WindowsEventLog; yield return WindowsPerfmon; yield return WindowsRegistry; yield return WindowsWmi; } } /// /// Gets the kind of this input /// public string Kind { get { return this.kind; } } /// /// Gets the relative path of this input /// public string RelPath { get { return this.relpath; } } /// /// Gets the class type of this input /// public Type InputClass { get { return this.inputClass; } } /// /// Creates an input. /// /// The relative path /// The input kind public static InputKind Create(string relPath) { if (knownRelativePaths.ContainsKey(relPath)) { return knownRelativePaths[relPath]; } else { return new InputKind(relPath, typeof(Input)); } } } }