Skip to content

Commit ceba6a0

Browse files
author
Shakeel Mohamed
committed
Release 1.6.0
2 parents 3a7df39 + 6d30252 commit ceba6a0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+948
-136
lines changed

.travis.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
notifications:
2+
email: false
3+
sudo: required
4+
5+
services:
6+
- docker
7+
8+
before_install:
9+
# Create .splunkrc file with default credentials
10+
- echo host=127.0.0.1 >> $HOME/.splunkrc
11+
- echo username=admin >> $HOME/.splunkrc
12+
- echo password=changeme >> $HOME/.splunkrc
13+
# Set SPLUNK_HOME
14+
- export SPLUNK_HOME="/opt/splunk"
15+
# Pull docker image
16+
- docker pull splunk/splunk-sdk-travis-ci:$SPLUNK_VERSION
17+
# Add DOCKER to iptables, 1/10 times this is needed, force 0 exit status
18+
- sudo iptables -N DOCKER || true
19+
# Start Docker container
20+
- docker run -p 127.0.0.1:8089:8089 -d splunk/splunk-sdk-travis-ci:$SPLUNK_VERSION
21+
# curl Splunk until it returns valid data indicating it has been setup, try 20 times maximum
22+
- 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
23+
# The upload test needs to refer to a file that Splunk has in the docker
24+
# container
25+
- export INPUT_EXAMPLE_UPLOAD=$SPLUNK_HOME/var/log/splunk/splunkd_ui_access.log
26+
# After initial setup, we do not want to give the SDK any notion that it has
27+
# a local Splunk installation it can use, so we create a blank SPLUNK_HOME
28+
# for it, and make a placeholder for log files (which some tests generate)
29+
- export SPLUNK_HOME=`pwd`/splunk_home
30+
- mkdir -p $SPLUNK_HOME/var/log/splunk
31+
32+
env:
33+
- SPLUNK_VERSION=6.2.6-sdk
34+
- SPLUNK_VERSION=6.3.1-sdk
35+
36+
language: python
37+
38+
python:
39+
- "2.7"
40+
- "2.6"
41+
42+
install: "pip install unittest2"
43+
44+
before_script: python setup.py build dist
45+
46+
script: python setup.py test

CHANGELOG.md

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,30 @@
11
# Splunk SDK for Python Changelog
22

