Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
af998ee
Updates to release 1.6.13
shilpabijam May 18, 2020
5f80fbd
updated changelog
shilpabijam May 18, 2020
7ff830d
Install sdk-app-collection via docker-compose
amysutedja May 22, 2020
b8aefd6
Helpful instructions around docker usage
amysutedja May 22, 2020
3e0c6f1
Move env variable directive in README quickstart to after the command
amysutedja May 29, 2020
6b51317
Fix extra chunks being sent for large chunks
aij Jan 3, 2020
2beb3e3
Keep chunk requests and responses synchronized
aij Jan 17, 2020
5002dc6
Fix generating commands
aij Jan 21, 2020
da3fc20
Clean up and match previous behavior more closely
aij Jan 22, 2020
9052c90
Fix test_internals_v2.py
aij Jan 22, 2020
bb0d71b
search_command no longer sends a successful response on fatal errors
aij Jan 22, 2020
390d327
Rename and cleanup follow-up for chunk synchronization
amysutedja Jun 5, 2020
d60a22c
Merge branch 'master' of github.com:splunk/splunk-sdk-python into dev…
amysutedja Sep 1, 2020
7d83b29
Merge branch 'master' of github.com:splunk/splunk-sdk-python into dev…
amysutedja Sep 9, 2020
b8f24af
Fix for incorrect merge in interaction between multibyte characters a…
amysutedja Sep 10, 2020
9badb9a
Fix SyntaxWarning over comparison of literals using is
tirkarthi Apr 11, 2020
98ab7bb
Fix deprecation warning regarding invalid escape sequences.
tirkarthi Apr 11, 2020
ef5e40e
Merge pull request #317 from tirkarthi/fix-warnings
amysutedja Sep 10, 2020
1f0a076
Update copyright years to 2020
amysutedja Sep 22, 2020
027e761
Merge pull request #348 from splunk/copyright-updates-2020
amysutedja Oct 14, 2020
26d6156
Add docstring and tests describing how to add body to POST request.
zenmoto Oct 14, 2020
04a94c0
fix handling of body parameters in Context.post(...)
zenmoto Oct 16, 2020
fdff4a6
allow params to be in either order in test
zenmoto Dec 3, 2020
c723347
Merge branch 'develop' into tests_and_docstring_for_post_body
zenmoto Dec 9, 2020
ed75051
Merge pull request #352 from splunk/tests_and_docstring_for_post_body
zenmoto Dec 10, 2020
d9f08dd
Merge branch 'master' into release/1.6.15
fantavlik Jan 28, 2021
f7222b3
Updates files for 1.6.15 release.
fantavlik Jan 28, 2021
ddebf73
Update CHANGELOG
fantavlik Jan 28, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@ before_install:
- echo password=changed! >> $HOME/.splunkrc
# Set SPLUNK_HOME
- export SPLUNK_HOME="/opt/splunk"
# Pull docker image
- docker pull splunk/splunk-sdk-travis-ci:$SPLUNK_VERSION
# Add DOCKER to iptables, 1/10 times this is needed, force 0 exit status
- sudo iptables -N DOCKER || true
# Start Docker container
- docker run -p 127.0.0.1:8089:8089 -d splunk/splunk-sdk-travis-ci:$SPLUNK_VERSION
# curl Splunk until it returns valid data indicating it has been setup, try 20 times maximum
- for i in `seq 0 20`; do if curl --fail -k https://localhost:8089/services/server/info &> /dev/null; then break; fi; echo $i; sleep 1; done
# Start docker-compose in detached mode
- docker-compose up -d
# Health Check (3 minutes)
- for i in `seq 0 180`; do if docker exec -it splunk /sbin/checkstate.sh &> /dev/null; then break; fi; echo $i; sleep 1; done
# The upload test needs to refer to a file that Splunk has in the docker
# container
- export INPUT_EXAMPLE_UPLOAD=$SPLUNK_HOME/var/log/splunk/splunkd_ui_access.log
Expand All @@ -32,8 +30,8 @@ before_install:
language: python

