splunklib.data¶
The splunklib.data module reads the responses from splunkd in Atom Feed format, which is the format used by most of the REST API.
-
splunklib.data.load(text, match=None)¶ This function reads a string that contains the XML of an Atom Feed, then returns the data in a native Python structure (a
dictorlist). If you also provide a tag name or path to match, only the matching sub-elements are loaded.Parameters: - text (
string) – The XML text to load. - match (
string) – A tag name or path to match (optional).
- text (
-
splunklib.data.record(value=None)¶ This function returns a
Recordinstance constructed with an initial value that you provide.Parameters: value ( dict) – An initial record value.
-
class
splunklib.data.Record¶ This generic utility class enables dot access to members of a Python dictionary.
Any key that is also a valid Python identifier can be retrieved as a field. So, for an instance of
Recordcalledr,r.keyis equivalent tor['key']. A key such asinvalid-keyorinvalid.keycannot be retrieved as a field, because-and.are not allowed in identifiers.Keys of the form
a.b.care very natural to write in Python as fields. If a group of keys shares a prefix ending in., you can retrieve keys as a nested dictionary by calling only the prefix. For example, ifrcontains keys'foo','bar.baz', and'bar.qux',r.barreturns a record with the keysbazandqux. If a key contains multiple., each one is placed into a nested dictionary, so you can writer.bar.quxorr['bar.qux']interchangeably.