|
5 | 5 |
|
6 | 6 |
|
7 | 7 | @click.command('key', short_help='Create API key') |
| 8 | +@click.option('--api-key', '-K', help='User-defined API Key. [default: random string]') |
8 | 9 | @click.option('--username', '-u', help='User (Admin only)') |
9 | 10 | @click.option('--scope', 'scopes', multiple=True, help='List of permissions eg. admin:keys, write:alerts') |
10 | 11 | @click.option('--duration', metavar='SECONDS', type=int, help='Duration API key is valid') |
11 | 12 | @click.option('--text', help='Description of API key use') |
12 | 13 | @click.option('--customer', metavar='STRING', help='Customer') |
13 | 14 | @click.option('--delete', '-D', metavar='ID', help='Delete API key using ID or KEY') |
14 | 15 | @click.pass_obj |
15 | | -def cli(obj, username, scopes, duration, text, customer, delete): |
| 16 | +def cli(obj, api_key, username, scopes, duration, text, customer, delete): |
16 | 17 | """Create or delete an API key.""" |
17 | 18 | client = obj['client'] |
18 | 19 | if delete: |
19 | 20 | client.delete_key(delete) |
20 | 21 | else: |
21 | 22 | try: |
22 | 23 | expires = datetime.utcnow() + timedelta(seconds=duration) if duration else None |
23 | | - key = client.create_key(username, scopes, expires, text, customer) |
| 24 | + key = client.create_key(username, scopes, expires, text, customer, key=api_key) |
24 | 25 | except Exception as e: |
25 | 26 | click.echo('ERROR: {}'.format(e), err=True) |
26 | 27 | sys.exit(1) |
|
0 commit comments