Skip to content

Commit

Permalink
Issue #78 Implementing GET /services
Browse files Browse the repository at this point in the history
  • Loading branch information
JohanKJSchreurs committed Nov 2, 2022
1 parent 009d68c commit 466616e
Show file tree
Hide file tree
Showing 2 changed files with 747 additions and 5 deletions.
33 changes: 28 additions & 5 deletions src/openeo_aggregator/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from openeo_aggregator.utils import MultiDictGetter, subdict, dict_merge, normalize_issuer_url
from openeo_driver.ProcessGraphDeserializer import SimpleProcessing
from openeo_driver.backend import OpenEoBackendImplementation, AbstractCollectionCatalog, LoadParameters, Processing, \
OidcProvider, BatchJobs, BatchJobMetadata, SecondaryServices
OidcProvider, BatchJobs, BatchJobMetadata, SecondaryServices, ServiceMetadata
from openeo_driver.datacube import DriverDataCube
from openeo_driver.errors import CollectionNotFoundException, OpenEOApiException, ProcessGraphMissingException, \
JobNotFoundException, JobNotFinishedException, ProcessGraphInvalidException, PermissionsInsufficientException, \
Expand Down Expand Up @@ -808,10 +808,30 @@ def merge(formats: dict, to_add: dict):

return service_types

# next one to implement
# def list_services(self, user_id: str) -> List[ServiceMetadata]:
# """https://openeo.org/documentation/1.0/developers/api/reference.html#operation/list-services"""
# return []
def list_services(self, user_id: str) -> List[ServiceMetadata]:
"""https://openeo.org/documentation/1.0/developers/api/reference.html#operation/list-services"""

all_services = []
def merge(services, to_add):
# For now ignore the links
services_to_add = to_add.get("services")
if services_to_add:
services_metadata = [ServiceMetadata.from_dict(s) for s in services_to_add]
services.extend(services_metadata)

# Get stuff from backends
for con in self._backends:
services_json = None
try:
services_json = con.get("/services").json()
except Exception as e:
_log.warning("Failed to get services from {con.id}: {e!r}", exc_info=True)
continue

if services_json:
merge(all_services, services_json)

return all_services

class AggregatorBackendImplementation(OpenEoBackendImplementation):
# No basic auth: OIDC auth is required (to get EGI Check-in eduperson_entitlement data)
Expand Down Expand Up @@ -1000,3 +1020,6 @@ def postprocess_capabilities(self, capabilities: dict) -> dict:

def service_types(self) -> dict:
return self.secondary_services.service_types()

def list_services(self, user_id: str) -> List[ServiceMetadata]:
return self.secondary_services.list_services(user_id=user_id)
Loading

0 comments on commit 466616e

Please sign in to comment.