Merge pull request #16 from Delta-Sierra/master

add function get_attributes_statistics
pull/21/head
Alexandre Dulaunoy 2016-04-28 14:34:18 +02:00
commit 1e622cf584
1 changed files with 19 additions and 1 deletions

View File

@ -976,8 +976,24 @@ class PyMISP(object):
url = urljoin(self.root_url, 'attributes/text/download/%s' % type_attr) url = urljoin(self.root_url, 'attributes/text/download/%s' % type_attr)
response = session.get(url) response = session.get(url)
return response return response
# ############## Deprecated (Pure XML API should not be used) ##################
# ############## Statistics ##################
def get_attributes_statistics(self, context='type', percentage=None, force_out=None):
"""
Get statistics from the MISP instance
"""
session = self.__prepare_session(force_out)
if (context != 'category'):
context = 'type'
if(percentage!=None):
url = urljoin(self.root_url, 'attributes/attributeStatistics/{}/{}'.format(context, percentage))
else:
url = urljoin(self.root_url, 'attributes/attributeStatistics/{}'.format(context))
print(url)
return session.get(url).json()
# ############## Deprecated (Pure XML API should not be used) ##################
@deprecated @deprecated
def download_all(self): def download_all(self):
""" """
@ -1001,3 +1017,5 @@ class PyMISP(object):
template = urljoin(self.root_url, 'events/xml/download/{}/{}'.format(event_id, attach)) template = urljoin(self.root_url, 'events/xml/download/{}/{}'.format(event_id, attach))
session = self.__prepare_session('xml') session = self.__prepare_session('xml')
return session.get(template) return session.get(template)