Splunk Dev

How can I make a parameter optional in a modular input?

andrew207
Path Finder

I've created a modular input using the Python API. I would like to know how I can make parameters optional.

I have set hard-coded defaults in inputs.conf and in the script itself, however, the GUI add input page has all fields set to mandatory -- I would like to change this.

My scheme is defined in the python script itself, a sample is below. How can I make a parameter optional?

SCHEME = """<scheme>
    <title>SOAP Polling</title>
    <description>Get data from a SOAP Service.</description>
    <use_external_validation>true</use_external_validation>
    <streaming_mode>simple</streaming_mode>
    <endpoint>
        <args>
            <arg name="param1">
                <title>my title</title>
                <description>my description</description>
            </arg>
            <arg name="param2"> <!-- I want to make this optional -->
                <title>my title</title>
                <description>my description</description>
            </arg>
        </args>
    </endpoint>
</scheme>
"""
0 Karma
1 Solution

renjith_nair
Legend

From http://docs.splunk.com/Documentation/Splunk/6.5.1/AdvancedDev/ModInputsScripts#Define_a_scheme_for_i... , below probably should help you,

<required_on_edit>  true | false (Default is false.)

Indicates whether the parameter is required for edit. Default behavior is that arguments for edit are optional. Set this to true to override this behavior, and make the parameter required.

<required_on_create>    true | false (Default is true.)

Indicates whether the parameter is required for create. Default behavior is that arguments for create are required. Set this to false to override this behavior, and make the parameter optional. 
---
What goes around comes around. If it helps, hit it with Karma 🙂

View solution in original post

renjith_nair
Legend

From http://docs.splunk.com/Documentation/Splunk/6.5.1/AdvancedDev/ModInputsScripts#Define_a_scheme_for_i... , below probably should help you,

<required_on_edit>  true | false (Default is false.)

Indicates whether the parameter is required for edit. Default behavior is that arguments for edit are optional. Set this to true to override this behavior, and make the parameter required.

<required_on_create>    true | false (Default is true.)

Indicates whether the parameter is required for create. Default behavior is that arguments for create are required. Set this to false to override this behavior, and make the parameter optional. 
---
What goes around comes around. If it helps, hit it with Karma 🙂
Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer at Splunk .conf24 ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...