Skip to content

Commit 5f11ebd

Browse files
committed
Issue #668 just reuse ProcessListingResponse for UDPs
1 parent 883555c commit 5f11ebd

File tree

2 files changed

+4
-50
lines changed

2 files changed

+4
-50
lines changed

openeo/rest/connection.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@
7070
CollectionListingResponse,
7171
JobListingResponse,
7272
ProcessListingResponse,
73-
UserDefinedProcessListingResponse,
7473
)
7574
from openeo.rest.service import Service
7675
from openeo.rest.udp import Parameter, RESTUserDefinedProcess
@@ -696,7 +695,7 @@ def list_collections(self) -> CollectionListingResponse:
696695
# TODO: add caching #383, but reset cache on auth change #254
697696
# TODO #677 add pagination support?
698697
data = self.get("/collections", expected_status=200).json()
699-
return CollectionListingResponse(data)
698+
return CollectionListingResponse(response_data=data)
700699

701700
def list_collection_ids(self) -> List[str]:
702701
"""
@@ -942,18 +941,18 @@ def save_user_defined_process(
942941
)
943942
return udp
944943

945-
def list_user_defined_processes(self) -> UserDefinedProcessListingResponse:
944+
def list_user_defined_processes(self) -> ProcessListingResponse:
946945
"""
947946
Lists all user-defined processes of the authenticated user.
948947
949948
.. versionchanged:: 0.38.0
950-
Returns a :py:class:`~openeo.rest.models.general.UserDefinedProcessListingResponse` object
949+
Returns a :py:class:`~openeo.rest.models.general.ProcessListingResponse` object
951950
instead of a simple ``List[dict]``.
952951
"""
953952
# TODO #677 add pagination support?
954953
self.assert_user_defined_process_support()
955954
data = self.get("/process_graphs", expected_status=200).json()
956-
return UserDefinedProcessListingResponse(response_data=data)
955+
return ProcessListingResponse(response_data=data)
957956

958957
def user_defined_process(self, user_defined_process_id: str) -> RESTUserDefinedProcess:
959958
"""

openeo/rest/models/general.py

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -112,51 +112,6 @@ def ext_federation(self) -> FederationExtension:
112112
return FederationExtension(self._data)
113113

114114

115-
class UserDefinedProcessListingResponse(list):
116-
"""
117-
Container for process metadata listing received
118-
from a ``GET /process_graphs`` request.
119-
120-
.. note::
121-
This object mimics a simple list of collection metadata dictionaries,
122-
which was the original return API of
123-
:py:meth:`~openeo.rest.connection.Connection.list_user_defined_processes()`,
124-
but now also provides methods/properties to access additional response data.
125-
126-
:param response_data: response data from a ``GET /process_graphs`` request
127-
128-
.. seealso:: :py:meth:`openeo.rest.connection.Connection.list_user_defined_processes()`
129-
130-
.. versionadded:: 0.38.0
131-
"""
132-
133-
# TODO: this is a copy of ProcessListingResponse, but with different class name
134-
135-
__slots__ = ["_data"]
136-
137-
def __init__(self, response_data: dict, *, warn_on_federation_missing: bool = True):
138-
self._data = response_data
139-
# Mimic original list of process metadata dictionaries
140-
super().__init__(response_data["processes"])
141-
if warn_on_federation_missing:
142-
self.ext_federation.warn_on_missing(resource_name="process listing")
143-
144-
def _repr_html_(self):
145-
return render_component(
146-
component="processes", data=self, parameters={"show-graph": True, "provide-download": False}
147-
)
148-
149-
@property
150-
def links(self) -> List[Link]:
151-
"""Get links related to this resource."""
152-
return [Link.from_dict(d) for d in self._data.get("links", [])]
153-
154-
@property
155-
def ext_federation(self) -> FederationExtension:
156-
"""Accessor for federation extension data related to this resource."""
157-
return FederationExtension(self._data)
158-
159-
160115
class JobListingResponse(list):
161116
"""
162117
Container for job metadata listing received

0 commit comments

Comments
 (0)