def format(item): """Return pretty-formatted item.""" list_schema = [ ('Name', 'Tags', _name_from_tags), ('SnapshotId', 'SnapshotId', None), ('VolumeId', 'VolumeId', None), ('State', 'State', None), ('Progress', 'Progress', None), ('VolumeSize', 'VolumeSize', None), ('StartTime', 'StartTime', None), ('Description', 'Description', None), ] item_schema = [ ('Name', 'Tags', _name_from_tags), ('Description', 'Description', None), ('SnapshotId', 'SnapshotId', None), ('VolumeId', 'VolumeId', None), ('State', 'State', None), ('Progress', 'Progress', None), ('VolumeSize', 'VolumeSize', None), ('StartTime', 'StartTime', None), ('Encrypted', 'Encrypted', None), ('KmsKeyId', 'KmsKeyId', None), ('tags', 'Tags', _fmt_tags()), ] format_item = tablefmt.make_dict_to_table(item_schema) format_list = tablefmt.make_list_to_table(list_schema) if isinstance(item, list): return format_list(item) else: return format_item(item)
def format(item): """Return pretty-formatted item.""" list_schema = [ ('UserName', 'UserName', None), ('Arn', 'Arn', None), ] item_schema = [ ('UserName', 'UserName', None), ('Path', 'Path', None), ('Arn', 'Arn', None), ('CreateDate', 'CreateDate', None), ('UserId', 'UserId', None), ('UserPolicies', 'UserPolicies', None), ('AttachedPolicies', 'AttachedPolicies', _fmt_attached_policies), ] format_item = tablefmt.make_dict_to_table(item_schema) format_list = tablefmt.make_list_to_table(list_schema) if isinstance(item, list): return format_list(item) else: return format_item(item)
def format(item): """Return pretty-formatted item.""" schema = [ ('aws_account', 'aws_account', None), ('aws_admin', 'aws_admin', None), ('aws_region', 'aws_region', None), ('docker-registries', 'docker_registries', ','.join), ('disk-size', 'disk_size', None), ('hostgroups', 'hostgroups', ','.join), ('image', 'image', None), ('image-accounts', 'image_accounts', ','.join), ('instance-profile', 'instance_profile', None), ('realm', 'realm', None), ('secgroup', 'secgroup', None), ('size', 'size', None), ('sns-topic', 'sns_topic', None), ('subnets', 'subnets', ','.join), ('s3_registry_bucket', 's3_registry_bucket', None), ('tls_certs', 'tls_certs', None), ] format_item = tablefmt.make_dict_to_table(schema) format_list = tablefmt.make_list_to_table(schema) if isinstance(item, list): return format_list(item) else: return format_item(item)
def format(item): """Return pretty-formatted item.""" list_schema = [ ('id', None, None), ('type', None, None), ] item_schema = [ ('id', None, None), ('type', None, None), ('groups', '_ipa', lambda ipa: '\n'.join(ipa.get('memberof_group', []))), ('indirect-groups', '_ipa', lambda ipa: '\n'.join(ipa.get('memberofindirect_group', []))), ('hbac-rule', '_ipa', lambda ipa: '\n'.join(ipa.get('memberofindirect_hbacrule', []))), ('sudo-rule', '_ipa', lambda ipa: '\n'.join(ipa.get('memberofindirect_sudorule', []))), ('iam-user', '_iam', lambda iam: yaml.dump(iam['user'])), ('iam-role', '_iam', lambda iam: yaml.dump(iam['role'])), ] format_item = tablefmt.make_dict_to_table(item_schema) format_list = tablefmt.make_list_to_table(list_schema) if isinstance(item, list): return format_list(item) else: return format_item(item)
def format(item): """Return pretty-formatted item.""" list_schema = [ ('RoleName', 'RoleName', None), ('Arn', 'Arn', None), ('MaxSessionDuration', 'MaxSessionDuration', None), ('CreateDate', 'CreateDate', None), ] item_schema = [ ('RoleName', 'RoleName', None), ('Path', 'Path', None), ('Arn', 'Arn', None), ('MaxSessionDuration', 'MaxSessionDuration', None), ('CreateDate', 'CreateDate', None), ('RoleId', 'RoleId', None), ('TrustedEntities', 'AssumeRolePolicyDocument', _fmt_trusted_entities), ('RolePolicies', 'RolePolicies', None), ('AttachedPolicies', 'AttachedPolicies', _fmt_attached_policies), ] format_item = tablefmt.make_dict_to_table(item_schema) format_list = tablefmt.make_list_to_table(list_schema) if isinstance(item, list): return format_list(item) else: return format_item(item)
def format(item): """Return pretty-formatted item.""" list_schema = [ ('AttachmentCount', 'DefaultVersionId', None), ('DefaultVersionId', 'DefaultVersionId', None), ('Arn', 'Arn', None), ('MaxSessionDuration', 'MaxSessionDuration', None), ('CreateDate', 'CreateDate', None), ] item_schema = [('Arn', 'Arn', None), ('PolicyName', 'PolicyName', None), ('Path', 'Path', None), ('DefaultVersionId', 'DefaultVersionId', None), ('IsAttachable', 'IsAttachable', None), ('AttachmentCount', 'AttachmentCount', None), ('Description', 'Description', None), ('CreateDate', 'CreateDate', None), ('UpdateDate', 'UpdateDate', None), ('PolicyVersion', 'PolicyVersion', _fmt_policy_version)] format_item = tablefmt.make_dict_to_table(item_schema) format_list = tablefmt.make_list_to_table(list_schema) if isinstance(item, list): return format_list(item) else: return format_item(item)
def format(item): """Return pretty-formatted item.""" item_schema = [ ('id', 'id', None), ('status', 'state', None), ('code', 'status_code', None), ('changed', 'status_timestamp', None), ('zone', 'az', None), ('subnet', 'subnet', None), ('type', 'instance_type', None), ('instance_id', 'instance_id', None), ('ami_id', 'ami_id', None), ('hostname', 'hostname', None), ('launch', 'instance_launch', None), ('state', 'instance_status', None), ('duration', 'duration', None), ] list_schema = item_schema format_item = tablefmt.make_dict_to_table(item_schema) format_list = tablefmt.make_list_to_table(list_schema) if isinstance(item, list): return format_list(item) else: return format_item(item)
def format(item): """Return pretty-formatted item.""" item_schema = [ ('hostname', 'Tags', _name_from_tags), ('id', 'InstanceId', None), ('arch', 'Architecture', None), ('image', 'ImageId', None), ('type', 'InstanceType', None), ('key', 'KeyName', None), ('launch', 'LaunchTime', None), ('state', 'State', _state), ('vpc', 'VpcId', None), ('subnet', 'SubnetId', None), ('secgroups', 'SecurityGroups', _fmt_secgroups()), ('tags', 'Tags', _fmt_tags()), ] list_schema = [ ('hostname', 'Tags', _name_from_tags), ('id', 'InstanceId', None), ('image', 'ImageId', None), ('type', 'InstanceType', None), ('key', 'KeyName', None), ('vpc', 'VpcId', None), ('subnet', 'SubnetId', None), ('tags', 'Tags', _fmt_tags()), ] format_item = tablefmt.make_dict_to_table(item_schema) format_list = tablefmt.make_list_to_table(list_schema) if isinstance(item, list): return format_list(item) else: return format_item(item)
def format(item): """Return pretty-formatted item.""" schema = [ ('id', 'VpcId', None), ('default', 'IsDefault', None), ('state', 'State', None), ('cidr_block', 'CidrBlock', None), ('tags', 'Tags', _fmt_tags()), ] format_item = tablefmt.make_dict_to_table(schema) format_list = tablefmt.make_list_to_table(schema) if isinstance(item, list): return format_list(item) else: return format_item(item)
def test_table(self): """Tests table output.""" schema = [('A', 'a', None), ('b', None, None), ('c', None, None)] tbl = tablefmt.make_dict_to_table(schema) list_tbl = tablefmt.make_list_to_table(schema) self.assertEqual(_lines(tbl({ 'a': 1, 'b': 2, 'c': [1, 2, 3] })), ['A : 1', 'b : 2', 'c : 1,2,3']) self.assertEqual(_lines(list_tbl([{ 'a': 1, 'b': 2, 'c': [1, 2, 3] }])), ['A b c', '1 2 1,2,3'])
def format(item): """Return pretty-formatted item.""" list_schema = [ ('id', 'User', lambda _: _['UserName']), ] item_schema = [ ('id', 'user', lambda _: _['UserName']), ('user', 'user', yaml.dump), ('role', 'role', yaml.dump), ] format_item = tablefmt.make_dict_to_table(item_schema) format_list = tablefmt.make_list_to_table(list_schema) if isinstance(item, list): return format_list(item) else: return format_item(item)
def format(item): """Return pretty-formatted item.""" list_schema = [ ('name', 'RoleName', None), ('id', 'RoleId', None), ('path', 'Path', None), ] # TODO: add role policy document schema. item_schema = list_schema + [ ('arn', 'Arn', None), ] format_item = tablefmt.make_dict_to_table(item_schema) format_list = tablefmt.make_list_to_table(list_schema) if isinstance(item, list): return format_list(item) else: return format_item(item)
def format(item): """Return pretty-formatted item.""" def _hostname_from_tags(tags): """Get hostname from tags.""" for tag in tags: if tag['Key'] == 'Name': return tag['Value'] return None item_schema = [ ('hostname', 'Tags', _hostname_from_tags), ('id', 'InstanceId', None), ('arch', 'Architecture', None), ('image', 'ImageId', None), ('type', 'InstanceType', None), ('key', 'KeyName', None), ('launch', 'LaunchTime', None), ('status', 'Status', None), ('vpc', 'VpcId', None), ('subnet', 'SubnetId', None), ('tags', 'Tags', _fmt_tags()), ] list_schema = [ ('hostname', 'Tags', _hostname_from_tags), ('id', 'InstanceId', None), ('image', 'ImageId', None), ('type', 'InstanceType', None), ('key', 'KeyName', None), ('vpc', 'VpcId', None), ('subnet', 'SubnetId', None), ('tags', 'Tags', _fmt_tags()), ] format_item = tablefmt.make_dict_to_table(item_schema) format_list = tablefmt.make_list_to_table(list_schema) if isinstance(item, list): return format_list(item) else: return format_item(item)
def format(item): """Return pretty-formatted item.""" list_schema = [ ('id', 'uid', lambda _: _[0]), ] item_schema = [ ('id', 'uid', lambda _: _[0]), ('type', 'userclass', lambda _: _[0]), ('groups', 'memberof_group', '\n'.join), ('indirect-groups', 'memberofindirect_group', '\n'.join), ('hbac-rule', 'memberofindirect_hbacrule', '\n'.join), ('sudo-rule', 'memberofindirect_sudorule', '\n'.join), ] format_item = tablefmt.make_dict_to_table(item_schema) format_list = tablefmt.make_list_to_table(list_schema) if isinstance(item, list): return format_list(item) else: return format_item(item)
def format(item): """Return pretty-formatted item.""" list_schema = [ ('id', 'ImageId', None), ('name', 'Name', None), ('owner', 'OwnerId', None), ('created', 'CreationDate', None), ('public', 'Public', lambda v: 'yes' if v else 'no'), ('state', 'State', None), ] item_schema = list_schema + [ ('tags', 'Tags', _fmt_tags()), ] format_item = tablefmt.make_dict_to_table(item_schema) format_list = tablefmt.make_list_to_table(list_schema) if isinstance(item, list): return format_list(item) else: return format_item(item)
def format(item): """Return pretty-formatted item.""" schema = [ ('autoscale', 'autoscale', None), ('image', 'image', None), ('instance-types', 'instance_types', ','.join), ('spot-instance-types', 'spot_instance_types', ','.join), ('disk-size', 'disk_size', None), ('hostgroups', 'hostgroups', ','.join), ('secgroup', 'secgroup', None), ('instance-profile', 'instance_profile', None), ('subnets', 'subnets', ','.join), ('s3_registry_bucket', 's3_registry_bucket', None), ] format_item = tablefmt.make_dict_to_table(schema) format_list = tablefmt.make_list_to_table(schema) if isinstance(item, list): return format_list(item) else: return format_item(item)
def format(item): """Return pretty-formatted item.""" list_schema = [ ('id', 'GroupId', None), ('owner', 'OwnerId', None), ('vpc', 'VpcId', None), ('tags', 'Tags', _fmt_tags()), ] # TODO: add ip ingress/egress permissions to the output. item_schema = [ ('id', 'GroupId', None), ('owner', 'OwnerId', None), ('vpc', 'VpcId', None), ('tags', 'Tags', _fmt_tags()), ] format_item = tablefmt.make_dict_to_table(item_schema) format_list = tablefmt.make_list_to_table(list_schema) if isinstance(item, list): return format_list(item) else: return format_item(item)