Skip to content
Browse files

Merge branch 'develop'

Conflicts:
	README.md
  • Loading branch information...
2 parents e9b0154 + 580aceb commit b33648a69845d2036cefc91afbb7fd2aa42e398f @blovering blovering committed Apr 20, 2012
Showing with 6,348 additions and 3,715 deletions.
  1. +3 −4 .gitignore
  2. +134 −3 CHANGELOG.md
  3. +91 −60 README.md
  4. +153 −0 docs/Makefile
  5. +246 −0 docs/conf.py
  6. +0 −141 docs/endpoints.csv
  7. +165 −0 docs/index.rst
  8. +190 −0 docs/make.bat
  9. +1 −1 examples/abc/a.py
  10. +2 −2 examples/abc/b.py
  11. +2 −2 examples/abc/c.py
  12. +3 −2 examples/analytics/README.md
  13. +2 −2 examples/analytics/__init__.py
  14. +9 −8 examples/analytics/input.py
  15. +6 −5 examples/analytics/output.py
  16. +1 −1 examples/analytics/server.py
  17. +5 −4 examples/async/async.py
  18. +4 −2 examples/binding1.py
  19. +3 −4 examples/conf.py
  20. +2 −2 examples/custom_search/bin/usercount.py
  21. +16 −11 examples/dashboard/feed.py
  22. +41 −0 examples/event_types.py
  23. +1,041 −548 examples/explorer/endpoints.js
  24. +1 −1 examples/explorer/explorer.css
  25. +17 −17 examples/explorer/explorer.html
  26. +11 −12 examples/explorer/explorer.py
  27. +2 −2 examples/explorer/server.py
  28. +8 −11 examples/export/export.py
  29. +346 −0 examples/export/export2.py
  30. +44 −0 examples/fired_alerts.py
  31. +8 −8 examples/follow.py
  32. +2 −2 examples/genevents.py
  33. +10 −6 examples/handlers/handler_certs.py
  34. +4 −5 examples/handlers/handler_debug.py
  35. +5 −8 examples/handlers/handler_proxy.py
  36. +3 −3 examples/handlers/handler_urllib2.py
  37. +25 −14 examples/handlers/tiny-proxy.py
  38. +9 −13 examples/index.py
  39. +9 −9 examples/info.py
  40. +10 −7 examples/inputs.py
  41. +8 −9 examples/job.py
  42. +3 −3 examples/loggers.py
  43. +0 −46 examples/odata/README.md
  44. +0 −721 examples/odata/excel_proxy.py
  45. +5 −7 examples/oneshot.py
  46. +2 −2 examples/results.py
  47. +0 −109 examples/saved_search/README.md
  48. +2 −2 examples/saved_search/saved_search.py
  49. +47 −0 examples/saved_searches.py
  50. +4 −4 examples/search.py
  51. +4 −4 examples/spcmd.py
  52. +3 −3 examples/spurl.py
  53. +3 −3 examples/stail.py
  54. +4 −4 examples/submit.py
  55. +9 −8 examples/twitted/input.py
  56. +2 −2 examples/twitted/twitted/bin/hashtags.py
  57. +2 −2 examples/twitted/twitted/bin/tophashtags.py
  58. +0 −44 examples/twitted/twitted/local/viewstates.conf
  59. +0 −10 examples/twitted/twitted/metadata/local.meta
  60. +4 −4 examples/upload.py
  61. +4 −4 setup.py
  62. +1 −1 sitecustomize.py
  63. +0 −286 splunk/binding.py
  64. +0 −608 splunk/client.py
  65. +2 −2 {splunk → splunklib}/__init__.py
  66. +444 −0 splunklib/binding.py
  67. +1,014 −0 splunklib/client.py
  68. +28 −6 {splunk → splunklib}/data.py
  69. +24 −9 {splunk → splunklib}/results.py
  70. +6 −3 splunkrc.spec
  71. +22 −7 tests/runtests.py
  72. +0 −1 tests/splunk.baseline
  73. +0 −2 tests/splunk.client.baseline
  74. +1 −0 tests/splunklib.baseline
  75. +1 −1 tests/{splunk.binding.baseline → splunklib.binding.baseline}
  76. +2 −0 tests/splunklib.client.baseline
  77. +1 −1 tests/{splunk.data.baseline → splunklib.data.baseline}
  78. 0 tests/{splunk.results.baseline → splunklib.results.baseline}
  79. +73 −0 tests/test_app.py
  80. +256 −258 tests/test_binding.py
  81. +0 −492 tests/test_client.py
  82. +125 −0 tests/test_collection.py
  83. +145 −0 tests/test_conf.py
  84. +8 −6 tests/test_data.py
  85. +69 −0 tests/test_event_type.py
  86. +93 −115 tests/test_examples.py
  87. +130 −0 tests/test_fired_alert.py
  88. +95 −0 tests/test_index.py
  89. +124 −0 tests/test_input.py
  90. +162 −0 tests/test_job.py
  91. +51 −0 tests/test_logger.py
  92. +75 −0 tests/test_message.py
  93. +51 −0 tests/test_module.py
  94. +55 −0 tests/test_role.py
  95. +182 −0 tests/test_saved_search.py
  96. +176 −0 tests/test_service.py
  97. +76 −0 tests/test_user.py
  98. +105 −0 tests/testlib.py
  99. +9 −5 utils/__init__.py
  100. +2 −1 utils/cmdopts.py
