Skip to content

Commit 19acb9a

Browse files
Merge pull request #443 from splunk/release/1.6.19
Release/1.6.19
2 parents ef88e9d + adb6fcd commit 19acb9a

Some content is hidden

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

91 files changed

+955
-395
lines changed

.env

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Splunk host (default: localhost)
2+
host=localhost
3+
# Splunk admin port (default: 8089)
4+
port=8089
5+
# Splunk username
6+
username=admin
7+
# Splunk password
8+
password=changed!
9+
# Access scheme (default: https)
10+
scheme=https
11+
# Your version of Splunk (default: 6.2)
12+
version=8.0
13+
# Bearer token for authentication
14+
#bearerToken="<Bearer-token>"
15+
# Session key for authentication
16+
#sessionKey="<Session-Key>"

.github/workflows/release.yml

+14-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ on:
33
push:
44
branches:
55
- master
6-
workflow_dispatch: {}
6+
workflow_dispatch: { }
77

88
jobs:
99
find_version:
@@ -21,6 +21,13 @@ jobs:
2121
- name: Get version
2222
id: get-version
2323
run: python -c 'import splunklib; print("::set-output name=version::%s" % splunklib.__version__)'
24+
- name: Install tox
25+
run: pip install tox
26+
- name: Generate API docs
27+
run: |
28+
rm -rf ./docs/_build
29+
tox -e docs
30+
cd ./docs/_build/html && zip -r ../docs_html.zip . -x ".*" -x "__MACOSX"
2431
tag_version:
2532
needs: find_version
2633
name: Tag Version
@@ -32,7 +39,7 @@ jobs:
3239
repo-token: ${{ secrets.GITHUB_TOKEN }}
3340
tag: ${{ needs.find_version.outputs.version }}
3441
release:
35-
needs: [find_version, tag_version]
42+
needs: [ find_version, tag_version ]
3643
name: Create Release
3744
runs-on: ubuntu-latest
3845
steps:
@@ -52,6 +59,11 @@ jobs:
5259
**TODO: Insert CHANGELOG.md contents here.**
5360
draft: false
5461
prerelease: false
62+
- name: Upload Artifact
63+
uses: actions/upload-artifact@v3
64+
with:
65+
name: apidocs
66+
path: docs/_build/docs_html.zip
5567
publish:
5668
needs: release
5769
name: Deploy Release to PyPI

.github/workflows/test.yml

+2-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Python CI
22

33
on:
4-
[push, pull_request]
4+
[ push, pull_request ]
55

66
jobs:
77
build:
@@ -11,7 +11,7 @@ jobs:
1111
matrix:
1212
os:
1313
- ubuntu-latest
14-
python: [2.7, 3.7]
14+
python: [ 2.7, 3.7 ]
1515
splunk-version:
1616
- "8.0"
1717
- "latest"
@@ -36,15 +36,6 @@ jobs:
3636
uses: actions/setup-python@v2
3737
with:
3838
python-version: ${{ matrix.python }}
39-
- name: Create .splunkrc file
40-
run: |
41-
cd ~
42-
echo host=localhost > .splunkrc
43-
echo port=8089 >> .splunkrc
44-
echo username=admin >> .splunkrc
45-
echo password=changed! >> .splunkrc
46-
echo scheme=https >> .splunkrc
47-
echo version=${{ matrix.splunk }} >> .splunkrc
4839
- name: Install tox
4940
run: pip install tox
5041
- name: Test Execution

CHANGELOG.md

+37
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,42 @@
11
# Splunk Enterprise SDK for Python Changelog
22

