diff --git a/eodag/rest/stac.py b/eodag/rest/stac.py index 1764ccd9f..d196e003c 100644 --- a/eodag/rest/stac.py +++ b/eodag/rest/stac.py @@ -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), @@ -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) @@ -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 @@ -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