id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
222,100 | splunk/splunk-sdk-python | examples/analytics/bottle.py | tob | def tob(data, enc='utf8'):
""" Convert anything to bytes """
return data.encode(enc) if isinstance(data, six.text_type) else bytes(data) | python | def tob(data, enc='utf8'):
""" Convert anything to bytes """
return data.encode(enc) if isinstance(data, six.text_type) else bytes(data) | [
"def",
"tob",
"(",
"data",
",",
"enc",
"=",
"'utf8'",
")",
":",
"return",
"data",
".",
"encode",
"(",
"enc",
")",
"if",
"isinstance",
"(",
"data",
",",
"six",
".",
"text_type",
")",
"else",
"bytes",
"(",
"data",
")"
] | Convert anything to bytes | [
"Convert",
"anything",
"to",
"bytes"
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/examples/analytics/bottle.py#L91-L93 |
222,101 | splunk/splunk-sdk-python | examples/analytics/bottle.py | make_default_app_wrapper | def make_default_app_wrapper(name):
''' Return a callable that relays calls to the current default app. '''
@functools.wraps(getattr(Bottle, name))
def wrapper(*a, **ka):
return getattr(app(), name)(*a, **ka)
return wrapper | python | def make_default_app_wrapper(name):
''' Return a callable that relays calls to the current default app. '''
@functools.wraps(getattr(Bottle, name))
def wrapper(*a, **ka):
return getattr(app(), name)(*a, **ka)
return wrapper | [
"def",
"make_default_app_wrapper",
"(",
"name",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"getattr",
"(",
"Bottle",
",",
"name",
")",
")",
"def",
"wrapper",
"(",
"*",
"a",
",",
"*",
"*",
"ka",
")",
":",
"return",
"getattr",
"(",
"app",
"(",
")... | Return a callable that relays calls to the current default app. | [
"Return",
"a",
"callable",
"that",
"relays",
"calls",
"to",
"the",
"current",
"default",
"app",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/examples/analytics/bottle.py#L1644-L1649 |
222,102 | splunk/splunk-sdk-python | examples/analytics/bottle.py | load_app | def load_app(target):
""" Load a bottle application based on a target string and return the
application object.
If the target is an import path (e.g. package.module), the application
stack is used to isolate the routes defined in that module.
If the target contains a colon (e.g. pac... | python | def load_app(target):
""" Load a bottle application based on a target string and return the
application object.
If the target is an import path (e.g. package.module), the application
stack is used to isolate the routes defined in that module.
If the target contains a colon (e.g. pac... | [
"def",
"load_app",
"(",
"target",
")",
":",
"tmp",
"=",
"app",
".",
"push",
"(",
")",
"# Create a new \"default application\"",
"rv",
"=",
"_load",
"(",
"target",
")",
"# Import the target module",
"app",
".",
"remove",
"(",
"tmp",
")",
"# Remove the temporary a... | Load a bottle application based on a target string and return the
application object.
If the target is an import path (e.g. package.module), the application
stack is used to isolate the routes defined in that module.
If the target contains a colon (e.g. package.module:myapp) the
... | [
"Load",
"a",
"bottle",
"application",
"based",
"on",
"a",
"target",
"string",
"and",
"return",
"the",
"application",
"object",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/examples/analytics/bottle.py#L1935-L1947 |
222,103 | splunk/splunk-sdk-python | examples/analytics/bottle.py | run | def run(app=None, server='wsgiref', host='127.0.0.1', port=8080,
interval=1, reloader=False, quiet=False, **kargs):
""" Start a server instance. This method blocks until the server terminates.
:param app: WSGI application or target string supported by
:func:`load_app`. (default: :fun... | python | def run(app=None, server='wsgiref', host='127.0.0.1', port=8080,
interval=1, reloader=False, quiet=False, **kargs):
""" Start a server instance. This method blocks until the server terminates.
:param app: WSGI application or target string supported by
:func:`load_app`. (default: :fun... | [
"def",
"run",
"(",
"app",
"=",
"None",
",",
"server",
"=",
"'wsgiref'",
",",
"host",
"=",
"'127.0.0.1'",
",",
"port",
"=",
"8080",
",",
"interval",
"=",
"1",
",",
"reloader",
"=",
"False",
",",
"quiet",
"=",
"False",
",",
"*",
"*",
"kargs",
")",
... | Start a server instance. This method blocks until the server terminates.
:param app: WSGI application or target string supported by
:func:`load_app`. (default: :func:`default_app`)
:param server: Server adapter to use. See :data:`server_names` keys
for valid names or pass ... | [
"Start",
"a",
"server",
"instance",
".",
"This",
"method",
"blocks",
"until",
"the",
"server",
"terminates",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/examples/analytics/bottle.py#L1950-L1995 |
222,104 | splunk/splunk-sdk-python | examples/analytics/bottle.py | Router.build | def build(self, _name, *anon, **args):
''' Return a string that matches a named route. Use keyword arguments
to fill out named wildcards. Remaining arguments are appended as a
query string. Raises RouteBuildError or KeyError.'''
if _name not in self.named:
raise Route... | python | def build(self, _name, *anon, **args):
''' Return a string that matches a named route. Use keyword arguments
to fill out named wildcards. Remaining arguments are appended as a
query string. Raises RouteBuildError or KeyError.'''
if _name not in self.named:
raise Route... | [
"def",
"build",
"(",
"self",
",",
"_name",
",",
"*",
"anon",
",",
"*",
"*",
"args",
")",
":",
"if",
"_name",
"not",
"in",
"self",
".",
"named",
":",
"raise",
"RouteBuildError",
"(",
"\"No route with that name.\"",
",",
"_name",
")",
"rule",
",",
"pairs... | Return a string that matches a named route. Use keyword arguments
to fill out named wildcards. Remaining arguments are appended as a
query string. Raises RouteBuildError or KeyError. | [
"Return",
"a",
"string",
"that",
"matches",
"a",
"named",
"route",
".",
"Use",
"keyword",
"arguments",
"to",
"fill",
"out",
"named",
"wildcards",
".",
"Remaining",
"arguments",
"are",
"appended",
"as",
"a",
"query",
"string",
".",
"Raises",
"RouteBuildError",
... | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/examples/analytics/bottle.py#L278-L304 |
222,105 | splunk/splunk-sdk-python | examples/analytics/bottle.py | Router._match_path | def _match_path(self, environ):
''' Optimized PATH_INFO matcher. '''
path = environ['PATH_INFO'] or '/'
# Assume we are in a warm state. Search compiled rules first.
match = self.static.get(path)
if match: return match, {}
for combined, rules in self.dynamic:
... | python | def _match_path(self, environ):
''' Optimized PATH_INFO matcher. '''
path = environ['PATH_INFO'] or '/'
# Assume we are in a warm state. Search compiled rules first.
match = self.static.get(path)
if match: return match, {}
for combined, rules in self.dynamic:
... | [
"def",
"_match_path",
"(",
"self",
",",
"environ",
")",
":",
"path",
"=",
"environ",
"[",
"'PATH_INFO'",
"]",
"or",
"'/'",
"# Assume we are in a warm state. Search compiled rules first.",
"match",
"=",
"self",
".",
"static",
".",
"get",
"(",
"path",
")",
"if",
... | Optimized PATH_INFO matcher. | [
"Optimized",
"PATH_INFO",
"matcher",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/examples/analytics/bottle.py#L324-L350 |
222,106 | splunk/splunk-sdk-python | examples/analytics/bottle.py | Router._compile | def _compile(self):
''' Prepare static and dynamic search structures. '''
self.static = {}
self.dynamic = []
def fpat_sub(m):
return m.group(0) if len(m.group(1)) % 2 else m.group(1) + '(?:'
for rule in self.rules:
target = self.routes[rule]
if... | python | def _compile(self):
''' Prepare static and dynamic search structures. '''
self.static = {}
self.dynamic = []
def fpat_sub(m):
return m.group(0) if len(m.group(1)) % 2 else m.group(1) + '(?:'
for rule in self.rules:
target = self.routes[rule]
if... | [
"def",
"_compile",
"(",
"self",
")",
":",
"self",
".",
"static",
"=",
"{",
"}",
"self",
".",
"dynamic",
"=",
"[",
"]",
"def",
"fpat_sub",
"(",
"m",
")",
":",
"return",
"m",
".",
"group",
"(",
"0",
")",
"if",
"len",
"(",
"m",
".",
"group",
"("... | Prepare static and dynamic search structures. | [
"Prepare",
"static",
"and",
"dynamic",
"search",
"structures",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/examples/analytics/bottle.py#L352-L374 |
222,107 | splunk/splunk-sdk-python | examples/analytics/bottle.py | Router._compile_pattern | def _compile_pattern(self, rule):
''' Return a regular expression with named groups for each wildcard. '''
out = ''
for i, part in enumerate(self.syntax.split(rule)):
if i%3 == 0: out += re.escape(part.replace('\\:',':'))
elif i%3 == 1: out += '(?P<%s>' % part if part e... | python | def _compile_pattern(self, rule):
''' Return a regular expression with named groups for each wildcard. '''
out = ''
for i, part in enumerate(self.syntax.split(rule)):
if i%3 == 0: out += re.escape(part.replace('\\:',':'))
elif i%3 == 1: out += '(?P<%s>' % part if part e... | [
"def",
"_compile_pattern",
"(",
"self",
",",
"rule",
")",
":",
"out",
"=",
"''",
"for",
"i",
",",
"part",
"in",
"enumerate",
"(",
"self",
".",
"syntax",
".",
"split",
"(",
"rule",
")",
")",
":",
"if",
"i",
"%",
"3",
"==",
"0",
":",
"out",
"+=",... | Return a regular expression with named groups for each wildcard. | [
"Return",
"a",
"regular",
"expression",
"with",
"named",
"groups",
"for",
"each",
"wildcard",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/examples/analytics/bottle.py#L376-L383 |
222,108 | splunk/splunk-sdk-python | examples/analytics/bottle.py | Bottle.mount | def mount(self, app, prefix, **options):
''' Mount an application to a specific URL prefix. The prefix is added
to SCIPT_PATH and removed from PATH_INFO before the sub-application
is called.
:param app: an instance of :class:`Bottle`.
:param prefix: path prefix u... | python | def mount(self, app, prefix, **options):
''' Mount an application to a specific URL prefix. The prefix is added
to SCIPT_PATH and removed from PATH_INFO before the sub-application
is called.
:param app: an instance of :class:`Bottle`.
:param prefix: path prefix u... | [
"def",
"mount",
"(",
"self",
",",
"app",
",",
"prefix",
",",
"*",
"*",
"options",
")",
":",
"if",
"not",
"isinstance",
"(",
"app",
",",
"Bottle",
")",
":",
"raise",
"TypeError",
"(",
"'Only Bottle instances are supported for now.'",
")",
"prefix",
"=",
"'/... | Mount an application to a specific URL prefix. The prefix is added
to SCIPT_PATH and removed from PATH_INFO before the sub-application
is called.
:param app: an instance of :class:`Bottle`.
:param prefix: path prefix used as a mount-point.
All other paramete... | [
"Mount",
"an",
"application",
"to",
"a",
"specific",
"URL",
"prefix",
".",
"The",
"prefix",
"is",
"added",
"to",
"SCIPT_PATH",
"and",
"removed",
"from",
"PATH_INFO",
"before",
"the",
"sub",
"-",
"application",
"is",
"called",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/examples/analytics/bottle.py#L424-L449 |
222,109 | splunk/splunk-sdk-python | examples/analytics/bottle.py | Bottle.uninstall | def uninstall(self, plugin):
''' Uninstall plugins. Pass an instance to remove a specific plugin.
Pass a type object to remove all plugins that match that type.
Subclasses are not removed. Pass a string to remove all plugins with
a matching ``name`` attribute. Pass ``True`` t... | python | def uninstall(self, plugin):
''' Uninstall plugins. Pass an instance to remove a specific plugin.
Pass a type object to remove all plugins that match that type.
Subclasses are not removed. Pass a string to remove all plugins with
a matching ``name`` attribute. Pass ``True`` t... | [
"def",
"uninstall",
"(",
"self",
",",
"plugin",
")",
":",
"removed",
",",
"remove",
"=",
"[",
"]",
",",
"plugin",
"for",
"i",
",",
"plugin",
"in",
"list",
"(",
"enumerate",
"(",
"self",
".",
"plugins",
")",
")",
"[",
":",
":",
"-",
"1",
"]",
":... | Uninstall plugins. Pass an instance to remove a specific plugin.
Pass a type object to remove all plugins that match that type.
Subclasses are not removed. Pass a string to remove all plugins with
a matching ``name`` attribute. Pass ``True`` to remove all plugins.
The lis... | [
"Uninstall",
"plugins",
".",
"Pass",
"an",
"instance",
"to",
"remove",
"a",
"specific",
"plugin",
".",
"Pass",
"a",
"type",
"object",
"to",
"remove",
"all",
"plugins",
"that",
"match",
"that",
"type",
".",
"Subclasses",
"are",
"not",
"removed",
".",
"Pass"... | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/examples/analytics/bottle.py#L467-L481 |
222,110 | splunk/splunk-sdk-python | examples/analytics/bottle.py | Bottle.close | def close(self):
''' Close the application and all installed plugins. '''
for plugin in self.plugins:
if hasattr(plugin, 'close'): plugin.close()
self.stopped = True | python | def close(self):
''' Close the application and all installed plugins. '''
for plugin in self.plugins:
if hasattr(plugin, 'close'): plugin.close()
self.stopped = True | [
"def",
"close",
"(",
"self",
")",
":",
"for",
"plugin",
"in",
"self",
".",
"plugins",
":",
"if",
"hasattr",
"(",
"plugin",
",",
"'close'",
")",
":",
"plugin",
".",
"close",
"(",
")",
"self",
".",
"stopped",
"=",
"True"
] | Close the application and all installed plugins. | [
"Close",
"the",
"application",
"and",
"all",
"installed",
"plugins",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/examples/analytics/bottle.py#L493-L497 |
222,111 | splunk/splunk-sdk-python | examples/analytics/bottle.py | Bottle._build_callback | def _build_callback(self, config):
''' Apply plugins to a route and return a new callable. '''
wrapped = config['callback']
plugins = self.plugins + config['apply']
skip = config['skip']
try:
for plugin in reversed(plugins):
if True in skip: break
... | python | def _build_callback(self, config):
''' Apply plugins to a route and return a new callable. '''
wrapped = config['callback']
plugins = self.plugins + config['apply']
skip = config['skip']
try:
for plugin in reversed(plugins):
if True in skip: break
... | [
"def",
"_build_callback",
"(",
"self",
",",
"config",
")",
":",
"wrapped",
"=",
"config",
"[",
"'callback'",
"]",
"plugins",
"=",
"self",
".",
"plugins",
"+",
"config",
"[",
"'apply'",
"]",
"skip",
"=",
"config",
"[",
"'skip'",
"]",
"try",
":",
"for",
... | Apply plugins to a route and return a new callable. | [
"Apply",
"plugins",
"to",
"a",
"route",
"and",
"return",
"a",
"new",
"callable",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/examples/analytics/bottle.py#L520-L538 |
222,112 | splunk/splunk-sdk-python | examples/analytics/bottle.py | Bottle.hook | def hook(self, name):
""" Return a decorator that attaches a callback to a hook. """
def wrapper(func):
self.hooks.add(name, func)
return func
return wrapper | python | def hook(self, name):
""" Return a decorator that attaches a callback to a hook. """
def wrapper(func):
self.hooks.add(name, func)
return func
return wrapper | [
"def",
"hook",
"(",
"self",
",",
"name",
")",
":",
"def",
"wrapper",
"(",
"func",
")",
":",
"self",
".",
"hooks",
".",
"add",
"(",
"name",
",",
"func",
")",
"return",
"func",
"return",
"wrapper"
] | Return a decorator that attaches a callback to a hook. | [
"Return",
"a",
"decorator",
"that",
"attaches",
"a",
"callback",
"to",
"a",
"hook",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/examples/analytics/bottle.py#L624-L629 |
222,113 | splunk/splunk-sdk-python | examples/analytics/bottle.py | Request.bind | def bind(self, environ):
""" Bind a new WSGI environment.
This is done automatically for the global `bottle.request`
instance on every request.
"""
self.environ = environ
# These attributes are used anyway, so it is ok to compute them here
self.path = '/'... | python | def bind(self, environ):
""" Bind a new WSGI environment.
This is done automatically for the global `bottle.request`
instance on every request.
"""
self.environ = environ
# These attributes are used anyway, so it is ok to compute them here
self.path = '/'... | [
"def",
"bind",
"(",
"self",
",",
"environ",
")",
":",
"self",
".",
"environ",
"=",
"environ",
"# These attributes are used anyway, so it is ok to compute them here",
"self",
".",
"path",
"=",
"'/'",
"+",
"environ",
".",
"get",
"(",
"'PATH_INFO'",
",",
"'/'",
")"... | Bind a new WSGI environment.
This is done automatically for the global `bottle.request`
instance on every request. | [
"Bind",
"a",
"new",
"WSGI",
"environment",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/examples/analytics/bottle.py#L787-L796 |
222,114 | splunk/splunk-sdk-python | examples/analytics/bottle.py | Request._body | def _body(self):
""" The HTTP request body as a seekable file-like object.
This property returns a copy of the `wsgi.input` stream and should
be used instead of `environ['wsgi.input']`.
"""
maxread = max(0, self.content_length)
stream = self.environ['wsgi.input'... | python | def _body(self):
""" The HTTP request body as a seekable file-like object.
This property returns a copy of the `wsgi.input` stream and should
be used instead of `environ['wsgi.input']`.
"""
maxread = max(0, self.content_length)
stream = self.environ['wsgi.input'... | [
"def",
"_body",
"(",
"self",
")",
":",
"maxread",
"=",
"max",
"(",
"0",
",",
"self",
".",
"content_length",
")",
"stream",
"=",
"self",
".",
"environ",
"[",
"'wsgi.input'",
"]",
"body",
"=",
"BytesIO",
"(",
")",
"if",
"maxread",
"<",
"MEMFILE_MAX",
"... | The HTTP request body as a seekable file-like object.
This property returns a copy of the `wsgi.input` stream and should
be used instead of `environ['wsgi.input']`. | [
"The",
"HTTP",
"request",
"body",
"as",
"a",
"seekable",
"file",
"-",
"like",
"object",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/examples/analytics/bottle.py#L953-L969 |
222,115 | splunk/splunk-sdk-python | examples/analytics/bottle.py | Response.bind | def bind(self):
""" Resets the Response object to its factory defaults. """
self._COOKIES = None
self.status = 200
self.headers = HeaderDict()
self.content_type = 'text/html; charset=UTF-8' | python | def bind(self):
""" Resets the Response object to its factory defaults. """
self._COOKIES = None
self.status = 200
self.headers = HeaderDict()
self.content_type = 'text/html; charset=UTF-8' | [
"def",
"bind",
"(",
"self",
")",
":",
"self",
".",
"_COOKIES",
"=",
"None",
"self",
".",
"status",
"=",
"200",
"self",
".",
"headers",
"=",
"HeaderDict",
"(",
")",
"self",
".",
"content_type",
"=",
"'text/html; charset=UTF-8'"
] | Resets the Response object to its factory defaults. | [
"Resets",
"the",
"Response",
"object",
"to",
"its",
"factory",
"defaults",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/examples/analytics/bottle.py#L1022-L1027 |
222,116 | splunk/splunk-sdk-python | examples/analytics/bottle.py | Response.delete_cookie | def delete_cookie(self, key, **kwargs):
''' Delete a cookie. Be sure to use the same `domain` and `path`
parameters as used to create the cookie. '''
kwargs['max_age'] = -1
kwargs['expires'] = 0
self.set_cookie(key, '', **kwargs) | python | def delete_cookie(self, key, **kwargs):
''' Delete a cookie. Be sure to use the same `domain` and `path`
parameters as used to create the cookie. '''
kwargs['max_age'] = -1
kwargs['expires'] = 0
self.set_cookie(key, '', **kwargs) | [
"def",
"delete_cookie",
"(",
"self",
",",
"key",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'max_age'",
"]",
"=",
"-",
"1",
"kwargs",
"[",
"'expires'",
"]",
"=",
"0",
"self",
".",
"set_cookie",
"(",
"key",
",",
"''",
",",
"*",
"*",
"kwarg... | Delete a cookie. Be sure to use the same `domain` and `path`
parameters as used to create the cookie. | [
"Delete",
"a",
"cookie",
".",
"Be",
"sure",
"to",
"use",
"the",
"same",
"domain",
"and",
"path",
"parameters",
"as",
"used",
"to",
"create",
"the",
"cookie",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/examples/analytics/bottle.py#L1110-L1115 |
222,117 | splunk/splunk-sdk-python | examples/analytics/bottle.py | HooksPlugin.add | def add(self, name, func):
''' Attach a callback to a hook. '''
if name not in self.hooks:
raise ValueError("Unknown hook name %s" % name)
was_empty = self._empty()
self.hooks[name].append(func)
if self.app and was_empty and not self._empty(): self.app.reset() | python | def add(self, name, func):
''' Attach a callback to a hook. '''
if name not in self.hooks:
raise ValueError("Unknown hook name %s" % name)
was_empty = self._empty()
self.hooks[name].append(func)
if self.app and was_empty and not self._empty(): self.app.reset() | [
"def",
"add",
"(",
"self",
",",
"name",
",",
"func",
")",
":",
"if",
"name",
"not",
"in",
"self",
".",
"hooks",
":",
"raise",
"ValueError",
"(",
"\"Unknown hook name %s\"",
"%",
"name",
")",
"was_empty",
"=",
"self",
".",
"_empty",
"(",
")",
"self",
... | Attach a callback to a hook. | [
"Attach",
"a",
"callback",
"to",
"a",
"hook",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/examples/analytics/bottle.py#L1170-L1176 |
222,118 | splunk/splunk-sdk-python | examples/analytics/bottle.py | BaseTemplate.global_config | def global_config(cls, key, *args):
''' This reads or sets the global settings stored in class.settings. '''
if args:
cls.settings[key] = args[0]
else:
return cls.settings[key] | python | def global_config(cls, key, *args):
''' This reads or sets the global settings stored in class.settings. '''
if args:
cls.settings[key] = args[0]
else:
return cls.settings[key] | [
"def",
"global_config",
"(",
"cls",
",",
"key",
",",
"*",
"args",
")",
":",
"if",
"args",
":",
"cls",
".",
"settings",
"[",
"key",
"]",
"=",
"args",
"[",
"0",
"]",
"else",
":",
"return",
"cls",
".",
"settings",
"[",
"key",
"]"
] | This reads or sets the global settings stored in class.settings. | [
"This",
"reads",
"or",
"sets",
"the",
"global",
"settings",
"stored",
"in",
"class",
".",
"settings",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/examples/analytics/bottle.py#L2137-L2142 |
222,119 | splunk/splunk-sdk-python | splunklib/modularinput/script.py | Script.service | def service(self):
""" Returns a Splunk service object for this script invocation.
The service object is created from the Splunkd URI and session key
passed to the command invocation on the modular input stream. It is
available as soon as the :code:`Script.stream_events` method is
... | python | def service(self):
""" Returns a Splunk service object for this script invocation.
The service object is created from the Splunkd URI and session key
passed to the command invocation on the modular input stream. It is
available as soon as the :code:`Script.stream_events` method is
... | [
"def",
"service",
"(",
"self",
")",
":",
"if",
"self",
".",
"_service",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_service",
"if",
"self",
".",
"_input_definition",
"is",
"None",
":",
"return",
"None",
"splunkd_uri",
"=",
"self",
".",
"_input_def... | Returns a Splunk service object for this script invocation.
The service object is created from the Splunkd URI and session key
passed to the command invocation on the modular input stream. It is
available as soon as the :code:`Script.stream_events` method is
called.
:return: :c... | [
"Returns",
"a",
"Splunk",
"service",
"object",
"for",
"this",
"script",
"invocation",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/modularinput/script.py#L113-L144 |
222,120 | splunk/splunk-sdk-python | examples/random_numbers/random_numbers.py | MyScript.validate_input | def validate_input(self, validation_definition):
"""In this example we are using external validation to verify that min is
less than max. If validate_input does not raise an Exception, the input is
assumed to be valid. Otherwise it prints the exception as an error message
when telling sp... | python | def validate_input(self, validation_definition):
"""In this example we are using external validation to verify that min is
less than max. If validate_input does not raise an Exception, the input is
assumed to be valid. Otherwise it prints the exception as an error message
when telling sp... | [
"def",
"validate_input",
"(",
"self",
",",
"validation_definition",
")",
":",
"# Get the parameters from the ValidationDefinition object,",
"# then typecast the values as floats",
"minimum",
"=",
"float",
"(",
"validation_definition",
".",
"parameters",
"[",
"\"min\"",
"]",
"... | In this example we are using external validation to verify that min is
less than max. If validate_input does not raise an Exception, the input is
assumed to be valid. Otherwise it prints the exception as an error message
when telling splunkd that the configuration is invalid.
When using... | [
"In",
"this",
"example",
"we",
"are",
"using",
"external",
"validation",
"to",
"verify",
"that",
"min",
"is",
"less",
"than",
"max",
".",
"If",
"validate_input",
"does",
"not",
"raise",
"an",
"Exception",
"the",
"input",
"is",
"assumed",
"to",
"be",
"valid... | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/examples/random_numbers/random_numbers.py#L73-L93 |
222,121 | splunk/splunk-sdk-python | splunklib/modularinput/event.py | Event.write_to | def write_to(self, stream):
"""Write an XML representation of self, an ``Event`` object, to the given stream.
The ``Event`` object will only be written if its data field is defined,
otherwise a ``ValueError`` is raised.
:param stream: stream to write XML to.
"""
if self... | python | def write_to(self, stream):
"""Write an XML representation of self, an ``Event`` object, to the given stream.
The ``Event`` object will only be written if its data field is defined,
otherwise a ``ValueError`` is raised.
:param stream: stream to write XML to.
"""
if self... | [
"def",
"write_to",
"(",
"self",
",",
"stream",
")",
":",
"if",
"self",
".",
"data",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"Events must have at least the data field set to be written to XML.\"",
")",
"event",
"=",
"ET",
".",
"Element",
"(",
"\"event\"",
... | Write an XML representation of self, an ``Event`` object, to the given stream.
The ``Event`` object will only be written if its data field is defined,
otherwise a ``ValueError`` is raised.
:param stream: stream to write XML to. | [
"Write",
"an",
"XML",
"representation",
"of",
"self",
"an",
"Event",
"object",
"to",
"the",
"given",
"stream",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/modularinput/event.py#L72-L108 |
222,122 | splunk/splunk-sdk-python | splunklib/client.py | Service.capabilities | def capabilities(self):
"""Returns the list of system capabilities.
:return: A ``list`` of capabilities.
"""
response = self.get(PATH_CAPABILITIES)
return _load_atom(response, MATCH_ENTRY_CONTENT).capabilities | python | def capabilities(self):
"""Returns the list of system capabilities.
:return: A ``list`` of capabilities.
"""
response = self.get(PATH_CAPABILITIES)
return _load_atom(response, MATCH_ENTRY_CONTENT).capabilities | [
"def",
"capabilities",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"get",
"(",
"PATH_CAPABILITIES",
")",
"return",
"_load_atom",
"(",
"response",
",",
"MATCH_ENTRY_CONTENT",
")",
".",
"capabilities"
] | Returns the list of system capabilities.
:return: A ``list`` of capabilities. | [
"Returns",
"the",
"list",
"of",
"system",
"capabilities",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L423-L429 |
222,123 | splunk/splunk-sdk-python | splunklib/client.py | Service.modular_input_kinds | def modular_input_kinds(self):
"""Returns the collection of the modular input kinds on this Splunk instance.
:return: A :class:`ReadOnlyCollection` of :class:`ModularInputKind` entities.
"""
if self.splunk_version >= (5,):
return ReadOnlyCollection(self, PATH_MODULAR_INPUTS,... | python | def modular_input_kinds(self):
"""Returns the collection of the modular input kinds on this Splunk instance.
:return: A :class:`ReadOnlyCollection` of :class:`ModularInputKind` entities.
"""
if self.splunk_version >= (5,):
return ReadOnlyCollection(self, PATH_MODULAR_INPUTS,... | [
"def",
"modular_input_kinds",
"(",
"self",
")",
":",
"if",
"self",
".",
"splunk_version",
">=",
"(",
"5",
",",
")",
":",
"return",
"ReadOnlyCollection",
"(",
"self",
",",
"PATH_MODULAR_INPUTS",
",",
"item",
"=",
"ModularInputKind",
")",
"else",
":",
"raise",... | Returns the collection of the modular input kinds on this Splunk instance.
:return: A :class:`ReadOnlyCollection` of :class:`ModularInputKind` entities. | [
"Returns",
"the",
"collection",
"of",
"the",
"modular",
"input",
"kinds",
"on",
"this",
"Splunk",
"instance",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L506-L514 |
222,124 | splunk/splunk-sdk-python | splunklib/client.py | Service.restart_required | def restart_required(self):
"""Indicates whether splunkd is in a state that requires a restart.
:return: A ``boolean`` that indicates whether a restart is required.
"""
response = self.get("messages").body.read()
messages = data.load(response)['feed']
if 'entry' not in ... | python | def restart_required(self):
"""Indicates whether splunkd is in a state that requires a restart.
:return: A ``boolean`` that indicates whether a restart is required.
"""
response = self.get("messages").body.read()
messages = data.load(response)['feed']
if 'entry' not in ... | [
"def",
"restart_required",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"get",
"(",
"\"messages\"",
")",
".",
"body",
".",
"read",
"(",
")",
"messages",
"=",
"data",
".",
"load",
"(",
"response",
")",
"[",
"'feed'",
"]",
"if",
"'entry'",
"not... | Indicates whether splunkd is in a state that requires a restart.
:return: A ``boolean`` that indicates whether a restart is required. | [
"Indicates",
"whether",
"splunkd",
"is",
"in",
"a",
"state",
"that",
"requires",
"a",
"restart",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L580-L596 |
222,125 | splunk/splunk-sdk-python | splunklib/client.py | Service.splunk_version | def splunk_version(self):
"""Returns the version of the splunkd instance this object is attached
to.
The version is returned as a tuple of the version components as
integers (for example, `(4,3,3)` or `(5,)`).
:return: A ``tuple`` of ``integers``.
"""
if self._s... | python | def splunk_version(self):
"""Returns the version of the splunkd instance this object is attached
to.
The version is returned as a tuple of the version components as
integers (for example, `(4,3,3)` or `(5,)`).
:return: A ``tuple`` of ``integers``.
"""
if self._s... | [
"def",
"splunk_version",
"(",
"self",
")",
":",
"if",
"self",
".",
"_splunk_version",
"is",
"None",
":",
"self",
".",
"_splunk_version",
"=",
"tuple",
"(",
"[",
"int",
"(",
"p",
")",
"for",
"p",
"in",
"self",
".",
"info",
"[",
"'version'",
"]",
".",
... | Returns the version of the splunkd instance this object is attached
to.
The version is returned as a tuple of the version components as
integers (for example, `(4,3,3)` or `(5,)`).
:return: A ``tuple`` of ``integers``. | [
"Returns",
"the",
"version",
"of",
"the",
"splunkd",
"instance",
"this",
"object",
"is",
"attached",
"to",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L656-L667 |
222,126 | splunk/splunk-sdk-python | splunklib/client.py | Endpoint.get | def get(self, path_segment="", owner=None, app=None, sharing=None, **query):
"""Performs a GET operation on the path segment relative to this endpoint.
This method is named to match the HTTP method. This method makes at least
one roundtrip to the server, one additional round trip for
ea... | python | def get(self, path_segment="", owner=None, app=None, sharing=None, **query):
"""Performs a GET operation on the path segment relative to this endpoint.
This method is named to match the HTTP method. This method makes at least
one roundtrip to the server, one additional round trip for
ea... | [
"def",
"get",
"(",
"self",
",",
"path_segment",
"=",
"\"\"",
",",
"owner",
"=",
"None",
",",
"app",
"=",
"None",
",",
"sharing",
"=",
"None",
",",
"*",
"*",
"query",
")",
":",
"# self.path to the Endpoint is relative in the SDK, so passing",
"# owner, app, shari... | Performs a GET operation on the path segment relative to this endpoint.
This method is named to match the HTTP method. This method makes at least
one roundtrip to the server, one additional round trip for
each 303 status returned, plus at most two additional round
trips if
the `... | [
"Performs",
"a",
"GET",
"operation",
"on",
"the",
"path",
"segment",
"relative",
"to",
"this",
"endpoint",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L697-L759 |
222,127 | splunk/splunk-sdk-python | splunklib/client.py | Entity._run_action | def _run_action(self, path_segment, **kwargs):
"""Run a method and return the content Record from the returned XML.
A method is a relative path from an Entity that is not itself
an Entity. _run_action assumes that the returned XML is an
Atom field containing one Entry, and the contents ... | python | def _run_action(self, path_segment, **kwargs):
"""Run a method and return the content Record from the returned XML.
A method is a relative path from an Entity that is not itself
an Entity. _run_action assumes that the returned XML is an
Atom field containing one Entry, and the contents ... | [
"def",
"_run_action",
"(",
"self",
",",
"path_segment",
",",
"*",
"*",
"kwargs",
")",
":",
"response",
"=",
"self",
".",
"get",
"(",
"path_segment",
",",
"*",
"*",
"kwargs",
")",
"data",
"=",
"self",
".",
"_load_atom_entry",
"(",
"response",
")",
"rec"... | Run a method and return the content Record from the returned XML.
A method is a relative path from an Entity that is not itself
an Entity. _run_action assumes that the returned XML is an
Atom field containing one Entry, and the contents of Entry is
what should be the return value. This ... | [
"Run",
"a",
"method",
"and",
"return",
"the",
"content",
"Record",
"from",
"the",
"returned",
"XML",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L958-L970 |
222,128 | splunk/splunk-sdk-python | splunklib/client.py | Entity._proper_namespace | def _proper_namespace(self, owner=None, app=None, sharing=None):
"""Produce a namespace sans wildcards for use in entity requests.
This method tries to fill in the fields of the namespace which are `None`
or wildcard (`'-'`) from the entity's namespace. If that fails, it uses
the servic... | python | def _proper_namespace(self, owner=None, app=None, sharing=None):
"""Produce a namespace sans wildcards for use in entity requests.
This method tries to fill in the fields of the namespace which are `None`
or wildcard (`'-'`) from the entity's namespace. If that fails, it uses
the servic... | [
"def",
"_proper_namespace",
"(",
"self",
",",
"owner",
"=",
"None",
",",
"app",
"=",
"None",
",",
"sharing",
"=",
"None",
")",
":",
"if",
"owner",
"is",
"None",
"and",
"app",
"is",
"None",
"and",
"sharing",
"is",
"None",
":",
"# No namespace provided",
... | Produce a namespace sans wildcards for use in entity requests.
This method tries to fill in the fields of the namespace which are `None`
or wildcard (`'-'`) from the entity's namespace. If that fails, it uses
the service's namespace.
:param owner:
:param app:
:param sha... | [
"Produce",
"a",
"namespace",
"sans",
"wildcards",
"for",
"use",
"in",
"entity",
"requests",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L972-L994 |
222,129 | splunk/splunk-sdk-python | splunklib/client.py | Entity.refresh | def refresh(self, state=None):
"""Refreshes the state of this entity.
If *state* is provided, load it as the new state for this
entity. Otherwise, make a roundtrip to the server (by calling
the :meth:`read` method of ``self``) to fetch an updated state,
plus at most two addition... | python | def refresh(self, state=None):
"""Refreshes the state of this entity.
If *state* is provided, load it as the new state for this
entity. Otherwise, make a roundtrip to the server (by calling
the :meth:`read` method of ``self``) to fetch an updated state,
plus at most two addition... | [
"def",
"refresh",
"(",
"self",
",",
"state",
"=",
"None",
")",
":",
"if",
"state",
"is",
"not",
"None",
":",
"self",
".",
"_state",
"=",
"state",
"else",
":",
"self",
".",
"_state",
"=",
"self",
".",
"read",
"(",
"self",
".",
"get",
"(",
")",
"... | Refreshes the state of this entity.
If *state* is provided, load it as the new state for this
entity. Otherwise, make a roundtrip to the server (by calling
the :meth:`read` method of ``self``) to fetch an updated state,
plus at most two additional round trips if
the ``autologin`... | [
"Refreshes",
"the",
"state",
"of",
"this",
"entity",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L1008-L1033 |
222,130 | splunk/splunk-sdk-python | splunklib/client.py | Entity.disable | def disable(self):
"""Disables the entity at this endpoint."""
self.post("disable")
if self.service.restart_required:
self.service.restart(120)
return self | python | def disable(self):
"""Disables the entity at this endpoint."""
self.post("disable")
if self.service.restart_required:
self.service.restart(120)
return self | [
"def",
"disable",
"(",
"self",
")",
":",
"self",
".",
"post",
"(",
"\"disable\"",
")",
"if",
"self",
".",
"service",
".",
"restart_required",
":",
"self",
".",
"service",
".",
"restart",
"(",
"120",
")",
"return",
"self"
] | Disables the entity at this endpoint. | [
"Disables",
"the",
"entity",
"at",
"this",
"endpoint",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L1052-L1057 |
222,131 | splunk/splunk-sdk-python | splunklib/client.py | ReadOnlyCollection._entity_path | def _entity_path(self, state):
"""Calculate the path to an entity to be returned.
*state* should be the dictionary returned by
:func:`_parse_atom_entry`. :func:`_entity_path` extracts the
link to this entity from *state*, and strips all the namespace
prefixes from it to leave on... | python | def _entity_path(self, state):
"""Calculate the path to an entity to be returned.
*state* should be the dictionary returned by
:func:`_parse_atom_entry`. :func:`_entity_path` extracts the
link to this entity from *state*, and strips all the namespace
prefixes from it to leave on... | [
"def",
"_entity_path",
"(",
"self",
",",
"state",
")",
":",
"# This has been factored out so that it can be easily",
"# overloaded by Configurations, which has to switch its",
"# entities' endpoints from its own properties/ to configs/.",
"raw_path",
"=",
"urllib",
".",
"parse",
".",... | Calculate the path to an entity to be returned.
*state* should be the dictionary returned by
:func:`_parse_atom_entry`. :func:`_entity_path` extracts the
link to this entity from *state*, and strips all the namespace
prefixes from it to leave only the relative path of the entity
... | [
"Calculate",
"the",
"path",
"to",
"an",
"entity",
"to",
"be",
"returned",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L1291-L1312 |
222,132 | splunk/splunk-sdk-python | splunklib/client.py | ReadOnlyCollection.itemmeta | def itemmeta(self):
"""Returns metadata for members of the collection.
Makes a single roundtrip to the server, plus two more at most if
the ``autologin`` field of :func:`connect` is set to ``True``.
:return: A :class:`splunklib.data.Record` object containing the metadata.
**Ex... | python | def itemmeta(self):
"""Returns metadata for members of the collection.
Makes a single roundtrip to the server, plus two more at most if
the ``autologin`` field of :func:`connect` is set to ``True``.
:return: A :class:`splunklib.data.Record` object containing the metadata.
**Ex... | [
"def",
"itemmeta",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"get",
"(",
"\"_new\"",
")",
"content",
"=",
"_load_atom",
"(",
"response",
",",
"MATCH_ENTRY_CONTENT",
")",
"return",
"_parse_atom_metadata",
"(",
"content",
")"
] | Returns metadata for members of the collection.
Makes a single roundtrip to the server, plus two more at most if
the ``autologin`` field of :func:`connect` is set to ``True``.
:return: A :class:`splunklib.data.Record` object containing the metadata.
**Example**::
import s... | [
"Returns",
"metadata",
"for",
"members",
"of",
"the",
"collection",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L1351-L1388 |
222,133 | splunk/splunk-sdk-python | splunklib/client.py | ReadOnlyCollection.iter | def iter(self, offset=0, count=None, pagesize=None, **kwargs):
"""Iterates over the collection.
This method is equivalent to the :meth:`list` method, but
it returns an iterator and can load a certain number of entities at a
time from the server.
:param offset: The index of the ... | python | def iter(self, offset=0, count=None, pagesize=None, **kwargs):
"""Iterates over the collection.
This method is equivalent to the :meth:`list` method, but
it returns an iterator and can load a certain number of entities at a
time from the server.
:param offset: The index of the ... | [
"def",
"iter",
"(",
"self",
",",
"offset",
"=",
"0",
",",
"count",
"=",
"None",
",",
"pagesize",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"assert",
"pagesize",
"is",
"None",
"or",
"pagesize",
">",
"0",
"if",
"count",
"is",
"None",
":",
"co... | Iterates over the collection.
This method is equivalent to the :meth:`list` method, but
it returns an iterator and can load a certain number of entities at a
time from the server.
:param offset: The index of the first entity to return (optional).
:type offset: ``integer``
... | [
"Iterates",
"over",
"the",
"collection",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L1390-L1440 |
222,134 | splunk/splunk-sdk-python | splunklib/client.py | ReadOnlyCollection.list | def list(self, count=None, **kwargs):
"""Retrieves a list of entities in this collection.
The entire collection is loaded at once and is returned as a list. This
function makes a single roundtrip to the server, plus at most two more if
the ``autologin`` field of :func:`connect` is set t... | python | def list(self, count=None, **kwargs):
"""Retrieves a list of entities in this collection.
The entire collection is loaded at once and is returned as a list. This
function makes a single roundtrip to the server, plus at most two more if
the ``autologin`` field of :func:`connect` is set t... | [
"def",
"list",
"(",
"self",
",",
"count",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# response = self.get(count=count, **kwargs)",
"# return self._load_list(response)",
"return",
"list",
"(",
"self",
".",
"iter",
"(",
"count",
"=",
"count",
",",
"*",
"*... | Retrieves a list of entities in this collection.
The entire collection is loaded at once and is returned as a list. This
function makes a single roundtrip to the server, plus at most two more if
the ``autologin`` field of :func:`connect` is set to ``True``.
There is no caching--every ca... | [
"Retrieves",
"a",
"list",
"of",
"entities",
"in",
"this",
"collection",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L1443-L1472 |
222,135 | splunk/splunk-sdk-python | splunklib/client.py | Collection.delete | def delete(self, name, **params):
"""Deletes a specified entity from the collection.
:param name: The name of the entity to delete.
:type name: ``string``
:return: The collection.
:rtype: ``self``
This method is implemented for consistency with the REST API's DELETE
... | python | def delete(self, name, **params):
"""Deletes a specified entity from the collection.
:param name: The name of the entity to delete.
:type name: ``string``
:return: The collection.
:rtype: ``self``
This method is implemented for consistency with the REST API's DELETE
... | [
"def",
"delete",
"(",
"self",
",",
"name",
",",
"*",
"*",
"params",
")",
":",
"name",
"=",
"UrlEncoded",
"(",
"name",
",",
"encode_slash",
"=",
"True",
")",
"if",
"'namespace'",
"in",
"params",
":",
"namespace",
"=",
"params",
".",
"pop",
"(",
"'name... | Deletes a specified entity from the collection.
:param name: The name of the entity to delete.
:type name: ``string``
:return: The collection.
:rtype: ``self``
This method is implemented for consistency with the REST API's DELETE
method.
If there is no *name* e... | [
"Deletes",
"a",
"specified",
"entity",
"from",
"the",
"collection",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L1572-L1613 |
222,136 | splunk/splunk-sdk-python | splunklib/client.py | Collection.get | def get(self, name="", owner=None, app=None, sharing=None, **query):
"""Performs a GET request to the server on the collection.
If *owner*, *app*, and *sharing* are omitted, this method takes a
default namespace from the :class:`Service` object for this :class:`Endpoint`.
All other keyw... | python | def get(self, name="", owner=None, app=None, sharing=None, **query):
"""Performs a GET request to the server on the collection.
If *owner*, *app*, and *sharing* are omitted, this method takes a
default namespace from the :class:`Service` object for this :class:`Endpoint`.
All other keyw... | [
"def",
"get",
"(",
"self",
",",
"name",
"=",
"\"\"",
",",
"owner",
"=",
"None",
",",
"app",
"=",
"None",
",",
"sharing",
"=",
"None",
",",
"*",
"*",
"query",
")",
":",
"name",
"=",
"UrlEncoded",
"(",
"name",
",",
"encode_slash",
"=",
"True",
")",... | Performs a GET request to the server on the collection.
If *owner*, *app*, and *sharing* are omitted, this method takes a
default namespace from the :class:`Service` object for this :class:`Endpoint`.
All other keyword arguments are included in the URL as query parameters.
:raises Auth... | [
"Performs",
"a",
"GET",
"request",
"to",
"the",
"server",
"on",
"the",
"collection",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L1615-L1661 |
222,137 | splunk/splunk-sdk-python | splunklib/client.py | Stanza.submit | def submit(self, stanza):
"""Adds keys to the current configuration stanza as a
dictionary of key-value pairs.
:param stanza: A dictionary of key-value pairs for the stanza.
:type stanza: ``dict``
:return: The :class:`Stanza` object.
"""
body = _encode(**stanza)
... | python | def submit(self, stanza):
"""Adds keys to the current configuration stanza as a
dictionary of key-value pairs.
:param stanza: A dictionary of key-value pairs for the stanza.
:type stanza: ``dict``
:return: The :class:`Stanza` object.
"""
body = _encode(**stanza)
... | [
"def",
"submit",
"(",
"self",
",",
"stanza",
")",
":",
"body",
"=",
"_encode",
"(",
"*",
"*",
"stanza",
")",
"self",
".",
"service",
".",
"post",
"(",
"self",
".",
"path",
",",
"body",
"=",
"body",
")",
"return",
"self"
] | Adds keys to the current configuration stanza as a
dictionary of key-value pairs.
:param stanza: A dictionary of key-value pairs for the stanza.
:type stanza: ``dict``
:return: The :class:`Stanza` object. | [
"Adds",
"keys",
"to",
"the",
"current",
"configuration",
"stanza",
"as",
"a",
"dictionary",
"of",
"key",
"-",
"value",
"pairs",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L1757-L1767 |
222,138 | splunk/splunk-sdk-python | splunklib/client.py | Indexes.delete | def delete(self, name):
""" Deletes a given index.
**Note**: This method is only supported in Splunk 5.0 and later.
:param name: The name of the index to delete.
:type name: ``string``
"""
if self.service.splunk_version >= (5,):
Collection.delete(self, name)... | python | def delete(self, name):
""" Deletes a given index.
**Note**: This method is only supported in Splunk 5.0 and later.
:param name: The name of the index to delete.
:type name: ``string``
"""
if self.service.splunk_version >= (5,):
Collection.delete(self, name)... | [
"def",
"delete",
"(",
"self",
",",
"name",
")",
":",
"if",
"self",
".",
"service",
".",
"splunk_version",
">=",
"(",
"5",
",",
")",
":",
"Collection",
".",
"delete",
"(",
"self",
",",
"name",
")",
"else",
":",
"raise",
"IllegalOperationException",
"(",... | Deletes a given index.
**Note**: This method is only supported in Splunk 5.0 and later.
:param name: The name of the index to delete.
:type name: ``string`` | [
"Deletes",
"a",
"given",
"index",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L1913-L1925 |
222,139 | splunk/splunk-sdk-python | splunklib/client.py | Index.attached_socket | def attached_socket(self, *args, **kwargs):
"""Opens a raw socket in a ``with`` block to write data to Splunk.
The arguments are identical to those for :meth:`attach`. The socket is
automatically closed at the end of the ``with`` block, even if an
exception is raised in the block.
... | python | def attached_socket(self, *args, **kwargs):
"""Opens a raw socket in a ``with`` block to write data to Splunk.
The arguments are identical to those for :meth:`attach`. The socket is
automatically closed at the end of the ``with`` block, even if an
exception is raised in the block.
... | [
"def",
"attached_socket",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"sock",
"=",
"self",
".",
"attach",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"yield",
"sock",
"finally",
":",
"sock",
".",
"shutdown",
... | Opens a raw socket in a ``with`` block to write data to Splunk.
The arguments are identical to those for :meth:`attach`. The socket is
automatically closed at the end of the ``with`` block, even if an
exception is raised in the block.
:param host: The host value for events written to t... | [
"Opens",
"a",
"raw",
"socket",
"in",
"a",
"with",
"block",
"to",
"write",
"data",
"to",
"Splunk",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L1977-L2008 |
222,140 | splunk/splunk-sdk-python | splunklib/client.py | Index.clean | def clean(self, timeout=60):
"""Deletes the contents of the index.
This method blocks until the index is empty, because it needs to restore
values at the end of the operation.
:param timeout: The time-out period for the operation, in seconds (the
default is 60).
:ty... | python | def clean(self, timeout=60):
"""Deletes the contents of the index.
This method blocks until the index is empty, because it needs to restore
values at the end of the operation.
:param timeout: The time-out period for the operation, in seconds (the
default is 60).
:ty... | [
"def",
"clean",
"(",
"self",
",",
"timeout",
"=",
"60",
")",
":",
"self",
".",
"refresh",
"(",
")",
"tds",
"=",
"self",
"[",
"'maxTotalDataSizeMB'",
"]",
"ftp",
"=",
"self",
"[",
"'frozenTimePeriodInSecs'",
"]",
"was_disabled_initially",
"=",
"self",
".",
... | Deletes the contents of the index.
This method blocks until the index is empty, because it needs to restore
values at the end of the operation.
:param timeout: The time-out period for the operation, in seconds (the
default is 60).
:type timeout: ``integer``
:return... | [
"Deletes",
"the",
"contents",
"of",
"the",
"index",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L2010-L2053 |
222,141 | splunk/splunk-sdk-python | splunklib/client.py | Index.submit | def submit(self, event, host=None, source=None, sourcetype=None):
"""Submits a single event to the index using ``HTTP POST``.
:param event: The event to submit.
:type event: ``string``
:param `host`: The host value of the event.
:type host: ``string``
:param `source`: Th... | python | def submit(self, event, host=None, source=None, sourcetype=None):
"""Submits a single event to the index using ``HTTP POST``.
:param event: The event to submit.
:type event: ``string``
:param `host`: The host value of the event.
:type host: ``string``
:param `source`: Th... | [
"def",
"submit",
"(",
"self",
",",
"event",
",",
"host",
"=",
"None",
",",
"source",
"=",
"None",
",",
"sourcetype",
"=",
"None",
")",
":",
"args",
"=",
"{",
"'index'",
":",
"self",
".",
"name",
"}",
"if",
"host",
"is",
"not",
"None",
":",
"args"... | Submits a single event to the index using ``HTTP POST``.
:param event: The event to submit.
:type event: ``string``
:param `host`: The host value of the event.
:type host: ``string``
:param `source`: The source value of the event.
:type source: ``string``
:param ... | [
"Submits",
"a",
"single",
"event",
"to",
"the",
"index",
"using",
"HTTP",
"POST",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L2063-L2087 |
222,142 | splunk/splunk-sdk-python | splunklib/client.py | Index.upload | def upload(self, filename, **kwargs):
"""Uploads a file for immediate indexing.
**Note**: The file must be locally accessible from the server.
:param filename: The name of the file to upload. The file can be a
plain, compressed, or archived file.
:type filename: ``string``
... | python | def upload(self, filename, **kwargs):
"""Uploads a file for immediate indexing.
**Note**: The file must be locally accessible from the server.
:param filename: The name of the file to upload. The file can be a
plain, compressed, or archived file.
:type filename: ``string``
... | [
"def",
"upload",
"(",
"self",
",",
"filename",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'index'",
"]",
"=",
"self",
".",
"name",
"path",
"=",
"'data/inputs/oneshot'",
"self",
".",
"service",
".",
"post",
"(",
"path",
",",
"name",
"=",
"file... | Uploads a file for immediate indexing.
**Note**: The file must be locally accessible from the server.
:param filename: The name of the file to upload. The file can be a
plain, compressed, or archived file.
:type filename: ``string``
:param kwargs: Additional arguments (opti... | [
"Uploads",
"a",
"file",
"for",
"immediate",
"indexing",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L2090-L2107 |
222,143 | splunk/splunk-sdk-python | splunklib/client.py | Input.update | def update(self, **kwargs):
"""Updates the server with any changes you've made to the current input
along with any additional arguments you specify.
:param kwargs: Additional arguments (optional). For more about the
available parameters, see `Input parameters <http://dev.splunk.com/... | python | def update(self, **kwargs):
"""Updates the server with any changes you've made to the current input
along with any additional arguments you specify.
:param kwargs: Additional arguments (optional). For more about the
available parameters, see `Input parameters <http://dev.splunk.com/... | [
"def",
"update",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"# UDP and TCP inputs require special handling due to their restrictToHost",
"# field. For all other inputs kinds, we can dispatch to the superclass method.",
"if",
"self",
".",
"kind",
"not",
"in",
"[",
"'tcp'",
... | Updates the server with any changes you've made to the current input
along with any additional arguments you specify.
:param kwargs: Additional arguments (optional). For more about the
available parameters, see `Input parameters <http://dev.splunk.com/view/SP-CAAAEE6#inputparams>`_ on Splun... | [
"Updates",
"the",
"server",
"with",
"any",
"changes",
"you",
"ve",
"made",
"to",
"the",
"current",
"input",
"along",
"with",
"any",
"additional",
"arguments",
"you",
"specify",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L2137-L2173 |
222,144 | splunk/splunk-sdk-python | splunklib/client.py | Inputs.create | def create(self, name, kind, **kwargs):
"""Creates an input of a specific kind in this collection, with any
arguments you specify.
:param `name`: The input name.
:type name: ``string``
:param `kind`: The kind of input:
- "ad": Active Directory
- "monito... | python | def create(self, name, kind, **kwargs):
"""Creates an input of a specific kind in this collection, with any
arguments you specify.
:param `name`: The input name.
:type name: ``string``
:param `kind`: The kind of input:
- "ad": Active Directory
- "monito... | [
"def",
"create",
"(",
"self",
",",
"name",
",",
"kind",
",",
"*",
"*",
"kwargs",
")",
":",
"kindpath",
"=",
"self",
".",
"kindpath",
"(",
"kind",
")",
"self",
".",
"post",
"(",
"kindpath",
",",
"name",
"=",
"name",
",",
"*",
"*",
"kwargs",
")",
... | Creates an input of a specific kind in this collection, with any
arguments you specify.
:param `name`: The input name.
:type name: ``string``
:param `kind`: The kind of input:
- "ad": Active Directory
- "monitor": Files and directories
- "registry"... | [
"Creates",
"an",
"input",
"of",
"a",
"specific",
"kind",
"in",
"this",
"collection",
"with",
"any",
"arguments",
"you",
"specify",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L2264-L2314 |
222,145 | splunk/splunk-sdk-python | splunklib/client.py | Inputs.delete | def delete(self, name, kind=None):
"""Removes an input from the collection.
:param `kind`: The kind of input:
- "ad": Active Directory
- "monitor": Files and directories
- "registry": Windows Registry
- "script": Scripts
- "splunktcp": TC... | python | def delete(self, name, kind=None):
"""Removes an input from the collection.
:param `kind`: The kind of input:
- "ad": Active Directory
- "monitor": Files and directories
- "registry": Windows Registry
- "script": Scripts
- "splunktcp": TC... | [
"def",
"delete",
"(",
"self",
",",
"name",
",",
"kind",
"=",
"None",
")",
":",
"if",
"kind",
"is",
"None",
":",
"self",
".",
"service",
".",
"delete",
"(",
"self",
"[",
"name",
"]",
".",
"path",
")",
"else",
":",
"self",
".",
"service",
".",
"d... | Removes an input from the collection.
:param `kind`: The kind of input:
- "ad": Active Directory
- "monitor": Files and directories
- "registry": Windows Registry
- "script": Scripts
- "splunktcp": TCP, processed
- "tcp": TCP, unproc... | [
"Removes",
"an",
"input",
"from",
"the",
"collection",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L2316-L2351 |
222,146 | splunk/splunk-sdk-python | splunklib/client.py | Job.cancel | def cancel(self):
"""Stops the current search and deletes the results cache.
:return: The :class:`Job`.
"""
try:
self.post("control", action="cancel")
except HTTPError as he:
if he.status == 404:
# The job has already been cancelled, so
... | python | def cancel(self):
"""Stops the current search and deletes the results cache.
:return: The :class:`Job`.
"""
try:
self.post("control", action="cancel")
except HTTPError as he:
if he.status == 404:
# The job has already been cancelled, so
... | [
"def",
"cancel",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"post",
"(",
"\"control\"",
",",
"action",
"=",
"\"cancel\"",
")",
"except",
"HTTPError",
"as",
"he",
":",
"if",
"he",
".",
"status",
"==",
"404",
":",
"# The job has already been cancelled, ... | Stops the current search and deletes the results cache.
:return: The :class:`Job`. | [
"Stops",
"the",
"current",
"search",
"and",
"deletes",
"the",
"results",
"cache",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L2634-L2648 |
222,147 | splunk/splunk-sdk-python | splunklib/client.py | Job.events | def events(self, **kwargs):
"""Returns a streaming handle to this job's events.
:param kwargs: Additional parameters (optional). For a list of valid
parameters, see `GET search/jobs/{search_id}/events
<http://docs.splunk.com/Documentation/Splunk/latest/RESTAPI/RESTsearch#GET_sea... | python | def events(self, **kwargs):
"""Returns a streaming handle to this job's events.
:param kwargs: Additional parameters (optional). For a list of valid
parameters, see `GET search/jobs/{search_id}/events
<http://docs.splunk.com/Documentation/Splunk/latest/RESTAPI/RESTsearch#GET_sea... | [
"def",
"events",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'segmentation'",
"]",
"=",
"kwargs",
".",
"get",
"(",
"'segmentation'",
",",
"'none'",
")",
"return",
"self",
".",
"get",
"(",
"\"events\"",
",",
"*",
"*",
"kwargs",
")"... | Returns a streaming handle to this job's events.
:param kwargs: Additional parameters (optional). For a list of valid
parameters, see `GET search/jobs/{search_id}/events
<http://docs.splunk.com/Documentation/Splunk/latest/RESTAPI/RESTsearch#GET_search.2Fjobs.2F.7Bsearch_id.7D.2Fevents>`... | [
"Returns",
"a",
"streaming",
"handle",
"to",
"this",
"job",
"s",
"events",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L2668-L2680 |
222,148 | splunk/splunk-sdk-python | splunklib/client.py | Job.is_done | def is_done(self):
"""Indicates whether this job finished running.
:return: ``True`` if the job is done, ``False`` if not.
:rtype: ``boolean``
"""
if not self.is_ready():
return False
done = (self._state.content['isDone'] == '1')
return done | python | def is_done(self):
"""Indicates whether this job finished running.
:return: ``True`` if the job is done, ``False`` if not.
:rtype: ``boolean``
"""
if not self.is_ready():
return False
done = (self._state.content['isDone'] == '1')
return done | [
"def",
"is_done",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"is_ready",
"(",
")",
":",
"return",
"False",
"done",
"=",
"(",
"self",
".",
"_state",
".",
"content",
"[",
"'isDone'",
"]",
"==",
"'1'",
")",
"return",
"done"
] | Indicates whether this job finished running.
:return: ``True`` if the job is done, ``False`` if not.
:rtype: ``boolean`` | [
"Indicates",
"whether",
"this",
"job",
"finished",
"running",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L2690-L2699 |
222,149 | splunk/splunk-sdk-python | splunklib/client.py | Job.is_ready | def is_ready(self):
"""Indicates whether this job is ready for querying.
:return: ``True`` if the job is ready, ``False`` if not.
:rtype: ``boolean``
"""
response = self.get()
if response.status == 204:
return False
self._state = self.read(response)
... | python | def is_ready(self):
"""Indicates whether this job is ready for querying.
:return: ``True`` if the job is ready, ``False`` if not.
:rtype: ``boolean``
"""
response = self.get()
if response.status == 204:
return False
self._state = self.read(response)
... | [
"def",
"is_ready",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"get",
"(",
")",
"if",
"response",
".",
"status",
"==",
"204",
":",
"return",
"False",
"self",
".",
"_state",
"=",
"self",
".",
"read",
"(",
"response",
")",
"ready",
"=",
"sel... | Indicates whether this job is ready for querying.
:return: ``True`` if the job is ready, ``False`` if not.
:rtype: ``boolean`` | [
"Indicates",
"whether",
"this",
"job",
"is",
"ready",
"for",
"querying",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L2701-L2713 |
222,150 | splunk/splunk-sdk-python | splunklib/client.py | Job.preview | def preview(self, **query_params):
"""Returns a streaming handle to this job's preview search results.
Unlike :class:`splunklib.results.ResultsReader`, which requires a job to
be finished to
return any results, the ``preview`` method returns any results that have
been generated ... | python | def preview(self, **query_params):
"""Returns a streaming handle to this job's preview search results.
Unlike :class:`splunklib.results.ResultsReader`, which requires a job to
be finished to
return any results, the ``preview`` method returns any results that have
been generated ... | [
"def",
"preview",
"(",
"self",
",",
"*",
"*",
"query_params",
")",
":",
"query_params",
"[",
"'segmentation'",
"]",
"=",
"query_params",
".",
"get",
"(",
"'segmentation'",
",",
"'none'",
")",
"return",
"self",
".",
"get",
"(",
"\"results_preview\"",
",",
"... | Returns a streaming handle to this job's preview search results.
Unlike :class:`splunklib.results.ResultsReader`, which requires a job to
be finished to
return any results, the ``preview`` method returns any results that have
been generated so far, whether the job is running or not. The... | [
"Returns",
"a",
"streaming",
"handle",
"to",
"this",
"job",
"s",
"preview",
"search",
"results",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L2771-L2812 |
222,151 | splunk/splunk-sdk-python | splunklib/client.py | Jobs.create | def create(self, query, **kwargs):
""" Creates a search using a search query and any additional parameters
you provide.
:param query: The search query.
:type query: ``string``
:param kwargs: Additiona parameters (optional). For a list of available
parameters, see `Se... | python | def create(self, query, **kwargs):
""" Creates a search using a search query and any additional parameters
you provide.
:param query: The search query.
:type query: ``string``
:param kwargs: Additiona parameters (optional). For a list of available
parameters, see `Se... | [
"def",
"create",
"(",
"self",
",",
"query",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"kwargs",
".",
"get",
"(",
"\"exec_mode\"",
",",
"None",
")",
"==",
"\"oneshot\"",
":",
"raise",
"TypeError",
"(",
"\"Cannot specify exec_mode=oneshot; use the oneshot method in... | Creates a search using a search query and any additional parameters
you provide.
:param query: The search query.
:type query: ``string``
:param kwargs: Additiona parameters (optional). For a list of available
parameters, see `Search job parameters
<http://dev.spl... | [
"Creates",
"a",
"search",
"using",
"a",
"search",
"query",
"and",
"any",
"additional",
"parameters",
"you",
"provide",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L2920-L2938 |
222,152 | splunk/splunk-sdk-python | splunklib/client.py | Jobs.oneshot | def oneshot(self, query, **params):
"""Run a oneshot search and returns a streaming handle to the results.
The ``InputStream`` object streams XML fragments from the server. To
parse this stream into usable Python objects,
pass the handle to :class:`splunklib.results.ResultsReader`::
... | python | def oneshot(self, query, **params):
"""Run a oneshot search and returns a streaming handle to the results.
The ``InputStream`` object streams XML fragments from the server. To
parse this stream into usable Python objects,
pass the handle to :class:`splunklib.results.ResultsReader`::
... | [
"def",
"oneshot",
"(",
"self",
",",
"query",
",",
"*",
"*",
"params",
")",
":",
"if",
"\"exec_mode\"",
"in",
"params",
":",
"raise",
"TypeError",
"(",
"\"Cannot specify an exec_mode to oneshot.\"",
")",
"params",
"[",
"'segmentation'",
"]",
"=",
"params",
".",... | Run a oneshot search and returns a streaming handle to the results.
The ``InputStream`` object streams XML fragments from the server. To
parse this stream into usable Python objects,
pass the handle to :class:`splunklib.results.ResultsReader`::
import splunklib.client as client
... | [
"Run",
"a",
"oneshot",
"search",
"and",
"returns",
"a",
"streaming",
"handle",
"to",
"the",
"results",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L2995-L3047 |
222,153 | splunk/splunk-sdk-python | splunklib/client.py | SavedSearch.dispatch | def dispatch(self, **kwargs):
"""Runs the saved search and returns the resulting search job.
:param `kwargs`: Additional dispatch arguments (optional). For details,
see the `POST saved/searches/{name}/dispatch
<http://docs.splunk.com/Documentation/Splun... | python | def dispatch(self, **kwargs):
"""Runs the saved search and returns the resulting search job.
:param `kwargs`: Additional dispatch arguments (optional). For details,
see the `POST saved/searches/{name}/dispatch
<http://docs.splunk.com/Documentation/Splun... | [
"def",
"dispatch",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"response",
"=",
"self",
".",
"post",
"(",
"\"dispatch\"",
",",
"*",
"*",
"kwargs",
")",
"sid",
"=",
"_load_sid",
"(",
"response",
")",
"return",
"Job",
"(",
"self",
".",
"service",
... | Runs the saved search and returns the resulting search job.
:param `kwargs`: Additional dispatch arguments (optional). For details,
see the `POST saved/searches/{name}/dispatch
<http://docs.splunk.com/Documentation/Splunk/latest/RESTAPI/RESTsearch#POST_saved.2F... | [
"Runs",
"the",
"saved",
"search",
"and",
"returns",
"the",
"resulting",
"search",
"job",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L3142-L3154 |
222,154 | splunk/splunk-sdk-python | splunklib/client.py | SavedSearch.history | def history(self):
"""Returns a list of search jobs corresponding to this saved search.
:return: A list of :class:`Job` objects.
"""
response = self.get("history")
entries = _load_atom_entries(response)
if entries is None: return []
jobs = []
for entry in... | python | def history(self):
"""Returns a list of search jobs corresponding to this saved search.
:return: A list of :class:`Job` objects.
"""
response = self.get("history")
entries = _load_atom_entries(response)
if entries is None: return []
jobs = []
for entry in... | [
"def",
"history",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"get",
"(",
"\"history\"",
")",
"entries",
"=",
"_load_atom_entries",
"(",
"response",
")",
"if",
"entries",
"is",
"None",
":",
"return",
"[",
"]",
"jobs",
"=",
"[",
"]",
"for",
"... | Returns a list of search jobs corresponding to this saved search.
:return: A list of :class:`Job` objects. | [
"Returns",
"a",
"list",
"of",
"search",
"jobs",
"corresponding",
"to",
"this",
"saved",
"search",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L3177-L3189 |
222,155 | splunk/splunk-sdk-python | splunklib/client.py | SavedSearch.update | def update(self, search=None, **kwargs):
"""Updates the server with any changes you've made to the current saved
search along with any additional arguments you specify.
:param `search`: The search query (optional).
:type search: ``string``
:param `kwargs`: Additional arguments (... | python | def update(self, search=None, **kwargs):
"""Updates the server with any changes you've made to the current saved
search along with any additional arguments you specify.
:param `search`: The search query (optional).
:type search: ``string``
:param `kwargs`: Additional arguments (... | [
"def",
"update",
"(",
"self",
",",
"search",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# Updates to a saved search *require* that the search string be",
"# passed, so we pass the current search string if a value wasn't",
"# provided by the caller.",
"if",
"search",
"is",... | Updates the server with any changes you've made to the current saved
search along with any additional arguments you specify.
:param `search`: The search query (optional).
:type search: ``string``
:param `kwargs`: Additional arguments (optional). For a list of available
param... | [
"Updates",
"the",
"server",
"with",
"any",
"changes",
"you",
"ve",
"made",
"to",
"the",
"current",
"saved",
"search",
"along",
"with",
"any",
"additional",
"arguments",
"you",
"specify",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L3191-L3210 |
222,156 | splunk/splunk-sdk-python | splunklib/client.py | SavedSearch.scheduled_times | def scheduled_times(self, earliest_time='now', latest_time='+1h'):
"""Returns the times when this search is scheduled to run.
By default this method returns the times in the next hour. For different
time ranges, set *earliest_time* and *latest_time*. For example,
for all times in the la... | python | def scheduled_times(self, earliest_time='now', latest_time='+1h'):
"""Returns the times when this search is scheduled to run.
By default this method returns the times in the next hour. For different
time ranges, set *earliest_time* and *latest_time*. For example,
for all times in the la... | [
"def",
"scheduled_times",
"(",
"self",
",",
"earliest_time",
"=",
"'now'",
",",
"latest_time",
"=",
"'+1h'",
")",
":",
"response",
"=",
"self",
".",
"get",
"(",
"\"scheduled_times\"",
",",
"earliest_time",
"=",
"earliest_time",
",",
"latest_time",
"=",
"latest... | Returns the times when this search is scheduled to run.
By default this method returns the times in the next hour. For different
time ranges, set *earliest_time* and *latest_time*. For example,
for all times in the last day use "earliest_time=-1d" and
"latest_time=now".
:param ... | [
"Returns",
"the",
"times",
"when",
"this",
"search",
"is",
"scheduled",
"to",
"run",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L3212-L3234 |
222,157 | splunk/splunk-sdk-python | splunklib/client.py | SavedSearches.create | def create(self, name, search, **kwargs):
""" Creates a saved search.
:param name: The name for the saved search.
:type name: ``string``
:param search: The search query.
:type search: ``string``
:param kwargs: Additional arguments (optional). For a list of available
... | python | def create(self, name, search, **kwargs):
""" Creates a saved search.
:param name: The name for the saved search.
:type name: ``string``
:param search: The search query.
:type search: ``string``
:param kwargs: Additional arguments (optional). For a list of available
... | [
"def",
"create",
"(",
"self",
",",
"name",
",",
"search",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"Collection",
".",
"create",
"(",
"self",
",",
"name",
",",
"search",
"=",
"search",
",",
"*",
"*",
"kwargs",
")"
] | Creates a saved search.
:param name: The name for the saved search.
:type name: ``string``
:param search: The search query.
:type search: ``string``
:param kwargs: Additional arguments (optional). For a list of available
parameters, see `Saved search parameters
... | [
"Creates",
"a",
"saved",
"search",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L3278-L3292 |
222,158 | splunk/splunk-sdk-python | splunklib/client.py | User.role_entities | def role_entities(self):
"""Returns a list of roles assigned to this user.
:return: The list of roles.
:rtype: ``list``
"""
return [self.service.roles[name] for name in self.content.roles] | python | def role_entities(self):
"""Returns a list of roles assigned to this user.
:return: The list of roles.
:rtype: ``list``
"""
return [self.service.roles[name] for name in self.content.roles] | [
"def",
"role_entities",
"(",
"self",
")",
":",
"return",
"[",
"self",
".",
"service",
".",
"roles",
"[",
"name",
"]",
"for",
"name",
"in",
"self",
".",
"content",
".",
"roles",
"]"
] | Returns a list of roles assigned to this user.
:return: The list of roles.
:rtype: ``list`` | [
"Returns",
"a",
"list",
"of",
"roles",
"assigned",
"to",
"this",
"user",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L3320-L3326 |
222,159 | splunk/splunk-sdk-python | splunklib/client.py | Role.grant | def grant(self, *capabilities_to_grant):
"""Grants additional capabilities to this role.
:param capabilities_to_grant: Zero or more capabilities to grant this
role. For a list of capabilities, see
`Capabilities <http://dev.splunk.com/view/SP-CAAAEJ6#capabilities>`_
o... | python | def grant(self, *capabilities_to_grant):
"""Grants additional capabilities to this role.
:param capabilities_to_grant: Zero or more capabilities to grant this
role. For a list of capabilities, see
`Capabilities <http://dev.splunk.com/view/SP-CAAAEJ6#capabilities>`_
o... | [
"def",
"grant",
"(",
"self",
",",
"*",
"capabilities_to_grant",
")",
":",
"possible_capabilities",
"=",
"self",
".",
"service",
".",
"capabilities",
"for",
"capability",
"in",
"capabilities_to_grant",
":",
"if",
"capability",
"not",
"in",
"possible_capabilities",
... | Grants additional capabilities to this role.
:param capabilities_to_grant: Zero or more capabilities to grant this
role. For a list of capabilities, see
`Capabilities <http://dev.splunk.com/view/SP-CAAAEJ6#capabilities>`_
on Splunk Developer Portal.
:type capabilitie... | [
"Grants",
"additional",
"capabilities",
"to",
"this",
"role",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L3404-L3426 |
222,160 | splunk/splunk-sdk-python | splunklib/client.py | Role.revoke | def revoke(self, *capabilities_to_revoke):
"""Revokes zero or more capabilities from this role.
:param capabilities_to_revoke: Zero or more capabilities to grant this
role. For a list of capabilities, see
`Capabilities <http://dev.splunk.com/view/SP-CAAAEJ6#capabilities>`_
... | python | def revoke(self, *capabilities_to_revoke):
"""Revokes zero or more capabilities from this role.
:param capabilities_to_revoke: Zero or more capabilities to grant this
role. For a list of capabilities, see
`Capabilities <http://dev.splunk.com/view/SP-CAAAEJ6#capabilities>`_
... | [
"def",
"revoke",
"(",
"self",
",",
"*",
"capabilities_to_revoke",
")",
":",
"possible_capabilities",
"=",
"self",
".",
"service",
".",
"capabilities",
"for",
"capability",
"in",
"capabilities_to_revoke",
":",
"if",
"capability",
"not",
"in",
"possible_capabilities",... | Revokes zero or more capabilities from this role.
:param capabilities_to_revoke: Zero or more capabilities to grant this
role. For a list of capabilities, see
`Capabilities <http://dev.splunk.com/view/SP-CAAAEJ6#capabilities>`_
on Splunk Developer Portal.
:type capab... | [
"Revokes",
"zero",
"or",
"more",
"capabilities",
"from",
"this",
"role",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L3428-L3457 |
222,161 | splunk/splunk-sdk-python | splunklib/client.py | Roles.create | def create(self, name, **params):
"""Creates a new role.
This function makes two roundtrips to the server, plus at most
two more if
the ``autologin`` field of :func:`connect` is set to ``True``.
:param name: Name for the role.
:type name: ``string``
:param param... | python | def create(self, name, **params):
"""Creates a new role.
This function makes two roundtrips to the server, plus at most
two more if
the ``autologin`` field of :func:`connect` is set to ``True``.
:param name: Name for the role.
:type name: ``string``
:param param... | [
"def",
"create",
"(",
"self",
",",
"name",
",",
"*",
"*",
"params",
")",
":",
"if",
"not",
"isinstance",
"(",
"name",
",",
"six",
".",
"string_types",
")",
":",
"raise",
"ValueError",
"(",
"\"Invalid role name: %s\"",
"%",
"str",
"(",
"name",
")",
")",... | Creates a new role.
This function makes two roundtrips to the server, plus at most
two more if
the ``autologin`` field of :func:`connect` is set to ``True``.
:param name: Name for the role.
:type name: ``string``
:param params: Additional arguments (optional). For a lis... | [
"Creates",
"a",
"new",
"role",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L3472-L3510 |
222,162 | splunk/splunk-sdk-python | splunklib/client.py | KVStoreCollections.create | def create(self, name, indexes = {}, fields = {}, **kwargs):
"""Creates a KV Store Collection.
:param name: name of collection to create
:type name: ``string``
:param indexes: dictionary of index definitions
:type indexes: ``dict``
:param fields: dictionary of field defi... | python | def create(self, name, indexes = {}, fields = {}, **kwargs):
"""Creates a KV Store Collection.
:param name: name of collection to create
:type name: ``string``
:param indexes: dictionary of index definitions
:type indexes: ``dict``
:param fields: dictionary of field defi... | [
"def",
"create",
"(",
"self",
",",
"name",
",",
"indexes",
"=",
"{",
"}",
",",
"fields",
"=",
"{",
"}",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"k",
",",
"v",
"in",
"six",
".",
"iteritems",
"(",
"indexes",
")",
":",
"if",
"isinstance",
"(",
... | Creates a KV Store Collection.
:param name: name of collection to create
:type name: ``string``
:param indexes: dictionary of index definitions
:type indexes: ``dict``
:param fields: dictionary of field definitions
:type fields: ``dict``
:param kwargs: a dictiona... | [
"Creates",
"a",
"KV",
"Store",
"Collection",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L3545-L3565 |
222,163 | splunk/splunk-sdk-python | splunklib/client.py | KVStoreCollection.update_index | def update_index(self, name, value):
"""Changes the definition of a KV Store index.
:param name: name of index to change
:type name: ``string``
:param value: new index definition
:type value: ``dict`` or ``string``
:return: Result of POST request
"""
kwa... | python | def update_index(self, name, value):
"""Changes the definition of a KV Store index.
:param name: name of index to change
:type name: ``string``
:param value: new index definition
:type value: ``dict`` or ``string``
:return: Result of POST request
"""
kwa... | [
"def",
"update_index",
"(",
"self",
",",
"name",
",",
"value",
")",
":",
"kwargs",
"=",
"{",
"}",
"kwargs",
"[",
"'index.'",
"+",
"name",
"]",
"=",
"value",
"if",
"isinstance",
"(",
"value",
",",
"basestring",
")",
"else",
"json",
".",
"dumps",
"(",
... | Changes the definition of a KV Store index.
:param name: name of index to change
:type name: ``string``
:param value: new index definition
:type value: ``dict`` or ``string``
:return: Result of POST request | [
"Changes",
"the",
"definition",
"of",
"a",
"KV",
"Store",
"index",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L3576-L3588 |
222,164 | splunk/splunk-sdk-python | splunklib/client.py | KVStoreCollection.update_field | def update_field(self, name, value):
"""Changes the definition of a KV Store field.
:param name: name of field to change
:type name: ``string``
:param value: new field definition
:type value: ``string``
:return: Result of POST request
"""
kwargs = {}
... | python | def update_field(self, name, value):
"""Changes the definition of a KV Store field.
:param name: name of field to change
:type name: ``string``
:param value: new field definition
:type value: ``string``
:return: Result of POST request
"""
kwargs = {}
... | [
"def",
"update_field",
"(",
"self",
",",
"name",
",",
"value",
")",
":",
"kwargs",
"=",
"{",
"}",
"kwargs",
"[",
"'field.'",
"+",
"name",
"]",
"=",
"value",
"return",
"self",
".",
"post",
"(",
"*",
"*",
"kwargs",
")"
] | Changes the definition of a KV Store field.
:param name: name of field to change
:type name: ``string``
:param value: new field definition
:type value: ``string``
:return: Result of POST request | [
"Changes",
"the",
"definition",
"of",
"a",
"KV",
"Store",
"field",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L3590-L3602 |
222,165 | splunk/splunk-sdk-python | splunklib/client.py | KVStoreCollectionData.query | def query(self, **query):
"""
Gets the results of query, with optional parameters sort, limit, skip, and fields.
:param query: Optional parameters. Valid options are sort, limit, skip, and fields
:type query: ``dict``
:return: Array of documents retrieved by query.
:rty... | python | def query(self, **query):
"""
Gets the results of query, with optional parameters sort, limit, skip, and fields.
:param query: Optional parameters. Valid options are sort, limit, skip, and fields
:type query: ``dict``
:return: Array of documents retrieved by query.
:rty... | [
"def",
"query",
"(",
"self",
",",
"*",
"*",
"query",
")",
":",
"return",
"json",
".",
"loads",
"(",
"self",
".",
"_get",
"(",
"''",
",",
"*",
"*",
"query",
")",
".",
"body",
".",
"read",
"(",
")",
".",
"decode",
"(",
"'utf-8'",
")",
")"
] | Gets the results of query, with optional parameters sort, limit, skip, and fields.
:param query: Optional parameters. Valid options are sort, limit, skip, and fields
:type query: ``dict``
:return: Array of documents retrieved by query.
:rtype: ``array`` | [
"Gets",
"the",
"results",
"of",
"query",
"with",
"optional",
"parameters",
"sort",
"limit",
"skip",
"and",
"fields",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L3626-L3636 |
222,166 | splunk/splunk-sdk-python | splunklib/client.py | KVStoreCollectionData.query_by_id | def query_by_id(self, id):
"""
Returns object with _id = id.
:param id: Value for ID. If not a string will be coerced to string.
:type id: ``string``
:return: Document with id
:rtype: ``dict``
"""
return json.loads(self._get(UrlEncoded(str(id))).body.rea... | python | def query_by_id(self, id):
"""
Returns object with _id = id.
:param id: Value for ID. If not a string will be coerced to string.
:type id: ``string``
:return: Document with id
:rtype: ``dict``
"""
return json.loads(self._get(UrlEncoded(str(id))).body.rea... | [
"def",
"query_by_id",
"(",
"self",
",",
"id",
")",
":",
"return",
"json",
".",
"loads",
"(",
"self",
".",
"_get",
"(",
"UrlEncoded",
"(",
"str",
"(",
"id",
")",
")",
")",
".",
"body",
".",
"read",
"(",
")",
".",
"decode",
"(",
"'utf-8'",
")",
"... | Returns object with _id = id.
:param id: Value for ID. If not a string will be coerced to string.
:type id: ``string``
:return: Document with id
:rtype: ``dict`` | [
"Returns",
"object",
"with",
"_id",
"=",
"id",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L3638-L3648 |
222,167 | splunk/splunk-sdk-python | splunklib/client.py | KVStoreCollectionData.insert | def insert(self, data):
"""
Inserts item into this collection. An _id field will be generated if not assigned in the data.
:param data: Document to insert
:type data: ``string``
:return: _id of inserted object
:rtype: ``dict``
"""
return json.loads(self.... | python | def insert(self, data):
"""
Inserts item into this collection. An _id field will be generated if not assigned in the data.
:param data: Document to insert
:type data: ``string``
:return: _id of inserted object
:rtype: ``dict``
"""
return json.loads(self.... | [
"def",
"insert",
"(",
"self",
",",
"data",
")",
":",
"return",
"json",
".",
"loads",
"(",
"self",
".",
"_post",
"(",
"''",
",",
"headers",
"=",
"KVStoreCollectionData",
".",
"JSON_HEADER",
",",
"body",
"=",
"data",
")",
".",
"body",
".",
"read",
"(",... | Inserts item into this collection. An _id field will be generated if not assigned in the data.
:param data: Document to insert
:type data: ``string``
:return: _id of inserted object
:rtype: ``dict`` | [
"Inserts",
"item",
"into",
"this",
"collection",
".",
"An",
"_id",
"field",
"will",
"be",
"generated",
"if",
"not",
"assigned",
"in",
"the",
"data",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L3650-L3660 |
222,168 | splunk/splunk-sdk-python | splunklib/client.py | KVStoreCollectionData.update | def update(self, id, data):
"""
Replaces document with _id = id with data.
:param id: _id of document to update
:type id: ``string``
:param data: the new document to insert
:type data: ``string``
:return: id of replaced document
:rtype: ``dict``
... | python | def update(self, id, data):
"""
Replaces document with _id = id with data.
:param id: _id of document to update
:type id: ``string``
:param data: the new document to insert
:type data: ``string``
:return: id of replaced document
:rtype: ``dict``
... | [
"def",
"update",
"(",
"self",
",",
"id",
",",
"data",
")",
":",
"return",
"json",
".",
"loads",
"(",
"self",
".",
"_post",
"(",
"UrlEncoded",
"(",
"str",
"(",
"id",
")",
")",
",",
"headers",
"=",
"KVStoreCollectionData",
".",
"JSON_HEADER",
",",
"bod... | Replaces document with _id = id with data.
:param id: _id of document to update
:type id: ``string``
:param data: the new document to insert
:type data: ``string``
:return: id of replaced document
:rtype: ``dict`` | [
"Replaces",
"document",
"with",
"_id",
"=",
"id",
"with",
"data",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L3684-L3696 |
222,169 | splunk/splunk-sdk-python | splunklib/client.py | KVStoreCollectionData.batch_find | def batch_find(self, *dbqueries):
"""
Returns array of results from queries dbqueries.
:param dbqueries: Array of individual queries as dictionaries
:type dbqueries: ``array`` of ``dict``
:return: Results of each query
:rtype: ``array`` of ``array``
"""
... | python | def batch_find(self, *dbqueries):
"""
Returns array of results from queries dbqueries.
:param dbqueries: Array of individual queries as dictionaries
:type dbqueries: ``array`` of ``dict``
:return: Results of each query
:rtype: ``array`` of ``array``
"""
... | [
"def",
"batch_find",
"(",
"self",
",",
"*",
"dbqueries",
")",
":",
"if",
"len",
"(",
"dbqueries",
")",
"<",
"1",
":",
"raise",
"Exception",
"(",
"'Must have at least one query.'",
")",
"data",
"=",
"json",
".",
"dumps",
"(",
"dbqueries",
")",
"return",
"... | Returns array of results from queries dbqueries.
:param dbqueries: Array of individual queries as dictionaries
:type dbqueries: ``array`` of ``dict``
:return: Results of each query
:rtype: ``array`` of ``array`` | [
"Returns",
"array",
"of",
"results",
"from",
"queries",
"dbqueries",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L3698-L3713 |
222,170 | splunk/splunk-sdk-python | splunklib/client.py | KVStoreCollectionData.batch_save | def batch_save(self, *documents):
"""
Inserts or updates every document specified in documents.
:param documents: Array of documents to save as dictionaries
:type documents: ``array`` of ``dict``
:return: Results of update operation as overall stats
:rtype: ``dict``
... | python | def batch_save(self, *documents):
"""
Inserts or updates every document specified in documents.
:param documents: Array of documents to save as dictionaries
:type documents: ``array`` of ``dict``
:return: Results of update operation as overall stats
:rtype: ``dict``
... | [
"def",
"batch_save",
"(",
"self",
",",
"*",
"documents",
")",
":",
"if",
"len",
"(",
"documents",
")",
"<",
"1",
":",
"raise",
"Exception",
"(",
"'Must have at least one document.'",
")",
"data",
"=",
"json",
".",
"dumps",
"(",
"documents",
")",
"return",
... | Inserts or updates every document specified in documents.
:param documents: Array of documents to save as dictionaries
:type documents: ``array`` of ``dict``
:return: Results of update operation as overall stats
:rtype: ``dict`` | [
"Inserts",
"or",
"updates",
"every",
"document",
"specified",
"in",
"documents",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L3715-L3730 |
222,171 | splunk/splunk-sdk-python | setup.py | DistCommand.get_python_files | def get_python_files(files):
"""Utility function to get .py files from a list"""
python_files = []
for file_name in files:
if file_name.endswith(".py"):
python_files.append(file_name)
return python_files | python | def get_python_files(files):
"""Utility function to get .py files from a list"""
python_files = []
for file_name in files:
if file_name.endswith(".py"):
python_files.append(file_name)
return python_files | [
"def",
"get_python_files",
"(",
"files",
")",
":",
"python_files",
"=",
"[",
"]",
"for",
"file_name",
"in",
"files",
":",
"if",
"file_name",
".",
"endswith",
"(",
"\".py\"",
")",
":",
"python_files",
".",
"append",
"(",
"file_name",
")",
"return",
"python_... | Utility function to get .py files from a list | [
"Utility",
"function",
"to",
"get",
".",
"py",
"files",
"from",
"a",
"list"
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/setup.py#L146-L153 |
222,172 | splunk/splunk-sdk-python | splunklib/binding.py | _parse_cookies | def _parse_cookies(cookie_str, dictionary):
"""Tries to parse any key-value pairs of cookies in a string,
then updates the the dictionary with any key-value pairs found.
**Example**::
dictionary = {}
_parse_cookies('my=value', dictionary)
# Now the following is True
dictiona... | python | def _parse_cookies(cookie_str, dictionary):
"""Tries to parse any key-value pairs of cookies in a string,
then updates the the dictionary with any key-value pairs found.
**Example**::
dictionary = {}
_parse_cookies('my=value', dictionary)
# Now the following is True
dictiona... | [
"def",
"_parse_cookies",
"(",
"cookie_str",
",",
"dictionary",
")",
":",
"parsed_cookie",
"=",
"six",
".",
"moves",
".",
"http_cookies",
".",
"SimpleCookie",
"(",
"cookie_str",
")",
"for",
"cookie",
"in",
"parsed_cookie",
".",
"values",
"(",
")",
":",
"dicti... | Tries to parse any key-value pairs of cookies in a string,
then updates the the dictionary with any key-value pairs found.
**Example**::
dictionary = {}
_parse_cookies('my=value', dictionary)
# Now the following is True
dictionary['my'] == 'value'
:param cookie_str: A strin... | [
"Tries",
"to",
"parse",
"any",
"key",
"-",
"value",
"pairs",
"of",
"cookies",
"in",
"a",
"string",
"then",
"updates",
"the",
"the",
"dictionary",
"with",
"any",
"key",
"-",
"value",
"pairs",
"found",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/binding.py#L78-L95 |
222,173 | splunk/splunk-sdk-python | splunklib/binding.py | namespace | def namespace(sharing=None, owner=None, app=None, **kwargs):
"""This function constructs a Splunk namespace.
Every Splunk resource belongs to a namespace. The namespace is specified by
the pair of values ``owner`` and ``app`` and is governed by a ``sharing`` mode.
The possible values for ``sharing`` ar... | python | def namespace(sharing=None, owner=None, app=None, **kwargs):
"""This function constructs a Splunk namespace.
Every Splunk resource belongs to a namespace. The namespace is specified by
the pair of values ``owner`` and ``app`` and is governed by a ``sharing`` mode.
The possible values for ``sharing`` ar... | [
"def",
"namespace",
"(",
"sharing",
"=",
"None",
",",
"owner",
"=",
"None",
",",
"app",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"sharing",
"in",
"[",
"\"system\"",
"]",
":",
"return",
"record",
"(",
"{",
"'sharing'",
":",
"sharing",
"... | This function constructs a Splunk namespace.
Every Splunk resource belongs to a namespace. The namespace is specified by
the pair of values ``owner`` and ``app`` and is governed by a ``sharing`` mode.
The possible values for ``sharing`` are: "user", "app", "global" and "system",
which map to the follow... | [
"This",
"function",
"constructs",
"a",
"Splunk",
"namespace",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/binding.py#L355-L412 |
222,174 | splunk/splunk-sdk-python | splunklib/binding.py | Context.request | def request(self, path_segment, method="GET", headers=None, body="",
owner=None, app=None, sharing=None):
"""Issues an arbitrary HTTP request to the REST path segment.
This method is named to match ``httplib.request``. This function
makes a single round trip to the server.
... | python | def request(self, path_segment, method="GET", headers=None, body="",
owner=None, app=None, sharing=None):
"""Issues an arbitrary HTTP request to the REST path segment.
This method is named to match ``httplib.request``. This function
makes a single round trip to the server.
... | [
"def",
"request",
"(",
"self",
",",
"path_segment",
",",
"method",
"=",
"\"GET\"",
",",
"headers",
"=",
"None",
",",
"body",
"=",
"\"\"",
",",
"owner",
"=",
"None",
",",
"app",
"=",
"None",
",",
"sharing",
"=",
"None",
")",
":",
"if",
"headers",
"i... | Issues an arbitrary HTTP request to the REST path segment.
This method is named to match ``httplib.request``. This function
makes a single round trip to the server.
If *owner*, *app*, and *sharing* are omitted, this method uses the
default :class:`Context` namespace. All other keyword ... | [
"Issues",
"an",
"arbitrary",
"HTTP",
"request",
"to",
"the",
"REST",
"path",
"segment",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/binding.py#L757-L824 |
222,175 | splunk/splunk-sdk-python | splunklib/binding.py | HttpLib.delete | def delete(self, url, headers=None, **kwargs):
"""Sends a DELETE request to a URL.
:param url: The URL.
:type url: ``string``
:param headers: A list of pairs specifying the headers for the HTTP
response (for example, ``[('Content-Type': 'text/cthulhu'), ('Token': 'boris')]``... | python | def delete(self, url, headers=None, **kwargs):
"""Sends a DELETE request to a URL.
:param url: The URL.
:type url: ``string``
:param headers: A list of pairs specifying the headers for the HTTP
response (for example, ``[('Content-Type': 'text/cthulhu'), ('Token': 'boris')]``... | [
"def",
"delete",
"(",
"self",
",",
"url",
",",
"headers",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"headers",
"is",
"None",
":",
"headers",
"=",
"[",
"]",
"if",
"kwargs",
":",
"# url is already a UrlEncoded. We have to manually declare",
"# the ... | Sends a DELETE request to a URL.
:param url: The URL.
:type url: ``string``
:param headers: A list of pairs specifying the headers for the HTTP
response (for example, ``[('Content-Type': 'text/cthulhu'), ('Token': 'boris')]``).
:type headers: ``list``
:param kwargs: ... | [
"Sends",
"a",
"DELETE",
"request",
"to",
"a",
"URL",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/binding.py#L1131-L1158 |
222,176 | splunk/splunk-sdk-python | splunklib/binding.py | HttpLib.get | def get(self, url, headers=None, **kwargs):
"""Sends a GET request to a URL.
:param url: The URL.
:type url: ``string``
:param headers: A list of pairs specifying the headers for the HTTP
response (for example, ``[('Content-Type': 'text/cthulhu'), ('Token': 'boris')]``).
... | python | def get(self, url, headers=None, **kwargs):
"""Sends a GET request to a URL.
:param url: The URL.
:type url: ``string``
:param headers: A list of pairs specifying the headers for the HTTP
response (for example, ``[('Content-Type': 'text/cthulhu'), ('Token': 'boris')]``).
... | [
"def",
"get",
"(",
"self",
",",
"url",
",",
"headers",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"headers",
"is",
"None",
":",
"headers",
"=",
"[",
"]",
"if",
"kwargs",
":",
"# url is already a UrlEncoded. We have to manually declare",
"# the que... | Sends a GET request to a URL.
:param url: The URL.
:type url: ``string``
:param headers: A list of pairs specifying the headers for the HTTP
response (for example, ``[('Content-Type': 'text/cthulhu'), ('Token': 'boris')]``).
:type headers: ``list``
:param kwargs: Add... | [
"Sends",
"a",
"GET",
"request",
"to",
"a",
"URL",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/binding.py#L1160-L1183 |
222,177 | splunk/splunk-sdk-python | splunklib/binding.py | ResponseReader.peek | def peek(self, size):
"""Nondestructively retrieves a given number of characters.
The next :meth:`read` operation behaves as though this method was never
called.
:param size: The number of characters to retrieve.
:type size: ``integer``
"""
c = self.read(size)
... | python | def peek(self, size):
"""Nondestructively retrieves a given number of characters.
The next :meth:`read` operation behaves as though this method was never
called.
:param size: The number of characters to retrieve.
:type size: ``integer``
"""
c = self.read(size)
... | [
"def",
"peek",
"(",
"self",
",",
"size",
")",
":",
"c",
"=",
"self",
".",
"read",
"(",
"size",
")",
"self",
".",
"_buffer",
"=",
"self",
".",
"_buffer",
"+",
"c",
"return",
"c"
] | Nondestructively retrieves a given number of characters.
The next :meth:`read` operation behaves as though this method was never
called.
:param size: The number of characters to retrieve.
:type size: ``integer`` | [
"Nondestructively",
"retrieves",
"a",
"given",
"number",
"of",
"characters",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/binding.py#L1284-L1295 |
222,178 | splunk/splunk-sdk-python | splunklib/binding.py | ResponseReader.close | def close(self):
"""Closes this response."""
if self._connection:
self._connection.close()
self._response.close() | python | def close(self):
"""Closes this response."""
if self._connection:
self._connection.close()
self._response.close() | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"self",
".",
"_connection",
":",
"self",
".",
"_connection",
".",
"close",
"(",
")",
"self",
".",
"_response",
".",
"close",
"(",
")"
] | Closes this response. | [
"Closes",
"this",
"response",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/binding.py#L1297-L1301 |
222,179 | splunk/splunk-sdk-python | splunklib/binding.py | ResponseReader.readinto | def readinto(self, byte_array):
""" Read data into a byte array, upto the size of the byte array.
:param byte_array: A byte array/memory view to pour bytes into.
:type byte_array: ``bytearray`` or ``memoryview``
"""
max_size = len(byte_array)
data = self.read(max_size)
... | python | def readinto(self, byte_array):
""" Read data into a byte array, upto the size of the byte array.
:param byte_array: A byte array/memory view to pour bytes into.
:type byte_array: ``bytearray`` or ``memoryview``
"""
max_size = len(byte_array)
data = self.read(max_size)
... | [
"def",
"readinto",
"(",
"self",
",",
"byte_array",
")",
":",
"max_size",
"=",
"len",
"(",
"byte_array",
")",
"data",
"=",
"self",
".",
"read",
"(",
"max_size",
")",
"bytes_read",
"=",
"len",
"(",
"data",
")",
"byte_array",
"[",
":",
"bytes_read",
"]",
... | Read data into a byte array, upto the size of the byte array.
:param byte_array: A byte array/memory view to pour bytes into.
:type byte_array: ``bytearray`` or ``memoryview`` | [
"Read",
"data",
"into",
"a",
"byte",
"array",
"upto",
"the",
"size",
"of",
"the",
"byte",
"array",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/binding.py#L1322-L1333 |
222,180 | splunk/splunk-sdk-python | splunklib/modularinput/validation_definition.py | ValidationDefinition.parse | def parse(stream):
"""Creates a ``ValidationDefinition`` from a provided stream containing XML.
The XML typically will look like this:
``<items>``
`` <server_host>myHost</server_host>``
`` <server_uri>https://127.0.0.1:8089</server_uri>``
`` <session_key>12310... | python | def parse(stream):
"""Creates a ``ValidationDefinition`` from a provided stream containing XML.
The XML typically will look like this:
``<items>``
`` <server_host>myHost</server_host>``
`` <server_uri>https://127.0.0.1:8089</server_uri>``
`` <session_key>12310... | [
"def",
"parse",
"(",
"stream",
")",
":",
"definition",
"=",
"ValidationDefinition",
"(",
")",
"# parse XML from the stream, then get the root node",
"root",
"=",
"ET",
".",
"parse",
"(",
"stream",
")",
".",
"getroot",
"(",
")",
"for",
"node",
"in",
"root",
":"... | Creates a ``ValidationDefinition`` from a provided stream containing XML.
The XML typically will look like this:
``<items>``
`` <server_host>myHost</server_host>``
`` <server_uri>https://127.0.0.1:8089</server_uri>``
`` <session_key>123102983109283019283</session_key>... | [
"Creates",
"a",
"ValidationDefinition",
"from",
"a",
"provided",
"stream",
"containing",
"XML",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/modularinput/validation_definition.py#L44-L84 |
222,181 | splunk/splunk-sdk-python | examples/custom_search/bin/usercount.py | output_results | def output_results(results, mvdelim = '\n', output = sys.stdout):
"""Given a list of dictionaries, each representing
a single result, and an optional list of fields,
output those results to stdout for consumption by the
Splunk pipeline"""
# We collect all the unique field names, as well as
# c... | python | def output_results(results, mvdelim = '\n', output = sys.stdout):
"""Given a list of dictionaries, each representing
a single result, and an optional list of fields,
output those results to stdout for consumption by the
Splunk pipeline"""
# We collect all the unique field names, as well as
# c... | [
"def",
"output_results",
"(",
"results",
",",
"mvdelim",
"=",
"'\\n'",
",",
"output",
"=",
"sys",
".",
"stdout",
")",
":",
"# We collect all the unique field names, as well as ",
"# convert all multivalue keys to the right form",
"fields",
"=",
"set",
"(",
")",
"for",
... | Given a list of dictionaries, each representing
a single result, and an optional list of fields,
output those results to stdout for consumption by the
Splunk pipeline | [
"Given",
"a",
"list",
"of",
"dictionaries",
"each",
"representing",
"a",
"single",
"result",
"and",
"an",
"optional",
"list",
"of",
"fields",
"output",
"those",
"results",
"to",
"stdout",
"for",
"consumption",
"by",
"the",
"Splunk",
"pipeline"
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/examples/custom_search/bin/usercount.py#L79-L103 |
222,182 | splunk/splunk-sdk-python | examples/github_forks/github_forks.py | MyScript.validate_input | def validate_input(self, validation_definition):
"""In this example we are using external validation to verify that the Github
repository exists. If validate_input does not raise an Exception, the input
is assumed to be valid. Otherwise it prints the exception as an error message
when te... | python | def validate_input(self, validation_definition):
"""In this example we are using external validation to verify that the Github
repository exists. If validate_input does not raise an Exception, the input
is assumed to be valid. Otherwise it prints the exception as an error message
when te... | [
"def",
"validate_input",
"(",
"self",
",",
"validation_definition",
")",
":",
"# Get the values of the parameters, and construct a URL for the Github API",
"owner",
"=",
"validation_definition",
".",
"parameters",
"[",
"\"owner\"",
"]",
"repo_name",
"=",
"validation_definition"... | In this example we are using external validation to verify that the Github
repository exists. If validate_input does not raise an Exception, the input
is assumed to be valid. Otherwise it prints the exception as an error message
when telling splunkd that the configuration is invalid.
Wh... | [
"In",
"this",
"example",
"we",
"are",
"using",
"external",
"validation",
"to",
"verify",
"that",
"the",
"Github",
"repository",
"exists",
".",
"If",
"validate_input",
"does",
"not",
"raise",
"an",
"Exception",
"the",
"input",
"is",
"assumed",
"to",
"be",
"va... | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/examples/github_forks/github_forks.py#L73-L107 |
222,183 | splunk/splunk-sdk-python | splunklib/searchcommands/internals.py | InputHeader.read | def read(self, ifile):
""" Reads an input header from an input file.
The input header is read as a sequence of *<name>***:***<value>* pairs separated by a newline. The end of the
input header is signalled by an empty line or an end-of-file.
:param ifile: File-like object that supports ... | python | def read(self, ifile):
""" Reads an input header from an input file.
The input header is read as a sequence of *<name>***:***<value>* pairs separated by a newline. The end of the
input header is signalled by an empty line or an end-of-file.
:param ifile: File-like object that supports ... | [
"def",
"read",
"(",
"self",
",",
"ifile",
")",
":",
"name",
",",
"value",
"=",
"None",
",",
"None",
"for",
"line",
"in",
"ifile",
":",
"if",
"line",
"==",
"'\\n'",
":",
"break",
"item",
"=",
"line",
".",
"split",
"(",
"':'",
",",
"1",
")",
"if"... | Reads an input header from an input file.
The input header is read as a sequence of *<name>***:***<value>* pairs separated by a newline. The end of the
input header is signalled by an empty line or an end-of-file.
:param ifile: File-like object that supports iteration over lines. | [
"Reads",
"an",
"input",
"header",
"from",
"an",
"input",
"file",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/searchcommands/internals.py#L352-L376 |
222,184 | splunk/splunk-sdk-python | splunklib/modularinput/input_definition.py | InputDefinition.parse | def parse(stream):
"""Parse a stream containing XML into an ``InputDefinition``.
:param stream: stream containing XML to parse.
:return: definition: an ``InputDefinition`` object.
"""
definition = InputDefinition()
# parse XML from the stream, then get the root node
... | python | def parse(stream):
"""Parse a stream containing XML into an ``InputDefinition``.
:param stream: stream containing XML to parse.
:return: definition: an ``InputDefinition`` object.
"""
definition = InputDefinition()
# parse XML from the stream, then get the root node
... | [
"def",
"parse",
"(",
"stream",
")",
":",
"definition",
"=",
"InputDefinition",
"(",
")",
"# parse XML from the stream, then get the root node",
"root",
"=",
"ET",
".",
"parse",
"(",
"stream",
")",
".",
"getroot",
"(",
")",
"for",
"node",
"in",
"root",
":",
"... | Parse a stream containing XML into an ``InputDefinition``.
:param stream: stream containing XML to parse.
:return: definition: an ``InputDefinition`` object. | [
"Parse",
"a",
"stream",
"containing",
"XML",
"into",
"an",
"InputDefinition",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/modularinput/input_definition.py#L42-L60 |
222,185 | splunk/splunk-sdk-python | splunklib/searchcommands/environment.py | configure_logging | def configure_logging(logger_name, filename=None):
""" Configure logging and return the named logger and the location of the logging configuration file loaded.
This function expects a Splunk app directory structure::
<app-root>
bin
...
default
..... | python | def configure_logging(logger_name, filename=None):
""" Configure logging and return the named logger and the location of the logging configuration file loaded.
This function expects a Splunk app directory structure::
<app-root>
bin
...
default
..... | [
"def",
"configure_logging",
"(",
"logger_name",
",",
"filename",
"=",
"None",
")",
":",
"if",
"filename",
"is",
"None",
":",
"if",
"logger_name",
"is",
"None",
":",
"probing_paths",
"=",
"[",
"path",
".",
"join",
"(",
"'local'",
",",
"'logging.conf'",
")",... | Configure logging and return the named logger and the location of the logging configuration file loaded.
This function expects a Splunk app directory structure::
<app-root>
bin
...
default
...
local
...
This function ... | [
"Configure",
"logging",
"and",
"return",
"the",
"named",
"logger",
"and",
"the",
"location",
"of",
"the",
"logging",
"configuration",
"file",
"loaded",
"."
] | a245a4eeb93b3621730418008e31715912bcdcd8 | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/searchcommands/environment.py#L27-L111 |
222,186 | kennethreitz/legit | legit/scm.py | SCMRepo.git_exec | def git_exec(self, command, **kwargs):
"""Execute git commands"""
from .cli import verbose_echo
command.insert(0, self.git)
if kwargs.pop('no_verbose', False): # used when git output isn't helpful to user
verbose = False
else:
verbose = self.verbose
... | python | def git_exec(self, command, **kwargs):
"""Execute git commands"""
from .cli import verbose_echo
command.insert(0, self.git)
if kwargs.pop('no_verbose', False): # used when git output isn't helpful to user
verbose = False
else:
verbose = self.verbose
... | [
"def",
"git_exec",
"(",
"self",
",",
"command",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
".",
"cli",
"import",
"verbose_echo",
"command",
".",
"insert",
"(",
"0",
",",
"self",
".",
"git",
")",
"if",
"kwargs",
".",
"pop",
"(",
"'no_verbose'",
",",
... | Execute git commands | [
"Execute",
"git",
"commands"
] | 699802c5be665bd358456a940953b5c1d8672754 | https://github.com/kennethreitz/legit/blob/699802c5be665bd358456a940953b5c1d8672754/legit/scm.py#L47-L65 |
222,187 | kennethreitz/legit | legit/scm.py | SCMRepo.unstash_index | def unstash_index(self, sync=False, branch=None):
"""Returns an unstash index if one is available."""
stash_list = self.git_exec(['stash', 'list'], no_verbose=True)
if branch is None:
branch = self.get_current_branch_name()
for stash in stash_list.splitlines():
... | python | def unstash_index(self, sync=False, branch=None):
"""Returns an unstash index if one is available."""
stash_list = self.git_exec(['stash', 'list'], no_verbose=True)
if branch is None:
branch = self.get_current_branch_name()
for stash in stash_list.splitlines():
... | [
"def",
"unstash_index",
"(",
"self",
",",
"sync",
"=",
"False",
",",
"branch",
"=",
"None",
")",
":",
"stash_list",
"=",
"self",
".",
"git_exec",
"(",
"[",
"'stash'",
",",
"'list'",
"]",
",",
"no_verbose",
"=",
"True",
")",
"if",
"branch",
"is",
"Non... | Returns an unstash index if one is available. | [
"Returns",
"an",
"unstash",
"index",
"if",
"one",
"is",
"available",
"."
] | 699802c5be665bd358456a940953b5c1d8672754 | https://github.com/kennethreitz/legit/blob/699802c5be665bd358456a940953b5c1d8672754/legit/scm.py#L88-L110 |
222,188 | kennethreitz/legit | legit/scm.py | SCMRepo.unstash_it | def unstash_it(self, sync=False):
"""
Unstashes changes from current branch for branch sync.
Requires prior code setting self.stash_index.
"""
if self.stash_index is not None:
return self.git_exec(
['stash', 'pop', 'stash@{{{0}}}'.format(self.stash_ind... | python | def unstash_it(self, sync=False):
"""
Unstashes changes from current branch for branch sync.
Requires prior code setting self.stash_index.
"""
if self.stash_index is not None:
return self.git_exec(
['stash', 'pop', 'stash@{{{0}}}'.format(self.stash_ind... | [
"def",
"unstash_it",
"(",
"self",
",",
"sync",
"=",
"False",
")",
":",
"if",
"self",
".",
"stash_index",
"is",
"not",
"None",
":",
"return",
"self",
".",
"git_exec",
"(",
"[",
"'stash'",
",",
"'pop'",
",",
"'stash@{{{0}}}'",
".",
"format",
"(",
"self",... | Unstashes changes from current branch for branch sync.
Requires prior code setting self.stash_index. | [
"Unstashes",
"changes",
"from",
"current",
"branch",
"for",
"branch",
"sync",
".",
"Requires",
"prior",
"code",
"setting",
"self",
".",
"stash_index",
"."
] | 699802c5be665bd358456a940953b5c1d8672754 | https://github.com/kennethreitz/legit/blob/699802c5be665bd358456a940953b5c1d8672754/legit/scm.py#L118-L125 |
222,189 | kennethreitz/legit | legit/scm.py | SCMRepo.checkout_branch | def checkout_branch(self, branch):
"""Checks out given branch."""
_, stdout, stderr = self.git_exec(
['checkout', branch],
with_extended_output=True)
return '\n'.join([stderr, stdout]) | python | def checkout_branch(self, branch):
"""Checks out given branch."""
_, stdout, stderr = self.git_exec(
['checkout', branch],
with_extended_output=True)
return '\n'.join([stderr, stdout]) | [
"def",
"checkout_branch",
"(",
"self",
",",
"branch",
")",
":",
"_",
",",
"stdout",
",",
"stderr",
"=",
"self",
".",
"git_exec",
"(",
"[",
"'checkout'",
",",
"branch",
"]",
",",
"with_extended_output",
"=",
"True",
")",
"return",
"'\\n'",
".",
"join",
... | Checks out given branch. | [
"Checks",
"out",
"given",
"branch",
"."
] | 699802c5be665bd358456a940953b5c1d8672754 | https://github.com/kennethreitz/legit/blob/699802c5be665bd358456a940953b5c1d8672754/legit/scm.py#L194-L200 |
222,190 | kennethreitz/legit | legit/scm.py | SCMRepo.unpublish_branch | def unpublish_branch(self, branch):
"""Unpublishes given branch."""
try:
return self.git_exec(
['push', self.remote.name, ':{0}'.format(branch)])
except GitCommandError:
_, _, log = self.git_exec(
['fetch', self.remote.name, '--prune'],
... | python | def unpublish_branch(self, branch):
"""Unpublishes given branch."""
try:
return self.git_exec(
['push', self.remote.name, ':{0}'.format(branch)])
except GitCommandError:
_, _, log = self.git_exec(
['fetch', self.remote.name, '--prune'],
... | [
"def",
"unpublish_branch",
"(",
"self",
",",
"branch",
")",
":",
"try",
":",
"return",
"self",
".",
"git_exec",
"(",
"[",
"'push'",
",",
"self",
".",
"remote",
".",
"name",
",",
"':{0}'",
".",
"format",
"(",
"branch",
")",
"]",
")",
"except",
"GitCom... | Unpublishes given branch. | [
"Unpublishes",
"given",
"branch",
"."
] | 699802c5be665bd358456a940953b5c1d8672754 | https://github.com/kennethreitz/legit/blob/699802c5be665bd358456a940953b5c1d8672754/legit/scm.py#L202-L212 |
222,191 | kennethreitz/legit | legit/scm.py | SCMRepo.undo | def undo(self, hard=False):
"""Makes last commit not exist"""
if not self.fake:
return self.repo.git.reset('HEAD^', working_tree=hard)
else:
click.echo(crayons.red('Faked! >>> git reset {}{}'
.format('--hard ' if hard else '', 'HEAD^'))... | python | def undo(self, hard=False):
"""Makes last commit not exist"""
if not self.fake:
return self.repo.git.reset('HEAD^', working_tree=hard)
else:
click.echo(crayons.red('Faked! >>> git reset {}{}'
.format('--hard ' if hard else '', 'HEAD^'))... | [
"def",
"undo",
"(",
"self",
",",
"hard",
"=",
"False",
")",
":",
"if",
"not",
"self",
".",
"fake",
":",
"return",
"self",
".",
"repo",
".",
"git",
".",
"reset",
"(",
"'HEAD^'",
",",
"working_tree",
"=",
"hard",
")",
"else",
":",
"click",
".",
"ec... | Makes last commit not exist | [
"Makes",
"last",
"commit",
"not",
"exist"
] | 699802c5be665bd358456a940953b5c1d8672754 | https://github.com/kennethreitz/legit/blob/699802c5be665bd358456a940953b5c1d8672754/legit/scm.py#L220-L228 |
222,192 | kennethreitz/legit | legit/scm.py | SCMRepo.get_branches | def get_branches(self, local=True, remote_branches=True):
"""Returns a list of local and remote branches."""
if not self.repo.remotes:
remote_branches = False
branches = []
if remote_branches:
# Remote refs.
try:
for b in self.remot... | python | def get_branches(self, local=True, remote_branches=True):
"""Returns a list of local and remote branches."""
if not self.repo.remotes:
remote_branches = False
branches = []
if remote_branches:
# Remote refs.
try:
for b in self.remot... | [
"def",
"get_branches",
"(",
"self",
",",
"local",
"=",
"True",
",",
"remote_branches",
"=",
"True",
")",
":",
"if",
"not",
"self",
".",
"repo",
".",
"remotes",
":",
"remote_branches",
"=",
"False",
"branches",
"=",
"[",
"]",
"if",
"remote_branches",
":",... | Returns a list of local and remote branches. | [
"Returns",
"a",
"list",
"of",
"local",
"and",
"remote",
"branches",
"."
] | 699802c5be665bd358456a940953b5c1d8672754 | https://github.com/kennethreitz/legit/blob/699802c5be665bd358456a940953b5c1d8672754/legit/scm.py#L289-L318 |
222,193 | kennethreitz/legit | legit/scm.py | SCMRepo.display_available_branches | def display_available_branches(self):
"""Displays available branches."""
if not self.repo.remotes:
remote_branches = False
else:
remote_branches = True
branches = self.get_branches(local=True, remote_branches=remote_branches)
if not branches:
... | python | def display_available_branches(self):
"""Displays available branches."""
if not self.repo.remotes:
remote_branches = False
else:
remote_branches = True
branches = self.get_branches(local=True, remote_branches=remote_branches)
if not branches:
... | [
"def",
"display_available_branches",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"repo",
".",
"remotes",
":",
"remote_branches",
"=",
"False",
"else",
":",
"remote_branches",
"=",
"True",
"branches",
"=",
"self",
".",
"get_branches",
"(",
"local",
"=",
... | Displays available branches. | [
"Displays",
"available",
"branches",
"."
] | 699802c5be665bd358456a940953b5c1d8672754 | https://github.com/kennethreitz/legit/blob/699802c5be665bd358456a940953b5c1d8672754/legit/scm.py#L326-L356 |
222,194 | kennethreitz/legit | legit/utils.py | status_log | def status_log(func, message, *args, **kwargs):
"""Emits header message, executes a callable, and echoes the return strings."""
click.echo(message)
log = func(*args, **kwargs)
if log:
out = []
for line in log.split('\n'):
if not line.startswith('#'):
out.ap... | python | def status_log(func, message, *args, **kwargs):
"""Emits header message, executes a callable, and echoes the return strings."""
click.echo(message)
log = func(*args, **kwargs)
if log:
out = []
for line in log.split('\n'):
if not line.startswith('#'):
out.ap... | [
"def",
"status_log",
"(",
"func",
",",
"message",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"click",
".",
"echo",
"(",
"message",
")",
"log",
"=",
"func",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"if",
"log",
":",
"out",
"=",
... | Emits header message, executes a callable, and echoes the return strings. | [
"Emits",
"header",
"message",
"executes",
"a",
"callable",
"and",
"echoes",
"the",
"return",
"strings",
"."
] | 699802c5be665bd358456a940953b5c1d8672754 | https://github.com/kennethreitz/legit/blob/699802c5be665bd358456a940953b5c1d8672754/legit/utils.py#L8-L20 |
222,195 | kennethreitz/legit | legit/utils.py | verbose_echo | def verbose_echo(str, verbose=False, fake=False):
"""Selectively output ``str``, with special formatting if ``fake`` is True"""
verbose = fake or verbose
if verbose:
color = crayons.green
prefix = ''
if fake:
color = crayons.red
prefix = 'Faked!'
clic... | python | def verbose_echo(str, verbose=False, fake=False):
"""Selectively output ``str``, with special formatting if ``fake`` is True"""
verbose = fake or verbose
if verbose:
color = crayons.green
prefix = ''
if fake:
color = crayons.red
prefix = 'Faked!'
clic... | [
"def",
"verbose_echo",
"(",
"str",
",",
"verbose",
"=",
"False",
",",
"fake",
"=",
"False",
")",
":",
"verbose",
"=",
"fake",
"or",
"verbose",
"if",
"verbose",
":",
"color",
"=",
"crayons",
".",
"green",
"prefix",
"=",
"''",
"if",
"fake",
":",
"color... | Selectively output ``str``, with special formatting if ``fake`` is True | [
"Selectively",
"output",
"str",
"with",
"special",
"formatting",
"if",
"fake",
"is",
"True"
] | 699802c5be665bd358456a940953b5c1d8672754 | https://github.com/kennethreitz/legit/blob/699802c5be665bd358456a940953b5c1d8672754/legit/utils.py#L23-L33 |
222,196 | kennethreitz/legit | legit/utils.py | output_aliases | def output_aliases(aliases):
"""Display git aliases"""
for alias in aliases:
cmd = '!legit ' + alias
click.echo(columns([colored.yellow('git ' + alias), 20], [cmd, None])) | python | def output_aliases(aliases):
"""Display git aliases"""
for alias in aliases:
cmd = '!legit ' + alias
click.echo(columns([colored.yellow('git ' + alias), 20], [cmd, None])) | [
"def",
"output_aliases",
"(",
"aliases",
")",
":",
"for",
"alias",
"in",
"aliases",
":",
"cmd",
"=",
"'!legit '",
"+",
"alias",
"click",
".",
"echo",
"(",
"columns",
"(",
"[",
"colored",
".",
"yellow",
"(",
"'git '",
"+",
"alias",
")",
",",
"20",
"]"... | Display git aliases | [
"Display",
"git",
"aliases"
] | 699802c5be665bd358456a940953b5c1d8672754 | https://github.com/kennethreitz/legit/blob/699802c5be665bd358456a940953b5c1d8672754/legit/utils.py#L36-L40 |
222,197 | kennethreitz/legit | legit/cli.py | cli | def cli(ctx, verbose, fake, install, uninstall, config):
"""legit command line interface"""
# Create a repo object and remember it as as the context object. From
# this point onwards other commands can refer to it by using the
# @pass_scm decorator.
ctx.obj = SCMRepo()
ctx.obj.fake = fake
c... | python | def cli(ctx, verbose, fake, install, uninstall, config):
"""legit command line interface"""
# Create a repo object and remember it as as the context object. From
# this point onwards other commands can refer to it by using the
# @pass_scm decorator.
ctx.obj = SCMRepo()
ctx.obj.fake = fake
c... | [
"def",
"cli",
"(",
"ctx",
",",
"verbose",
",",
"fake",
",",
"install",
",",
"uninstall",
",",
"config",
")",
":",
"# Create a repo object and remember it as as the context object. From",
"# this point onwards other commands can refer to it by using the",
"# @pass_scm decorator."... | legit command line interface | [
"legit",
"command",
"line",
"interface"
] | 699802c5be665bd358456a940953b5c1d8672754 | https://github.com/kennethreitz/legit/blob/699802c5be665bd358456a940953b5c1d8672754/legit/cli.py#L82-L103 |
222,198 | kennethreitz/legit | legit/cli.py | switch | def switch(scm, to_branch, verbose, fake):
"""Switches from one branch to another, safely stashing and restoring local changes.
"""
scm.fake = fake
scm.verbose = fake or verbose
scm.repo_check()
if to_branch is None:
scm.display_available_branches()
raise click.BadArgumentUsage... | python | def switch(scm, to_branch, verbose, fake):
"""Switches from one branch to another, safely stashing and restoring local changes.
"""
scm.fake = fake
scm.verbose = fake or verbose
scm.repo_check()
if to_branch is None:
scm.display_available_branches()
raise click.BadArgumentUsage... | [
"def",
"switch",
"(",
"scm",
",",
"to_branch",
",",
"verbose",
",",
"fake",
")",
":",
"scm",
".",
"fake",
"=",
"fake",
"scm",
".",
"verbose",
"=",
"fake",
"or",
"verbose",
"scm",
".",
"repo_check",
"(",
")",
"if",
"to_branch",
"is",
"None",
":",
"s... | Switches from one branch to another, safely stashing and restoring local changes. | [
"Switches",
"from",
"one",
"branch",
"to",
"another",
"safely",
"stashing",
"and",
"restoring",
"local",
"changes",
"."
] | 699802c5be665bd358456a940953b5c1d8672754 | https://github.com/kennethreitz/legit/blob/699802c5be665bd358456a940953b5c1d8672754/legit/cli.py#L111-L126 |
222,199 | kennethreitz/legit | legit/cli.py | sync | def sync(ctx, scm, to_branch, verbose, fake):
"""Stashes unstaged changes, Fetches remote data, Performs smart
pull+merge, Pushes local commits up, and Unstashes changes.
Defaults to current branch.
"""
scm.fake = fake
scm.verbose = fake or verbose
scm.repo_check(require_remote=True)
... | python | def sync(ctx, scm, to_branch, verbose, fake):
"""Stashes unstaged changes, Fetches remote data, Performs smart
pull+merge, Pushes local commits up, and Unstashes changes.
Defaults to current branch.
"""
scm.fake = fake
scm.verbose = fake or verbose
scm.repo_check(require_remote=True)
... | [
"def",
"sync",
"(",
"ctx",
",",
"scm",
",",
"to_branch",
",",
"verbose",
",",
"fake",
")",
":",
"scm",
".",
"fake",
"=",
"fake",
"scm",
".",
"verbose",
"=",
"fake",
"or",
"verbose",
"scm",
".",
"repo_check",
"(",
"require_remote",
"=",
"True",
")",
... | Stashes unstaged changes, Fetches remote data, Performs smart
pull+merge, Pushes local commits up, and Unstashes changes.
Defaults to current branch. | [
"Stashes",
"unstaged",
"changes",
"Fetches",
"remote",
"data",
"Performs",
"smart",
"pull",
"+",
"merge",
"Pushes",
"local",
"commits",
"up",
"and",
"Unstashes",
"changes",
"."
] | 699802c5be665bd358456a940953b5c1d8672754 | https://github.com/kennethreitz/legit/blob/699802c5be665bd358456a940953b5c1d8672754/legit/cli.py#L135-L173 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.