|
| 1 | +"""Display details for a specified email.""" |
| 2 | +# :license: MIT, see LICENSE for more details. |
| 3 | + |
| 4 | +import click |
| 5 | +from SoftLayer.CLI import environment |
| 6 | +from SoftLayer.CLI import formatting |
| 7 | +from SoftLayer.managers.email import EmailManager |
| 8 | +from SoftLayer import utils |
| 9 | + |
| 10 | + |
| 11 | +@click.command() |
| 12 | +@click.argument('identifier') |
| 13 | +@environment.pass_env |
| 14 | +def cli(env, identifier): |
| 15 | + """Display details for a specified email.""" |
| 16 | + |
| 17 | + email_manager = EmailManager(env.client) |
| 18 | + result = email_manager.get_instance(identifier) |
| 19 | + |
| 20 | + table = formatting.KeyValueTable(['name', 'value']) |
| 21 | + table.align['name'] = 'r' |
| 22 | + table.align['value'] = 'l' |
| 23 | + |
| 24 | + table.add_row(['id', result.get('id')]) |
| 25 | + table.add_row(['username', result.get('username')]) |
| 26 | + table.add_row(['create_date', result.get('createDate')]) |
| 27 | + table.add_row(['categoryCode', utils.lookup(result, 'billingItem', 'categoryCode')]) |
| 28 | + table.add_row(['description', utils.lookup(result, 'billingItem', 'description')]) |
| 29 | + table.add_row(['type_description', utils.lookup(result, 'type', 'description')]) |
| 30 | + table.add_row(['type', utils.lookup(result, 'type', 'keyName')]) |
| 31 | + table.add_row(['vendor', utils.lookup(result, 'vendor', 'keyName')]) |
| 32 | + |
| 33 | + env.fout(table) |
0 commit comments