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
11 changes: 11 additions & 0 deletions alertaclient/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,17 @@ def get_alerts(self, query=None, page=1, page_size=None):
r = self.http.get('/alerts', query, page=page, page_size=page_size)
return [Alert.parse(a) for a in r['alerts']]

def get_all_alerts(self, query=None, page_size=1000):
alerts = []
page = 1
while True:
r = self.http.get('/alerts', query, page=page, page_size=page_size)
alerts.extend([Alert.parse(a) for a in r['alerts']])
if len(r['alerts']) < page_size:
break
page += 1
return alerts

def get_history(self, query=None, page=1, page_size=None):
r = self.http.get('/alerts/history', query, page=page, page_size=page_size)
return [RichHistory.parse(a) for a in r['history']]
Expand Down
2 changes: 1 addition & 1 deletion alertaclient/commands/cmd_ack.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ def cli(obj, ids, query, filters, text):
else:
query = build_query(filters)
total, _, _ = client.get_count(query)
ids = [a.id for a in client.get_alerts(query)]
ids = [a.id for a in client.get_all_alerts(query)]

action_progressbar(client, action='ack', ids=ids, label=f'Acking {total} alerts', text=text)
2 changes: 1 addition & 1 deletion alertaclient/commands/cmd_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def cli(obj, action, ids, query, filters, text):
else:
query = build_query(filters)
total, _, _ = client.get_count(query)
ids = [a.id for a in client.get_alerts(query)]
ids = [a.id for a in client.get_all_alerts(query)]

label = f'Action ({action}) {total} alerts'
action_progressbar(client, action=action, ids=ids, label=label, text=text)
2 changes: 1 addition & 1 deletion alertaclient/commands/cmd_close.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ def cli(obj, ids, query, filters, text):
else:
query = build_query(filters)
total, _, _ = client.get_count(query)
ids = [a.id for a in client.get_alerts(query)]
ids = [a.id for a in client.get_all_alerts(query)]

action_progressbar(client, action='close', ids=ids, label=f'Closing {total} alerts', text=text)
2 changes: 1 addition & 1 deletion alertaclient/commands/cmd_delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def cli(obj, ids, query, filters):
else:
query = build_query(filters)
total, _, _ = client.get_count(query)
ids = [a.id for a in client.get_alerts(query)]
ids = [a.id for a in client.get_all_alerts(query)]

with click.progressbar(ids, label=f'Deleting {total} alerts') as bar:
for id in bar:
Expand Down
2 changes: 1 addition & 1 deletion alertaclient/commands/cmd_note.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def cli(obj, alert_ids, query, filters, text, delete):
else:
query = build_query(filters)
total, _, _ = client.get_count(query)
alert_ids = [a.id for a in client.get_alerts(query)]
alert_ids = [a.id for a in client.get_all_alerts(query)]

with click.progressbar(alert_ids, label=f'Add note to {total} alerts') as bar:
for id in bar:
Expand Down
2 changes: 1 addition & 1 deletion alertaclient/commands/cmd_shelve.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def cli(obj, ids, query, filters, timeout, text):
else:
query = build_query(filters)
total, _, _ = client.get_count(query)
ids = [a.id for a in client.get_alerts(query)]
ids = [a.id for a in client.get_all_alerts(query)]

action_progressbar(client, action='shelve', ids=ids,
label=f'Shelving {total} alerts', text=text, timeout=timeout)
2 changes: 1 addition & 1 deletion alertaclient/commands/cmd_tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def cli(obj, ids, query, filters, tags):
else:
query = build_query(filters)
total, _, _ = client.get_count(query)
ids = [a.id for a in client.get_alerts(query)]
ids = [a.id for a in client.get_all_alerts(query)]

with click.progressbar(ids, label=f'Tagging {total} alerts') as bar:
for id in bar:
Expand Down
2 changes: 1 addition & 1 deletion alertaclient/commands/cmd_unack.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ def cli(obj, ids, query, filters, text):
else:
query = build_query(filters)
total, _, _ = client.get_count(query)
ids = [a.id for a in client.get_alerts(query)]
ids = [a.id for a in client.get_all_alerts(query)]

action_progressbar(client, action='unack', ids=ids, label=f'Un-acking {total} alerts', text=text)
2 changes: 1 addition & 1 deletion alertaclient/commands/cmd_unshelve.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ def cli(obj, ids, query, filters, text):
else:
query = build_query(filters)
total, _, _ = client.get_count(query)
ids = [a.id for a in client.get_alerts(query)]
ids = [a.id for a in client.get_all_alerts(query)]

action_progressbar(client, 'unshelve', ids, label=f'Un-shelving {total} alerts', text=text)
2 changes: 1 addition & 1 deletion alertaclient/commands/cmd_untag.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def cli(obj, ids, query, filters, tags):
else:
query = build_query(filters)
total, _, _ = client.get_count(query)
ids = [a.id for a in client.get_alerts(query)]
ids = [a.id for a in client.get_all_alerts(query)]

with click.progressbar(ids, label=f'Untagging {total} alerts') as bar:
for id in bar:
Expand Down
2 changes: 1 addition & 1 deletion alertaclient/commands/cmd_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def cli(obj, ids, query, filters, attributes):
else:
query = build_query(filters)
total, _, _ = client.get_count(query)
ids = [a.id for a in client.get_alerts(query)]
ids = [a.id for a in client.get_all_alerts(query)]

with click.progressbar(ids, label=f'Updating {total} alerts') as bar:
for id in bar:
Expand Down
Loading