splunk-sdk-python icon indicating copy to clipboard operation
splunk-sdk-python copied to clipboard

validators.Set() and validators.OptionName() aren't fully implemented

Open kkirsche opened this issue 11 years ago • 4 comments

Hey,

I'm trying to use the Set validator to ensure that the input provided is in a list. I have defined the validator like so:

validate=validators.Set('geography', 'domain', 'zipcode', 'isp', 'asn', 'organization'))

Yet when I call the command which houses this I get:

External search command 'custom_command' returned error code 1. Script output = " ERROR "NotImplementedError at ""/opt/splunk/etc/apps/custom_command/bin/splunklib/searchcommands/validators.py"", line 42 : " "

This doesn't make sense considering your function definition for Set:

class Set(Validator):
    """ Validates set option values.

    """
    def __init__(self, *args):
        self.membership = args

    def __call__(self, value):
        if value is not None:
            value = str(value)
            if value not in self.membership:
                raise ValueError('Unrecognized value: %s' % value)
                return value

Is this error caused by something I'm doing wrong or is this an issue with the SDK? I couldn't find any documentation about your validators or proper usage of them.

I have tried to pass a list instead of individual values as well but then the validator never looks inside the list (for example: validate=validators.Set(['geography', 'domain', 'zipcode', 'isp', 'asn', 'organization']))

kkirsche avatar Jul 20 '15 15:07 kkirsche

Looks like it's in the develop branch since Sept 19, 2014, but not the master branch. a67ef414a6b1352e35c739509f4bed6f7b727391

rhaarm avatar Jul 20 '15 16:07 rhaarm

Yep. It appears this is another instance of code not making it to the master branch from develop in the same way that #110 was.

This issue isn't limited to Set() it would appear, and seems to also apply to OptionName() which is missing it's format function as well.

kkirsche avatar Jul 20 '15 17:07 kkirsche

@shakeelmohamed it's not in progress it's already in your develop. It was lost when you guys did the hotfix for Python 2.7

kkirsche avatar Jul 20 '15 18:07 kkirsche

Hi @kkirsche we've just released v1.4.0 that addresses this.

shakeelmohamed avatar Aug 05 '15 00:08 shakeelmohamed