swh.lister.bitbucket.lister module#
- class swh.lister.bitbucket.lister.BitbucketListerState(last_repo_cdate: datetime | None = None)[source]#
- Bases: - object- State of Bitbucket lister 
- class swh.lister.bitbucket.lister.BitbucketLister(scheduler: SchedulerInterface, url: str = 'https://api.bitbucket.org/2.0/repositories', instance: str = 'bitbucket', page_size: int = 1000, incremental: bool = True, credentials: Dict[str, Dict[str, List[Dict[str, str]]]] | None = None, max_origins_per_page: int | None = None, max_pages: int | None = None, enable_origins: bool = True)[source]#
- Bases: - Lister[- BitbucketListerState,- List[- Dict[- str,- Any]]]- List origins from Bitbucket using its API. - Bitbucket API has the following rate-limit configuration: - 60 requests per hour for anonymous users 
- 1000 requests per hour for authenticated users 
 - The lister is working in anonymous mode by default but Bitbucket account credentials can be provided to perform authenticated requests. - INSTANCE = 'bitbucket'#
 - API_URL = 'https://api.bitbucket.org/2.0/repositories'#
 - state_from_dict(d: Dict[str, Any]) BitbucketListerState[source]#
- Convert the state stored in the scheduler backend (as a dict), to the concrete StateType for this lister. 
 - state_to_dict(state: BitbucketListerState) Dict[str, Any][source]#
- Convert the StateType for this lister to its serialization as dict for storage in the scheduler. - Values must be JSON-compatible as that’s what the backend database expects. 
 - set_credentials(username: str | None, password: str | None) None[source]#
- Set basic authentication headers with given credentials. 
 - get_pages() Iterator[List[Dict[str, Any]]][source]#
- Retrieve a list of pages of listed results. This is the main loop of the lister. - Returns:
- an iterator of raw pages fetched from the platform currently being listed. 
 
 - get_origins_from_page(page: List[Dict[str, Any]]) Iterator[ListedOrigin][source]#
- Convert a page of Bitbucket repositories into a list of ListedOrigins. 
 - commit_page(page: List[Dict[str, Any]]) None[source]#
- Update the currently stored state using the latest listed page. 
 - finalize() None[source]#
- Custom hook to finalize the lister state before returning from the main loop. - This method must set - updatedif the lister has done some work.- If relevant, this method can use :meth`get_state_from_scheduler` to merge the current lister state with the one from the scheduler backend, reducing the risk of race conditions if we’re running concurrent listings. - This method is called in a finally block, which means it will also run when the lister fails.