Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/interface.py
Show First 20 Lines • Show All 828 Lines • ▼ Show 20 Lines | def origin_visit_upsert(self, visits: Iterable[OriginVisit]) -> None: | ||||
- **status**: Visit's new status | - **status**: Visit's new status | ||||
- **metadata**: Data associated to the visit | - **metadata**: Data associated to the visit | ||||
- **snapshot**: identifier of the snapshot to add to | - **snapshot**: identifier of the snapshot to add to | ||||
the visit | the visit | ||||
""" | """ | ||||
... | ... | ||||
@remote_api_endpoint('origin/visit/get') | @remote_api_endpoint('origin/visit/get') | ||||
def origin_visit_get(self, origin: str, last_visit: Optional[int] = None, | def origin_visit_get( | ||||
limit: Optional[int] = None): | self, origin: str, last_visit: Optional[int] = None, | ||||
limit: Optional[int] = None) -> Iterable[Dict[str, Any]]: | |||||
"""Retrieve all the origin's visit's information. | """Retrieve all the origin's visit's information. | ||||
Args: | Args: | ||||
origin: The visited origin | origin: The visited origin | ||||
last_visit: Starting point from which listing the next visits | last_visit: Starting point from which listing the next visits | ||||
Default to None | Default to None | ||||
limit: Number of results to return from the last visit. | limit: Number of results to return from the last visit. | ||||
Default to None | Default to None | ||||
Yields: | Yields: | ||||
List of visits. | List of visits. | ||||
""" | """ | ||||
... | ... | ||||
@remote_api_endpoint('origin/visit/find_by_date') | @remote_api_endpoint('origin/visit/find_by_date') | ||||
def origin_visit_find_by_date(self, origin, visit_date): | def origin_visit_find_by_date( | ||||
self, origin: str, | |||||
visit_date: datetime.datetime) -> Optional[Dict[str, Any]]: | |||||
"""Retrieves the origin visit whose date is closest to the provided | """Retrieves the origin visit whose date is closest to the provided | ||||
timestamp. | timestamp. | ||||
In case of a tie, the visit with largest id is selected. | In case of a tie, the visit with largest id is selected. | ||||
Args: | Args: | ||||
origin (str): The occurrence's origin (URL). | origin: origin (URL) | ||||
target (datetime): target timestamp | visit_date: expected visit date | ||||
Returns: | Returns: | ||||
A visit. | A visit | ||||
""" | """ | ||||
... | ... | ||||
@remote_api_endpoint('origin/visit/getby') | @remote_api_endpoint('origin/visit/getby') | ||||
def origin_visit_get_by(self, origin, visit): | def origin_visit_get_by( | ||||
self, origin: str, visit: int) -> Optional[Dict[str, Any]]: | |||||
"""Retrieve origin visit's information. | """Retrieve origin visit's information. | ||||
Args: | Args: | ||||
origin: The occurrence's origin (identifier). | origin: origin (URL) | ||||
visit: visit id | |||||
Returns: | Returns: | ||||
The information on that particular (origin, visit) or None if | The information on that particular (origin, visit) or None if | ||||
it does not exist | it does not exist | ||||
""" | """ | ||||
... | ... | ||||
@remote_api_endpoint('origin/visit/get_latest') | @remote_api_endpoint('origin/visit/get_latest') | ||||
def origin_visit_get_latest( | def origin_visit_get_latest( | ||||
self, origin, allowed_statuses=None, require_snapshot=False): | self, origin: str, allowed_statuses: Optional[List[str]] = None, | ||||
require_snapshot: bool = False) -> 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 known snapshot. | ||||
Args: | Args: | ||||
origin (str): the origin's URL | origin: origin URL | ||||
allowed_statuses (list of str): 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 (bool): 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 | ||||
▲ Show 20 Lines • Show All 379 Lines • Show Last 20 Lines |