From 5c23d12f2c91c85a955c67493ddedc09afb5b452 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A9borah=20Servili?= Date: Thu, 28 Apr 2016 13:29:54 +0200 Subject: [PATCH] add function get_attributes_statistics --- pymisp/api.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/pymisp/api.py b/pymisp/api.py index 11e16dd..7bf9f61 100644 --- a/pymisp/api.py +++ b/pymisp/api.py @@ -976,8 +976,24 @@ class PyMISP(object): url = urljoin(self.root_url, 'attributes/text/download/%s' % type_attr) response = session.get(url) 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 def download_all(self): """ @@ -1001,3 +1017,5 @@ class PyMISP(object): template = urljoin(self.root_url, 'events/xml/download/{}/{}'.format(event_id, attach)) session = self.__prepare_session('xml') return session.get(template) + +