You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
980 B

# Copyright (C) 2005-2025 Splunk Inc. All Rights Reserved.
from urllib.parse import urlparse
import splunk.rest as rest
import SA_ITOA_app_common.splunklib.client as client
from integrations.commons.server import Server
class Splunk(Server):
def __init__(self, session_key):
self._session_key = session_key
@property
def session_key(self):
return self._session_key
@session_key.setter
def session_key(self, session_key):
self._session_key = session_key
def get_service(self, **kwargs):
splund_uri = rest.makeSplunkdUri()
splund_uri_obj = urlparse(splund_uri)
if 'host' not in kwargs:
kwargs['host'] = splund_uri_obj.netloc.split(':')[0]
if 'port' not in kwargs:
kwargs['port'] = splund_uri_obj.port
if 'scheme' not in kwargs:
kwargs['scheme'] = splund_uri_obj.scheme
kwargs['token'] = self.session_key
return client.connect(**kwargs)