Skip to content

Commit c1aba42

Browse files
authored
Merge pull request #79 from alerta/release-5-rc1
Release 5 RC1
2 parents 8f80f8b + daacd2c commit c1aba42

25 files changed

Lines changed: 100 additions & 103 deletions

README.md

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Profiles can be used to easily switch between different configuration settings.
3333
| timezone | timezone | n/a | n/a | Europe/London |
3434
| SSL verify | sslverify | ``REQUESTS_CA_BUNDLE`` | n/a | verify SSL certificates |
3535
| timeout | timeout | n/a | n/a | 5s TCP connection timeout |
36-
| output | output | n/a | ``--output OUTPUT`` | simple |
36+
| output | output | n/a | ``--output-format OUTPUT`` | simple |
3737
| color | color | ``CLICOLOR`` | ``--color``, ``--no-color`` | color on |
3838
| debug | debug | ``DEBUG`` | ``--debug`` | no debug |
3939

@@ -89,38 +89,38 @@ Usage
8989
--help Show this message and exit.
9090

9191
Commands:
92-
ack acknowledge alert
93-
blackout suppress alerts
94-
blackouts list alert suppressions
95-
close close alert
96-
customer add customer lookup
97-
customers list customer lookups
98-
delete delete alert
99-
heartbeat send a heartbeat
100-
heartbeats list heartbeats
101-
help show this help
102-
history show alert history
103-
key create API key
104-
keys list API keys
105-
login login with user credentials
106-
logout clear local login credentials
107-
perm add role-permission lookup
108-
perms list role-permission lookups
109-
query search for alerts
110-
raw show alert raw data
111-
revoke revoke API key
112-
send send an alert
113-
status display status and metrics
114-
tag tag alert
115-
token display current auth token
116-
unack un-acknowledge alert
117-
untag untag alert
118-
update update alert attributes
119-
uptime display server uptime
120-
user update user
121-
users list users
122-
version display version info
123-
whoami disply current logged in user
92+
ack Acknowledge alerts
93+
blackout Suppress alerts
94+
blackouts List alert suppressions
95+
close Close alerts
96+
customer Add customer lookup
97+
customers List customer lookups
98+
delete Delete alerts
99+
heartbeat Send a heartbeat
100+
heartbeats List heartbeats
101+
help Show this help
102+
history Show alert history
103+
key Create API key
104+
keys List API keys
105+
login Login with user credentials
106+
logout Clear login credentials
107+
perm Add role-permission lookup
108+
perms List role-permission lookups
109+
query Search for alerts
110+
raw Show alert raw data
111+
revoke Revoke API key
112+
send Send an alert
113+
status Display status and metrics
114+
tag Tag alerts
115+
token Display current auth token
116+
unack Un-acknowledge alerts
117+
untag Untag alerts
118+
update Update alert attributes
119+
uptime Display server uptime
120+
user Update user
121+
users List users
122+
version Display version info
123+
whoami Display current logged in user
124124

125125
Python SDK
126126
==========

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5.0.0-beta1
1+
5.0.0rc1

alertaclient/cli.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ def get_command(self, ctx, name):
4141
@click.option('--config-file', metavar='<FILE>', help='Configuration file.')
4242
@click.option('--profile', metavar='<PROFILE>', help='Configuration profile.')
4343
@click.option('--endpoint-url', metavar='<URL>', help='API endpoint URL.')
44-
@click.option('--output-format', metavar='<FORMAT>', default='psql', help='Output format. eg. simple, grid, psql, presto, rst')
44+
@click.option('--output', 'output', metavar='<FORMAT>', help='Output format. eg. simple, grid, psql, presto, rst')
4545
@click.option('--color/--no-color', help='Color-coded output based on severity.')
4646
@click.option('--debug', is_flag=True, help='Debug mode.')
4747
@click.pass_context
48-
def cli(ctx, config_file, profile, endpoint_url, output_format, color, debug):
48+
def cli(ctx, config_file, profile, endpoint_url, output, color, debug):
4949
"""
5050
Alerta client unified command-line tool.
5151
"""
@@ -54,14 +54,16 @@ def cli(ctx, config_file, profile, endpoint_url, output_format, color, debug):
5454

5555
ctx.obj = dict()
5656
ctx.obj['timezone'] = config.options['timezone']
57+
ctx.obj['output'] = output or config.options['output']
58+
ctx.obj['color'] = color or config.options['color']
5759

5860
endpoint = endpoint_url or config.options['endpoint']
5961

6062
ctx.obj['client'] = Client(
6163
endpoint=endpoint,
6264
key=config.options['key'],
6365
token=get_token(endpoint),
64-
timeout=config.options['timeout'],
66+
timeout=float(config.options['timeout']),
6567
ssl_verify=config.options['sslverify'],
6668
debug=debug or config.options['debug']
6769
)

alertaclient/commands/cmd_blackouts.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
@click.command('blackouts', short_help='List alert suppressions')
99
@click.option('--purge', is_flag=True, help='Delete all expired blackouts')
1010
@click.pass_obj
11-
@click.pass_context
12-
def cli(ctx, obj, purge):
11+
def cli(obj, purge):
1312
"""List alert suppressions."""
1413
client = obj['client']
1514
timezone = obj['timezone']
@@ -19,7 +18,7 @@ def cli(ctx, obj, purge):
1918
'duration': 'DURATION', 'status': 'STATUS', 'remaining': 'REMAINING', 'customer': 'CUSTOMER'
2019
}
2120
blackouts = client.get_blackouts()
22-
click.echo(tabulate([b.serialize(timezone) for b in blackouts], headers=headers, tablefmt=ctx.parent.params['output_format']))
21+
click.echo(tabulate([b.serialize(timezone) for b in blackouts], headers=headers, tablefmt=obj['output']))
2322

