How to use the solnlib.splunk_rest_client.SplunkRestClient function in solnlib

To help you get started, we’ve selected a few solnlib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github remg427 / misp42splunk / misp42splunk / bin / packages / aob_py2 / splunktaucclib / global_config / __init__.py View on Github external
def __init__(self, splunkd_uri, session_key, schema):
        """
        Global Config.

        :param splunkd_uri:
        :param session_key:
        :param schema:
        :type schema: GlobalConfigSchema
        """
        self._splunkd_uri = splunkd_uri
        self._session_key = session_key
        self._schema = schema

        splunkd_info = urlparse(self._splunkd_uri)
        self._client = SplunkRestClient(
            self._session_key,
            self._schema.product,
            scheme=splunkd_info.scheme,
            host=splunkd_info.hostname,
            port=splunkd_info.port,
        )
        self._configuration = Configuration(self._client, self._schema)
        self._inputs = Inputs(self._client, self._schema)
        self._configs = Configs(self._client, self._schema)
        self._settings = Settings(self._client, self._schema)
github PaloAltoNetworks / pandevice / install / Splunk_TA_paloalto / bin / splunk_ta_paloalto / solnlib / user_access.py View on Github external
:type port: ``integer``
    :param context: Other configurations for Splunk rest client.
    :type context: ``dict``
    :returns: User capabilities.
    :rtype: ``list``

    :raises UserNotExistException: If `username` does not exist.

    Usage::

       >>> from solnlib import user_access
       >>> user_capabilities = user_access.get_user_capabilities(
       >>>     session_key, 'test_user')
    '''

    _rest_client = rest_client.SplunkRestClient(
        session_key,
        '-',
        scheme=scheme,
        host=host,
        port=port,
        **context)
    url = '/services/authentication/users/{username}'.format(username=username)
    try:
        response = _rest_client.get(url, output_mode='json').body.read()
    except binding.HTTPError as e:
        if e.status != 404:
            raise

        raise UserNotExistException('User: %s does not exist.' % username)

    return json.loads(response)['entry'][0]['content']['capabilities']
github PaloAltoNetworks / pandevice / install / Splunk_TA_paloalto / bin / splunk_ta_paloalto / solnlib / user_access.py View on Github external
:param port: (optional) The port number, default is None.
    :type port: ``integer``
    :param context: Other configurations for Splunk rest client.
    :type context: ``dict``
    :returns: User roles.
    :rtype: ``list``

    :raises UserNotExistException: If `username` does not exist.

    Usage::

       >>> from solnlib import user_access
       >>> user_roles = user_access.get_user_roles(session_key, 'test_user')
    '''

    _rest_client = rest_client.SplunkRestClient(
        session_key,
        '-',
        scheme=scheme,
        host=host,
        port=port,
        **context)
    url = '/services/authentication/users/{username}'.format(username=username)
    try:
        response = _rest_client.get(url, output_mode='json').body.read()
    except binding.HTTPError as e:
        if e.status != 404:
            raise

        raise UserNotExistException('User: %s does not exist.' % username)

    return json.loads(response)['entry'][0]['content']['roles']
github PaloAltoNetworks / pandevice / install / Splunk_TA_paloalto / bin / splunk_ta_paloalto / solnlib / modular_input / checkpointer.py View on Github external
def _get_collection_data(self, collection_name, session_key, app, owner,
                             scheme, host, port, **context):

        if not context.get('pool_connections'):
            context['pool_connections'] = 5

        if not context.get('pool_maxsize'):
            context['pool_maxsize'] = 5

        kvstore = rest_client.SplunkRestClient(session_key,
                                               app,
                                               owner=owner,
                                               scheme=scheme,
                                               host=host,
                                               port=port,
                                               **context).kvstore

        collection_name = re.sub(r'[^\w]+', '_', collection_name)
        try:
            kvstore.get(name=collection_name)
        except binding.HTTPError as e:
            if e.status != 404:
                raise

            fields = {'state': 'string'}
            kvstore.create(collection_name, fields=fields)