Skip to content

Commit fd1decb

Browse files
author
Guilherme Baufaker Rêgo
committed
Change ApiOject to ApiObject
1 parent 8ded67c commit fd1decb

3 files changed

Lines changed: 28 additions & 32 deletions

File tree

hawkular/alerts.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@
1414
See the License for the specific language governing permissions and
1515
limitations under the License.
1616
"""
17-
from hawkular.client import ApiOject, HawkularBaseClient
17+
from hawkular.client import ApiObject, HawkularBaseClient
1818

19-
20-
class Trigger(ApiOject):
19+
class Trigger(ApiObject):
2120
__slots__ = [
2221
'id', 'name', 'description', 'type', 'event_type', 'event_category',
2322
'event_text', 'event_category', 'event_text', 'severity', 'context',
@@ -26,8 +25,7 @@ class Trigger(ApiOject):
2625
'enabled', 'firing_match', 'source'
2726
]
2827

29-
30-
class Condition(ApiOject):
28+
class Condition(ApiObject):
3129
__slots__ = [
3230
'trigger_id', 'trigger_mode', 'type', 'condition_set_size',
3331
'condition_set_index', 'condition_id', 'context', 'data_id',
@@ -37,14 +35,13 @@ class Condition(ApiOject):
3735
]
3836

3937

40-
class Dampening(ApiOject):
38+
class Dampening(ApiObject):
4139
__slots__ = [
4240
'trigger_id', 'trigger_mode', 'type', 'eval_true_setting',
4341
'eval_total_setting', 'eval_time_setting', 'dampening_id'
4442
]
4543

46-
47-
class FullTrigger(ApiOject):
44+
class FullTrigger(ApiObject):
4845
defaults = {
4946
'conditions': [],
5047
'dampenings': []
@@ -60,20 +57,20 @@ def __init__(self, dictionary=dict()):
6057
self.conditions = Condition.list_to_object_list(udict.get('conditions'))
6158

6259

63-
class GroupMemberInfo(ApiOject):
60+
class GroupMemberInfo(ApiObject):
6461
__slots__ = [
6562
'group_id', 'member_id', 'member_name', 'member_description', 'member_context',
6663
'member_tags', 'data_id_map'
6764
]
6865

6966

70-
class GroupConditionsInfo(ApiOject):
67+
class GroupConditionsInfo(ApiObject):
7168
__slots__ = [
7269
'conditions', 'data_id_member_map'
7370
]
7471

7572
def __init__(self, dictionary=dict()):
76-
ApiOject.__init__(self, dictionary)
73+
ApiObject.__init__(self, dictionary)
7774
udict = self.transform_dict_to_underscore(dictionary)
7875
self.conditions = Condition.list_to_object_list(udict.get('conditions'))
7976

@@ -199,7 +196,6 @@ def put_trigger_conditions(self, trigger_id, trigger_mode, conditions):
199196
response = self._put(url, data)
200197
return Condition.list_to_object_list(response)
201198

202-
203199
def get_trigger_conditions(self, trigger_id):
204200
"""
205201
Get all conditions for a specific trigger

hawkular/client.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
class ApiJsonEncoder(json.JSONEncoder):
4242
def default(self, obj):
43-
if isinstance(obj, ApiOject):
43+
if isinstance(obj, ApiObject):
4444
return obj.to_json_object()
4545
else:
4646
return json.JSONEncoder.default(self, obj)
@@ -71,12 +71,12 @@ def http_response(self, request, response):
7171
https_response = http_response
7272

7373

74-
class ApiOject:
74+
class ApiObject:
7575

7676
defaults = dict()
7777

7878
def __init__(self, dictionary=dict()):
79-
udict = ApiOject.transform_dict_to_underscore(dictionary)
79+
udict = ApiObject.transform_dict_to_underscore(dictionary)
8080
for k in self.__slots__:
8181
setattr(self, k, udict.get(k,self.defaults.get(k)))
8282

@@ -85,7 +85,7 @@ def to_json_object(self):
8585
for attribute in self.__slots__:
8686
if hasattr(self,attribute):
8787
dictionary[attribute] = getattr(self,attribute)
88-
return ApiOject.transform_dict_to_camelcase(dictionary)
88+
return ApiObject.transform_dict_to_camelcase(dictionary)
8989

