Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions alertaclient/commands/cmd_note.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,30 @@


@click.command('note', short_help='Add note')
@click.option('--ids', '-i', metavar='ID', multiple=True, help='List of note IDs')
@click.option('--alert-ids', '-i', metavar='ID', multiple=True, help='List of alert IDs (can use short 8-char id)')
@click.option('--query', '-q', 'query', metavar='QUERY', help='severity:"warning" AND resource:web')
@click.option('--filter', '-f', 'filters', metavar='FILTER', multiple=True, help='KEY=VALUE eg. serverity=warning resource=web')
@click.option('--text', help='Note or message')
@click.option('--delete', '-D', metavar='ID', nargs=2, help='Delete note parent ID and note ID')
@click.option('--delete', '-D', metavar='ID', nargs=2, help='Delete note, using alert ID and note ID')
@click.pass_obj
def cli(obj, ids, alert_ids, query, filters, text, delete):
"""Add or delete note to alerts."""
def cli(obj, alert_ids, query, filters, text, delete):
"""
Add or delete note to alerts.

EXAMPLES

Add a note to an alert.

$ alerta note --alert-ids <alert-id> --text <note>

List notes for an alert.

$ alerta notes --alert-ids <alert-id>

Delete a note for an alert.

$ alerta note -D <alert-id> <note-id>
"""
client = obj['client']
if delete:
client.delete_alert_note(*delete)
Expand Down
4 changes: 2 additions & 2 deletions alertaclient/models/note.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ def tabular(self, timezone=None):
note = {
'id': self.id,
'text': self.text,
'createTime': DateTime.localtime(self.create_time, timezone),
'user': self.user,
# 'attributes': self.attributes,
'type': self.note_type,
'createTime': DateTime.localtime(self.create_time, timezone),
'updateTime': DateTime.localtime(self.update_time, timezone),
'related': self.alert,
'updateTime': DateTime.localtime(self.update_time, timezone),
'customer': self.customer
}
return note