1919
2020class Argument (object ):
2121 """Class representing an argument to a modular input kind.
22+
2223 Argument is meant to be used with Scheme to generate an XML definition of the modular input
23- kind that Splunk understands."""
24+ kind that Splunk understands.
2425
25- # Constant values, do not change
26- dataTypeBoolean = "BOOLEAN"
27- dataTypeNumber = "NUMBER"
28- dataTypeString = "STRING"
29-
30- def __init__ (self , name , description = None , validation = None , \
31- dataType = dataTypeString , requiredOnEdit = False , requiredOnCreate = False ):
32- """name is the only required parameter for the constructor
26+ name is the only required parameter for the constructor
3327
3428 Example with least parameters:
3529
@@ -41,29 +35,40 @@ def __init__(self, name, description=None, validation=None, \
4135 name="arg2",
4236 description="This is an argument with lots of parameters",
4337 validation="is_pos_int('some_name')",
44- dataType =Argument.dataTypeNumber ,
45- requiredOnEdit =True,
46- requiredOnCreate =True
38+ data_type =Argument.data_type_number ,
39+ required_on_edit =True,
40+ required_on_create =True
4741 )
42+ """
4843
44+ # Constant values, do not change
45+ data_type_boolean = "BOOLEAN"
46+ data_type_number = "NUMBER"
47+ data_type_string = "STRING"
48+
49+ def __init__ (self , name , description = None , validation = None , \
50+ data_type = data_type_string , required_on_edit = False , required_on_create = False ):
51+ """
4952 :param name: string, identifier for this argument in Splunk
5053 :param description: string, human readable description of the argument
51- :param validation: string, specifying how the argument should be validated, if using internal validation. If using
52- external validation, this will be ignored.
53- :param dataType : string, data type of this field; use the class constants
54- dataTypeBoolean, dataTypeNumber , or dataTypeString
55- :param requiredOnEdit : boolean, is this arg required when editing an existing modular input of this kind?
56- :param requiredOnCreate : boolean, is this arg required when creating a modular input of this kind?
54+ :param validation: string, specifying how the argument should be validated, if using internal validation.
55+ If using external validation, this will be ignored.
56+ :param data_type : string, data type of this field; use the class constants
57+ data_type_boolean, data_type_number , or data_type_string
58+ :param required_on_edit : boolean, is this arg required when editing an existing modular input of this kind?
59+ :param required_on_create : boolean, is this arg required when creating a modular input of this kind?
5760 """
5861 self .name = name
5962 self .description = description
6063 self .validation = validation
61- self .dataType = dataType
62- self .requiredOnEdit = requiredOnEdit
63- self .requiredOnCreate = requiredOnCreate
64+ self .data_type = data_type
65+ self .required_on_edit = required_on_edit
66+ self .required_on_create = required_on_create
6467
6568 def add_to_document (self , parent ):
66- """Adds an <arg> SubElement to the Parent Element, typically <args>
69+ """Add an Argument object to this ElementTree Document
70+
71+ Adds an <arg> SubElement to the Parent Element, typically <args>
6772 and setup its subelements with their respective text
6873
6974 :param parent: an ET.Element to be the parent of a new <arg> SubElement
@@ -75,11 +80,11 @@ def add_to_document(self, parent):
7580 if self .description is not None :
7681 ET .SubElement (arg , "description" ).text = self .description
7782
78- if self .validation :
83+ if self .validation is not None :
7984 ET .SubElement (arg , "validation" ).text = self .validation
8085
81- ET .SubElement (arg , "data_type" ).text = self .dataType .lower ()
82- ET .SubElement (arg , "required_on_edit" ).text = str (self .requiredOnEdit ).lower ()
83- ET .SubElement (arg , "required_on_create" ).text = str (self .requiredOnCreate ).lower ()
86+ ET .SubElement (arg , "data_type" ).text = self .data_type .lower ()
87+ ET .SubElement (arg , "required_on_edit" ).text = str (self .required_on_edit ).lower ()
88+ ET .SubElement (arg , "required_on_create" ).text = str (self .required_on_create ).lower ()
8489
8590 return arg
0 commit comments