Skip to content

Commit 7203525

Browse files
authored
fix: improve alert note command (#263)
1 parent 2576cc1 commit 7203525

2 files changed

Lines changed: 21 additions & 6 deletions

File tree

alertaclient/commands/cmd_note.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,30 @@
44

55

66
@click.command('note', short_help='Add note')
7-
@click.option('--ids', '-i', metavar='ID', multiple=True, help='List of note IDs')
87
@click.option('--alert-ids', '-i', metavar='ID', multiple=True, help='List of alert IDs (can use short 8-char id)')
98
@click.option('--query', '-q', 'query', metavar='QUERY', help='severity:"warning" AND resource:web')
109
@click.option('--filter', '-f', 'filters', metavar='FILTER', multiple=True, help='KEY=VALUE eg. serverity=warning resource=web')
1110
@click.option('--text', help='Note or message')
12-
@click.option('--delete', '-D', metavar='ID', nargs=2, help='Delete note parent ID and note ID')
11+
@click.option('--delete', '-D', metavar='ID', nargs=2, help='Delete note, using alert ID and note ID')
1312
@click.pass_obj
14-
def cli(obj, ids, alert_ids, query, filters, text, delete):
15-
"""Add or delete note to alerts."""
13+
def cli(obj, alert_ids, query, filters, text, delete):
14+
"""
15+
Add or delete note to alerts.
16+
17+
EXAMPLES
18+
19+
Add a note to an alert.
20+
21+
$ alerta note --alert-ids <alert-id> --text <note>
22+
23+
List notes for an alert.
24+
25+
$ alerta notes --alert-ids <alert-id>
26+
27+
Delete a note for an alert.
28+
29+
$ alerta note -D <alert-id> <note-id>
30+
"""
1631
client = obj['client']
1732
if delete:
1833
client.delete_alert_note(*delete)

alertaclient/models/note.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ def tabular(self, timezone=None):
4040
note = {
4141
'id': self.id,
4242
'text': self.text,
43+
'createTime': DateTime.localtime(self.create_time, timezone),
4344
'user': self.user,
4445
# 'attributes': self.attributes,
4546
'type': self.note_type,
46-
'createTime': DateTime.localtime(self.create_time, timezone),
47-
'updateTime': DateTime.localtime(self.update_time, timezone),
4847
'related': self.alert,
48+
'updateTime': DateTime.localtime(self.update_time, timezone),
4949
'customer': self.customer
5050
}
5151
return note

0 commit comments

Comments
 (0)