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

fix(server): merge providers by group & use groups in item links #1192

Merged
merged 1 commit into from
Jun 11, 2024
Merged
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
fix(server): merge providers by group & use groups in item links
  • Loading branch information
alambare committed Jun 8, 2024
commit 8542c7fca22b46a29c3702612827196d64e04b07
17 changes: 12 additions & 5 deletions eodag/rest/stac.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,11 @@ def as_dict(self) -> Dict[str, Any]:

def get_provider_dict(self, provider: str) -> Dict[str, Any]:
"""Generate STAC provider dict"""
provider_config = [
provider_config = next(
p
for p in self.eodag_api.providers_config.values()
if provider in [p.name, getattr(p, "group", None)]
][0]
)
return {
"name": getattr(provider_config, "group", provider_config.name),
"description": getattr(provider_config, "description", None),
Expand Down Expand Up @@ -321,7 +321,8 @@ def __get_item_list(
else f"{url_parts.netloc}{url_parts.path}"
)
# add provider to query-args
query_dict.update(provider=[product.provider])
p_config = self.eodag_api.providers_config[product.provider]
query_dict.update(provider=[getattr(p_config, "group", p_config.name)])
# add datacube query-string to query-args
if _dc_qs:
query_dict.update(_dc_qs=_dc_qs)
Expand Down Expand Up @@ -625,7 +626,7 @@ def get_stac_item_from_product(self, product: EOProduct) -> Dict[str, Any]:
item_model,
{
"product": product_dict,
"providers": self.get_provider_dict(product.provider),
"providers": [self.get_provider_dict(product.provider)],
},
)
# parse f-strings
Expand Down Expand Up @@ -735,12 +736,18 @@ def __generate_stac_collection(
"""
providers = self.__list_product_type_providers(product_type)

providers_dict: Dict[str, Dict[str, Any]] = {}
for provider in providers:
p_dict = self.get_provider_dict(provider)
providers_dict.setdefault(p_dict["name"], p_dict)
providers_list = list(providers_dict.values())

# parse jsonpath
product_type_collection = jsonpath_parse_dict_items(
collection_model,
{
"product_type": product_type,
"providers": [self.get_provider_dict(p) for p in providers],
"providers": providers_list,
},
)
# override EODAG's collection with the external collection
Expand Down
Loading
  NODES
COMMUNITY 2
Note 1
Project 2
USERS 1