2423
expired = [b for b in blackouts if b.status == 'expired']
2524
if purge:

alertaclient/commands/cmd_customer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
@click.command('customer', short_help='Add customer lookup')
77
@click.option('--customer', help='customer name')
8-
@click.option('--org', '--group', '--domain', '--role', 'match', help='used to lookup customer')
9-
@click.option('--delete', '-D', metavar='ID', help='delete customer')
8+
@click.option('--org', '--group', '--domain', '--role', 'match', help='Used to lookup customer')
9+
@click.option('--delete', '-D', metavar='ID', help='Delete customer lookup')
1010
@click.pass_obj
1111
def cli(obj, customer, match, delete):
1212
"""Add group/org/domain/role-to-customer or delete lookup entry."""

alertaclient/commands/cmd_customers.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77

88
@click.command('customers', short_help='List customer lookups')
99
@click.pass_obj
10-
@click.pass_context
11-
def cli(ctx, obj):
10+
def cli(obj):
1211
"""List customer lookups."""
1312
client = obj['client']
1413
headers = {'id': 'ID', 'customer': 'CUSTOMER', 'match': 'GROUP'}
15-
click.echo(tabulate([c.serialize() for c in client.get_customers()], headers=headers, tablefmt=ctx.parent.params['output_format']))
14+
click.echo(tabulate([c.serialize() for c in client.get_customers()], headers=headers, tablefmt=obj['output']))

alertaclient/commands/cmd_heartbeat.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
@click.command('heartbeat', short_help='Send a heartbeat')
1111
@click.option('--origin', default='{}/{}'.format(prog, platform.uname()[1]))
1212
@click.option('--tag', '-T', 'tags', multiple=True)
13-
@click.option('--timeout', metavar='EXPIRES', help='seconds before heartbeat is stale')
14-
@click.option('--delete', '-D', metavar='ID', help='delete hearbeat')
13+
@click.option('--timeout', metavar='EXPIRES', help='Seconds before heartbeat is stale')
14+
@click.option('--delete', '-D', metavar='ID', help='Delete hearbeat')
1515
@click.pass_obj
1616
def cli(obj, origin, tags, timeout, delete):
1717
"""Send or delete a heartbeat."""

alertaclient/commands/cmd_heartbeats.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55

66

77
@click.command('heartbeats', short_help='List heartbeats')
8-
@click.option('--purge', is_flag=True)
8+
@click.option('--purge', is_flag=True, help='Delete stale heartbeats')
99
@click.pass_obj
10-
@click.pass_context
11-
def cli(ctx, obj, purge):
10+
def cli(obj, purge):
1211
"""List heartbeats."""
1312
client = obj['client']
1413
timezone = obj['timezone']
@@ -17,7 +16,7 @@ def cli(ctx, obj, purge):
1716
'receiveTime': 'RECEIVED', 'latency': 'LATENCY', 'timeout': 'TIMEOUT', 'since': 'SINCE', 'status': 'STATUS'
1817
}
1918
heartbeats = client.get_heartbeats()
20-
click.echo(tabulate([h.serialize(timezone) for h in heartbeats], headers=headers, tablefmt=ctx.parent.params['output_format']))
19+
click.echo(tabulate([h.serialize(timezone) for h in heartbeats], headers=headers, tablefmt=obj['output']))
2120

2221
expired = [hb for hb in heartbeats if hb.status == 'expired']
2322
if purge:

alertaclient/commands/cmd_history.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
@click.option('--ids', '-i', metavar='UUID', multiple=True, help='List of alert IDs (can use short 8-char id)')
1010
@click.option('--filter', '-f', 'filters', metavar='FILTER', multiple=True, help='KEY=VALUE eg. serverity=warning resource=web')
1111
@click.pass_obj
12-
@click.pass_context
13-
def cli(ctx, obj, ids, filters):
12+
def cli(obj, ids, filters):
1413
"""Show status and severity changes for alerts."""
1514
client = obj['client']
1615
timezone = obj['timezone']
@@ -24,4 +23,4 @@ def cli(ctx, obj, ids, filters):
2423
'type': 'TYPE', 'customer': 'CUSTOMER', 'environment': 'ENVIRONMENT', 'service': 'SERVICE',
2524
'resource': 'RESOURCE', 'group': 'GROUP', 'event': 'EVENT', 'value': 'VALUE', 'text': 'TEXT'}
2625
click.echo(
27-
tabulate([a.serialize(timezone) for a in alerts], headers=headers, tablefmt=ctx.parent.params['output_format']))
26+
tabulate([a.serialize(timezone) for a in alerts], headers=headers, tablefmt=obj['output']))

alertaclient/commands/cmd_key.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66

77
@click.command('key', short_help='Create API key')
88
@click.option('--username', '-u')
9-
@click.option('--scope', 'scopes', multiple=True)
9+
@click.option('--scope', 'scopes', multiple=True, help='List of permissions eg. admin:keys, write:alerts')
1010
@click.option('--duration', type=int)
1111
@click.option('--text')
12-
@click.option('--delete', '-D', metavar='ID', help='delete API key')
12+
@click.option('--delete', '-D', metavar='ID', help='Delete API key')
1313
@click.pass_obj
1414
def cli(obj, username, scopes, duration, text, delete):
1515
"""Create or delete an API key."""

0 commit comments

Comments
 (0)