According to the Apache libcloud documentation there is no way to accomplish that using only libcloud. There is however a pythonic way to do this using list comprehensions. Let's print the entire content of the bucket:
driver.list_container_objects(bucket)
We get:
`[<Object: name=A_dirty_chubby_anthropomorphic_badger, size=410938, hash=59643edb7beb48e8904d6557ab4d3d8e, provider=Amazon S3 (eu-central-1) ...>,
<Object: name=A_dirty_chubby_anthropomorphic_badger2, size=379704, hash=6e7f3f1608638be56cecfbd66c1ac902, provider=Amazon S3 (eu-central-1) ...>,
<Object: name=LFS-BOOK-7.9.pdf, size=1736489, hash=e6802cdbec8f4b50d43c3d9cd710bfc2, provider=Amazon S3 (eu-central-1) ...>,
<Object: name=badgers/A_dirty_chubby_anthropomorphic_badger, size=410938, hash=59643edb7beb48e8904d6557ab4d3d8e, provider=Amazon S3 (eu-central-1) ...>,
<Object: name=badgers/A_dirty_chubby_anthropomorphic_badger2, size=379704, hash=6e7f3f1608638be56cecfbd66c1ac902, provider=Amazon S3 (eu-central-1) ...>]`
If we want to limit by depth we can do:
[obj for obj in driver.list_container_objects(bucket) if (obj.name.count('/') < 1)]
Where we will get:
`[<Object: name=A_dirty_chubby_anthropomorphic_badger, size=410938, hash=59643edb7beb48e8904d6557ab4d3d8e, provider=Amazon S3 (eu-central-1) ...>,
<Object: name=A_dirty_chubby_anthropomorphic_badger2, size=379704, hash=6e7f3f1608638be56cecfbd66c1ac902, provider=Amazon S3 (eu-central-1) ...>,
<Object: name=LFS-BOOK-7.9.pdf, size=1736489, hash=e6802cdbec8f4b50d43c3d9cd710bfc2, provider=Amazon S3 (eu-central-1) ...>]
And if we want to filter by suffix we can just do:
[obj for obj in driver.list_container_objects(bucket) if (obj.name.endswith("badger"))]
Where we end up getting:
`[<Object: name=A_dirty_chubby_anthropomorphic_badger, size=410938, hash=59643edb7beb48e8904d6557ab4d3d8e, provider=Amazon S3 (eu-central-1) ...>,
<Object: name=badgers/A_dirty_chubby_anthropomorphic_badger, size=410938, hash=59643edb7beb48e8904d6557ab4d3d8e, provider=Amazon S3 (eu-central-1) ...>]`