summaryrefslogtreecommitdiffstats
path: root/dashboard/dashboard/common/elastic_access.py
diff options
context:
space:
mode:
authorSerenaFeng <feng.xiaowei@zte.com.cn>2017-12-06 09:07:43 +0800
committerSerenaFeng <feng.xiaowei@zte.com.cn>2017-12-06 09:07:43 +0800
commit3f672f0e918c5c461008a7fc0e53e63b79083d34 (patch)
tree12bfc267788dff461cc6bb500ada150223f42ca2 /dashboard/dashboard/common/elastic_access.py
parent41ff15069d96ea1040cb457b39f909967dabb8bc (diff)
remove deprecated dashboard code
dashboard is not used anymore, substitute by Bitergia dashboard Change-Id: Iccfd634d0d404d23b09d88454dab38425359a2b8 Signed-off-by: SerenaFeng <feng.xiaowei@zte.com.cn>
Diffstat (limited to 'dashboard/dashboard/common/elastic_access.py')
-rw-r--r--dashboard/dashboard/common/elastic_access.py51
1 files changed, 0 insertions, 51 deletions
diff --git a/dashboard/dashboard/common/elastic_access.py b/dashboard/dashboard/common/elastic_access.py
deleted file mode 100644
index eb29ce8..0000000
--- a/dashboard/dashboard/common/elastic_access.py
+++ /dev/null
@@ -1,51 +0,0 @@
-import json
-import urlparse
-
-import urllib3
-
-http = urllib3.PoolManager()
-
-
-def _request(method, url, creds=None, body=None):
- headers = urllib3.make_headers(basic_auth=creds)
- return http.request(method, url, headers=headers, body=body)
-
-
-def _post(url, creds=None, body=None):
- return _request('POST', url, creds=creds, body=body)
-
-
-def _get(url, creds=None, body=None):
- return json.loads(_request('GET', url, creds=creds, body=body).data)
-
-
-def delete_docs(url, creds=None, body=None):
- return _request('DELETE', url, creds=creds, body=body)
-
-
-def publish_docs(url, creds=None, body=None):
- result = _post(url, creds=creds, body=(json.dumps(body)))
- return result.status, result.data
-
-
-def _get_docs_nr(url, creds=None, body=None):
- res_data = _get('{}/_search?size=0'.format(url), creds=creds, body=body)
- print(type(res_data), res_data)
- return res_data['hits']['total']
-
-
-def get_docs(url, creds=None, body=None, field='_source'):
-
- docs_nr = _get_docs_nr(url, creds=creds, body=body)
- res_data = _get('{}/_search?size={}'.format(url, docs_nr),
- creds=creds, body=body)
-
- docs = []
- for hit in res_data['hits']['hits']:
- docs.append(hit[field])
- return docs
-
-
-def publish_kibana(url, creds, type, id, body):
- url = urlparse.urljoin(url, '/.kibana/{}/{}'.format(type, id))
- publish_docs(url, creds, body)