This repository was archived by the owner on Jul 20, 2024. It is now read-only.
forked from splunk/splunk-sdk-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInputKind.java
More file actions
136 lines (113 loc) · 4.75 KB
/
InputKind.java
File metadata and controls
136 lines (113 loc) · 4.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/*
* 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.
*/
package com.splunk;
import java.util.HashMap;
import java.util.Map;
/**
* The {@code InputKind} enumeration defines the different types of Splunk data
* inputs (<i>input kinds</i>). For example, a raw TCP input is
* {@code InputKind.Tcp}, and a cooked TCP input is {@code InputKind.TcpSplunk}.
* Each modular input kind shows up as a separate instance of {@code InputKind}.
*/
public class InputKind {
private String kind;
private String relpath;
private Class<? extends Input> inputClass;
private static Map<String, InputKind> knownRelpaths = new HashMap<String, InputKind>();
/** Unknown type of input. */
public static final InputKind Unknown = new InputKind(null, Input.class, "unknown");
/** Monitor input. */
public static final InputKind Monitor = new InputKind("monitor", MonitorInput.class);
/** Script input. */
public static final InputKind Script = new InputKind("script", ScriptInput.class);
/** Raw TCP input. */
public static final InputKind Tcp = new InputKind("tcp/raw", TcpInput.class, "tcp");
/** Cooked TCP input. */
public static final InputKind TcpSplunk = new InputKind("tcp/cooked", TcpSplunkInput.class);
/** UDP input. */
public static final InputKind Udp = new InputKind("udp", UdpInput.class);
/** Windows Active Directory input. */
public static final InputKind WindowsActiveDirectory = new InputKind("ad", WindowsActiveDirectoryInput.class);
/** Windows event log input. */
public static final InputKind WindowsEventLog = new InputKind("win-event-log-collections",WindowsEventLogInput.class);
// As of Splunk 6, "win-event-log-collections" has changed to "WinEventLog".
public static final InputKind WinEventLog = new InputKind("WinEventLog", WindowsEventLogInput.class);
/** Windows performance monitor input. */
public static final InputKind WindowsPerfmon = new InputKind("win-perfmon", WindowsPerfmonInput.class);
/** Windows Registry input. */
public static final InputKind WindowsRegistry = new InputKind("registry", WindowsRegistryInput.class);
// As of Splunk 6, "registry" has changed to "WinRegMon".
public static final InputKind WinRegMon = new InputKind("WinRegMon", WindowsRegistryInput.class);
/** Windows Management Instrumentation (WMI) input. */
public static final InputKind WindowsWmi = new InputKind("win-wmi-collections", WindowsWmiInput.class);
private InputKind(String relpath, Class<? extends Input> inputClass, String kind) {
this.relpath = relpath;
this.inputClass = inputClass;
this.kind = kind;
knownRelpaths.put(relpath, this);
}
private InputKind(String relpath, Class<? extends Input> inputClass) {
this(
relpath,
inputClass,
relpath
);
}
/**
* @return A string that specifies the input kind, as it is
* represented in the Atom entry for an input entity.
*/
String getKind() {
return kind;
}
/**
* @return A string that contains the relative endpoint path from the
* data/inputs/ endpoint to this input kind.
*/
String getRelativePath() {
return relpath;
}
/**
* @return The class to use to create instances for this input kind.
*/
Class<? extends Input> getInputClass() {
return inputClass;
}
/**
* Create an {@code InputKind} object from a {@code String} giving
* the relative path from data/inputs/ to the kind. For example,
* "tcp/raw" or "monitor".
*
* {@code InputKind}'s constructors are private. You should use this method
* to create an {@code InputKind}.
*
* @param relpath The relative path from data/inputs specifying the {@code InputKind} to create.
* @return An {@code InputKind} object.
*/
public static InputKind create(String relpath) {
if (knownRelpaths.containsKey(relpath)) {
return knownRelpaths.get(relpath);
} else {
return new InputKind(relpath, Input.class);
}
}
/**
* @return Textual representation for debugging purposes.
*/
public String toString() {
return relpath;
}
}