View
7 .gitignore
@@ -3,11 +3,10 @@
*.idea
*.DS_Store*
*coverage_html_report*
+.coverage
.coverage.*
+__stdout__
+docs/_build
proxypid
proxy.log
-__stdout__
-.coverage
MANIFEST
-build/*
-dist/*
View
137 CHANGELOG.md
@@ -1,10 +1,141 @@
# Splunk Python SDK Changelog
-## v0.1.0a
+## 0.8.0 (beta)
+
+### Features
+
+* Improvements to entity state management
+* Improvements to usability of entity collections
+* Support for collection paging - collections now support the paging arguments:
+ `count`, `offset`, `search`, `sort_dir`, `sort_key` and `sort_mode`. Note
+ that `Inputs` and `Jobs` are not pageable collections and only support basic
+ enumeration and iteration.
+* Support for event types:
+ - Added Service.event_types + units
+ - Added examples/event_types.py
+* Support for fired alerts:
+ - Added Service.fired_alerts + units
+ - Added examples/fired_alerts.py
+* Support for saved searches:
+ - Added Service.saved_searches + units
+ - Added examples/saved_searches.py
+* Sphinx based SDK docs and improved source code docstrings.
+* Support for IPv6 - it is now possible to connect to a Splunk instance
+ listening on an IPv6 address.
+
+### Breaking changes
+
+#### Module name
+
+The core module was renamed from `splunk` to `splunklib`. The Splunk product
+ships with an internal Python module named `splunk` and the name conflict
+with the SDK prevented installing the SDK into Splunk Python sandbox for use
+by Splunk extensions. This module name change enables the Python SDK to be
+installed on the Splunk server.
+
+#### State caching
+
+The client module was modified to enable Entity state caching which required
+changes to the `Entity` interface and changes to the typical usage pattern.
+
+Previously, entity state values where retrieved with a call to `Entity.read`
+which would issue a round-trip to the server and return a dictionary of values
+corresponding to the entity `content` field and, in a similar way, a call to
+`Entity.readmeta` would issue in a round-trip and return a dictionary
+contianing entity metadata values.
+
+With the change to enable state caching, the entity is instantiated with a
+copy of its entire state record, which can be accessed using a variety of
+properties:
+
+* `Entity.state` returns the entire state record
+* `Entity.content` returns the content field of the state record
+* `Entity.access` returns entity access metadata
+* `Entity.fields` returns entity content metadata
+
+`Entity.refresh` is a new method that issues a round-trip to the server
+and updates the local, cached state record.
+
+`Entity.read` still exists but has been changed slightly to return the
+entire state record and not just the content field. Note that `read` does
+not update the cached state record. The `read` method is basically a thin
+wrapper over the corresponding HTTP GET that returns a parsed entity state
+record instaed of the raw HTTP response.
+
+The entity _callable_ returns the `content` field as before, but now returns
+the value from the local state cache instead of issuing a round-trip as it
+did before.
+
+It is important to note that refreshing the local state cache is always
+explicit and always requires a call to `Entity.refresh`. So, for example
+if you call `Entity.update` and then attempt to retrieve local values, you
+will not see the newly updated values, you will see the previously cached
+values. The interface is designed to give the caller complete control of
+when round-trips are issued and enable multiple updates to be made before
+refreshing the entity.
+
+The `update` and action methods are all designed to support a _fluent_ style
+of programming, so for example you can write:
+
+ entity.update(attr=value).refresh()
+
+And
+
+ entity.disable().refresh()
+
+An important benefit and one of the primary motivations for this change is
+that iterating a collection of entities now results in a single round-trip
+to the server, because every entity collection member is initialized with
+the result of the initial GET on the collection resource instead of requiring
+N+1 round-trips (one for each entity + one for the collection), which was the
+case in the previous model. This is a significant improvement for many
+common scenarios.
+
+#### Collections
+
+The `Collection` interface was changed so that `Collection.list` and the
+corresponding collection callable return a list of member `Entity` objects
+instead of a list of member entity names. This change was a result of user
+feedback indicating that people expected to see eg: `service.apps()` return
+a list of apps and not a list of app names.
+
+#### Naming context
+
+Previously the binding context (`binding.Context`) and all tests & samples took
+a single (optional) `namespace` argument that specified both the app and owner
+names to use for the binding context. However, the underlying Splunk REST API
+takes these as separate `app` and `owner` arguments and it turned out to be more
+convenient to reflect these arguments directly in the SDK, so the binding
+context (and all samples & test) now take separate (and optional) `app` and
+`owner` arguments instead of the prior `namespace` argument.
+
+You can find a detailed description of Splunk namespaces in the Splunk REST
+API reference under the section on accessing Splunk resources at:
+
+* http://docs.splunk.com/Documentation/Splunk/latest/RESTAPI/RESTresources
+
+#### Misc. API
+
+* Update all classes in the core library modules to use new-style classes
+* Rename Job.setpriority to Job.set_priority
+* Rename Job.setttl to Job.set_ttl
+
+### Bug fixes
+
+* Fix for GitHub Issues: 2, 10, 12, 15, 17, 18, 21
+* Fix for incorrect handling of mixed case new user names (need to account for
+ fact that Splunk automatically lowercases)
+* Fix for Service.settings so that updates get sent to the correct endpoint
+* Check name arg passed to Collection.create and raise ValueError if not
+ a basestring
+* Fix handling of resource names that are not valid URL segments by quoting the
+ resource name when constructing its path
+
+## 0.1.0a (preview)
* Fix a bug in the dashboard example
* Ramp up README with more info
-## v0.1.0
+## 0.1.0 (preview)
-* Initial Python SDK release
+* Initial Python SDK release
View
151 README.md
@@ -1,4 +1,4 @@
-# The Splunk Software Development Kit for Python (Preview Release)
+# The Splunk Software Development Kit for Python (Beta Release)
This SDK contains library code and examples designed to enable developers to
build applications using Splunk.
@@ -16,48 +16,33 @@ The Splunk developer platform enables developers to take advantage of the same
technology used by the Splunk product to build exciting new applications that
are enabled by Splunk's unique capabilities.
-
## License
The Splunk Software Development Kit for Python is licensed under the Apache
License 2.0. Details can be found in the file LICENSE.
-## This SDK is a Preview Release
-
-1. This Preview release a pre-beta release. There will also be a beta release
- prior to a general release. It is incomplete and may have bugs.
-
-2. The Apache license only applies to the SDK and no other Software provided
- by Splunk.
-
-3. Splunk in using the Apache license is not providing any warranties,
- indemnification or accepting any liabilities with the Preview SDK.
-
-4. Splunk is not accepting any Contributions to the Preview release of the SDK.
- All Contributions during the Preview SDK will be returned without review.
-
## Getting Started
In order to use the SDK you are going to need a copy of Splunk. If you don't
already have a copy you can download one from http://www.splunk.com/download.
You can get a copy of the SDK sources by cloning into the repository with git:
- git clone https://github.com/splunk/splunk-sdk-python.git
+> git clone https://github.com/splunk/splunk-sdk-python.git
#### Installing
You can install the Splunk SDK libraries by using `easy_install` or `pip`:
- [sudo] easy_install splunk-sdk
+> [sudo] easy_install splunk-sdk
Or
- [sudo] pip install splunk-sdk
+> [sudo] pip install splunk-sdk
Alternatively, you can use `setup.py` on the sources you cloned from GitHub:
- [sudo] python setup.py install
+> [sudo] python setup.py install
However, it's not necessarry to install the libraries in order to run the
examples and unit tests from the SDK.
@@ -88,7 +73,7 @@ command line, for example:
password=changeme
The `.splunkrc` file is a feature of the SDK examples and unit tests and not
-the Splunk platform or SDK libraries and is indended simply as convenience for
+the Splunk platform or SDK libraries and is intended simply as convenience for
developers using the SDK.
The `.splunkrc` file should not be used for storing user credentials for apps
@@ -122,11 +107,11 @@ including:
* A pluggable HTTP component that can be user-supplied.
* Handles authentication and namespace URL management
* Accessible low-level HTTP interface for use by developers who want
- to be close to the wire.
+ to be close to the wire.
You can see an example use of the library here:
- import splunk.binding as binding
+ import splunklib.binding as binding
# host defaults to localhost and port defaults to 8089
context = binding.connect(username="admin", password="changeme")
@@ -140,43 +125,55 @@ The second layer is referred to as the _client_ layer and builds on the
_binding_ layer to provide a friendlier interface to Splunk that abstracts
away some of the lower level details of the _binding_ layer.
- from pprint import pprint
-
- import splunk.client as client
+ import splunklib.client as client
# host defaults to localhost and port defaults to 8089
service = client.connect(username="admin", password="changeme")
for user in service.users:
- pprint(user())
+ print user.name
### Unit tests
The SDK contains a small but growing collection of unit tests. Running the
tests is simple and rewarding:
- cd tests
- ./runtests.py
+> cd tests<br>
+> python runtests.py
Alternatively, you can read more about our testing "framework"
[here](https://github.com/splunk/splunk-sdk-python/tree/master/tests).
### Layout of the repository
-<dl>
-<dt>./docs</dt>
-<dd>Contains a few detailed notes specific to the SDK. In general documentation
- about developing on Splunk can be found on dev.splunk.com.</dd>
-<dt>./examples</dt>
-<dd>Contains s variety of Splunk samples demonstrating the various library
- modules.</dd>
-<dt>./splunk</dt>
-<dd>The Splunk library modules.</dd>
-<dt>./tests</dt>
-<dd>The SDK unit tests.</dd>
-<dt>./utils</dt>
-<dd>Generic utility code shared by the examples and unit tests.</dd>
-</dl>
+<table>
+
+<tr>
+<td>docs</td>
+<td>Source for Sphinx based docs and build</td>
+</tr>
+
+<tr>
+<td>examples</td>
+<td>Examples demonstrating various SDK features</td>
+<tr>
+
+<tr>
+<td>splunklib</td>
+<td>Source for the Splunk library modules</td>
+<tr>
+
+<tr>
+<td>tests</td>
+<td>Source for unit tests</td>
+<tr>
+
+<tr>
+<td>utils</td>
+<td>Source for utilities shared by the examples and unit tests</td>
+<tr>
+
+</table>
### Changelog
@@ -194,36 +191,70 @@ You can read more about our branching model on our
You can find anything having to do with developing on Splunk at the Splunk
developer portal:
-* http://dev.splunk.com
+* http://dev.splunk.com
-You can also find full reference documentation of the REST API:
+Reference documentation for the Python SDK:
-* http://docs.splunk.com/Documentation/Splunk/latest/RESTAPI
+* http://splunk.github.com/splunk-sdk-python/docs/0.8.0
-For a gentle introduction to the Splunk product and some of its capabilities:
+Reference documentation for the Splunk REST API:
-* http://docs.splunk.com/Documentation/Splunk/latest/User/SplunkOverview
+* http://docs.splunk.com/Documentation/Splunk/latest/RESTAPI
+
+Overview of Splunk and links to additional product information:
+
+* http://docs.splunk.com/Documentation/Splunk/latest/User/SplunkOverview
## Community
-* Email: Stay connected with other developers building on Splunk: devinfo@splunk.com
-* Issues: https://github.com/splunk/splunk-sdk-python/issues
-* Answers: Check out this tag on Splunk answers for:
- http://splunk-base.splunk.com/tags/python/
-* Blog: http://blogs.splunk.com/dev/
-* Twitter: [@splunkdev](http://twitter.com/#!/splunkdev)
+Stay connected with other developers building on Splunk.
+
+<table>
+
+<tr>
+<td><em>Email</em></td>
+<td>devinfo@splunk.com</td>
+</tr>
+
+<tr>
+<td><em>Issues</em>
+<td><span>https://github.com/splunk/splunk-sdk-java/issues/</span></td>
+</tr>
+
+<tr>
+<td><em>Answers</em>
+<td><span>http://splunk-base.splunk.com/tags/java/</span></td>
+</tr>
+
+<tr>
+<td><em>Blog</em>
+<td><span>http://blogs.splunk.com/dev/</span></td>
+</tr>
+
+<tr>
+<td><em>Twitter</em>
+<td>@splunkdev</td>
+</tr>
+
+</table>
### How to contribute
-We aren't ready to accept code contributions yet, but will be shortly. Check
-this README for more updates soon.
+If you would like to contribute to the SDK, please follow one of the links
+provided below.
-### Support
+* [Individual contributions](http://dev.splunk.com/goto/individualcontributions)
-* SDKs in Preview will not be Splunk supported. Once the Python SDK moves to
-an Open Beta we will provide more detail on support.
+* [Company contributions](http://dev.splunk.com/view/companycontributions/SP-CAAAEDR)
-* Issues should be filed here: https://github.com/splunk/splunk-sdk-python/issues
+### Support
+
+1. You will be granted support if you or your company are already covered under an existing maintenance/support agreement. Send an email to support@splunk.com and please include the SDK you are referring to in the subject.
+2. If you are not covered under an existing maintenance/support agreement you can find help through the broader community at:
+<br>Splunk answers - http://splunk-base.splunk.com/answers/ Specific tags (SDK, java, python, javascript) are available to identify your questions
+<br>Splunk dev google group - http://groups.google.com/group/splunkdev
+3. Splunk will NOT provide support for SDKs if the core library (this is the code in the splunklib directory) has been modified. If you modify an SDK and want support, you can find help through the broader community and Splunk answers (see above). We also want to know about why you modified the core library. You can send feedback to: devinfo@splunk.com
### Contact Us
+
You can reach the Dev Platform team at devinfo@splunk.com
View
153 docs/Makefile
@@ -0,0 +1,153 @@
+# Makefile for Sphinx documentation
+#
+
+# You can set these variables from the command line.
+SPHINXOPTS =
+SPHINXBUILD = sphinx-build
+PAPER =
+BUILDDIR = _build
+
+# Internal variables.
+PAPEROPT_a4 = -D latex_paper_size=a4
+PAPEROPT_letter = -D latex_paper_size=letter
+ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+# the i18n builder cannot share the environment and doctrees with the others
+I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+
+.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
+
+help:
+ @echo "Please use \`make <target>' where <target> is one of"
+ @echo " html to make standalone HTML files"
+ @echo " dirhtml to make HTML files named index.html in directories"
+ @echo " singlehtml to make a single large HTML file"
+ @echo " pickle to make pickle files"
+ @echo " json to make JSON files"
+ @echo " htmlhelp to make HTML files and a HTML help project"
+ @echo " qthelp to make HTML files and a qthelp project"
+ @echo " devhelp to make HTML files and a Devhelp project"
+ @echo " epub to make an epub"
+ @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
+ @echo " latexpdf to make LaTeX files and run them through pdflatex"
+ @echo " text to make text files"
+ @echo " man to make manual pages"
+ @echo " texinfo to make Texinfo files"
+ @echo " info to make Texinfo files and run them through makeinfo"
+ @echo " gettext to make PO message catalogs"
+ @echo " changes to make an overview of all changed/added/deprecated items"
+ @echo " linkcheck to check all external links for integrity"
+ @echo " doctest to run all doctests embedded in the documentation (if enabled)"
+
+clean:
+ -rm -rf $(BUILDDIR)/*
+
+html:
+ $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
+ @echo
+ @echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
+
+dirhtml:
+ $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
+ @echo
+ @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
+
+singlehtml:
+ $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
+ @echo
+ @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
+
+pickle:
+ $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
+ @echo
+ @echo "Build finished; now you can process the pickle files."
+
+json:
+ $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
+ @echo
+ @echo "Build finished; now you can process the JSON files."
+
+htmlhelp:
+ $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
+ @echo
+ @echo "Build finished; now you can run HTML Help Workshop with the" \
+ ".hhp project file in $(BUILDDIR)/htmlhelp."
+
+qthelp:
+ $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
+ @echo
+ @echo "Build finished; now you can run "qcollectiongenerator" with the" \
+ ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
+ @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/SplunkPythonSDK.qhcp"
+ @echo "To view the help file:"
+ @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/SplunkPythonSDK.qhc"
+
+devhelp:
+ $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
+ @echo
+ @echo "Build finished."
+ @echo "To view the help file:"
+ @echo "# mkdir -p $$HOME/.local/share/devhelp/SplunkPythonSDK"
+ @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/SplunkPythonSDK"
+ @echo "# devhelp"
+
+epub:
+ $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
+ @echo
+ @echo "Build finished. The epub file is in $(BUILDDIR)/epub."
+
+latex:
+ $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+ @echo
+ @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
+ @echo "Run \`make' in that directory to run these through (pdf)latex" \
+ "(use \`make latexpdf' here to do that automatically)."
+
+latexpdf:
+ $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+ @echo "Running LaTeX files through pdflatex..."
+ $(MAKE) -C $(BUILDDIR)/latex all-pdf
+ @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
+
+text:
+ $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
+ @echo
+ @echo "Build finished. The text files are in $(BUILDDIR)/text."
+
+man:
+ $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
+ @echo
+ @echo "Build finished. The manual pages are in $(BUILDDIR)/man."
+
+texinfo:
+ $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
+ @echo
+ @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
+ @echo "Run \`make' in that directory to run these through makeinfo" \
+ "(use \`make info' here to do that automatically)."
+
+info:
+ $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
+ @echo "Running Texinfo files through makeinfo..."
+ make -C $(BUILDDIR)/texinfo info
+ @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
+
+gettext:
+ $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
+ @echo
+ @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
+
+changes:
+ $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
+ @echo
+ @echo "The overview file is in $(BUILDDIR)/changes."
+
+linkcheck:
+ $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
+ @echo
+ @echo "Link check complete; look for any errors in the above output " \
+ "or in $(BUILDDIR)/linkcheck/output.txt."
+
+doctest:
+ $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
+ @echo "Testing of doctests in the sources finished, look at the " \
+ "results in $(BUILDDIR)/doctest/output.txt."
View
246 docs/conf.py
@@ -0,0 +1,246 @@
+# -*- coding: utf-8 -*-
+#
+# Splunk Python SDK documentation build configuration file, created by
+# sphinx-quickstart on Fri Apr 13 12:28:15 2012.
+#
+# This file is execfile()d with the current directory set to its containing dir.
+#
+# Note that not all possible configuration values are present in this
+# autogenerated file.
+#
+# All configuration values have a default; values that are commented out
+# serve to show the default.
+
+import sys, os
+
+import splunklib
+
+# If extensions (or modules to document with autodoc) are in another directory,
+# add these directories to sys.path here. If the directory is relative to the
+# documentation root, use os.path.abspath to make it absolute, like shown here.
+#sys.path.insert(0, os.path.abspath('.'))
+
+# -- General configuration -----------------------------------------------------
+
+# If your documentation needs a minimal Sphinx version, state it here.
+#needs_sphinx = '1.0'
+
+# Add any Sphinx extension module names here, as strings. They can be extensions
+# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
+extensions = ['sphinx.ext.autodoc', 'sphinx.ext.ifconfig']
+
+# Add any paths that contain templates here, relative to this directory.
+templates_path = ['_templates']
+
+# The suffix of source filenames.
+source_suffix = '.rst'
+
+# The encoding of source files.
+#source_encoding = 'utf-8-sig'
+
+# The master toctree document.
+master_doc = 'index'
+
+# General information about the project.
+project = u'Splunk Python SDK'
+copyright = u'2012, 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
+# built documents.
+#
+# The short X.Y version.
+version = splunklib.__version__
+# The full version, including alpha/beta/rc tags.
+release = splunklib.__version__
+
+# The language for content autogenerated by Sphinx. Refer to documentation
+# for a list of supported languages.
+#language = None
+
+# There are two options for replacing |today|: either, you set today to some
+# non-false value, then it is used:
+#today = ''
+# Else, today_fmt is used as the format for a strftime call.
+#today_fmt = '%B %d, %Y'
+
+# List of patterns, relative to source directory, that match files and
+# directories to ignore when looking for source files.
+exclude_patterns = ['_build']
+
+# The reST default role (used for this markup: `text`) to use for all documents.
+#default_role = None
+
+# If true, '()' will be appended to :func: etc. cross-reference text.
+#add_function_parentheses = True
+
+# If true, the current module name will be prepended to all description
+# unit titles (such as .. function::).
+#add_module_names = True
+
+# If true, sectionauthor and moduleauthor directives will be shown in the
+# output. They are ignored by default.
+#show_authors = False
+
+# The name of the Pygments (syntax highlighting) style to use.
+pygments_style = 'sphinx'
+
+# A list of ignored prefixes for module index sorting.
+#modindex_common_prefix = []
+
+
+# -- Options for HTML output ---------------------------------------------------
+
+# The theme to use for HTML and HTML Help pages. See the documentation for
+# a list of builtin themes.
+
+# agogo, default, epub, haiku, nature, pyramid, scrolls, sphinxdoc, traditional
+html_theme = 'haiku'
+
+# 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
+# documentation.
+#html_theme_options = {}
+
+# Add any paths that contain custom themes here, relative to this directory.
+#html_theme_path = []
+
+# The name for this set of Sphinx documents. If None, it defaults to
+# "<project> v<release> documentation".
+#html_title = None
+
+# A shorter title for the navigation bar. Default is the same as html_title.
+#html_short_title = None
+
+# The name of an image file (relative to this directory) to place at the top
+# of the sidebar.
+#html_logo = None
+
+# The name of an image file (within the static path) to use as favicon of the
+# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
+# pixels large.
+#html_favicon = None
+
+# Add any paths that contain custom static files (such as style sheets) here,
+# relative to this directory. They are copied after the builtin static files,
+# so a file named "default.css" will overwrite the builtin "default.css".
+html_static_path = ['_static']
+
+# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
+# using the given strftime format.
+#html_last_updated_fmt = '%b %d, %Y'
+
+# If true, SmartyPants will be used to convert quotes and dashes to
+# typographically correct entities.
+#html_use_smartypants = True
+
+# Custom sidebar templates, maps document names to template names.
+#html_sidebars = {}
+
+# Additional templates that should be rendered to pages, maps page names to
+# template names.
+#html_additional_pages = {}
+
+# If false, no module index is generated.
+#html_domain_indices = True
+
+# If false, no index is generated.
+#html_use_index = True
+
+# If true, the index is split into individual pages for each letter.
+#html_split_index = False
+
+# If true, links to the reST sources are added to the pages.
+#html_show_sourcelink = True
+
+# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
+#html_show_sphinx = True
+
+# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
+#html_show_copyright = True
+
+# If true, an OpenSearch description file will be output, and all pages will
+# contain a <link> tag referring to it. The value of this option must be the
+# base URL from which the finished HTML is served.
+#html_use_opensearch = ''
+
+# This is the file name suffix for HTML files (e.g. ".xhtml").
+#html_file_suffix = None
+
+# Output file base name for HTML help builder.
+htmlhelp_basename = 'SplunkPythonSDKdoc'
+
+
+# -- Options for LaTeX output --------------------------------------------------
+
+latex_elements = {
+# The paper size ('letterpaper' or 'a4paper').
+#'papersize': 'letterpaper',
+
+# The font size ('10pt', '11pt' or '12pt').
+#'pointsize': '10pt',
+
+# Additional stuff for the LaTeX preamble.
+#'preamble': '',
+}
+
+# Grouping the document tree into LaTeX files. List of tuples
+# (source start file, target name, title, author, documentclass [howto/manual]).
+latex_documents = [
+ ('index', 'SplunkPythonSDK.tex', u'Splunk Python SDK Documentation',
+ u'Splunk Inc.', 'manual'),
+]
+
+# The name of an image file (relative to this directory) to place at the top of
+# the title page.
+#latex_logo = None
+
+# For "manual" documents, if this is true, then toplevel headings are parts,
+# not chapters.
+#latex_use_parts = False
+
+# If true, show page references after internal links.
+#latex_show_pagerefs = False
+
+# If true, show URL addresses after external links.
+#latex_show_urls = False
+
+# Documents to append as an appendix to all manuals.
+#latex_appendices = []
+
+# If false, no module index is generated.
+#latex_domain_indices = True
+
+
+# -- Options for manual page output --------------------------------------------
+
+# One entry per manual page. List of tuples
+# (source start file, name, description, authors, manual section).
+man_pages = [
+ ('index', 'splunkpythonsdk', u'Splunk Python SDK Documentation',
+ [u'Splunk Inc.'], 1)
+]
+
+# If true, show URL addresses after external links.
+#man_show_urls = False
+
+
+# -- Options for Texinfo output ------------------------------------------------
+
+# Grouping the document tree into Texinfo files. List of tuples
+# (source start file, target name, title, author,
+# dir menu entry, description, category)
+texinfo_documents = [
+ ('index', 'SplunkPythonSDK', u'Splunk Python SDK Documentation',
+ u'Splunk Inc.', 'SplunkPythonSDK', 'One line description of project.',
+ 'Miscellaneous'),
+]
+
+# Documents to append as an appendix to all manuals.
+#texinfo_appendices = []
+
+# If false, no module index is generated.
+#texinfo_domain_indices = True
+
+# How to display URL addresses: 'footnote', 'no', or 'inline'.
+#texinfo_show_urls = 'footnote'
View
141 docs/endpoints.csv
@@ -1,141 +0,0 @@
-|auth/login
-alerts/fired_alerts
-alerts/fired_alerts/{-}
-apps/appinstall
-apps/apptemplates
-apps/apptemplates/{name}
-apps/local
-apps/local/{name}
-apps/local/{name}/package
-#apps/remote
-authentication/auth-tokens
-authentication/auth-tokens/{?}
-authentication/changepassword
-authentication/changepassword/{name}
-authentication/current-context
-authentication/current-context/context
-authentication/httpauth-tokens
-authentication/httpauth-tokens/{key}
-authentication/roles
-authentication/roles/{name}
-authentication/users
-authentication/users/{name}
-authorization/capabilities
-authorization/capabilities/{name}
-authorization/roles
-authorization/roles/{name}
-configs/deploymentclient
-configs/inputs
-configs/inputs/{name}
-configs/wmi
-data/commands
-data/commands/{name}
-data/indexes
-data/indexes/{name}
-data/inputs/monitor
-data/inputs/monitor/{name}
-data/inputs/monitor/{name}/members
-data/inputs/monitor/{name}/members/{name}
-data/inputs/oneshot
-data/inputs/script
-data/inputs/script/restart
-data/inputs/tcp/cooked
-data/inputs/tcp/cooked/{name}
-data/inputs/tcp/raw
-data/inputs/tcp/raw/{name}
-data/inputs/tcp/ssl
-data/inputs/udp
-data/lookup-table-files
-data/lookup-table-files/{name}
-data/outputs/tcp/default
-data/outputs/tcp/default/{name}
-data/outputs/tcp/group
-data/outputs/tcp/group/{name}
-data/outputs/tcp/server
-data/outputs/tcp/server/{name}
-data/outputs/tcp/syslog
-data/outputs/tcp/syslog/{name}
-data/props/extractions
-data/props/extractions/{name}
-data/props/fieldaliases
-data/props/fieldaliases/{name}
-data/props/lookups
-data/props/lookups/{name}
-data/props/sourcetype-rename
-data/props/sourcetype-rename/{name}
-data/transforms/extractions
-data/transforms/extractions/{name}
-data/transforms/lookups
-data/transforms/lookups/{name}
-#data/ui/...
-#data/user-prefs/...
-deployment/client
-deployment/server
-deployment/server/default
-deployment/serverclass
-deployment/serverclass/{name}
-deployment/serverclass_status
-deployment/serverclass_status/{name}
-deployment/tenants
-deployment/tenants/default
-directory
-directory/{name}
-licenser/groups
-licenser/groups/{name}
-licenser/licenses
-licenser/licenses/{hash}
-licenser/messages
-licenser/pools
-licenser/pools/{name}
-licenser/slaves
-licenser/slaves/{guid}
-licenser/stacks
-licenser/stacks/{name}
-messages
-|properties
-|properties/{file}
-|properties/{file}/{stanza}
-|properties/{file}/{stanza}/{key}
-receivers/simple
-receivers/stream
-saved/eventtypes
-saved/eventtypes/{name}
-saved/searches
-saved/searches/{name}
-saved/searches/{name}/acknowledge
-saved/searches/{name}/disable
-saved/searches/{name}/dispatch
-saved/searches/{name}/history
-saved/searches/{name}/notify
-saved/searches/{name}/scheduled_times
-saved/searches/{name}/suppress
-scheduled/views
-#search/commands
-#search/commands/{name}
-search/distributed/config
-search/distributed/peers
-|search/fields
-|search/fields/{name}
-|search/fields/{name}/tags
-|search/jobs
-|search/jobs/{sid}/control
-|search/jobs/{sid}/events
-|search/jobs/{sid}/results
-|search/jobs/{sid}/results_preview
-|search/jobs/{sid}/search.log
-|search/jobs/{sid}/timeline
-|search/jobs/{sid}/summary
-|search/jobs/export
-|search/parser
-|search/tags
-|search/tags/{name}
-|search/timeparser
-|search/typeahead
-server/control
-server/info
-server/info/server-info
-server/logger
-server/logger/{name}
-server/settings
-storage/passwords
-storage/passwords/{name}
View
165 docs/index.rst
@@ -0,0 +1,165 @@
+Splunk Software Development Kit for Python
+==========================================
+
+Contents:
+
+.. toctree::
+ :maxdepth: 2
+
+splunklib.binding
+-----------------
+
+.. automodule:: splunklib.binding
+
+.. autofunction:: connect
+
+.. autoclass:: Context
+ :members:
+ :inherited-members:
+ :undoc-members:
+
+.. autofunction:: handler
+
+.. autoclass:: HTTPError
+ :members:
+ :inherited-members:
+ :undoc-members:
+
+splunklib.client
+----------------
+
+.. automodule:: splunklib.client
+
+.. autofunction:: connect
+
+.. autoclass:: Collection
+ :members:
+ :inherited-members:
+ :undoc-members:
+
+.. autoclass:: Endpoint
+ :members:
+ :inherited-members:
+ :undoc-members:
+
+.. autoclass:: Entity
+ :members:
+ :inherited-members:
+ :undoc-members:
+
+.. autoclass:: Service
+ :members:
+ :inherited-members:
+ :undoc-members:
+
+.. autoclass:: AlertGroup
+ :members:
+ :inherited-members:
+ :undoc-members:
+
+.. autoclass:: Conf
+ :members:
+ :inherited-members:
+ :undoc-members:
+
+.. autoclass:: Confs
+ :members:
+ :inherited-members:
+ :undoc-members:
+
+.. autoclass:: Stanza
+ :members:
+ :inherited-members:
+ :undoc-members:
+
+.. autoclass:: Index
+ :members:
+ :inherited-members:
+ :undoc-members:
+
+.. autoclass:: Input
+ :members:
+ :inherited-members:
+ :undoc-members:
+
+.. autoclass:: Inputs
+ :members:
+ :inherited-members:
+ :undoc-members:
+
+.. autoclass:: Job
+ :members:
+ :inherited-members:
+ :undoc-members:
+
+.. autoclass:: Jobs
+ :members:
+ :inherited-members:
+ :undoc-members:
+
+.. autoclass:: Loggers
+ :members:
+ :inherited-members:
+
+.. autoclass:: Message
+ :members:
+ :inherited-members:
+ :undoc-members:
+
+.. autoclass:: SavedSearch
+ :members:
+ :inherited-members:
+ :undoc-members:
+
+.. autoclass:: SavedSearches
+ :members:
+ :inherited-members:
+ :undoc-members:
+
+.. autoclass:: Settings
+ :members:
+ :inherited-members:
+ :undoc-members:
+
+.. autoclass:: Users
+ :members:
+ :inherited-members:
+ :undoc-members:
+
+.. autoclass:: NotSupportedError
+ :members:
+ :inherited-members:
+ :undoc-members:
+
+.. autoclass:: OperationError
+ :members:
+ :inherited-members:
+ :undoc-members:
+
+splunklib.data
+--------------
+
+.. automodule:: splunklib.data
+
+.. autofunction:: load
+
+.. autofunction:: record
+
+.. autoclass:: Record
+ :members:
+ :undoc-members:
+
+splunklib.results
+-----------------
+
+.. automodule:: splunklib.results
+
+.. autoclass:: ResultsReader
+
+Indices and tables
+==================
+
+* :ref:`genindex`
+* :ref:`modindex`
+* :ref:`search`
+
View
190 docs/make.bat
@@ -0,0 +1,190 @@
+@ECHO OFF
+
+REM Command file for Sphinx documentation
+
+if "%SPHINXBUILD%" == "" (
+ set SPHINXBUILD=sphinx-build
+)
+set BUILDDIR=_build
+set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% .
+set I18NSPHINXOPTS=%SPHINXOPTS% .
+if NOT "%PAPER%" == "" (
+ set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
+ set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS%
+)
+
+if "%1" == "" goto help
+
+if "%1" == "help" (
+ :help
+ echo.Please use `make ^<target^>` where ^<target^> is one of
+ echo. html to make standalone HTML files
+ echo. dirhtml to make HTML files named index.html in directories
+ echo. singlehtml to make a single large HTML file
+ echo. pickle to make pickle files
+ echo. json to make JSON files
+ echo. htmlhelp to make HTML files and a HTML help project
+ echo. qthelp to make HTML files and a qthelp project
+ echo. devhelp to make HTML files and a Devhelp project
+ echo. epub to make an epub
+ echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter
+ echo. text to make text files
+ echo. man to make manual pages
+ echo. texinfo to make Texinfo files
+ echo. gettext to make PO message catalogs
+ echo. changes to make an overview over all changed/added/deprecated items
+ echo. linkcheck to check all external links for integrity
+ echo. doctest to run all doctests embedded in the documentation if enabled
+ goto end
+)
+
+if "%1" == "clean" (
+ for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i
+ del /q /s %BUILDDIR%\*
+ goto end
+)
+
+if "%1" == "html" (
+ %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished. The HTML pages are in %BUILDDIR%/html.
+ goto end
+)
+
+if "%1" == "dirhtml" (
+ %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.
+ goto end
+)
+
+if "%1" == "singlehtml" (
+ %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml.
+ goto end
+)
+
+if "%1" == "pickle" (
+ %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished; now you can process the pickle files.
+ goto end
+)
+
+if "%1" == "json" (
+ %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished; now you can process the JSON files.
+ goto end
+)
+
+if "%1" == "htmlhelp" (
+ %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished; now you can run HTML Help Workshop with the ^
+.hhp project file in %BUILDDIR%/htmlhelp.
+ goto end
+)
+
+if "%1" == "qthelp" (
+ %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished; now you can run "qcollectiongenerator" with the ^
+.qhcp project file in %BUILDDIR%/qthelp, like this:
+ echo.^> qcollectiongenerator %BUILDDIR%\qthelp\SplunkPythonSDK.qhcp
+ echo.To view the help file:
+ echo.^> assistant -collectionFile %BUILDDIR%\qthelp\SplunkPythonSDK.ghc
+ goto end
+)
+
+if "%1" == "devhelp" (
+ %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished.
+ goto end
+)
+
+if "%1" == "epub" (
+ %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished. The epub file is in %BUILDDIR%/epub.
+ goto end
+)
+
+if "%1" == "latex" (
+ %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished; the LaTeX files are in %BUILDDIR%/latex.
+ goto end
+)
+
+if "%1" == "text" (
+ %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished. The text files are in %BUILDDIR%/text.
+ goto end
+)
+
+if "%1" == "man" (
+ %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished. The manual pages are in %BUILDDIR%/man.
+ goto end
+)
+
+if "%1" == "texinfo" (
+ %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo.
+ goto end
+)
+
+if "%1" == "gettext" (
+ %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished. The message catalogs are in %BUILDDIR%/locale.
+ goto end
+)
+
+if "%1" == "changes" (
+ %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.The overview file is in %BUILDDIR%/changes.
+ goto end
+)
+
+if "%1" == "linkcheck" (
+ %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Link check complete; look for any errors in the above output ^
+or in %BUILDDIR%/linkcheck/output.txt.
+ goto end
+)
+
+if "%1" == "doctest" (
+ %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Testing of doctests in the sources finished, look at the ^
+results in %BUILDDIR%/doctest/output.txt.
+ goto end
+)
+
+:end
View
2 examples/abc/a.py 100644 → 100755
@@ -1,4 +1,4 @@
-# Copyright 2011 Splunk, Inc.
+# Copyright 2011-2012 Splunk, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"): you may
# not use this file except in compliance with the License. You may obtain
View
4 examples/abc/b.py 100644 → 100755
@@ -1,4 +1,4 @@
-# Copyright 2011 Splunk, Inc.
+# Copyright 2011-2012 Splunk, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"): you may
# not use this file except in compliance with the License. You may obtain
@@ -16,7 +16,7 @@
from xml.etree import ElementTree
-import splunk.binding as binding
+import splunklib.binding as binding
HOST = "localhost"
PORT = 8089
View
4 examples/abc/c.py 100644 → 100755
@@ -1,4 +1,4 @@
-# Copyright 2011 Splunk, Inc.
+# Copyright 2011-2012 Splunk, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"): you may
# not use this file except in compliance with the License. You may obtain
@@ -14,7 +14,7 @@
"""Retrieves a list of installed apps from Splunk using the client module."""
-import splunk.client as client
+import splunklib.client as client
HOST = "localhost"
PORT = 8089
View
5 examples/analytics/README.md
@@ -147,6 +147,7 @@ In order to run the sample, you can simply execute:
./server.py
-And navigate to http://localhost:8080. I suggest you input some
+And navigate to http://localhost:8080/applications. I suggest you input some
events in beforehand, though `server.py` logs some events itself
-as you navigate the site (it's meta analytics!).
+as you navigate the site (it's meta analytics!).
+
View
4 examples/analytics/__init__.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright 2011 Splunk, Inc.
+# Copyright 2011-2012 Splunk, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"): you may
# not use this file except in compliance with the License. You may obtain
@@ -15,4 +15,4 @@
# under the License.
import input
-import output
+import output
View
17 examples/analytics/input.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright 2011 Splunk, Inc.
+# Copyright 2011-2012 Splunk, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"): you may
# not use this file except in compliance with the License. You may obtain
@@ -16,7 +16,8 @@
import urllib2, sys
from datetime import datetime
-import splunk.client, utils
+import splunklib.client as client
+import utils
__all__ = [
"AnalyticsTracker",
@@ -33,20 +34,20 @@
class AnalyticsTracker:
def __init__(self, application_name, splunk_info, index = ANALYTICS_INDEX_NAME):
self.application_name = application_name
- self.splunk = splunk.client.connect(**splunk_info)
+ self.splunk = client.connect(**splunk_info)
self.index = index
- if self.index not in self.splunk.indexes.list():
+ if not self.splunk.indexes.contains(self.index):
self.splunk.indexes.create(self.index)
+ assert(self.splunk.indexes.contains(self.index))
- assert(self.index in self.splunk.indexes.list())
-
- if ANALYTICS_SOURCETYPE not in self.splunk.confs["props"].list():
+ if not self.splunk.confs['props'].contains(ANALYTICS_SOURCETYPE):
self.splunk.confs["props"].create(ANALYTICS_SOURCETYPE)
stanza = self.splunk.confs["props"][ANALYTICS_SOURCETYPE]
stanza.submit("LINE_BREAKER = (%s)" % EVENT_TERMINATOR)
stanza.submit("CHARSET = UTF-8")
stanza.submit("SHOULD_LINEMERGE = false")
+ assert(self.splunk.confs['props'].contains(ANALYTICS_SOURCETYPE))
@staticmethod
def encode(props):
@@ -94,4 +95,4 @@ def main():
#tracker.track("test_event", "abc123", foo="bar", bar="foo")
if __name__ == "__main__":
- main()
+ main()
View
11 examples/analytics/output.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright 2011 Splunk, Inc.
+# Copyright 2011-2012 Splunk, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"): you may
# not use this file except in compliance with the License. You may obtain
@@ -15,8 +15,9 @@
# under the License.
import urllib2, sys
-import splunk.client, utils
-import splunk.results as results
+import splunklib.client as client
+import splunklib.results as results
+import utils
__all__ = [
"TimeRange",
@@ -39,7 +40,7 @@ class TimeRange:
class AnalyticsRetriever:
def __init__(self, application_name, splunk_info, index = ANALYTICS_INDEX_NAME):
self.application_name = application_name
- self.splunk = splunk.client.connect(**splunk_info)
+ self.splunk = client.connect(**splunk_info)
self.index = index
def applications(self):
@@ -165,4 +166,4 @@ def main():
#print retriever.events_over_time()
if __name__ == "__main__":
- main()
+ main()
View
2 examples/analytics/server.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright 2011 Splunk, Inc.
+# Copyright 2011-2012 Splunk, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"): you may
# not use this file except in compliance with the License. You may obtain
View
9 examples/async/async.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright 2011 Splunk, Inc.
+# Copyright 2011-2012 Splunk, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"): you may
# not use this file except in compliance with the License. You may obtain
@@ -24,7 +24,8 @@
import urllib
from time import sleep
-import splunk.client
+import splunklib.binding as binding
+import splunklib.client as client
from utils import parse, error
# Placeholder for a specific implementation of `urllib2`,
@@ -68,7 +69,7 @@ def main(argv):
# Create the service instance using our custom HTTP request handler.
- service = splunk.client.Service(handler=request, **opts.kwargs)
+ service = client.Service(handler=request, **opts.kwargs)
service.login()
# Record the current time at the start of the
@@ -186,7 +187,7 @@ def request(url, message, **kwargs):
'status': response.code,
'reason': response.msg,
'headers': response.info().dict,
- 'body': splunk.binding.ResponseReader(response)
+ 'body': binding.ResponseReader(response)
}
if __name__ == "__main__":
View
6 examples/binding1.py
@@ -1,4 +1,6 @@
-# Copyright 2011 Splunk, Inc.
+#!/usr/bin/env python
+#
+# Copyright 2011-2012 Splunk, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"): you may
# not use this file except in compliance with the License. You may obtain
@@ -19,7 +21,7 @@
import sys
-from splunk.binding import connect
+from splunklib.binding import connect
from utils import parse
View
7 examples/conf.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright 2011 Splunk, Inc.
+# Copyright 2011-2012 Splunk, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"): you may
# not use this file except in compliance with the License. You may obtain
@@ -18,7 +18,7 @@
import sys
-from splunk.client import connect
+from splunklib.client import connect
from utils import error, parse
class Program:
@@ -111,8 +111,7 @@ def list(self, opts):
for stanza in conf:
if (spres and argv[1] == stanza.name) or not spres:
print "[%s]" % stanza.name
- entity = stanza.read()
- for key, value in entity.iteritems():
+ for key, value in stanza.content.iteritems():
if (kpres and argv[2] == key) or not kpres:
print "%s = %s" % (key, value)
print
View
4 examples/custom_search/bin/usercount.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright 2011 Splunk, Inc.
+# Copyright 2011-2012 Splunk, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"): you may
# not use this file except in compliance with the License. You may obtain
@@ -182,4 +182,4 @@ def main(argv):
main(sys.argv)
except Exception:
import traceback
- traceback.print_exc(file=sys.stdout)
+ traceback.print_exc(file=sys.stdout)
View
27 examples/dashboard/feed.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright 2011 Splunk, Inc.
+# Copyright 2011-2012 Splunk, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"): you may
# not use this file except in compliance with the License. You may obtain
@@ -23,18 +23,22 @@
import sys, datetime, urllib2, json
from xml.etree import ElementTree
-import splunk.client
-import splunk.results as results
+import splunklib.client as client
+import splunklib.results as results
from utils import parse, error
leftronic_access_key = ""
-def send_data(access_key, stream_name, point):
+def send_data(access_key, stream_name, point = None, command = None):
data = {
"accessKey": access_key,
- "streamName": stream_name,
- "point": point,
+ "streamName": stream_name
}
+
+ if not point is None:
+ data["point"] = point
+ if not command is None:
+ data["command"] = command
request = urllib2.Request("https://beta.leftronic.com/customSend/",
data = json.dumps(data)
@@ -76,15 +80,19 @@ def geo(service):
def iterate(job):
reader = results.ResultsReader(job.preview())
+ points = []
for kind,result in reader:
if kind == results.RESULT:
lng, lat = result["coordinates_coordinates"].split(",")
point = {
"latitude": lat,
"longitude": lng,
}
+ points.append(point)
- send_data(access_key = leftronic_access_key, stream_name = "geo", point = point)
+
+ send_data(access_key = leftronic_access_key, stream_name = "geo", command = "clear")
+ send_data(access_key = leftronic_access_key, stream_name = "geo", point = points)
return (created_job, lambda job: iterate(job))
@@ -153,14 +161,11 @@ def iterate(job):
return (created_job, lambda job: iterate(job))
def main(argv):
- global urllib2
- usage = "async.py <sync | async>"
-
# Parse the command line args.
opts = parse(argv, {}, ".splunkrc")
# Connect to Splunk
- service = splunk.client.connect(**opts.kwargs)
+ service = client.connect(**opts.kwargs)
# This is the list of dashboard streams
streams = [
View
41 examples/event_types.py
@@ -0,0 +1,41 @@
+#!/usr/bin/env python
+#
+# Copyright 2011-2012 Splunk, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"): you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+"""A command line utility that lists Splunk event types."""
+
+import sys
+
+from splunklib.client import connect
+
+from utils import parse
+
+def main():
+ opts = parse(sys.argv[1:], {}, ".splunkrc")
+ service = connect(**opts.kwargs)
+
+ for item in service.event_types:
+ print "%s" % item.name
+ print '='*len(item.name)
+ content = item.content
+ for key in sorted(content.keys()):
+ value = content[key]
+ print "%s: %s" % (key, value)
+ print
+
+if __name__ == "__main__":
+ main()
+
+
View
1,589 examples/explorer/endpoints.js
1,041 additions, 548 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
2 examples/explorer/explorer.css
@@ -6,7 +6,7 @@
*{ margin:0; padding:0;}
body{ font:100% normal Arial, Helvetica, sans-serif; background:#161712;}
-form,input,select,textarea{margin:0; padding:0; color:#fff;}
+form,input,select,textarea{margin:0; padding:0;}
/* API RESPONSE CSS */
View
34 examples/explorer/explorer.html
@@ -219,17 +219,17 @@
// Replace the parameters with the POST body
params = postBody;
- // And we delete the namespace temporarily
- var namespace = $("#server-namespace").val();
+ // And we delete the app namespace temporarily
+ var app = $("#server-app").val();
}
execute = function() {
- // Save the old namespace
- var namespace = $("#server-namespace").val();
+ // Save the old app namespace
+ var app = $("#server-app").val();
if (nonFormRequest) {
- // If it is a non-form request, we have to erase the namespace
- $("#server-namespace").val(null);
+ // If it is a non-form request, we have to erase the app namespace
+ $("#server-app").val(null);
}
request(path, api.method, params, function(data, textStatus, xhr) {
@@ -238,8 +238,8 @@
//prettyPrint();
});
- // And we can restore the namespace regardless
- $("#server-namespace").val(namespace);
+ // And we can restore the app namespace regardless
+ $("#server-app").val(app);
};
// If we haven't logged in yet, then log in,
@@ -310,21 +310,21 @@
var host = $("#server-host").val();
var port = $("#server-port").val();
var owner = $("#server-owner").val();
- var namespace = $("#server-namespace").val();
+ var app = $("#server-app").val();
if (startsWith(path, "/")) {
path = path;
return path;
}
- if (!namespace) {
+ if (app === "" && owner === "") {
path = "services/" + path;
}
else {
- var owner = (owner === "*" ? "-" : owner);
- var namespace = (namespace === "*" ? "-" : namespace);
+ var owner = owner === "" ? "-" : owner;
+ var app = app === "" ? "-" : app;
- path = "servicesNS/" + owner + "/" + namespace + "/" + path;
+ path = "servicesNS/" + owner + "/" + app + "/" + path;
}
return scheme + "://" + host + ":" + port + "/" + path;
@@ -490,11 +490,11 @@
</div>
<div class="server-info-field">
<h3>owner</h3>
- <input id="server-owner" value="-"/>
+ <input id="server-owner" value=""/>
</div>
<div class="server-info-field">
- <h3>namespace</h3>
- <input id="server-namespace" value="-"/>
+ <h3>app</h3>
+ <input id="server-app" value=""/>
</div>
<div class="server-info-field">
<h3>Username</h3>
@@ -521,4 +521,4 @@
<pre class="prettyprint lang-xml" id="api-result-div"></pre>
</div>
</body>
-</html>
+</html>
View
23 examples/explorer/explorer.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright 2011 Splunk, Inc.
+# Copyright 2011-2012 Splunk, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"): you may
# not use this file except in compliance with the License. You may obtain
@@ -37,21 +37,20 @@ def main(argv):
opts = utils.parse(argv, redirect_port_args, ".splunkrc", usage=usage)
- # We have to provide a sensible value for namespace
- namespace = opts.kwargs["namespace"]
- namespace = namespace if namespace else "-"
-
- # Encode these arguments
- args = urllib.urlencode([
- ("scheme", opts.kwargs["scheme"]),
+ args = [("scheme", opts.kwargs["scheme"]),
("host", opts.kwargs["host"]),
("port", opts.kwargs["port"]),
("redirecthost", "localhost"),
("redirectport", opts.kwargs["redirectport"]),
("username", opts.kwargs["username"]),
- ("password", opts.kwargs["password"]),
- ("namespace", namespace)
- ]),
+ ("password", opts.kwargs["password"])]
+ if 'app' in opts.kwargs.keys():
+ args.append(('app', opts.kwargs['app']))
+ if 'owner' in opts.kwargs.keys():
+ args.append(('owner', opts.kwargs['owner']))
+
+ # Encode these arguments
+ args = urllib.urlencode(args)
# Launch the browser
webbrowser.open("file://%s" % os.path.join(os.getcwd(), "explorer.html?%s" % args))
@@ -65,4 +64,4 @@ def main(argv):
except KeyboardInterrupt:
pass
except:
- raise
+ raise
View
4 examples/explorer/server.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright 2011 Splunk, Inc.
+# Copyright 2011-2012 Splunk, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"): you may
# not use this file except in compliance with the License. You may obtain
@@ -159,4 +159,4 @@ def main(argv):
except KeyboardInterrupt:
pass
except:
- raise
+ raise
View
19 examples/export/export.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright 2011 Splunk, Inc.
+# Copyright 2011-2012 Splunk, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"): you may
# not use this file except in compliance with the License. You may obtain
@@ -26,8 +26,8 @@
import os
# splunk support files
-import splunk.binding as binding
-from splunk.binding import connect
+import splunklib.binding as binding
+from splunklib.binding import connect
from utils import parse
# hidden file
@@ -86,13 +86,12 @@ def query(context, start, end, span, index):
# generate a search
squery = "search * index=%s " % index
- squery = squery + "timeformat=%s "
# if start/end specified, use them
if start != 0:
- squery = squery + "starttime=%d " % start
+ squery = squery + "earliest_time=%d " % start
if end != 0:
- squery = squery + "endtime=%d " % end
+ squery = squery + "latest_time=%d " % end
# span is in seconds for buckets
squery = squery + "| timechart "
@@ -108,7 +107,7 @@ def query(context, start, end, span, index):
retry = True
while retry:
result = context.get('search/jobs/export', search=squery,
- output_mode="csv")
+ output_mode="csv", time_format="%s")
if result.status != 200:
print "Failed to get event counts, HTTP status=%d, retrying"\
% result.status
@@ -160,7 +159,6 @@ def get_buckets(context, start, end, index, limit, span):
# eventcount,starttime,timequantum
for line in lines:
elements = line.split(",")
-
# extract the element components
enumevents = int(elements[0])
estarttime = int(elements[1])
@@ -379,13 +377,12 @@ def export(options, context, bucket_list):
print "PROCESSING BUCKET:------ %s" % str(bucket)
# generate a search.
squery = "search * index=%s " % options.kwargs['index']
- squery = squery + "timeformat=%s "
start = bucket[1]
quantum = bucket[2]
- squery = squery + "starttime=%d " % start
- squery = squery + "endtime=%d " % (start+quantum)
+ squery = squery + "earliest_time=%d " % start
+ squery = squery + "latest_time=%d " % (start+quantum)
# issue query to splunkd
# count=0 overrides the maximum number of events
View
346 examples/export/export2.py
@@ -0,0 +1,346 @@
+#!/usr/bin/env python
+#
+# Copyright 2012 Splunk, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"): you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+"""
+This software exports a splunk index using the streaming export endpoint
+using a parameterized chunking mechanism.
+"""
+
+# installation support files
+import sys
+import time
+from os import path
+
+# splunk support files
+from splunklib.binding import connect
+from utils import error, parse
+
+# hidden file
+OUTPUT_FILE = "./export.out"
+OUTPUT_MODE = "xml"
+OUTPUT_MODES = ["csv", "xml", "json"]
+
+CLIRULES = {
+ 'end': {
+ 'flags': ["--endtime"],
+ 'default': "",
+ 'help': "Start time of export (default is start of index)"
+ },
+ 'index': {
+ 'flags': ["--index"],
+ 'default': "*",
+ 'help': "Index to export (default is all user defined indices)"
+ },
+ 'omode': {
+ 'flags': ["--omode"],
+ 'default': OUTPUT_MODE,
+ 'help': "output format %s default is %s" % (OUTPUT_MODES, OUTPUT_MODE)
+ },
+ 'output': {
+ 'flags': ["--output"],
+ 'default': OUTPUT_FILE,
+ 'help': "Output file name (default is %s)" % OUTPUT_FILE
+ },
+ 'recover': {
+ 'flags': ["--recover"],
+ 'default': False,
+ 'help': "Export attempts to recover from end of existing export"
+ },
+ 'search': {
+ 'flags': ["--search"],
+ 'default': "search *",
+ 'help': "search string (default 'search *')"
+ },
+ 'start': {
+ 'flags': ["--starttime"],
+ 'default': "",
+ 'help': "Start time of export (default is start of index)"
+ }
+}
+
+def get_csv_next_event_start(location, event_buffer):
+ """ determin the event start and end of *any* valid event """
+
+ start = -1
+ end = -1
+
+ event_start = event_buffer.find("\n", location + 1)
+ event_end = event_buffer.find('"\n', event_start + 1)
+
+ while (event_end > 0):
+ parts = event_buffer[event_start:event_end].split(",")
+ # test parts 0 and 1 of CSV. Format should be time.qqq, anything
+ # else is not time stamp to keep moving.
+ try:
+ int(parts[0].replace('\n',""))
+ timestamp = parts[1].replace('"', "")
+ timeparts = timestamp.split('.')
+ int(timeparts[0])
+ int(timeparts[1])
+ return (event_start, event_end)
+ except:
+ event_start = event_buffer.find("\n", event_end + 2)
+ event_end = event_buffer.find('"\n', event_start + 1)
+
+ return (start, end)
+
+def get_csv_event_start(event_buffer):
+ """ get the event start of an event that is different (in time)from the
+ adjoining event, in CSV format """