forked from splunk/splunk-sdk-csharp-pcl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScheme.cs
158 lines (147 loc) · 5.43 KB
/
Scheme.cs
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/*
* Copyright 2014 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.ModularInputs
{
using System;
using System.Collections.Generic;
using System.IO;
using System.Xml.Serialization;
/// <summary>
/// Represents the XML output when a modular input is called by Splunk for
/// introspection.
/// </summary>
/// <remarks>
/// The modular input script (that is, executable) returns the XML output
/// through standard output to Splunk.
/// <example>
/// Sample XML Output Document</example>
/// <code>
/// <![CDATA[
/// <?xml version="1.0" encoding="utf-16"?>
/// <scheme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
/// <title>Test Example</title>
/// <description>This is a test modular input that handles all the appropriate functionality</description>
/// <use_external_validation>true</use_external_validation>
/// <use_single_instance>false</use_single_instance>
/// <streaming_mode>xml</streaming_mode>
/// <endpoint>
/// <args>
/// <arg name="interval">
/// <description>Polling Interval</description>
/// <validation>is_pos_int('interval')</validation>
/// <data_type>number</data_type>
/// <required_on_edit>false</required_on_edit>
/// <required_on_create>true</required_on_create>
/// </arg>
/// <arg name="username">
/// <description>Admin Username</description>
/// <data_type>string</data_type>
/// <required_on_edit>false</required_on_edit>
/// <required_on_create>false</required_on_create>
/// </arg>
/// <arg name="password">
/// <description>Admin Password</description>
/// <data_type>string</data_type>
/// <required_on_edit>true</required_on_edit>
/// <required_on_create>true</required_on_create>
/// </arg>
/// </args>
/// </endpoint>
/// </scheme>]]>
/// </code>
/// </remarks>
[XmlRoot("scheme")]
public class Scheme
{
/// <summary>
/// Initializes a new instance of the <see cref="Scheme" /> class.
/// </summary>
/// <remarks>
/// This constructor sets up default values for this scheme.
/// </remarks>
public Scheme()
{
this.UseExternalValidation = true;
this.UseSingleInstance = false;
this.Endpoint = new EndpointElement();
}
/// <summary>
/// Gets or sets the title of the modular input.
/// </summary>
[XmlElement("title")]
public string Title { get; set; }
/// <summary>
/// Gets or sets the description of the modular input.
/// </summary>
[XmlElement("description")]
public string Description { get; set; }
/// <summary>
/// Gets or sets a value indicating whether external validation
/// is enabled for this modular input.
/// </summary>
/// <remarks>
/// <para>
/// Override <see cref="ModularInput.Validate"/> to perform the validation.
/// </para>
/// <para>
/// This property's default value is <c>true</c>.
/// </para>
/// </remarks>
[XmlElement("use_external_validation")]
public bool UseExternalValidation { get; set; }
/// <summary>
/// Gets or sets a value indicating whether to launch a single instance
/// of the script or one script instance for each input stanza.
/// </summary>
/// <remarks>
/// This property's default value is <c>false</c>.
/// </remarks>
[XmlElement("use_single_instance")]
public bool UseSingleInstance { get; set; }
/// <summary>
/// Gest or sets the streaming mode for this modular input (Simple or Xml).
/// </summary>
/// <remarks>
/// This property's default value is "Xml".
/// </remarks>
[XmlElement("streaming_mode")]
public StreamingMode StreamingMode { get; set; }
/// <summary>
/// Gets or sets the endpoint element for this scheme.
/// </summary>
[XmlElement("endpoint")]
public EndpointElement Endpoint { get; set; }
/// <summary>
/// Gets or sets the list of arguments specified by this Scheme.
/// </summary>
[XmlIgnore]
public List<Argument> Arguments
{
get { return Endpoint.Arguments; }
set { Endpoint.Arguments = value; }
}
public class EndpointElement
{
internal EndpointElement()
{
this.Arguments = new List<Argument>();
}
[XmlArray("args")]
[XmlArrayItem("arg")]
public List<Argument> Arguments { get; set; }
}
}
}