Provider#
- class eodag.api.provider.Provider(config)[source]#
Represents a data provider with its configuration and utility methods.
- Parameters:
config (
ProviderConfig|dict[str,Any]) – Provider configuration asProviderConfig()instance ordictcollections_fetched – Flag indicating whether collections have been fetched
Example#
>>> from eodag.api.provider import Provider >>> config = { ... 'name': 'example_provider', ... 'description': 'Example provider for testing', ... 'search': {'type': 'StacSearch'}, ... 'products': {'S2_MSI_L1C': {'_collection': 'S2_MSI_L1C'}} ... } >>> provider = Provider(config) >>> provider.name 'example_provider' >>> 'S2_MSI_L1C' in provider.collections_config True >>> provider.priority # Default priority 0
- property api_config: PluginConfig | None#
Return the api plugin config, if any.
- property collections_config: dict[str, Any]#
Return the collections configuration dictionary for this provider.
- property config: ProviderConfig#
Provider configuration (read-only assignment).
To update configuration safely, use
update_from_config()which handles metadata mapping and other provider-specific logic.Note: Direct config modification (
config.update(),config.name = ...) bypasses important provider validation.
- delete_collection(name)[source]#
Remove a collection from this provider.
- Parameters:
name (
str) – The collection name.- Raises:
UnsupportedCollection – If the collection is not found.
- Return type:
- property download_config: PluginConfig | None#
Return the download plugin config, if any.
- property search_config: PluginConfig | None#
Return the search plugin config, if any.
- sync_collections(dag, strict_mode)[source]#
Synchronize collections for a provider based on strict or permissive mode.
In strict mode, removes collections not in
collections_config. In permissive mode, adds empty collection to config for missing types.- Parameters:
dag (
EODataAccessGateway) – The gateway instance to use to list existing collections and to create new collection instances.strict_mode (
bool) – IfTrue, remove unknown collections; ifFalse, add empty configs for them.
- Return type:
- property unparsable_properties: set[str]#
Return set of unparsable properties from
generic_collection_unparsable_properties, if any.
- update_from_config(config)[source]#
Update the provider’s configuration from a given config.
- Parameters:
config (
ProviderConfig|dict[str,Any]) – The new configuration to update from.- Raises:
ValidationError – If the config attempts to change the provider name.
- Return type:
- class eodag.api.provider.ProviderConfig[source]#
EODAG configuration for a provider.
- Parameters:
name – The name of the provider
priority – (optional) The priority of the provider while searching a product. Lower value means lower priority. (Default: 0)
roles – The roles of the provider (e.g. “host”, “producer”, “licensor”, “processor”)
description – (optional) A short description of the provider
url – URL to the webpage representing the provider
api – (optional) The configuration of a plugin of type Api
search – (optional) The configuration of a plugin of type Search
products – (optional) The collections supported by the provider
download – (optional) The configuration of a plugin of type Download
auth – (optional) The configuration of a plugin of type Authentication
search_auth – (optional) The configuration of a plugin of type Authentication for search
download_auth – (optional) The configuration of a plugin of type Authentication for download
kwargs – Additional configuration variables for this provider
- classmethod from_mapping(mapping)[source]#
Build a
ProviderConfigfrom a mapping
- classmethod from_yaml(loader, node)[source]#
Build a
ProviderConfigfrom Yaml
- static validate(config_keys)[source]#
Validate a
ProviderConfig
- with_name(new_name)[source]#
Create a copy of this
ProviderConfigwith a different name.- Parameters:
new_name (
str) – The new name for the provider config.- Return type:
Self- Returns:
A new ProviderConfig instance with the updated name.
- yaml_loader#
alias of
Loader
- class eodag.api.provider.ProvidersDict(dict=None, /, **kwargs)[source]#
A dictionary-like collection of
Providerobjects, keyed by provider name.- Parameters:
providers – Initial providers to populate the dictionary.
- property configs: dict[str, ProviderConfig]#
Dictionary of provider configs keyed by provider name.
- Returns:
Dictionary mapping provider name to
ProviderConfig.
- delete_collection(provider, collection)[source]#
Delete a collection from a provider.
- Parameters:
- Raises:
UnsupportedProvider – If the provider or product is not found.
- Return type:
- filter(q=None)[source]#
Return providers whose name, group, description, URL or collection matches the free-text query.
Supports logical operators with parenthesis (
AND/OR/NOT), quoted phrases ("exact phrase"),*and?wildcards.If no query is provided, returns all providers.
- Parameters:
q (
str|None, default:None) – Free-text parameter to filter providers. If None, returns all providers.- Return type:
- Returns:
matching Provider objects in a
ProvidersDict.
Example#
>>> from eodag.api.provider import ProvidersDict, Provider >>> providers = ProvidersDict() >>> providers['test1'] = Provider({ ... 'name': 'test1', ... 'description': 'Satellite data', ... 'search': {'type': 'StacSearch'} ... }) >>> providers['test2'] = Provider({ ... 'name': 'test2', ... 'description': 'Weather data', ... 'search': {'type': 'StacSearch'} ... }) >>> # Filter by description content >>> providers.filter('Satellite') ProvidersDict(['test1']) >>> # Filter with logical operators >>> providers['test3'] = Provider({ ... 'name': 'test3', ... 'description': 'Satellite weather data', ... 'search': {'type': 'StacSearch'} ... }) >>> providers.filter('Satellite AND weather') ProvidersDict(['test3']) >>> # Get all providers when no filter >>> len(providers.filter()) 3
- filter_by_name_or_group(name_or_group=None)[source]#
Yield providers whose name or group matches the given
name_or_group.If
name_or_groupisNone, yields all providers.- Parameters:
name_or_group (
str|None, default:None) – The provider name or group to filter by. If None, yields all providers.- Return type:
- Returns:
Iterator of matching
Providerobjects.
Example#
>>> from eodag.api.provider import ProvidersDict, Provider >>> providers = ProvidersDict() >>> providers['sentinel'] = Provider({'name': 'sentinel', 'group': 'esa', 'search': {'type': 'StacSearch'}}) >>> providers['landsat'] = Provider({'name': 'landsat', 'group': 'usgs', 'search': {'type': 'StacSearch'}}) >>> providers['modis'] = Provider({'name': 'modis', 'group': 'nasa', 'search': {'type': 'StacSearch'}}) >>> >>> # Filter by exact provider name >>> list(p.name for p in providers.filter_by_name_or_group('sentinel')) ['sentinel'] >>> >>> # Filter by group (case-insensitive) >>> list(p.name for p in providers.filter_by_name_or_group('ESA')) ['sentinel'] >>> >>> # Get all providers when no filter >>> len(list(providers.filter_by_name_or_group())) 3
- classmethod from_configs(configs)[source]#
Build a ProvidersDict from a configuration mapping.
- Parameters:
configs (
Mapping[str,ProviderConfig|dict[str,Any]]) – A dictionary mapping provider names to configuration dicts orProviderConfiginstances.- Return type:
Self- Returns:
An instance of
ProvidersDictpopulated with the given configurations.
- get_config(provider)[source]#
Get a
ProviderConfigfrom provider name.- Parameters:
provider (
str) – The provider name.- Return type:
- Returns:
The
ProviderConfigif found, otherwise None.
- property groups: list[str]#
List of provider groups if exist or names.
- Returns:
List of provider groups if exist or names.
- property priorities: dict[str, int]#
Dictionary of provider priorities keyed by provider name.
- Returns:
Dictionary mapping provider name to priority integer.
- update_from_config_file(file_path)[source]#
Override provider configurations with values loaded from a YAML file.