11"""
2- Copyright 2015-2016 Red Hat, Inc. and/or its affiliates
2+ Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
33 and other contributors.
44
55 Licensed under the Apache License, Version 2.0 (the "License");
1717from __future__ import unicode_literals
1818
1919import codecs
20- import time
21- import collections
2220import base64
23- import ssl
2421
2522try :
2623 import simplejson as json
@@ -46,15 +43,15 @@ def default(self, obj):
4643 return json .JSONEncoder .default (self , obj )
4744
4845
49- class HawkularMetricsError (HTTPError ):
46+ class HawkularError (HTTPError ):
5047 pass
5148
5249
53- class HawkularMetricsConnectionError (URLError ):
50+ class HawkularConnectionError (URLError ):
5451 pass
5552
5653
57- class HawkularMetricsStatusError (ValueError ):
54+ class HawkularStatusError (ValueError ):
5855 pass
5956
6057
@@ -71,7 +68,9 @@ def http_response(self, request, response):
7168 https_response = http_response
7269
7370
74- class ApiObject :
71+ class ApiObject (object ):
72+
73+ __slots__ = []
7574
7675 defaults = dict ()
7776
@@ -114,21 +113,7 @@ def list_to_object_list(cls, o):
114113 return [cls (ob ) for ob in o ]
115114 return []
116115
117-
118- class HawkularHTTPErrorProcessor (HTTPErrorProcessor ):
119- """
120- Hawkular-Metrics uses http codes 201, 204
121- """
122-
123- def http_response (self , request , response ):
124- if response .code in [200 , 201 , 204 ]:
125- return response
126- return HTTPErrorProcessor .http_response (self , request , response )
127-
128- https_response = http_response
129-
130-
131- class HawkularBaseClient :
116+ class HawkularBaseClient (object ):
132117 """
133118 Creates new client for Hawkular-Metrics. As tenant_id, give intended tenant_id, even if it's not
134119 created yet. To change the instance's tenant_id, use tenant(tenant_id) method
@@ -284,7 +269,7 @@ def _serialize_object(o):
284269 def _handle_error (self , e ):
285270 if isinstance (e , HTTPError ):
286271 # Cast to HawkularMetricsError
287- ee = HawkularMetricsError (e .url , e .code , e .msg , e .hdrs , e .fp )
272+ ee = HawkularError (e .url , e .code , e .msg , e .hdrs , e .fp )
288273 err_json = e .read ()
289274
290275 try :
@@ -297,17 +282,17 @@ def _handle_error(self, e):
297282
298283 elif isinstance (e , URLError ):
299284 # Cast to HawkularMetricsConnectionError
300- ee = HawkularMetricsConnectionError (e )
285+ ee = HawkularConnectionError (e )
301286 ee .msg = "Error, could not send event(s) to the Hawkular Metrics: " + str (e .reason )
302287 raise ee
303288 elif isinstance (e , KeyError ):
304289 # Cast to HawkularMetricsStatusError
305- ee = HawkularMetricsStatusError (e )
290+ ee = HawkularStatusError (e )
306291 ee .msg = "Error, unable to get implementation version for metrics: " + str (e .reason )
307292 raise ee
308293 elif isinstance (e , ValueError ):
309294 # Cast to HawkularMetricsStatusError
310- ee = HawkularMetricsStatusError (e )
295+ ee = HawkularStatusError (e )
311296 ee .msg = "Error, unable to determine implementation version for metrics: " + str (e .reason )
312297 raise ee
313298 else :
0 commit comments