forked from softlayer/softlayer-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlist.py
More file actions
42 lines (36 loc) · 1.27 KB
/
list.py
File metadata and controls
42 lines (36 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
"""List SSL certificates."""
# :license: MIT, see LICENSE for more details.
import click
import SoftLayer
from SoftLayer.CLI import environment
from SoftLayer.CLI import formatting
@click.command()
@click.option('--status',
default="all",
show_default=True,
type=click.Choice(['all', 'valid', 'expired']),
help="Show certificates with this status")
@click.option('--sortby',
type=click.Choice(['id',
'common_name',
'days_until_expire',
'notes']),
help="Column to sort by")
@environment.pass_env
def cli(env, status, sortby):
"""List SSL certificates."""
manager = SoftLayer.SSLManager(env.client)
certificates = manager.list_certs(status)
table = formatting.Table(['id',
'common_name',
'days_until_expire',
'notes'])
for certificate in certificates:
table.add_row([
certificate['id'],
certificate['commonName'],
certificate['validityDays'],
certificate.get('notes', formatting.blank())
])
table.sortby = sortby
env.fout(table)