Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added pattern for list_collections #382

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion openeo/rest/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -640,10 +640,12 @@ def describe_account(self) -> str:
def user_jobs(self) -> dict:
return self.list_jobs()

def list_collections(self) -> List[dict]:
def list_collections(self, pattern: Optional[str] = None) -> List[dict]:
"""
List basic metadata of all collections provided by the back-end.

:param pattern: a pattern that matches the collections of interest, e.g. "sentinel"

.. caution::

Only the basic collection metadata will be returned.
Expand All @@ -653,6 +655,10 @@ def list_collections(self) -> List[dict]:
:return: list of dictionaries with basic collection metadata.
"""
data = self.get('/collections', expected_status=200).json()["collections"]

if pattern is not None:
data = [collection for collection in data if 'id' in collection and pattern in collection['id']]

return VisualList("collections", data=data)

def list_collection_ids(self) -> List[str]:
Expand Down