1 ##############################################################################
2 # Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
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 ##############################################################################
14 logger = logging.getLogger(__name__)
17 class HttpClient(object):
19 def post(self, url, data):
20 data = json.dumps(data)
21 headers = {'Content-Type': 'application/json'}
23 response = requests.post(url, data=data, headers=headers)
24 result = response.json()
25 logger.debug('The result is: %s', result)
28 except Exception as e:
29 logger.debug('Failed: %s', e)
33 response = requests.get(url)
34 return response.json()