Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/interface.py
# Copyright (C) 2015-2020 The Software Heritage developers | # Copyright (C) 2015-2020 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
from typing import Any, Dict, List, Optional | from typing import Any, Dict, List, Optional | ||||
from swh.core.api import remote_api_endpoint | from swh.core.api import remote_api_endpoint | ||||
def deprecated(f): | |||||
f.deprecated_endpoint = True | |||||
return f | |||||
class StorageInterface: | class StorageInterface: | ||||
@remote_api_endpoint('check_config') | @remote_api_endpoint('check_config') | ||||
def check_config(self, *, check_write): | def check_config(self, *, check_write): | ||||
"""Check that the storage is configured and ready to go.""" | """Check that the storage is configured and ready to go.""" | ||||
... | ... | ||||
@remote_api_endpoint('content/add') | @remote_api_endpoint('content/add') | ||||
def content_add(self, content): | def content_add(self, content): | ||||
▲ Show 20 Lines • Show All 106 Lines • ▼ Show 20 Lines | def content_get(self, content): | ||||
Raises: | Raises: | ||||
ValueError in case of too much contents are required. | ValueError in case of too much contents are required. | ||||
cf. BULK_BLOCK_CONTENT_LEN_MAX | cf. BULK_BLOCK_CONTENT_LEN_MAX | ||||
""" | """ | ||||
... | ... | ||||
@deprecated | |||||
@remote_api_endpoint('content/range') | @remote_api_endpoint('content/range') | ||||
def content_get_range(self, start, end, limit=1000): | def content_get_range(self, start, end, limit=1000): | ||||
"""Retrieve contents within range [start, end] bound by limit. | """Retrieve contents within range [start, end] bound by limit. | ||||
Note that this function may return more than one blob per hash. The | Note that this function may return more than one blob per hash. The | ||||
limit is enforced with multiplicity (ie. two blobs with the same hash | limit is enforced with multiplicity (ie. two blobs with the same hash | ||||
will count twice toward the limit). | will count twice toward the limit). | ||||
▲ Show 20 Lines • Show All 782 Lines • ▼ Show 20 Lines | def origin_get_by_sha1(self, sha1s): | ||||
Yields: | Yields: | ||||
dicts containing origin information as returned | dicts containing origin information as returned | ||||
by :meth:`swh.storage.storage.Storage.origin_get`, or None if an | by :meth:`swh.storage.storage.Storage.origin_get`, or None if an | ||||
origin matching the sha1 is not found. | origin matching the sha1 is not found. | ||||
""" | """ | ||||
... | ... | ||||
@deprecated | |||||
@remote_api_endpoint('origin/get_range') | @remote_api_endpoint('origin/get_range') | ||||
def origin_get_range(self, origin_from=1, origin_count=100): | def origin_get_range(self, origin_from=1, origin_count=100): | ||||
"""Retrieve ``origin_count`` origins whose ids are greater | """Retrieve ``origin_count`` origins whose ids are greater | ||||
or equal than ``origin_from``. | or equal than ``origin_from``. | ||||
Origins are sorted by id before retrieving them. | Origins are sorted by id before retrieving them. | ||||
Args: | Args: | ||||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | def origin_search(self, url_pattern, offset=0, limit=50, | ||||
with_visit (bool): if True, filter out origins with no visit | with_visit (bool): if True, filter out origins with no visit | ||||
Yields: | Yields: | ||||
dicts containing origin information as returned | dicts containing origin information as returned | ||||
by :meth:`swh.storage.storage.Storage.origin_get`. | by :meth:`swh.storage.storage.Storage.origin_get`. | ||||
""" | """ | ||||
... | ... | ||||
@deprecated | |||||
@remote_api_endpoint('origin/count') | @remote_api_endpoint('origin/count') | ||||
def origin_count(self, url_pattern, regexp=False, | def origin_count(self, url_pattern, regexp=False, | ||||
with_visit=False): | with_visit=False): | ||||
"""Count origins whose urls contain a provided string pattern | """Count origins whose urls contain a provided string pattern | ||||
or match a provided regular expression. | or match a provided regular expression. | ||||
The pattern search in origin urls is performed in a case insensitive | The pattern search in origin urls is performed in a case insensitive | ||||
way. | way. | ||||
▲ Show 20 Lines • Show All 169 Lines • ▼ Show 20 Lines | def metadata_provider_get_by(self, provider): | ||||
* provider_url: Its URL | * provider_url: Its URL | ||||
Returns: | Returns: | ||||
dict: same as `metadata_provider_add`; | dict: same as `metadata_provider_add`; | ||||
or None if it does not exist. | or None if it does not exist. | ||||
""" | """ | ||||
... | ... | ||||
@deprecated | |||||
anlambert: I think we can later safely remove those endpoints from the storage interface as only the… | |||||
vlorentzAuthorUnsubmitted Done Inline Actionswill do vlorentz: will do | |||||
@remote_api_endpoint('algos/diff_directories') | @remote_api_endpoint('algos/diff_directories') | ||||
def diff_directories(self, from_dir, to_dir, track_renaming=False): | def diff_directories(self, from_dir, to_dir, track_renaming=False): | ||||
"""Compute the list of file changes introduced between two arbitrary | """Compute the list of file changes introduced between two arbitrary | ||||
directories (insertion / deletion / modification / renaming of files). | directories (insertion / deletion / modification / renaming of files). | ||||
Args: | Args: | ||||
from_dir (bytes): identifier of the directory to compare from | from_dir (bytes): identifier of the directory to compare from | ||||
to_dir (bytes): identifier of the directory to compare to | to_dir (bytes): identifier of the directory to compare to | ||||
track_renaming (bool): whether or not to track files renaming | track_renaming (bool): whether or not to track files renaming | ||||
Returns: | Returns: | ||||
A list of dict describing the introduced file changes | A list of dict describing the introduced file changes | ||||
(see :func:`swh.storage.algos.diff.diff_directories` | (see :func:`swh.storage.algos.diff.diff_directories` | ||||
for more details). | for more details). | ||||
""" | """ | ||||
... | ... | ||||
@deprecated | |||||
@remote_api_endpoint('algos/diff_revisions') | @remote_api_endpoint('algos/diff_revisions') | ||||
def diff_revisions(self, from_rev, to_rev, track_renaming=False): | def diff_revisions(self, from_rev, to_rev, track_renaming=False): | ||||
"""Compute the list of file changes introduced between two arbitrary | """Compute the list of file changes introduced between two arbitrary | ||||
revisions (insertion / deletion / modification / renaming of files). | revisions (insertion / deletion / modification / renaming of files). | ||||
Args: | Args: | ||||
from_rev (bytes): identifier of the revision to compare from | from_rev (bytes): identifier of the revision to compare from | ||||
to_rev (bytes): identifier of the revision to compare to | to_rev (bytes): identifier of the revision to compare to | ||||
track_renaming (bool): whether or not to track files renaming | track_renaming (bool): whether or not to track files renaming | ||||
Returns: | Returns: | ||||
A list of dict describing the introduced file changes | A list of dict describing the introduced file changes | ||||
(see :func:`swh.storage.algos.diff.diff_directories` | (see :func:`swh.storage.algos.diff.diff_directories` | ||||
for more details). | for more details). | ||||
""" | """ | ||||
... | ... | ||||
@deprecated | |||||
@remote_api_endpoint('algos/diff_revision') | @remote_api_endpoint('algos/diff_revision') | ||||
def diff_revision(self, revision, track_renaming=False): | def diff_revision(self, revision, track_renaming=False): | ||||
"""Compute the list of file changes introduced by a specific revision | """Compute the list of file changes introduced by a specific revision | ||||
(insertion / deletion / modification / renaming of files) by comparing | (insertion / deletion / modification / renaming of files) by comparing | ||||
it against its first parent. | it against its first parent. | ||||
Args: | Args: | ||||
revision (bytes): identifier of the revision from which to | revision (bytes): identifier of the revision from which to | ||||
Show All 9 Lines |
I think we can later safely remove those endpoints from the storage interface as only the webapp use diff features and it now relies on the function located in swh.storage.algos.diff instead of those storage methods.