diff --git a/README.md b/README.md index 4e67795ff..e23767b76 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ [![Build Status](https://travis-ci.org/splunk/splunk-sdk-python.svg?branch=master)](https://travis-ci.org/splunk/splunk-sdk-python) +[![Documentation Status](https://readthedocs.org/projects/splunk-python-sdk/badge/?version=latest)](https://splunk-python-sdk.readthedocs.io/en/latest/?badge=latest) + # The Splunk Software Development Kit for Python #### Version 1.6.6 diff --git a/docs/index.rst b/docs/index.rst index b04f51b1d..8f209468f 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -3,6 +3,16 @@ For more information, see the `Splunk Developer Portal `` - `` myHost`` - `` https://127.0.0.1:8089`` - `` 123102983109283019283`` - `` /opt/splunk/var/lib/splunk/modinputs`` - `` `` - `` value1`` - `` `` - `` value2`` - `` value3`` - `` value4`` - `` `` - `` `` - ```` + .. code-block:: xml + + + myHost + https://127.0.0.1:8089 + 123102983109283019283 + /opt/splunk/var/lib/splunk/modinputs + + value1 + + value2 + value3 + value4 + + + :param stream: ``Stream`` containing XML to parse. - :return definition: A ``ValidationDefinition`` object. + :return: A ``ValidationDefinition`` object. """ diff --git a/splunklib/searchcommands/__init__.py b/splunklib/searchcommands/__init__.py index 12b14f32c..c56c510d5 100644 --- a/splunklib/searchcommands/__init__.py +++ b/splunklib/searchcommands/__init__.py @@ -30,7 +30,7 @@ field-name = ( "_" / alpha ) *( alpha / digit / "_" / "." / "-" ) It does not show that :code:`field-name` values may be comma-separated. This is because Splunk strips commas from - the command line. A search command will never see them. + the command line. A search command will never see them. 2. Search commands targeting versions of Splunk prior to 6.3 must be statically configured as follows: @@ -134,7 +134,7 @@ .. topic:: References - 1. `Search command style guide `_ + 1. `Search command style guide `__ 2. `Commands.conf.spec `_ diff --git a/splunklib/searchcommands/decorators.py b/splunklib/searchcommands/decorators.py index b5e16064a..36590a76b 100644 --- a/splunklib/searchcommands/decorators.py +++ b/splunklib/searchcommands/decorators.py @@ -36,7 +36,7 @@ class Configuration(object): variable to search command classes that don't have one. The :code:`name` is derived from the name of the class. By convention command class names end with the word "Command". To derive :code:`name` the word "Command" is removed from the end of the class name and then converted to lower case for conformance with the `Search command style guide - `_ + `__ """ def __init__(self, o=None, **kwargs): @@ -229,8 +229,9 @@ class Option(property): Short form (recommended). When you are satisfied with built-in or custom validation behaviors. - .. code-block:: python + .. code-block:: python :linenos: + from splunklib.searchcommands.decorators import Option from splunklib.searchcommands.validators import Fieldname @@ -247,8 +248,9 @@ class Option(property): also provide a deleter. You must be prepared to accept a value of :const:`None` which indicates that your :code:`Option` is unset. - .. code-block:: python + .. code-block:: python :linenos: + from splunklib.searchcommands import Option @Option() diff --git a/splunklib/searchcommands/external_search_command.py b/splunklib/searchcommands/external_search_command.py index 2c4ce50b7..c2306241e 100644 --- a/splunklib/searchcommands/external_search_command.py +++ b/splunklib/searchcommands/external_search_command.py @@ -105,13 +105,13 @@ def _execute(path, argv=None, environ=None): :param argv: Argument list. :type argv: list or tuple - The arguments to the child process should start with the name of the command being run, but this is not - enforced. A value of :const:`None` specifies that the base name of path name :param:`path` should be used. + The arguments to the child process should start with the name of the command being run, but this is not + enforced. A value of :const:`None` specifies that the base name of path name :param:`path` should be used. :param environ: A mapping which is used to define the environment variables for the new process. :type environ: dict or None. - This mapping is used instead of the current process’s environment. A value of :const:`None` specifies that - the :data:`os.environ` mapping should be used. + This mapping is used instead of the current process’s environment. A value of :const:`None` specifies that + the :data:`os.environ` mapping should be used. :return: None diff --git a/splunklib/searchcommands/generating_command.py b/splunklib/searchcommands/generating_command.py index fd0585e4c..46858cbdd 100644 --- a/splunklib/searchcommands/generating_command.py +++ b/splunklib/searchcommands/generating_command.py @@ -92,9 +92,10 @@ class StreamingGeneratingCommand(GeneratingCommand) +==========+===================================================+===================================================+ | streams | 1. Add this line to your command's stanza in | 1. Add this configuration setting to your code: | | | | | - | | default/commands.conf. | .. code-block:: python | - | | .. code-block:: python | @Configuration(distributed=True) | - | | local = false | class SomeCommand(GeneratingCommand) | + | | default/commands.conf:: | .. code-block:: python | + | | | | + | | local = false | @Configuration(distributed=True) | + | | | class SomeCommand(GeneratingCommand) | | | | ... | | | 2. Restart splunk | | | | | 2. You are good to go; no need to restart Splunk | @@ -112,6 +113,7 @@ class StreamingGeneratingCommand(GeneratingCommand) | | settings to your command class: | setting to your command class: | | | | | | | .. code-block:: python | .. code-block:: python | + | | | | | | @Configuration( | @Configuration(type='events') | | | retainsevents=True, streaming=False) | class SomeCommand(GeneratingCommand) | | | class SomeCommand(GeneratingCommand) | ... | @@ -119,22 +121,25 @@ class StreamingGeneratingCommand(GeneratingCommand) | | | | | | Or add these lines to default/commands.conf: | | | | | | - | | .. code-block:: | | - | | retains events = true | | + | | .. code-block:: text | | + | | | | + | | retainsevents = true | | | | streaming = false | | +----------+---------------------------------------------------+---------------------------------------------------+ Configure your command class like this, if you wish to support both protocols: - .. code-block:: python + .. code-block:: python + @Configuration(type='events', retainsevents=True, streaming=False) class SomeCommand(GeneratingCommand) ... You might also consider adding these lines to commands.conf instead of adding them to your command class: - .. code-block:: python - retains events = false + .. code-block:: python + + retainsevents = false streaming = false Reporting Generating command @@ -149,28 +154,32 @@ class SomeCommand(GeneratingCommand) | | settings to your command class: | setting to your command class: | | | | | | | .. code-block:: python | .. code-block:: python | + | | | | | | @Configuration(retainsevents=False) | @Configuration(type='reporting') | | | class SomeCommand(GeneratingCommand) | class SomeCommand(GeneratingCommand) | | | ... | ... | | | | | | | Or add this lines to default/commands.conf: | | | | | | - | | .. code-block:: | | - | | retains events = false | | + | | .. code-block:: text | | + | | | | + | | retainsevents = false | | | | streaming = false | | +----------+---------------------------------------------------+---------------------------------------------------+ Configure your command class like this, if you wish to support both protocols: - .. code-block:: python + .. code-block:: python + @Configuration(type='reporting', streaming=False) class SomeCommand(GeneratingCommand) ... You might also consider adding these lines to commands.conf instead of adding them to your command class: - .. code-block:: python - retains events = false + .. code-block:: text + + retainsevents = false streaming = false """ diff --git a/splunklib/searchcommands/search_command.py b/splunklib/searchcommands/search_command.py index 47918abb6..64b06aba1 100644 --- a/splunklib/searchcommands/search_command.py +++ b/splunklib/searchcommands/search_command.py @@ -256,7 +256,7 @@ def search_results_info(self): invocation. :return: Search results info:const:`None`, if the search results info file associated with the command - invocation is inaccessible. + invocation is inaccessible. :rtype: SearchResultsInfo or NoneType """ @@ -338,6 +338,7 @@ def service(self): specifying this pair of configuration settings in commands.conf: .. code-block:: python + enableheader = true requires_srinfo = true @@ -345,8 +346,8 @@ def service(self): :code:`requires_srinfo` setting is false by default. Hence, you must set it. :return: :class:`splunklib.client.Service`, if :code:`enableheader` and :code:`requires_srinfo` are both - :code:`true`. Otherwise, if either :code:`enableheader` or :code:`requires_srinfo` are :code:`false`, a value - of :code:`None` is returned. + :code:`true`. Otherwise, if either :code:`enableheader` or :code:`requires_srinfo` are :code:`false`, a value + of :code:`None` is returned. """ if self._service is not None: @@ -809,15 +810,15 @@ def write_metric(self, name, value): :param name: Name of the metric. :type name: basestring - :param value: A 4-tuple containing the value of metric :param:`name` where + :param value: A 4-tuple containing the value of metric ``name`` where value[0] = Elapsed seconds or :const:`None`. value[1] = Number of invocations or :const:`None`. value[2] = Input count or :const:`None`. value[3] = Output count or :const:`None`. - The :data:`SearchMetric` type provides a convenient encapsulation of :param:`value`. - The :data:`SearchMetric` type provides a convenient encapsulation of :param:`value`. + The :data:`SearchMetric` type provides a convenient encapsulation of ``value``. + The :data:`SearchMetric` type provides a convenient encapsulation of ``value``. :return: :const:`None`. @@ -1080,7 +1081,7 @@ def dispatch(command_class, argv=sys.argv, input_file=sys.stdin, output_file=sys **Example** - .. code-block:: python + .. code-block:: python :linenos: #!/usr/bin/env python @@ -1096,7 +1097,7 @@ def stream(records): **Example** - .. code-block:: python + .. code-block:: python :linenos: from splunklib.searchcommands import dispatch, StreamingCommand, Configuration, Option, validators diff --git a/splunklib/searchcommands/validators.py b/splunklib/searchcommands/validators.py index 66329375c..dca4cf422 100644 --- a/splunklib/searchcommands/validators.py +++ b/splunklib/searchcommands/validators.py @@ -81,9 +81,9 @@ class Code(Validator): def __init__(self, mode='eval'): """ :param mode: Specifies what kind of code must be compiled; it can be :const:`'exec'`, if source consists of a - sequence of statements, :const:`'eval'`, if it consists of a single expression, or :const:`'single'` if it - consists of a single interactive statement. In the latter case, expression statements that evaluate to - something other than :const:`None` will be printed. + sequence of statements, :const:`'eval'`, if it consists of a single expression, or :const:`'single'` if it + consists of a single interactive statement. In the latter case, expression statements that evaluate to + something other than :const:`None` will be printed. :type mode: unicode or bytes """