@Override
    public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException {
        if(log.isDebugEnabled()) {
            log.debug(String.format("List containers for %s", session));
        }
        try {
            final AttributedList<Path> buckets = new AttributedList<>();
            // List all buckets owned
            for(StorageBucket b : session.getClient().listAllBuckets()) {
                final PathAttributes attr = new PathAttributes();
                final Path bucket = new Path(PathNormalizer.normalize(b.getName()), EnumSet.of(Path.Type.volume, Path.Type.directory), attr);
                if(b.getOwner() != null) {
                    // Null if the owner is not available
                    attr.setOwner(b.getOwner().getId());
                }
                attr.setCreationDate(b.getCreationDate().getTime());
                if(b.isLocationKnown()) {
                    attr.setRegion(b.getLocation());
                }
                else {
                    if(region.getIdentifier() != null) {
                        final String location;
                        if(!b.isLocationKnown()) {
                            location = session.getFeature(Location.class).getLocation(bucket).getIdentifier();
                        }
                        else {
                            location = b.getLocation();
                        }
                        if(!StringUtils.equals(location, region.getIdentifier())) {
                            log.warn(String.format("Skip bucket %s in region %s", bucket, location));
                            continue;
                        }
                        attr.setRegion(location);
                    }
                }
                buckets.add(bucket);
                listener.chunk(directory, buckets);
            }
            return buckets;
        }
        catch(ServiceException e) {
            throw new S3ExceptionMappingService().map("Listing directory {0} failed", e, directory);
        }
    }
@Test
    public void testListRestrictRegion() throws Exception {
        final AttributedList<Path> list = new S3BucketListService(session, new S3LocationFeature.S3Region("eu-central-1")).list(
            new Path(String.valueOf(Path.DELIMITER), EnumSet.of(Path.Type.volume, Path.Type.directory)), new DisabledListProgressListener());
        assertFalse(list.isEmpty());
        for(Path bucket : list) {
            assertEquals("eu-central-1", bucket.attributes().getRegion());
            assertEquals(bucket.attributes(), new S3AttributesFinderFeature(session, new S3AccessControlListFeature(session)).find(bucket, new DisabledListProgressListener()));
        }
    }