Skip to content

Commit 24cc476

Browse files
mmulqueensatterly
authored andcommitted
Added housekeeping command to CLI. (#118)
1 parent 8ab04ee commit 24cc476

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

alertaclient/api.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,13 @@ def userinfo(self):
265265
def mgmt_status(self):
266266
return self.http.get('/management/status')
267267

268+
def housekeeping(self):
269+
# This endpoint isn't currently JSON-encoded.
270+
url = self.http.endpoint + "/management/housekeeping"
271+
response = self.http.session.get(url, auth=self.http.auth, timeout=self.http.timeout)
272+
if response.status_code != 200:
273+
raise UnknownError(response.text)
274+
268275

269276
class ApiAuth(AuthBase):
270277

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import click
2+
3+
4+
@click.command('housekeeping', short_help='Expired and clears old alerts.')
5+
@click.pass_obj
6+
def cli(obj):
7+
"""Trigger the expiration and deletion of alerts."""
8+
client = obj['client']
9+
client.housekeeping()

0 commit comments

Comments
 (0)