def list(gandi, only_data, only_snapshot, attached, detached, type, id, vm,
         snapshotprofile, datacenter, limit):
    """ List disks. """
    options = {
        'items_per_page': limit,
    }

    if attached and detached:
        raise UsageError('You cannot use both --attached and --detached.')

    if only_data:
        options.setdefault('type', []).append('data')
    if only_snapshot:
        options.setdefault('type', []).append('snapshot')
    if datacenter:
        options['datacenter_id'] = gandi.datacenter.usable_id(datacenter)

    output_keys = ['name', 'state', 'size']
    if type:
        output_keys.append('type')
    if id:
        output_keys.append('id')
    if vm:
        output_keys.append('vm')

    profiles = []
    if snapshotprofile:
        output_keys.append('profile')
        profiles = gandi.snapshotprofile.list()

    result = gandi.disk.list(options)
    vms = dict([(vm_['id'], vm_) for vm_ in gandi.iaas.list()])

    # filter results per attached/detached
    disks = []
    for disk in result:
        if attached and not disk['vms_id']:
            continue
        if detached and disk['vms_id']:
            continue
        disks.append(disk)

    for num, disk in enumerate(disks):
        if num:
            gandi.separator_line()
        output_disk(gandi, disk, [], vms, profiles, output_keys)

    return result
List disks.