3+
## Version 1.6.0
4+
5+
### New Features and APIs
6+
7+
* Added support for KV Store.
8+
9+
* Added support for HTTP basic authentication (GitHub issue #117).
10+
11+
* Improve support for HTTP keep-alive connections (GitHub issue #122).
12+
13+
14+
### Bug Fixes
15+
16+
* Fixed Python 2.6 compatibility (GitHub issue #141).
17+
18+
* Fixed appending restrictToHost to UDP inputs (GitHub issue #128).
19+
20+
### Minor Changes
21+
22+
* Added support for Travis CI.
23+
24+
* Updated the default test runner.
25+
26+
* Removed shortened links from documentation and comments.
27+
328
## Version 1.5.0
429

530
### New features and APIs
@@ -51,9 +76,9 @@
5176

5277
* Restored support for Python 2.6 (GitHub issues #96 & #114).
5378

54-
* Fix `SearchCommands` decorators and `Validator` classes (Github issue #113).
79+
* Fix `SearchCommands` decorators and `Validator` classes (GitHub issue #113).
5580

56-
* Fix `SearchCommands` bug iterating over `None` in `dict_reader.fieldnames` (Github issue #110).
81+
* Fix `SearchCommands` bug iterating over `None` in `dict_reader.fieldnames` (GitHub issue #110).
5782

5883
* Fixed JSON parsing errors (GitHub issue #100).
5984

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
[![Build Status](https://travis-ci.org/splunk/splunk-sdk-python.svg?branch=master)](https://travis-ci.org/splunk/splunk-sdk-python)
12
# The Splunk Software Development Kit for Python
23

3-
#### Version 1.5.0
4+
#### Version 1.6.0
45

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

docs/client.rst

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,18 @@ splunklib.client
6868
:members: create, export, itemmeta, oneshot
6969
:inherited-members:
7070

71+
.. autoclass:: KVStoreCollection
72+
:members: data, update_index, update_field
73+
:inherited-members:
74+
75+
.. autoclass:: KVStoreCollectionData
76+
:members: query, query_by_id, insert, delete, delete_by_id, update, batch_save
77+
:inherited-members:
78+
79+
.. autoclass:: KVStoreCollections
80+
:members: create
81+
:inherited-members:
82+
7183
.. autoclass:: Loggers
7284
:members: itemmeta
7385
:inherited-members:
@@ -110,7 +122,7 @@ splunklib.client
110122
:inherited-members:
111123

112124
.. autoclass:: Service
113-
:members: apps, confs, capabilities, event_types, fired_alerts, indexes, info, inputs, job, jobs, loggers, messages, modular_input_kinds, parse, restart, restart_required, roles, search, saved_searches, settings, splunk_version, storage_passwords, users
125+
:members: apps, confs, capabilities, event_types, fired_alerts, indexes, info, inputs, job, jobs, kvstore, loggers, messages, modular_input_kinds, parse, restart, restart_required, roles, search, saved_searches, settings, splunk_version, storage_passwords, users
114126
:inherited-members:
115127

116128
.. autoclass:: Settings

docs/index.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ For more information, see the `Splunk Developer Portal <http://dev.splunk.com/vi
6969

7070
:class:`~splunklib.client.Jobs` class
7171

72+
:class:`~splunklib.client.KVStoreCollection` class
73+
74+
:class:`~splunklib.client.KVStoreCollectionData` class
75+
76+
:class:`~splunklib.client.KVStoreCollections` class
77+
7278
:class:`~splunklib.client.Loggers` class
7379

7480
:class:`~splunklib.client.Message` class
@@ -147,6 +153,8 @@ For more information, see the `Splunk Developer Portal <http://dev.splunk.com/vi
147153
:doc:`searchcommands`
148154
---------------------
149155

156+
:class:`~splunklib.searchcommands.EventingCommand` class
157+
150158
:class:`~splunklib.searchcommands.GeneratingCommand` class
151159

152160
:class:`~splunklib.searchcommands.ReportingCommand` class

docs/searchcommands.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,20 @@ splunklib.searchcommands
55

66
.. autofunction:: dispatch(command_class[, argv=sys.argv, input_file=sys.stdin, output_file=sys.stdout, module_name=None])
77

8+
.. autoclass:: EventingCommand
9+
:members:
10+
:inherited-members:
11+
:exclude-members: ConfigurationSettings, process, transform
12+
13+
.. autoclass:: splunklib.searchcommands::EventingCommand.ConfigurationSettings
14+
:members:
15+
:inherited-members:
16+
:exclude-members: configuration_settings, fix_up, items, keys
17+
18+
.. automethod:: splunklib.searchcommands::EventingCommand.transform
19+
20+
.. automethod:: splunklib.searchcommands::EventingCommand.process(args=sys.argv[, input_file=sys.stdin, output_file=sys.stdout])
21+
822
.. autoclass:: GeneratingCommand
923
:members:
1024
:inherited-members:

examples/kvstore.py

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#!/usr/bin/env python
2+
#
3+
# Copyright 2011-2015 Splunk, Inc.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License"): you may
6+
# not use this file except in compliance with the License. You may obtain
7+
# a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
# License for the specific language governing permissions and limitations
15+
# under the License.
16+
17+
"""A command line utility for interacting with Splunk KV Store Collections."""
18+
19+
import sys, os, json
20+
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
21+
22+
from splunklib.client import connect
23+
24+
try:
25+
from utils import parse
26+
except ImportError:
27+
raise Exception("Add the SDK repository to your PYTHONPATH to run the examples "
28+
"(e.g., export PYTHONPATH=~/splunk-sdk-python.")
29+
30+
def main():
31+
opts = parse(sys.argv[1:], {}, ".splunkrc")
32+
opts.kwargs["owner"] = "nobody"
33+
opts.kwargs["app"] = "search"
34+
service = connect(**opts.kwargs)
35+
36+
print "KV Store Collections:"
37+
for collection in service.kvstore:
38+
print " %s" % collection.name
39+
40+
# Let's delete a collection if it already exists, and then create it
41+
collection_name = "example_collection"
42+
if collection_name in service.kvstore:
43+
service.kvstore.delete(collection_name)
44+
45+
# Let's create it and then make sure it exists
46+
service.kvstore.create(collection_name)
47+
collection = service.kvstore[collection_name]
48+
49+
# Let's make sure it doesn't have any data
50+
print "Should be empty: %s" % json.dumps(collection.data.query())
51+
52+
# Let's add some data
53+
collection.data.insert(json.dumps({"_key": "item1", "somekey": 1, "otherkey": "foo"}))
54+
collection.data.insert(json.dumps({"_key": "item2", "somekey": 2, "otherkey": "foo"}))
55+
collection.data.insert(json.dumps({"somekey": 3, "otherkey": "bar"}))
56+
57+
# Let's make sure it has the data we just entered
58+
print "Should have our data: %s" % json.dumps(collection.data.query(), indent=1)
59+
60+
# Let's run some queries
61+
print "Should return item1: %s" % json.dumps(collection.data.query_by_id("item1"), indent=1)
62+
63+
query = json.dumps({"otherkey": "foo"})
64+
print "Should return item1 and item2: %s" % json.dumps(collection.data.query(query=query), indent=1)
65+
66+
query = json.dumps({"otherkey": "bar"})
67+
print "Should return third item with auto-generated _key: %s" % json.dumps(collection.data.query(query=query), indent=1)
68+
69+
# Let's delete the collection
70+
collection.delete()
71+
72+
if __name__ == "__main__":
73+
main()
74+
75+

examples/searchcommands_app/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ The app is tested on Splunk 5 and 6. Here is its manifest:
4141
[3] [Python Logging HOWTO](http://docs.python.org/2/howto/logging.html)
4242
[4] [ConfigParser—Configuration file parser](http://docs.python.org/2/library/configparser.html)
4343
[5] [searchbnf.conf](http://docs.splunk.com/Documentation/Splunk/latest/admin/Searchbnfconf)
44-
[6] [Set permissions in the file system](http://goo.gl/1oDT7r)
44+
[6] [Set permissions in the file system](http://docs.splunk.com/Documentation/Splunk/latest/AdvancedDev/SetPermissions#Set_permissions_in_the_filesystem)
4545

4646
## Installation
4747

examples/searchcommands_app/package/README/logging.conf.spec

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#
22
# The format of this file is described in this article at Python.org:
33
#
4-
# [Configuration file format](http://goo.gl/K6edZ8)
4+
# [Configuration file format](https://docs.python.org/2/library/logging.config.html#configuration-file-format)
55
#
66
# This file must contain sections called [loggers], [handlers] and [formatters] which identify by name the entities of
77
# each type which are defined in the file. For each such entity, there is a separate section which identifies how that
@@ -57,7 +57,7 @@ propagate = [0|1]
5757

5858
[handlers]
5959
* Specifies a list of handler keys.
60-
* See [logging.handlers](http://goo.gl/9aoOx)
60+
* See [logging.handlers](https://docs.python.org/2/library/logging.handlers.html)
6161

6262
keys = <comma-separated strings>
6363
* A comma-separated list of handlers keys. Each key must have a corresponding [handler_<string>] section in the
@@ -86,7 +86,7 @@ formatter = <string>
8686

8787
[formatters]
8888
* Specifies a list of formatter keys.
89-
* See [logging.formatters](http://goo.gl/z5CBR3)
89+
* See [logging.formatters](https://docs.python.org/2/howto/logging.html#formatters)
9090

9191
keys = <comma-separated strings>
9292
* A comma-separated list of formatter keys. Each key must have a corresponding [formatter_<string>] section in the
@@ -105,12 +105,12 @@ datefmt = <string>
105105
* The strftime-compatible date/time format string. If empty, the package substitutes ISO8601 format date/times.
106106
* An example ISO8601 date/time is datetime(2015, 2, 6, 15, 53, 36, 786309).isoformat() ==
107107
* '2015-02-06T15:53:36.786309'. For a complete list of formatting directives, see section [strftime() and strptime()
108-
* Behavior](http://goo.gl/6zUAGv)
108+
* Behavior](https://docs.python.org/2/library/datetime.html#strftime-strptime-behavior)
109109
* Defaults to empty.
110110

111111
format = <string>
112112
* The overall format string. This string uses %(<dictionary key>)s styled string substitution; the possible keys are
113-
* documented in [LogRecord](http://goo.gl/qW83Dg) attributes. The following format string will log the time in a
113+
* documented in [LogRecord](https://docs.python.org/2/library/logging.html#logging.LogRecord) attributes. The following format string will log the time in a
114114
* human-readable format, the severity of the message, and the contents of the message, in that order:
115115
* format = '%(asctime)s - %(levelname)s - %(message)s'
116116
* A value is required.

examples/searchcommands_app/package/bin/countmatches.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def stream(self, records):
6464
for record in records:
6565
count = 0L
6666
for fieldname in self.fieldnames:
67-
matches = pattern.findall(unicode(record[fieldname]))
67+
matches = pattern.findall(unicode(record[fieldname].decode("utf-8")))
6868
count += len(matches)
6969
record[self.fieldname] = count
7070
yield record

0 commit comments

Comments
 (0)