3+
## Version 1.6.19
4+
5+
### New features and APIs
6+
* [#441](https://github.com/splunk/splunk-sdk-python/pull/441) JSONResultsReader added and deprecated ResultsReader
7+
* Pre-requisite: Query parameter 'output_mode' must be set to 'json'
8+
* Improves performance by approx ~80-90%
9+
* ResultsReader is deprecated and will be removed in future releases (NOTE: Please migrate to JSONResultsReader)
10+
* [#437](https://github.com/splunk/splunk-sdk-python/pull/437) added setup_logging() method in splunklib for logging
11+
* [#426](https://github.com/splunk/splunk-sdk-python/pull/426) Added new github_commit modular input example
12+
* [#392](https://github.com/splunk/splunk-sdk-python/pull/392) Break out search argument to option parsing for v2 custom search commands
13+
* [#384](https://github.com/splunk/splunk-sdk-python/pull/384) Added Float parameter validator for custom search commands
14+
* [#371](https://github.com/splunk/splunk-sdk-python/pull/371) Modinput preserve 'app' context
15+
16+
### Bug fixes
17+
* [#439](https://github.com/splunk/splunk-sdk-python/pull/439) Modified POST method debug log to not log sensitive body/data
18+
* [#431](https://github.com/splunk/splunk-sdk-python/pull/431) Add distsearch.conf to Stream Search Command examples [ [issue#418](https://github.com/splunk/splunk-sdk-python/issues/418) ]
19+
* [#419](https://github.com/splunk/splunk-sdk-python/pull/419) Hec endpoint issue[ [issue#345](https://github.com/splunk/splunk-sdk-python/issues/345) ]
20+
* [#416](https://github.com/splunk/splunk-sdk-python/pull/416) Removed strip() method in load_value() method from data.py file [ [issue#400](https://github.com/splunk/splunk-sdk-python/issues/400) ]
21+
* [#148](https://github.com/splunk/splunk-sdk-python/pull/148) Identical entity names will cause an infinite loop
22+
23+
### Minor changes
24+
* [#440](https://github.com/splunk/splunk-sdk-python/pull/440) Github release workflow modified to generate docs
25+
* [#430](https://github.com/splunk/splunk-sdk-python/pull/430) Fix indentation in README
26+
* [#429](https://github.com/splunk/splunk-sdk-python/pull/429) documented how to access modular input metadata
27+
* [#427](https://github.com/splunk/splunk-sdk-python/pull/427) Replace .splunkrc with .env file in test and examples
28+
* [#424](https://github.com/splunk/splunk-sdk-python/pull/424) Float validator test fix
29+
* [#423](https://github.com/splunk/splunk-sdk-python/pull/423) Python3 compatibility for ResponseReader.__str__()
30+
* [#422](https://github.com/splunk/splunk-sdk-python/pull/422) ordereddict and all its reference removed
31+
* [#421](https://github.com/splunk/splunk-sdk-python/pull/421) Update README.md
32+
* [#387](https://github.com/splunk/splunk-sdk-python/pull/387) Update filter.py
33+
* [#331](https://github.com/splunk/splunk-sdk-python/pull/331) Fix a couple of warnings spotted when running python 2.7 tests
34+
* [#330](https://github.com/splunk/splunk-sdk-python/pull/330) client: use six.string_types instead of basestring
35+
* [#329](https://github.com/splunk/splunk-sdk-python/pull/329) client: remove outdated comment in Index.submit
36+
* [#262](https://github.com/splunk/splunk-sdk-python/pull/262) properly add parameters to request based on the method of the request
37+
* [#237](https://github.com/splunk/splunk-sdk-python/pull/237) Don't output close tags if you haven't written a start tag
38+
* [#149](https://github.com/splunk/splunk-sdk-python/pull/149) "handlers" stanza missing in examples/searchcommands_template/default/logging.conf
39+
340
## Version 1.6.18
441

542
### Bug fixes

Makefile

+10-10
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,16 @@ test_smoke_no_app:
5656
@echo "$(ATTN_COLOR)==> test_smoke_no_app $(NO_COLOR)"
5757
@tox -e py27,py37 -- -m "smoke and not app"
5858

59-
.PHONY: splunkrc
60-
splunkrc:
61-
@echo "$(ATTN_COLOR)==> splunkrc $(NO_COLOR)"
62-
@echo "To make a .splunkrc:"
63-
@echo " [SPLUNK_INSTANCE_JSON] | python scripts/build-splunkrc.py ~/.splunkrc"
64-
65-
.PHONY: splunkrc_default
66-
splunkrc_default:
67-
@echo "$(ATTN_COLOR)==> splunkrc_default $(NO_COLOR)"
68-
@python scripts/build-splunkrc.py ~/.splunkrc
59+
.PHONY: env
60+
env:
61+
@echo "$(ATTN_COLOR)==> env $(NO_COLOR)"
62+
@echo "To make a .env:"
63+
@echo " [SPLUNK_INSTANCE_JSON] | python scripts/build-env.py"
64+
65+
.PHONY: env_default
66+
env_default:
67+
@echo "$(ATTN_COLOR)==> env_default $(NO_COLOR)"
68+
@python scripts/build-env.py
6969

7070
.PHONY: up
7171
up:

README.md

+49-33
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
# The Splunk Enterprise Software Development Kit for Python
55

6-
#### Version 1.6.18
6+
#### Version 1.6.19
77

88
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.
99

@@ -60,7 +60,6 @@ You'll need `docker` and `docker-compose` to get up and running using this metho
6060
```
6161
make up SPLUNK_VERSION=8.0
6262
make wait_up
63-
make splunkrc_default
6463
make test
6564
make down
6665
```
@@ -75,7 +74,7 @@ The SDK command-line examples require a common set of arguments that specify the
7574
#### Using username/password
7675
```python
7776
import splunklib.client as client
78-
service = client.connect(host=<host_url>, username=<username>, password=<password>, autoLogin=True)
77+
service = client.connect(host=<host_url>, username=<username>, password=<password>, autologin=True)
7978
```
8079

8180
#### Using bearer token
@@ -91,13 +90,13 @@ service = client.connect(host=<host_url>, token=<session_key>, autologin=True)
9190
```
9291

9392
###
94-
#### Create a .splunkrc convenience file
93+
#### Update a .env file
9594

96-
To connect to Splunk Enterprise, many of the SDK examples and unit tests take command-line arguments that specify values for the host, port, and login credentials for Splunk Enterprise. For convenience during development, you can store these arguments as key-value pairs in a text file named **.splunkrc**. Then, the SDK examples and unit tests use the values from the **.splunkrc** file when you don't specify them.
95+
To connect to Splunk Enterprise, many of the SDK examples and unit tests take command-line arguments that specify values for the host, port, and login credentials for Splunk Enterprise. For convenience during development, you can store these arguments as key-value pairs in a **.env** file. Then, the SDK examples and unit tests use the values from the **.env** file when you don't specify them.
9796

98-
>**Note**: Storing login credentials in the **.splunkrc** file is only for convenience during development. This file isn't part of the Splunk platform and shouldn't be used for storing user credentials for production. And, if you're at all concerned about the security of your credentials, enter them at the command line rather than saving them in this file.
97+
>**Note**: Storing login credentials in the **.env** file is only for convenience during development. This file isn't part of the Splunk platform and shouldn't be used for storing user credentials for production. And, if you're at all concerned about the security of your credentials, enter them at the command line rather than saving them in this file.
9998
100-
To use this convenience file, create a text file with the following format:
99+
here is an example of .env file:
101100

102101
# Splunk Enterprise host (default: localhost)
103102
host=localhost
@@ -106,27 +105,15 @@ To use this convenience file, create a text file with the following format:
106105
# Splunk Enterprise username
107106
username=admin
108107
# Splunk Enterprise password
109-
password=changeme
108+
password=changed!
110109
# Access scheme (default: https)
111110
scheme=https
112111
# Your version of Splunk Enterprise
113112
version=8.0
114-
115-
Save the file as **.splunkrc** in the current user's home directory.
116-
117-
* For example on OS X, save the file as:
118-
119-
~/.splunkrc
120-
121-
* On Windows, save the file as:
122-
123-
C:\Users\currentusername\.splunkrc
124-
125-
You might get errors in Windows when you try to name the file because ".splunkrc" appears to be a nameless file with an extension. You can use the command line to create this file by going to the **C:\Users\\&lt;currentusername&gt;** directory and entering the following command:
126-
127-
Notepad.exe .splunkrc
128-
129-
Click **Yes**, then continue creating the file.
113+
# Bearer token for authentication
114+
#bearerToken=<Bearer-token>
115+
# Session key for authentication
116+
#sessionKey=<Session-Key>
130117

131118
#### Run the examples
132119

@@ -144,7 +131,7 @@ Using Session key
144131

145132
python examplename.py --sessionKey="<value>"
146133

147-
If you saved your login credentials in the **.splunkrc** file, you can omit those arguments:
134+
If you saved your login credentials in the **.env** file, you can omit those arguments:
148135

149136
python examplename.py
150137

@@ -212,19 +199,48 @@ class CustomStreamingCommand(StreamingCommand):
212199
Do
213200
```python
214201
@Configuration()
215-
class GeneratorTest(GeneratingCommand):
216-
def generate(self):
217-
yield self.gen_record(_time=time.time(), one=1)
218-
yield self.gen_record(_time=time.time(), two=2)
202+
class GeneratorTest(GeneratingCommand):
203+
def generate(self):
204+
yield self.gen_record(_time=time.time(), one=1)
205+
yield self.gen_record(_time=time.time(), two=2)
219206
```
220207

221208
Don't
222209
```python
223210
@Configuration()
224-
class GeneratorTest(GeneratingCommand):
225-
def generate(self):
226-
yield {'_time': time.time(), 'one': 1}
227-
yield {'_time': time.time(), 'two': 2}
211+
class GeneratorTest(GeneratingCommand):
212+
def generate(self):
213+
yield {'_time': time.time(), 'one': 1}
214+
yield {'_time': time.time(), 'two': 2}
215+
```
216+
217+
### Access metadata of modular inputs app
218+
* In stream_events() method we can access modular input app metadata from InputDefinition object
219+
* See [GitHub Commit](https://github.com/splunk/splunk-sdk-python/blob/develop/examples/github_commits/bin/github_commits.py) Modular input App example for reference.
220+
```python
221+
def stream_events(self, inputs, ew):
222+
# other code
223+
224+
# access metadata (like server_host, server_uri, etc) of modular inputs app from InputDefinition object
225+
# here inputs is a InputDefinition object
226+
server_host = inputs.metadata["server_host"]
227+
server_uri = inputs.metadata["server_uri"]
228+
229+
# Get the checkpoint directory out of the modular input's metadata
230+
checkpoint_dir = inputs.metadata["checkpoint_dir"]
231+
```
232+
233+
#### Optional:Set up logging for splunklib
234+
+ The default level is WARNING, which means that only events of this level and above will be visible
235+
+ To change a logging level we can call setup_logging() method and pass the logging level as an argument.
236+
+ Optional: we can also pass log format and date format string as a method argument to modify default format
237+
238+
```python
239+
import logging
240+
from splunklib import setup_logging
241+
242+
# To see debug and above level logs
243+
setup_logging(logging.DEBUG)
228244
```
229245

230246
### Changelog

docker-compose.yml

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ services:
1414
- ./splunklib:/opt/splunk/etc/apps/github_forks/lib/splunklib
1515
- ./examples/random_numbers:/opt/splunk/etc/apps/random_numbers
1616
- ./splunklib:/opt/splunk/etc/apps/random_numbers/lib/splunklib
17+
- ./examples/github_commits:/opt/splunk/etc/apps/github_commits
18+
- ./splunklib:/opt/splunk/etc/apps/github_commits/lib/splunklib
1719
- ./examples/searchcommands_app/package:/opt/splunk/etc/apps/searchcommands_app
1820
- ./splunklib:/opt/splunk/etc/apps/searchcommands_app/lib/splunklib
1921
- ./examples/twitted/twitted:/opt/splunk/etc/apps/twitted

docs/searchcommands.rst

+4
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ splunklib.searchcommands
8888
:members:
8989
:inherited-members:
9090

91+
.. autoclass:: Float
92+
:members:
93+
:inherited-members:
94+
9195
.. autoclass:: RegularExpression
9296
:members:
9397
:inherited-members:

examples/analytics/input.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def main():
102102

103103
argv = sys.argv[1:]
104104

105-
splunk_opts = utils.parse(argv, {}, ".splunkrc", usage=usage)
105+
splunk_opts = utils.parse(argv, {}, ".env", usage=usage)
106106
tracker = AnalyticsTracker("cli_app", splunk_opts.kwargs)
107107

108108
#tracker.track("test_event", "abc123", foo="bar", bar="foo")

examples/analytics/output.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def main():
152152

153153
argv = sys.argv[1:]
154154

155-
opts = utils.parse(argv, {}, ".splunkrc", usage=usage)
155+
opts = utils.parse(argv, {}, ".env", usage=usage)
156156
retriever = AnalyticsRetriever(opts.args[0], opts.kwargs)
157157

158158
#events = retriever.events()

examples/analytics/server.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def application(name):
146146
def main():
147147
argv = sys.argv[1:]
148148

149-
opts = utils.parse(argv, {}, ".splunkrc")
149+
opts = utils.parse(argv, {}, ".env")
150150
global splunk_opts
151151
splunk_opts = opts.kwargs
152152

examples/async/async.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def main(argv):
5151
usage = "async.py <sync | async>"
5252

5353
# Parse the command line args.
54-
opts = parse(argv, {}, ".splunkrc")
54+
opts = parse(argv, {}, ".env")
5555

5656
# We have to see if we got either the "sync" or
5757
# "async" command line arguments.

examples/binding1.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def search(self, query, **kwargs):
5252
return self.context.post("search/jobs/export", search=query, **kwargs)
5353

5454
def main(argv):
55-
opts = parse(argv, {}, ".splunkrc")
55+
opts = parse(argv, {}, ".env")
5656
context = connect(**opts.kwargs)
5757
service = Service(context)
5858
assert service.apps().status == 200

examples/conf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def main():
151151
commands = ['create', 'delete', 'list']
152152

153153
# parse args, connect and setup
154-
opts = parse(argv, {}, ".splunkrc", usage=usage)
154+
opts = parse(argv, {}, ".env", usage=usage)
155155
service = connect(**opts.kwargs)
156156
program = Program(service)
157157

examples/dashboard/feed.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def iterate(job):
171171

172172
def main(argv):
173173
# Parse the command line args.
174-
opts = parse(argv, {}, ".splunkrc")
174+
opts = parse(argv, {}, ".env")
175175

176176
# Connect to Splunk
177177
service = client.connect(**opts.kwargs)

examples/event_types.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"(e.g., export PYTHONPATH=~/splunk-sdk-python.")
3131

3232
def main():
33-
opts = parse(sys.argv[1:], {}, ".splunkrc")
33+
opts = parse(sys.argv[1:], {}, ".env")
3434
service = connect(**opts.kwargs)
3535

3636
for item in service.event_types:

0 commit comments

Comments
 (0)