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
2 changes: 1 addition & 1 deletion alertaclient/commands/cmd_alerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from tabulate import tabulate


@click.command('alerts', short_help='List alert environments, services, groups and tags')
@click.command('alerts', short_help='List environments, services, groups and tags')
@click.option('--environments', '-E', is_flag=True, help='List alert environments.')
@click.option('--services', '-S', is_flag=True, help='List alert services.')
@click.option('--groups', '-g', is_flag=True, help='List alert groups.')
Expand Down
2 changes: 1 addition & 1 deletion alertaclient/commands/cmd_blackout.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
@click.option('--start', metavar='DATETIME', help='Start time in ISO8601 eg. 2018-02-01T12:00:00.000Z')
@click.option('--duration', metavar='SECONDS', type=int, help='Blackout period in seconds')
@click.option('--text', help='Reason for blackout')
@click.option('--delete', '-D', help='Delete blackout using ID')
@click.option('--delete', '-D', metavar='ID', help='Delete blackout using ID')
@click.pass_obj
def cli(obj, environment, service, resource, event, group, tags, origin, customer, start, duration, text, delete):
"""Suppress alerts for specified duration based on alert attributes."""
Expand Down
18 changes: 18 additions & 0 deletions alertaclient/commands/cmd_scopes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import json

import click
from tabulate import tabulate


@click.command('scopes', short_help='List scopes')
@click.pass_obj
def cli(obj):
"""List scopes."""
client = obj['client']

if obj['output'] == 'json':
r = client.http.get('/scopes')
click.echo(json.dumps(r['scopes'], sort_keys=True, indent=4, ensure_ascii=False))
else:
headers = {'scope': 'SCOPE'}
click.echo(tabulate([s.tabular() for s in client.get_scopes()], headers=headers, tablefmt=obj['output']))
2 changes: 1 addition & 1 deletion alertaclient/commands/cmd_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def parse_args(self, ctx, args):
@click.option('--role', 'roles', multiple=True, help='List of roles')
@click.option('--text', help='Description of user')
@click.option('--email-verified/--email-not-verified', default=None, help='Email address verified flag')
@click.option('--delete', '-D', metavar='UUID', help='Delete user using ID')
@click.option('--delete', '-D', metavar='ID', help='Delete user using ID')
@click.pass_obj
def cli(obj, id, name, email, password, status, roles, text, email_verified, delete):
"""Create user, show or update user details, including password reset."""
Expand Down
8 changes: 7 additions & 1 deletion alertaclient/models/enums.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
from enum import Enum


class Scope(str, Enum):
class Scope(str):

read = 'read'
write = 'write'
admin = 'admin'
read_alerts = 'read:alerts'
write_alerts = 'write:alerts'
delete_alerts = 'delete:alerts'
admin_alerts = 'admin:alerts'
read_blackouts = 'read:blackouts'
write_blackouts = 'write:blackouts'
Expand Down Expand Up @@ -58,6 +59,11 @@ def from_str(action: str, resource: str = None):
else:
return Scope(action)

def tabular(self):
return {
'scope': self
}


ADMIN_SCOPES = [Scope.admin, Scope.read, Scope.write]

Expand Down