Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add decorator to simplify creating JSON REST endpoints #473

Open
wants to merge 48 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
72d5fe1
removing python 2.7 from CI and local testing
ashah-splunk May 6, 2022
e3a09e7
code changes based on Pylint and 2to3 tool suggestions
ashah-splunk May 6, 2022
6429ae4
refractoring
ashah-splunk May 6, 2022
4cb0f4a
code changes
ashah-splunk May 6, 2022
aeae735
reverting f string change
ashah-splunk May 6, 2022
b0ca411
adding python 3.9 to CI
ashah-splunk May 9, 2022
5c90746
Merge branch 'py3-code-migration' into py3-testcases-refractor
ashah-splunk May 9, 2022
9329894
removed support for python2 from modularinput
akaila-splunk May 11, 2022
308873b
Merge branch 'py3-code-migration' into py3-modularinput-refactor
akaila-splunk May 11, 2022
83ecdf4
Update __init__.py
vmalaviya-splunk May 11, 2022
fe37aeb
Update binding.py
vmalaviya-splunk May 11, 2022
3231549
Update client.py
vmalaviya-splunk May 11, 2022
66dc351
Update data.py
vmalaviya-splunk May 11, 2022
a808a03
Update results.py
vmalaviya-splunk May 11, 2022
7e63b6a
Delete six.py
vmalaviya-splunk May 11, 2022
739a94a
Merge pull request #453 from splunk/py3-modularinput-refactor
ashah-splunk May 11, 2022
64de6a4
Merge pull request #454 from splunk/py3-testcases-refractor
ashah-splunk May 11, 2022
f68d408
Merge pull request #455 from splunk/py2to3-core
ashah-splunk May 11, 2022
4735248
Update argument.py
ashah-splunk May 11, 2022
464e75d
Merge branch 'py3-code-migration' of https://github.com/splunk/splunk…
ashah-splunk May 11, 2022
a066e7c
python 3.9
ashah-splunk May 11, 2022
5340cfc
Update tox.ini
ashah-splunk May 11, 2022
893b0d7
changes
ashah-splunk May 11, 2022
ec6907a
test changes for six.py removal
ashah-splunk May 11, 2022
9ffee31
refractor changes
ashah-splunk May 12, 2022
9df86a2
Merge branch 'develop' into py3-code-migration
ashah-splunk May 12, 2022
2c207d9
Update binding.py
ashah-splunk May 16, 2022
0250984
Update results.py
ashah-splunk May 16, 2022
b8d5b9c
Update client.py
ashah-splunk May 16, 2022
ea0b34b
refactoring
ashah-splunk May 17, 2022
079df7b
2to3 code refactoring
ashah-splunk May 17, 2022
3af370d
test case fix
ashah-splunk May 17, 2022
3a26633
sonar changes
ashah-splunk May 17, 2022
924a0eb
adding else after raise
ashah-splunk May 17, 2022
ed117bc
2to3 suggested changes
ashah-splunk May 17, 2022
468c92a
Update Makefile
ashah-splunk May 25, 2022
c772272
refractor changes
akaila-splunk Jun 3, 2022
78d9610
Merge branch 'develop' into py3-code-migration
ashah-splunk Jun 17, 2022
ff3f814
Update test.yml
ashah-splunk Oct 12, 2022
5094e0e
Update test.yml
ashah-splunk Oct 12, 2022
f1080cf
Merge branch 'develop' into py3-code-migration
akaila-splunk Oct 13, 2022
917cf04
updated binding.py
akaila-splunk Oct 13, 2022
8cc4c21
updated comments examples
akaila-splunk Nov 4, 2022
fc9b7c0
Merge branch 'develop' into py3-code-migration
ashah-splunk Dec 2, 2022
bf40010
added access to finished flag within metadata
ashah-splunk Dec 20, 2022
72372f9
Update internals.py
ashah-splunk Dec 20, 2022
14cdb92
Update test_search_command.py
ashah-splunk Dec 21, 2022
1481673
add decorator for json rest endpoints
marcusschiesser Jul 18, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
matrix:
os:
- ubuntu-latest
python: [ 2.7, 3.7 ]
python: [ 3.7, 3.9, 3.10.7]
splunk-version:
- "8.1"
- "8.2"
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ docs:
.PHONY: test
test:
@echo "$(ATTN_COLOR)==> test $(NO_COLOR)"
@tox -e py27,py37
@tox -e py37,py39

.PHONY: test_specific
test_specific:
Expand Down
8 changes: 3 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@
failed = False

def run_test_suite():
try:
import unittest2 as unittest
except ImportError:
import unittest
import unittest

def mark_failed():
global failed
Expand Down Expand Up @@ -143,7 +140,8 @@ def run(self):

packages = ["splunklib",
"splunklib.modularinput",
"splunklib.searchcommands"],
"splunklib.searchcommands",
"splunklib.customrest"],

url="http://github.com/splunk/splunk-sdk-python",

Expand Down
50 changes: 47 additions & 3 deletions splunklib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@

"""Python library for Splunk."""

from __future__ import absolute_import
from splunklib.six.moves import map
import logging

DEFAULT_LOG_FORMAT = '%(asctime)s, Level=%(levelname)s, Pid=%(process)s, Logger=%(name)s, File=%(filename)s, ' \
'Line=%(lineno)s, %(message)s'
'Line=%(lineno)s, %(message)s'
DEFAULT_DATE_FORMAT = '%Y-%m-%d %H:%M:%S %Z'


Expand All @@ -31,5 +29,51 @@ def setup_logging(level, log_format=DEFAULT_LOG_FORMAT, date_format=DEFAULT_DATE
format=log_format,
datefmt=date_format)


def ensure_binary(s, encoding='utf-8', errors='strict'):
"""
- `str` -> encoded to `bytes`
- `bytes` -> `bytes`
"""
if isinstance(s, str):
return s.encode(encoding, errors)

if isinstance(s, bytes):
return s

raise TypeError(f"not expecting type '{type(s)}'")


def ensure_str(s, encoding='utf-8', errors='strict'):
"""
- `str` -> `str`
- `bytes` -> decoded to `str`
"""
if isinstance(s, bytes):
return s.decode(encoding, errors)

if isinstance(s, str):
return s

raise TypeError(f"not expecting type '{type(s)}'")


def ensure_text(s, encoding='utf-8', errors='strict'):
"""
- `str` -> `str`
- `bytes` -> decoded to `str`
"""
if isinstance(s, bytes):
return s.decode(encoding, errors)
if isinstance(s, str):
return s
raise TypeError(f"not expecting type '{type(s)}'")


def assertRegex(self, *args, **kwargs):
return getattr(self, "assertRegex")(*args, **kwargs)


__version_info__ = (1, 7, 2)

__version__ = ".".join(map(str, __version_info__))