Source code for eodag.plugins.apis.base

# -*- coding: utf-8 -*-
# Copyright 2018, CS GROUP - France, https://www.csgroup.eu/
#
# This file is part of EODAG project
#     https://www.github.com/CS-SI/EODAG
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import annotations

from eodag.plugins.download.base import Download
from eodag.plugins.search.base import Search


[docs] class Api(Search, Download): """Plugins API Base plugin An Api plugin inherit the methods from Search and Download plugins. There are three methods that it must implement: - ``query``: search for products - ``download``: download a single :class:`~eodag.api.product._product.EOProduct` - ``download_all``: download multiple products from a :class:`~eodag.api.search_result.SearchResult` The download methods must: - download data in the ``outputs_prefix`` folder defined in the plugin's configuration or passed through kwargs - extract products from their archive (if relevant) if ``extract`` is set to True (True by default) - save a product in an archive/directory (in ``outputs_prefix``) whose name must be the product's ``title`` property - update the product's ``location`` attribute once its data is downloaded (and eventually after it's extracted) to the product's location given as a file URI (e.g. 'file:///tmp/product_folder' on Linux or 'file:///C:/Users/username/AppData/LOcal/Temp' on Windows) - save a *record* file in the directory ``outputs_prefix/.downloaded`` whose name is built on the MD5 hash of the product's ``product_type`` and ``properties['id']`` attributes (``hashlib.md5((product.product_type+"-"+product.properties['id']).encode("utf-8")).hexdigest()``) and whose content is the product's ``remote_location`` attribute itself. - not try to download a product whose ``location`` attribute already points to an existing file/directory - not try to download a product if its *record* file exists as long as the expected product's file/directory. If the *record* file only is found, it must be deleted (it certainly indicates that the download didn't complete) """