Skip to content

Commit a7ee10d

Browse files
committed
Allow customization of GET /process_graphs
for Open-EO/openeo-aggregator#125 and related to #377
1 parent 7ff8512 commit a7ee10d

File tree

4 files changed

+32
-10
lines changed

4 files changed

+32
-10
lines changed

CHANGELOG.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,17 @@ and start a new "In Progress" section above it.
1919

2020
<!-- start-of-changelog -->
2121

22-
## In progress: 0.129.0
22+
## In progress: 0.130.0
23+
24+
- Allow customization of `GET /process_graphs` response (for [Open-EO/openeo-aggregator#125](https://github.com/Open-EO/openeo-aggregator/issues/125))
25+
26+
27+
## 0.129.0
2328

2429
- array_apply: sub-process should now work on all supported processes ([Open-EO/openeo-geopyspark-driver#1064](https://github.com/Open-EO/openeo-geopyspark-driver/issues/1064))
2530
- Prevent access to non-public UDPs through URL guessing.
2631

32+
2733
## 0.128.0
2834

2935
- `load_collection`/`load_stac`: `spatial_extent` requires (Multi)Polygon geometries ([Open-EO/openeo-geopyspark-driver#996](https://github.com/Open-EO/openeo-geopyspark-driver/issues/996))

openeo_driver/_version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.129.0a1"
1+
__version__ = "0.130.0a1"

openeo_driver/backend.py

+19
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,18 @@ def to_api_dict(self, *, full: bool = True) -> dict:
653653
return dict_no_none(**d)
654654

655655

656+
class UserDefinedProcessesListing:
657+
# TODO #377 pagination support
658+
def __init__(self, udps: List[UserDefinedProcessMetadata]):
659+
self.udps = udps
660+
661+
def to_response_dict(self, full: bool = True) -> dict:
662+
return {
663+
"processes": [udp.to_api_dict(full=full) for udp in self.udps],
664+
"links": [],
665+
}
666+
667+
656668
class UserDefinedProcesses(MicroService):
657669
"""
658670
Base contract/implementation for User-Defined Processes "microservice"
@@ -671,8 +683,15 @@ def get_for_user(self, user_id: str) -> List[UserDefinedProcessMetadata]:
671683
List user's UDPs
672684
https://openeo.org/documentation/1.0/developers/api/reference.html#operation/list-custom-processes
673685
"""
686+
# TODO: eliminate this legacy API method
674687
raise NotImplementedError
675688

689+
def list_for_user(self, user_id: str) -> UserDefinedProcessesListing:
690+
# TODO: replace this adapter implementation with `raise NotImplementedError`
691+
# once `get_for_user` can be eliminated
692+
udps = self.get_for_user(user_id=user_id)
693+
return UserDefinedProcessesListing(udps=udps)
694+
676695
def save(self, user_id: str, process_id: str, spec: dict) -> None:
677696
"""
678697
Store new UDP

openeo_driver/views.py

+5-8
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,9 @@ def processes_from_namespace(namespace):
761761
# TODO: convention for user namespace? use '@' instead of "u:"
762762
if namespace.startswith("u:") and backend_implementation.user_defined_processes:
763763
user_id = namespace.partition("u:")[-1]
764-
user_udps = [p for p in backend_implementation.user_defined_processes.get_for_user(user_id) if p.public]
764+
user_udps = [
765+
p for p in backend_implementation.user_defined_processes.list_for_user(user_id).udps if p.public
766+
]
765767
processes = [udp.to_api_dict(full=full) for udp in user_udps]
766768
elif ":" not in namespace:
767769
process_registry = backend_implementation.processing.get_process_registry(
@@ -1767,13 +1769,8 @@ def udp_get(process_graph_id: str, user: User):
17671769
@blueprint.route('/process_graphs', methods=['GET'])
17681770
@auth_handler.requires_bearer_auth
17691771
def udp_list_for_user(user: User):
1770-
user_udps = backend_implementation.user_defined_processes.get_for_user(user.user_id)
1771-
return {
1772-
"processes": [udp.to_api_dict(full=False) for udp in user_udps],
1773-
# TODO: pagination links?
1774-
# TODO: allow backend_implementation to define links?
1775-
"links": [],
1776-
}
1772+
resp = backend_implementation.user_defined_processes.list_for_user(user_id=user.user_id)
1773+
return resp.to_response_dict(full=False)
17771774

17781775
@api_endpoint
17791776
@blueprint.route('/process_graphs/<process_graph_id>', methods=['DELETE'])

0 commit comments

Comments
 (0)