swh.lister.puppet.lister module#
- class swh.lister.puppet.lister.PuppetListerState(last_listing_date: datetime | None = None)[source]#
Bases:
object
Store lister state for incremental mode operations
- class swh.lister.puppet.lister.PuppetLister(scheduler: SchedulerInterface, url: str = 'https://forgeapi.puppet.com/', instance: str = 'puppet', 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
[PuppetListerState
,List
[Dict
[str
,Any
]]]The Puppet lister list origins from ‘Puppet Forge’
- VISIT_TYPE = 'puppet'#
- INSTANCE = 'puppet'#
- BASE_URL = 'https://forgeapi.puppet.com/'#
- state_from_dict(d: Dict[str, Any]) PuppetListerState [source]#
Convert the state stored in the scheduler backend (as a dict), to the concrete StateType for this lister.
- state_to_dict(state: PuppetListerState) 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.
- get_pages() Iterator[List[Dict[str, Any]]] [source]#
Yield an iterator which returns ‘page’
It request the http api endpoint to get a paginated results of modules, and retrieve a next url. It ends when next json value is null.
Open Api specification for getModules endpoint: https://forgeapi.puppet.com/#tag/Module-Operations/operation/getModules
- get_origins_from_page(page: List[Dict[str, Any]]) Iterator[ListedOrigin] [source]#
Iterate on all pages and yield ListedOrigin instances.
- finalize() None [source]#
Custom hook to finalize the lister state before returning from the main loop.
This method must set
updated
if 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.