# Path: splunklib/binding.py
# def connect(self):
#     """Returns an open connection (socket) to the Splunk instance.
# 
#     This method is used for writing bulk events to an index or similar tasks
#     where the overhead of opening a connection multiple times would be
#     prohibitive.
# 
#     :returns: A socket.
# 
#     **Example**::
# 
#         import splunklib.binding as binding
#         c = binding.connect(...)
#         socket = c.connect()
#         socket.write("POST %s HTTP/1.1\\r\\n" % "some/path/to/post/to")
#         socket.write("Host: %s:%s\\r\\n" % (c.host, c.port))
#         socket.write("Accept-Encoding: identity\\r\\n")
#         socket.write("Authorization: %s\\r\\n" % c.token)
#         socket.write("X-Splunk-Input-Mode: Streaming\\r\\n")
#         socket.write("\\r\\n")
#     """
#     sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
#     if self.scheme == "https":
#         sock = ssl.wrap_socket(sock)
#     sock.connect((socket.gethostbyname(self.host), self.port))
#     return sock


import sys, os
from splunklib.binding import connect
    from utils import parse
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))


try:
except ImportError:
    raise Exception("Add the SDK repository to your PYTHONPATH to run the examples "
                    "(e.g., export PYTHONPATH=~/splunk-sdk-python.")


class Service:
    def __init__(self, context):
        self.context = context

    def apps(self):
        return self.context.get("apps/local")

    def indexes(self):
        return self.context.get("data/indexes")

    def info(self):
        return self.context.get("/services/server/info")

    def settings(self):
        return self.context.get("/services/server/settings")

    def search(self, query, **kwargs):
        return self.context.post("search/jobs/export", search=query, **kwargs)

def main(argv):
    opts = parse(argv, {}, ".splunkrc")

# Path: splunklib/binding.py
# def connect(self):
#     """Returns an open connection (socket) to the Splunk instance.
# 
#     This method is used for writing bulk events to an index or similar tasks
#     where the overhead of opening a connection multiple times would be
#     prohibitive.
# 
#     :returns: A socket.
# 
#     **Example**::
# 
#         import splunklib.binding as binding
#         c = binding.connect(...)
#         socket = c.connect()
#         socket.write("POST %s HTTP/1.1\\r\\n" % "some/path/to/post/to")
#         socket.write("Host: %s:%s\\r\\n" % (c.host, c.port))
#         socket.write("Accept-Encoding: identity\\r\\n")
#         socket.write("Authorization: %s\\r\\n" % c.token)
#         socket.write("X-Splunk-Input-Mode: Streaming\\r\\n")
#         socket.write("\\r\\n")
#     """
#     sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
#     if self.scheme == "https":
#         sock = ssl.wrap_socket(sock)
#     sock.connect((socket.gethostbyname(self.host), self.port))
#     return sock


# Path: examples/binding1.py
import sys, os
from splunklib.binding import connect
    from utils import parse

sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))


try:
except ImportError:
    raise Exception("Add the SDK repository to your PYTHONPATH to run the examples "
                    "(e.g., export PYTHONPATH=~/splunk-sdk-python.")


class Service:
    def __init__(self, context):
        self.context = context

    def apps(self):
        return self.context.get("apps/local")

    def indexes(self):
        return self.context.get("data/indexes")

    def info(self):
        return self.context.get("/services/server/info")

    def settings(self):
        return self.context.get("/services/server/settings")

    def search(self, query, **kwargs):
        return self.context.post("search/jobs/export", search=query, **kwargs)

def main(argv):
    opts = parse(argv, {}, ".splunkrc")

    context = connect(**opts.kwargs)