Create API and command to create a influxDB container
[yardstick.git] / yardstick / common / httpClient.py
1 ##############################################################################
2 # Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
3 #
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
9 import json
10 import logging
11
12 import requests
13
14 logger = logging.getLogger(__name__)
15
16
17 class HttpClient(object):
18
19     def post(self, url, data):
20         data = json.dumps(data)
21         headers = {'Content-Type': 'application/json'}
22         try:
23             response = requests.post(url, data=data, headers=headers)
24             result = response.json()
25             logger.debug('The result is: %s', result)
26         except Exception as e:
27             logger.debug('Failed: %s', e)