forked from splunk/splunk-sdk-csharp-pcl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArgument.cs
138 lines (122 loc) · 4.25 KB
/
Argument.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
/*
* 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.Xml.Serialization;
/// <summary>
/// The <see cref="Argument"/> class represents an XML entity describing
/// an individual argument of a modular input.
/// </summary>
/// <remarks>
/// It corresponds to one of the keys that can be defined for an instance
/// of that modular input in a stanza in inputs.conf.
/// <example>
/// Sample XML Argument</example>
/// <code>
/// <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>
/// </code>
/// </remarks>
[XmlRoot("arg")]
public class Argument
{
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="Argument" /> class.
/// </summary>
public Argument()
{
DataType = DataType.String;
this.RequiredOnEdit = false;
this.RequiredOnCreate = true;
}
#endregion
#region Properties
/// <summary>
/// The unique name for the parameter.
/// </summary>
[XmlAttribute("name")]
public string Name { get; set; }
/// <summary>
/// The label for the parameter.
/// </summary>
[XmlElement("title")]
public string Title { get; set; }
/// <summary>
/// The description of the parameter.
/// </summary>
[XmlElement("description")]
public string Description { get; set; }
/// <summary>
/// The validation rules for arguments passed to an endpoint
/// create or edit action.
/// </summary>
[XmlElement("validation")]
public string Validation { get; set; }
public delegate bool ValidationHandler(Parameter parameter, out string errorMessage);
/// <summary>
/// Specify a delegate to run on the argument's value during validation (before the overall
/// Validate method is called).
/// </summary>
[XmlIgnore]
public ValidationHandler ValidationDelegate { get; set; }
/// <summary>
/// The value for use with scripts that return data in JSON format.
/// </summary>
/// <remarks>
/// <para>
/// This property defines the data type of the parameter.
/// </para>
/// <para>
/// The default data type is "string".
/// </para>
/// </remarks>
[XmlElement("data_type")]
public DataType DataType { get; set; }
/// <summary>
/// A value indicating whether the parameter is required for edit.
/// </summary>
/// <remarks>
/// <para>
/// Set this property to <c>true</c> to make the parameter required for edit.
/// </para>
/// <para>
/// This property's default value is <c>false</c>.
/// </para>
/// </remarks>
[XmlElement("required_on_edit")]
public bool RequiredOnEdit { get; set; }
/// <summary>
/// A value indicating whether the parameter is required for create.
/// </summary>
/// <remarks>
/// <para>
/// Set this property to <c>false</c> to make the parameter optional.
/// </para>
/// <para>
/// This property's default value is <c>true</c>.
/// </para>
/// </remarks>
[XmlElement("required_on_create")]
public bool RequiredOnCreate { get; set; }
#endregion
}
}