Skip to content

Commit 84da620

Browse files
committed
Draft support for the federation extension in Jupyter visual outputs #668
1 parent 238c8a6 commit 84da620

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

openeo/rest/connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ def list_collections(self) -> CollectionListingResponse:
713713
# TODO: add caching #383, but reset cache on auth change #254
714714
# TODO #677 add pagination support?
715715
data = self.get("/collections", expected_status=200).json()
716-
return CollectionListingResponse(response_data=data)
716+
return CollectionListingResponse(response_data=data, connection=self)
717717

718718
def list_collection_ids(self) -> List[str]:
719719
"""

openeo/rest/models/general.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,23 +43,33 @@ class CollectionListingResponse(list):
4343
but now also provides methods/properties to access additional response data.
4444
4545
:param response_data: response data from a ``GET /collections`` request
46+
:param connection: optional connection object to use for federation extension
4647
4748
.. seealso:: :py:meth:`openeo.rest.connection.Connection.list_collections()`
4849
4950
.. versionadded:: 0.38.0
5051
"""
5152

52-
__slots__ = ["_data"]
53+
__slots__ = ["_data", '_connection']
5354

54-
def __init__(self, response_data: dict):
55+
def __init__(self, response_data: dict, connection = None):
5556
self._data = response_data
57+
self._connection = connection
5658
# Mimic original list of collection metadata dictionaries
5759
super().__init__(response_data["collections"])
5860

5961
self.ext_federation_missing(auto_warn=True)
6062

6163
def _repr_html_(self):
62-
return render_component(component="collections", data=self)
64+
federation = self._connection.capabilities().ext_federation_backend_details() if self._connection else None
65+
return render_component(
66+
component="collections",
67+
data=self,
68+
parameters={
69+
"missing": self.ext_federation_missing(),
70+
"federation": federation,
71+
}
72+
)
6373

6474
@property
6575
def links(self) -> List[Link]:

0 commit comments

Comments
 (0)