env:
- SPLUNK_VERSION=7.3-sdk
- SPLUNK_VERSION=8.0-sdk
- SPLUNK_VERSION=7.3
- SPLUNK_VERSION=8.0

python:
- "2.7"
Expand Down
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Splunk Enterprise SDK for Python Changelog

## Version 1.6.15

### Bug fixes
[#301](https://github.com/splunk/splunk-sdk-python/pull/301) Fix chunk synchronization
[#327](https://github.com/splunk/splunk-sdk-python/pull/327) Rename and cleanup follow-up for chunk synchronization
[#352](https://github.com/splunk/splunk-sdk-python/pull/352) Allow supplying of a key-value body when calling Context.post()

### Minor changes
[#350](https://github.com/splunk/splunk-sdk-python/pull/350) Initial end-to-end tests for streaming, reporting, generating custom search commands
[#348](https://github.com/splunk/splunk-sdk-python/pull/348) Update copyright years to 2020
[#346](https://github.com/splunk/splunk-sdk-python/pull/346) Readme updates to urls, terminology, and formatting
[#317](https://github.com/splunk/splunk-sdk-python/pull/317) Fix deprecation warnings

## Version 1.6.14

### Bug fix
Expand Down
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# The Splunk Enterprise Software Development Kit for Python

#### Version 1.6.14
#### Version 1.6.15

The Splunk Enterprise Software Development Kit (SDK) for Python contains library code and examples designed to enable developers to build applications using the Splunk platform.

Expand All @@ -13,7 +13,7 @@ The Splunk platform is popular with system administrators for aggregation and mo

The Splunk developer platform enables developers to take advantage of the same technology used by the Splunk platform to build exciting new applications.

For more information, see [Splunk Enterprise SDK for Python](https://dev.splunk.com/enterprise/docs/devtools/python/sdk-python/) on the Splunk Developer Portal.
## Getting started with the Splunk SDK for Python


## Get started with the Splunk Enterprise SDK for Python
Expand All @@ -37,7 +37,6 @@ Here's what you need to get going with the Splunk Enterprise SDK for Python.

Get the Splunk Enterprise SDK for Python from [PyPI](https://pypi.org/project/splunk-sdk/). If you want to contribute to the SDK, clone the repository from [GitHub](https://github.com/splunk/splunk-sdk-python).


### Install the SDK

Use the following commands to install the Splunk Enterprise SDK for Python libraries in different ways. However, it's not necessary to install the libraries to run the examples and unit tests from the SDK.
Expand All @@ -58,8 +57,17 @@ Install the sources you cloned from GitHub:

[sudo] python setup.py install

## Testing Quickstart

You'll need `docker` and `docker-compose` to get up and running using this method.

### Run the examples and unit tests
```
make up SPLUNK_VERSION=8.0
make wait_up
make splunkrc_default
make test
make down
```

To run the examples and unit tests, you must put the root of the SDK on your PYTHONPATH. For example, if you downloaded the SDK to your home folder and are running OS X or Linux, add the following line to your **.bash_profile** file:

Expand Down
20 changes: 20 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: '3.6'

services:
splunk:
image: "splunk/splunk:${SPLUNK_VERSION}"
container_name: splunk
environment:
- SPLUNK_START_ARGS=--accept-license
- SPLUNK_HEC_TOKEN=11111111-1111-1111-1111-1111111111113
- SPLUNK_PASSWORD=changed!
- SPLUNK_APPS_URL=https://github.com/splunk/sdk-app-collection/releases/download/v1.0.0/sdk-app-collection.tgz
ports:
- 8000:8000
- 8088:8088
- 8089:8089
healthcheck:
test: ['CMD', 'curl', '-f', 'http://localhost:8000']
interval: 5s
timeout: 5s
retries: 20
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

# General information about the project.
project = u'Splunk SDK for Python'
copyright = u'2014, Splunk Inc'
copyright = u'2020, Splunk Inc'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -95,7 +95,7 @@
# a list of builtin themes.

# agogo, default, epub, haiku, nature, pyramid, scrolls, sphinxdoc, traditional
html_theme = 'default'
html_theme = 'default'

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
Expand Down
2 changes: 1 addition & 1 deletion examples/searchcommands_app/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ def run(self):
setup(
description='Custom Search Command examples',
name=os.path.basename(project_dir),
version='1.6.14',
version='1.6.15',
author='Splunk, Inc.',
author_email='[email protected]',
url='http://github.com/splunk/splunk-sdk-python',
Expand Down
4 changes: 2 additions & 2 deletions scripts/build-splunkrc.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
'host': 'localhost',
'port': '8089',
'username': 'admin',
'password': 'changeme',
'password': 'changed!',
'scheme': 'https',
'version': '6.3'
'version': '8.0'
}

DEFAULT_SPLUNKRC_PATH = os.path.join(str(Path.home()), '.splunkrc')
Expand Down
2 changes: 1 addition & 1 deletion splunklib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@

from __future__ import absolute_import
from splunklib.six.moves import map
__version_info__ = (1, 6, 14)
__version_info__ = (1, 6, 15)
__version__ = ".".join(map(str, __version_info__))
11 changes: 9 additions & 2 deletions splunklib/binding.py
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,12 @@ def post(self, path_segment, owner=None, app=None, sharing=None, headers=None, *
:type headers: ``list`` of 2-tuples.
:param query: All other keyword arguments, which are used as query
parameters.
:type query: ``string``
:param body: Parameters to be used in the post body. If specified,
any parameters in the query will be applied to the URL instead of
the body. If a dict is supplied, the key-value pairs will be form
encoded. If a string is supplied, the body will be passed through
in the request unchanged.
:type body: ``dict`` or ``str``
:return: The response from the server.
:rtype: ``dict`` with keys ``body``, ``headers``, ``reason``,
and ``status``
Expand Down Expand Up @@ -1223,6 +1228,8 @@ def post(self, url, headers=None, **kwargs):
headers.append(("Content-Type", "application/x-www-form-urlencoded"))

body = kwargs.pop('body')
if isinstance(body, dict):
body = _encode(**body).encode('utf-8')
if len(kwargs) > 0:
url = url + UrlEncoded('?' + _encode(**kwargs), skip_encode=True)
else:
Expand Down Expand Up @@ -1378,7 +1385,7 @@ def request(url, message, **kwargs):
head = {
"Content-Length": str(len(body)),
"Host": host,
"User-Agent": "splunk-sdk-python/1.6.14",
"User-Agent": "splunk-sdk-python/1.6.15",
"Accept": "*/*",
"Connection": "Close",
} # defaults
Expand Down
2 changes: 1 addition & 1 deletion splunklib/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1872,7 +1872,7 @@ def delete(self, username, realm=None):
name = UrlEncoded(realm, encode_slash=True) + ":" + UrlEncoded(username, encode_slash=True)

# Append the : expected at the end of the name
if name[-1] is not ":":
if name[-1] != ":":
name = name + ":"
return Collection.delete(self, name)

Expand Down
24 changes: 13 additions & 11 deletions splunklib/searchcommands/generating_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,19 +204,21 @@ def _execute(self, ifile, process):

"""
if self._protocol_version == 2:
result = self._read_chunk(self._as_binary_stream(ifile))
self._execute_v2(ifile, self.generate())
else:
assert self._protocol_version == 1
self._record_writer.write_records(self.generate())
self.finish()

if not result:
def _execute_chunk_v2(self, process, chunk):
count = 0
for row in process:
self._record_writer.write_record(row)
count += 1
if count == self._record_writer._maxresultrows:
self._finished = False
return

metadata, body = result
action = getattr(metadata, 'action', None)

if action != 'execute':
raise RuntimeError('Expected execute action, not {}'.format(action))

self._record_writer.write_records(self.generate())
self.finish()
self._finished = True

# endregion

Expand Down
Loading