Skip to content

Commit 0ef3cd0

Browse files
authored
Merge pull request #83 from alerta/tabular
Rename serialize to tabular to avoid confusion
2 parents c1819e6 + 9af2aa7 commit 0ef3cd0

File tree

18 files changed

+73
-73
lines changed

18 files changed

+73
-73
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5.0.1
1+
5.0.2

alertaclient/commands/cmd_blackouts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def cli(obj, purge):
1818
'duration': 'DURATION', 'status': 'STATUS', 'remaining': 'REMAINING', 'customer': 'CUSTOMER'
1919
}
2020
blackouts = client.get_blackouts()
21-
click.echo(tabulate([b.serialize(timezone) for b in blackouts], headers=headers, tablefmt=obj['output']))
21+
click.echo(tabulate([b.tabular(timezone) for b in blackouts], headers=headers, tablefmt=obj['output']))
2222

2323
expired = [b for b in blackouts if b.status == 'expired']
2424
if purge:

alertaclient/commands/cmd_customers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ def cli(obj):
1111
"""List customer lookups."""
1212
client = obj['client']
1313
headers = {'id': 'ID', 'customer': 'CUSTOMER', 'match': 'GROUP'}
14-
click.echo(tabulate([c.serialize() for c in client.get_customers()], headers=headers, tablefmt=obj['output']))
14+
click.echo(tabulate([c.tabular() for c in client.get_customers()], headers=headers, tablefmt=obj['output']))

alertaclient/commands/cmd_heartbeats.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def cli(obj, purge):
1616
'receiveTime': 'RECEIVED', 'latency': 'LATENCY', 'timeout': 'TIMEOUT', 'since': 'SINCE', 'status': 'STATUS'
1717
}
1818
heartbeats = client.get_heartbeats()
19-
click.echo(tabulate([h.serialize(timezone) for h in heartbeats], headers=headers, tablefmt=obj['output']))
19+
click.echo(tabulate([h.tabular(timezone) for h in heartbeats], headers=headers, tablefmt=obj['output']))
2020

2121
expired = [hb for hb in heartbeats if hb.status == 'expired']
2222
if purge:

alertaclient/commands/cmd_history.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ def cli(obj, ids, filters):
2323
'type': 'TYPE', 'customer': 'CUSTOMER', 'environment': 'ENVIRONMENT', 'service': 'SERVICE',
2424
'resource': 'RESOURCE', 'group': 'GROUP', 'event': 'EVENT', 'value': 'VALUE', 'text': 'TEXT'}
2525
click.echo(
26-
tabulate([a.serialize(timezone) for a in alerts], headers=headers, tablefmt=obj['output']))
26+
tabulate([a.tabular(timezone) for a in alerts], headers=headers, tablefmt=obj['output']))

alertaclient/commands/cmd_keys.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ def cli(obj):
1414
'id': 'ID', 'key': 'API KEY', 'user': 'USER', 'scopes': 'SCOPES', 'text': 'TEXT',
1515
'expireTime': 'EXPIRES', 'count': 'COUNT', 'lastUsedTime': 'LAST USED', 'customer': 'CUSTOMER'
1616
}
17-
click.echo(tabulate([k.serialize(timezone) for k in client.get_keys()], headers=headers, tablefmt=obj['output']))
17+
click.echo(tabulate([k.tabular(timezone) for k in client.get_keys()], headers=headers, tablefmt=obj['output']))

alertaclient/commands/cmd_perms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ def cli(obj):
1111
"""List permissions."""
1212
client = obj['client']
1313
headers = {'id': 'ID', 'scopes': 'SCOPES', 'match': 'ROLE'}
14-
click.echo(tabulate([p.serialize() for p in client.get_perms()], headers=headers, tablefmt=obj['output']))
14+
click.echo(tabulate([p.tabular() for p in client.get_perms()], headers=headers, tablefmt=obj['output']))

alertaclient/commands/cmd_query.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def cli(obj, ids, filters, compact):
3434
headers = {'id': 'ID', 'lastReceiveTime': 'LAST RECEIVED', 'severity': 'SEVERITY', 'duplicateCount': 'DUPL',
3535
'customer': 'CUSTOMER', 'environment': 'ENVIRONMENT', 'service': 'SERVICE', 'resource': 'RESOURCE',
3636
'group': 'GROUP', 'event': 'EVENT', 'value': 'VALUE'}
37-
click.echo(tabulate([a.serialize('summary', timezone) for a in alerts], headers=headers, tablefmt=obj['output']))
37+
click.echo(tabulate([a.tabular('summary', timezone) for a in alerts], headers=headers, tablefmt=obj['output']))
3838
else:
3939
for alert in alerts:
4040
color = COLOR_MAP.get(alert.severity, {'fg': 'white'})

alertaclient/commands/cmd_users.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ def cli(obj):
1313
timezone = obj['timezone']
1414
headers = {'id': 'ID', 'name': 'USER', 'email': 'EMAIL', 'roles': 'ROLES', 'status': 'STATUS', 'text': 'TEXT',
1515
'createTime': 'CREATED', 'updateTime': 'LAST UPDATED', 'lastLogin': 'LAST LOGIN', 'email_verified': 'VERIFIED'}
16-
click.echo(tabulate([u.serialize(timezone) for u in client.get_users()], headers=headers, tablefmt=obj['output']))
16+
click.echo(tabulate([u.tabular(timezone) for u in client.get_users()], headers=headers, tablefmt=obj['output']))

alertaclient/models/alert.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ def __init__(self, resource, event, **kwargs):
4646
self.last_receive_time = kwargs.get('last_receive_time', None)
4747
self.history = kwargs.get('history', None) or list()
4848

49+
def __repr__(self):
50+
return 'Alert(id=%r, environment=%r, resource=%r, event=%r, severity=%r, status=%r, customer=%r)' % (
51+
self.id, self.environment, self.resource, self.event, self.severity, self.status, self.customer)
52+
4953
@classmethod
5054
def parse(cls, json):
5155
if not isinstance(json.get('correlate', []), list):
@@ -91,7 +95,7 @@ def parse(cls, json):
9195
def get_id(self, short=False):
9296
return self.id[:8] if short else self.id
9397

94-
def serialize(self, fields='all', timezone='Europe/London'):
98+
def tabular(self, fields='all', timezone='Europe/London'):
9599
if fields == 'summary':
96100
return {
97101
'id': self.get_id(short=True),
@@ -147,7 +151,3 @@ def serialize(self, fields='all', timezone='Europe/London'):
147151
'lastReceiveTime': DateTime.localtime(self.last_receive_time, timezone),
148152
'history': [h.serialize(timezone) for h in self.history]
149153
}
150-
151-
def __repr__(self):
152-
return 'Alert(id=%r, environment=%r, resource=%r, event=%r, severity=%r, status=%r, customer=%r)' % (
153-
self.id, self.environment, self.resource, self.event, self.severity, self.status, self.customer)

0 commit comments

Comments
 (0)