當前位置: 首頁>>代碼示例>>Python>>正文


Python client.Entity方法代碼示例

本文整理匯總了Python中splunklib.client.Entity方法的典型用法代碼示例。如果您正苦於以下問題:Python client.Entity方法的具體用法?Python client.Entity怎麽用?Python client.Entity使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在splunklib.client的用法示例。


在下文中一共展示了client.Entity方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __eq__

# 需要導入模塊: from splunklib import client [as 別名]
# 或者: from splunklib.client import Entity [as 別名]
def __eq__(self, other):
        """Raises IncomparableException.

        Since Entity objects are snapshots of times on the server, no
        simple definition of equality will suffice beyond instance
        equality, and instance equality leads to strange situations
        such as::

            import splunklib.client as client
            c = client.connect(...)
            saved_searches = c.saved_searches
            x = saved_searches['asearch']

        but then ``x != saved_searches['asearch']``.

        whether or not there was a change on the server. Rather than
        try to do something fancy, we simple declare that equality is
        undefined for Entities.

        Makes no roundtrips to the server.
        """
        raise IncomparableException(
            "Equality is undefined for objects of class %s" % \
                self.__class__.__name__) 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:26,代碼來源:client.py

示例2: create

# 需要導入模塊: from splunklib import client [as 別名]
# 或者: from splunklib.client import Entity [as 別名]
def create(self, name):
        """ Creates a configuration file named *name*.

        If there is already a configuration file with that name,
        the existing file is returned.

        :param name: The name of the configuration file.
        :type name: ``string``

        :return: The :class:`ConfigurationFile` object.
        """
        # This has to be overridden to handle the plumbing of creating
        # a ConfigurationFile (which is a Collection) instead of some
        # Entity.
        if not isinstance(name, six.string_types):
            raise ValueError("Invalid name: %s" % repr(name))
        response = self.post(__conf=name)
        if response.status == 303:
            return self[name]
        elif response.status == 201:
            return ConfigurationFile(self.service, PATH_CONF % name, item=Stanza, state={'title': name})
        else:
            raise ValueError("Unexpected status code %s returned from creating a stanza" % response.status) 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:25,代碼來源:client.py

示例3: __init__

# 需要導入模塊: from splunklib import client [as 別名]
# 或者: from splunklib.client import Entity [as 別名]
def __init__(self, service, path, kind=None, **kwargs):
        # kind can be omitted (in which case it is inferred from the path)
        # Otherwise, valid values are the paths from data/inputs ("udp",
        # "monitor", "tcp/raw"), or two special cases: "tcp" (which is "tcp/raw")
        # and "splunktcp" (which is "tcp/cooked").
        Entity.__init__(self, service, path, **kwargs)
        if kind is None:
            path_segments = path.split('/')
            i = path_segments.index('inputs') + 1
            if path_segments[i] == 'tcp':
                self.kind = path_segments[i] + '/' + path_segments[i+1]
            else:
                self.kind = path_segments[i]
        else:
            self.kind = kind

        # Handle old input kind names.
        if self.kind == 'tcp':
            self.kind = 'tcp/raw'
        if self.kind == 'splunktcp':
            self.kind = 'tcp/cooked' 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:23,代碼來源:client.py

示例4: update

# 需要導入模塊: from splunklib import client [as 別名]
# 或者: from splunklib.client import Entity [as 別名]
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 (optional). For a list of available
            parameters, see `Saved search parameters
            <http://dev.splunk.com/view/SP-CAAAEE5#savedsearchparams>`_
            on Splunk Developer Portal.
        :type kwargs: ``dict``

        :return: The :class:`SavedSearch`.
        """
        # 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 None: search = self.content.search
        Entity.update(self, search=search, **kwargs)
        return self 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:22,代碼來源:client.py

示例5: event_types

# 需要導入模塊: from splunklib import client [as 別名]
# 或者: from splunklib.client import Entity [as 別名]
def event_types(self):
        """Returns the collection of event types defined in this Splunk instance.

        :return: An :class:`Entity` containing the event types.
        """
        return Collection(self, PATH_EVENT_TYPES) 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:8,代碼來源:client.py

示例6: _run_action

# 需要導入模塊: from splunklib import client [as 別名]
# 或者: from splunklib.client import Entity [as 別名]
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 of Entry is
        what should be the return value. This is right in enough cases
        to make this method useful.
        """
        response = self.get(path_segment, **kwargs)
        data = self._load_atom_entry(response)
        rec = _parse_atom_entry(data)
        return rec.content 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:15,代碼來源:client.py

示例7: get

# 需要導入模塊: from splunklib import client [as 別名]
# 或者: from splunklib.client import Entity [as 別名]
def get(self, path_segment="", owner=None, app=None, sharing=None, **query):
        owner, app, sharing = self._proper_namespace(owner, app, sharing)
        return super(Entity, self).get(path_segment, owner=owner, app=app, sharing=sharing, **query) 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:5,代碼來源:client.py

示例8: post

# 需要導入模塊: from splunklib import client [as 別名]
# 或者: from splunklib.client import Entity [as 別名]
def post(self, path_segment="", owner=None, app=None, sharing=None, **query):
        owner, app, sharing = self._proper_namespace(owner, app, sharing)
        return super(Entity, self).post(path_segment, owner=owner, app=app, sharing=sharing, **query) 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:5,代碼來源:client.py

示例9: __contains__

# 需要導入模塊: from splunklib import client [as 別名]
# 或者: from splunklib.client import Entity [as 別名]
def __contains__(self, name):
        args = self.state.content['endpoints']['args']
        if name in args:
            return True
        else:
            return Entity.__contains__(self, name) 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:8,代碼來源:client.py

示例10: __getitem__

# 需要導入模塊: from splunklib import client [as 別名]
# 或者: from splunklib.client import Entity [as 別名]
def __getitem__(self, name):
        args = self.state.content['endpoint']['args']
        if name in args:
            return args['item']
        else:
            return Entity.__getitem__(self, name) 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:8,代碼來源:client.py


注:本文中的splunklib.client.Entity方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。