Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/interface.py
Show First 20 Lines • Show All 865 Lines • ▼ Show 20 Lines | class StorageInterface: | ||||
def origin_visit_get_latest( | def origin_visit_get_latest( | ||||
self, | self, | ||||
origin: str, | origin: str, | ||||
allowed_statuses: Optional[List[str]] = None, | allowed_statuses: Optional[List[str]] = None, | ||||
require_snapshot: bool = False, | require_snapshot: bool = False, | ||||
) -> Optional[Dict[str, Any]]: | ) -> Optional[Dict[str, Any]]: | ||||
"""Get the latest origin visit for the given origin, optionally | """Get the latest origin visit for the given origin, optionally | ||||
looking only for those with one of the given allowed_statuses | looking only for those with one of the given allowed_statuses | ||||
or for those with a known snapshot. | or for those with a snapshot. | ||||
Args: | Args: | ||||
origin: origin URL | origin: origin URL | ||||
allowed_statuses: list of visit statuses considered | allowed_statuses: list of visit statuses considered | ||||
to find the latest visit. For instance, | to find the latest visit. For instance, | ||||
``allowed_statuses=['full']`` will only consider visits that | ``allowed_statuses=['full']`` will only consider visits that | ||||
have successfully run to completion. | have successfully run to completion. | ||||
require_snapshot: If True, only a visit with a snapshot | require_snapshot: If True, only a visit with a snapshot | ||||
will be returned. | will be returned. | ||||
Returns: | Returns: | ||||
dict: a dict with the following keys: | dict: a dict with the following keys: | ||||
- **origin**: the URL of the origin | - **origin**: the URL of the origin | ||||
- **visit**: origin visit id | - **visit**: origin visit id | ||||
- **type**: type of loader used for the visit | - **type**: type of loader used for the visit | ||||
- **date**: timestamp of such visit | - **date**: timestamp of such visit | ||||
- **status**: Visit's new status | - **status**: Visit's new status | ||||
- **metadata**: Data associated to the visit | - **metadata**: Data associated to the visit | ||||
- **snapshot** (Optional[sha1_git]): identifier of the snapshot | - **snapshot** (Optional[sha1_git]): identifier of the snapshot | ||||
associated to the visit | associated to the visit | ||||
""" | """ | ||||
... | ... | ||||
@remote_api_endpoint("origin/visit_status/get_latest") | |||||
def origin_visit_status_get_latest( | |||||
self, | |||||
origin_url: str, | |||||
visit: int, | |||||
allowed_statuses: Optional[List[str]] = None, | |||||
require_snapshot: bool = False, | |||||
) -> Optional[OriginVisitStatus]: | |||||
"""Get the latest origin visit status for the given origin visit, optionally | |||||
looking only for those with one of the given allowed_statuses or with a | |||||
snapshot. | |||||
Args: | |||||
origin: origin URL | |||||
allowed_statuses: list of visit statuses considered to find the latest | |||||
visit. Possible values are {created, ongoing, partial, full}. For | |||||
vlorentz: it should list all the possible statuses. | |||||
instance, ``allowed_statuses=['full']`` will only consider visits that | |||||
have successfully run to completion. | |||||
require_snapshot: If True, only a visit with a snapshot | |||||
will be returned. | |||||
Returns: | |||||
The OriginVisitStatus matching the criteria | |||||
""" | |||||
... | |||||
@remote_api_endpoint("origin/visit/get_random") | @remote_api_endpoint("origin/visit/get_random") | ||||
def origin_visit_get_random(self, type: str) -> Optional[Dict[str, Any]]: | def origin_visit_get_random(self, type: str) -> Optional[Dict[str, Any]]: | ||||
"""Randomly select one successful origin visit with <type> | """Randomly select one successful origin visit with <type> | ||||
made in the last 3 months. | made in the last 3 months. | ||||
Returns: | Returns: | ||||
dict representing an origin visit, in the same format as | dict representing an origin visit, in the same format as | ||||
:py:meth:`origin_visit_get`. | :py:meth:`origin_visit_get`. | ||||
▲ Show 20 Lines • Show All 384 Lines • Show Last 20 Lines |
it should list all the possible statuses.