|
| 1 | +"""Display permission details for a cloud object storage.""" |
| 2 | +# :license: MIT, see LICENSE for more details. |
| 3 | + |
| 4 | +import click |
| 5 | +import SoftLayer |
| 6 | +from SoftLayer.CLI import environment |
| 7 | +from SoftLayer.CLI import formatting |
| 8 | + |
| 9 | + |
| 10 | +@click.command(cls=SoftLayer.CLI.command.SLCommand, ) |
| 11 | +@click.argument('object_id') |
| 12 | +@environment.pass_env |
| 13 | +def cli(env, object_id): |
| 14 | + """Display permission details for a cloud object storage.""" |
| 15 | + |
| 16 | + block_manager = SoftLayer.BlockStorageManager(env.client) |
| 17 | + |
| 18 | + cloud = block_manager.get_network_message_delivery_accounts(object_id) |
| 19 | + end_points = block_manager.get_end_points(object_id) |
| 20 | + |
| 21 | + table = formatting.Table(['Name', 'Value']) |
| 22 | + |
| 23 | + table_credentials = formatting.Table(['Id', 'Access Key ID', 'Secret Access Key', 'Description']) |
| 24 | + |
| 25 | + for credential in cloud.get('credentials'): |
| 26 | + table_credentials.add_row([credential.get('id'), |
| 27 | + credential.get('username'), |
| 28 | + credential.get('password'), |
| 29 | + credential['type']['description']]) |
| 30 | + |
| 31 | + table_url = formatting.Table(['Region', |
| 32 | + 'Location', |
| 33 | + 'Type', |
| 34 | + 'URL']) |
| 35 | + for end_point in end_points: |
| 36 | + table_url.add_row([end_point.get('region') or '', |
| 37 | + end_point.get('location') or '', |
| 38 | + end_point.get('type'), |
| 39 | + end_point.get('url'), ]) |
| 40 | + |
| 41 | + table.add_row(['UUID', cloud.get('uuid')]) |
| 42 | + table.add_row(['Credentials', table_credentials]) |
| 43 | + table.add_row(['EndPoint URL´s', table_url]) |
| 44 | + env.fout(table) |
0 commit comments