9090
@staticmethod
9191
def _to_camelcase(word):
@@ -100,13 +100,13 @@ def _to_underscore(word):
100100
def transform_dict_to_camelcase(dictionary):
101101
if dictionary is None:
102102
return dict()
103-
return dict((ApiOject._to_camelcase(k), v) for k, v in dictionary.items() if v is not None)
103+
return dict((ApiObject._to_camelcase(k), v) for k, v in dictionary.items() if v is not None)
104104

105105
@staticmethod
106106
def transform_dict_to_underscore(dictionary):
107107
if dictionary is None:
108108
return dict()
109-
return dict((ApiOject._to_underscore(k), v) for k, v in dictionary.items() if v is not None)
109+
return dict((ApiObject._to_underscore(k), v) for k, v in dictionary.items() if v is not None)
110110

111111
@classmethod
112112
def list_to_object_list(cls, o):

hawkular/metrics.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
except ImportError:
2929
import json
3030

31-
from hawkular.client import ApiOject, HawkularBaseClient, HawkularMetricsError
31+
from hawkular.client import ApiObject, HawkularBaseClient, HawkularMetricsError
3232
from hawkular.client import HawkularMetricsConnectionError, HawkularMetricsStatusError
3333

3434
class MetricType:
@@ -91,25 +91,25 @@ def _get_single_id_url(self, previous_url, id):
9191
@staticmethod
9292
def _transform_tags(**tags):
9393
return ','.join("%s:%s" % (key,val) for (key,val) in tags.items())
94-
94+
9595
def _isfloat(value):
9696
try:
9797
float(value)
9898
return True
9999
except ValueError:
100100
return False
101-
101+
102102
"""
103103
External methods
104-
"""
104+
"""
105105

106106
def tenant(self, tenant_id):
107107
self.tenant_id = tenant_id
108108

109109
"""
110110
Instance methods
111111
"""
112-
112+
113113
def put(self, data):
114114
"""
115115
Send multiple different metric_ids to the server in a single batch. Metrics can be a mixture
@@ -219,7 +219,7 @@ def query_metric_definition(self, metric_type, metric_id):
219219
:param metric_id: Exact string matching metric id
220220
"""
221221
return self._get(self._get_metrics_single_url(metric_type, metric_id))
222-
222+
223223
def query_metric_definitions(self, metric_type=None, id_filter=None, **tags):
224224
"""
225225
Query available metric definitions.
@@ -280,7 +280,7 @@ def create_metric_definition(self, metric_type, metric_id, **tags):
280280
raise e
281281

282282
return True
283-
283+
284284
def query_metric_tags(self, metric_type, metric_id):
285285
"""
286286
Returns a list of tags in the metric definition.
@@ -303,7 +303,7 @@ def update_metric_tags(self, metric_type, metric_id, **tags):
303303

304304
def delete_metric_tags(self, metric_type, metric_id, **deleted_tags):
305305
"""
306-
Delete one or more tags from the metric definition.
306+
Delete one or more tags from the metric definition.
307307
308308
:param metric_type: MetricType to be matched (required)
309309
:param metric_id: Exact string matching metric id
@@ -312,12 +312,12 @@ def delete_metric_tags(self, metric_type, metric_id, **deleted_tags):
312312
tags = self._transform_tags(**deleted_tags)
313313
tags_url = self._get_metrics_tags_url(self._get_metrics_single_url(metric_type, metric_id)) + '/{0}'.format(tags)
314314

315-
self._delete(tags_url)
316-
315+
self._delete(tags_url)
316+
317317
"""
318318
Tenant related queries
319319
"""
320-
320+
321321
def query_tenants(self):
322322
"""
323323
Query available tenants and their information.
@@ -330,7 +330,7 @@ def create_tenant(self, tenant_id, retentions=None):
330330
version of Hawkular-Metrics has fixed implementation.
331331
332332
:param retentions: A set of retention settings, see Hawkular-Metrics documentation for more info
333-
"""
333+
"""
334334
item = { 'id': tenant_id }
335335
if retentions is not None:
336336
item['retentions'] = retentions
@@ -391,15 +391,15 @@ def create_metric(metric_type, metric_id, data):
391391
"""
392392
if not isinstance(data, list):
393393
data = [data]
394-
394+
395395
return { 'type': metric_type,'id': metric_id, 'data': data }
396396

397397
def create_percentiles_filter(*percentiles):
398398
"""
399399
Create percentiles filter from a list of float64 percentile values
400400
"""
401401
return ','.join("%s" % p for p in percentiles)
402-
402+
403403
def create_tags_filter(**tags):
404404
"""
405405
Transform a set of parameters to a tag query language filter

0 commit comments

Comments
 (0)