def iterate(
project: str,
environment: str,
*,
limit: int | None = None,
offset: int | None = None,
product: str | None = None,
timeout: float | None = None,
) -> Iterator[VersionResource]def iterate(
project: str,
environment: str,
*,
limit: int | None = None,
offset: int | None = None,
product: str | None = None,
timeout: float | None = None,
) -> AsyncIterator[VersionResource]Yields versions individually, fetching the next page only once the current one is drained. This is the right shape for scanning history for a particular label or note, because it stops fetching the moment you break.
It returns an iterator, so put the call straight into a for loop, or an async for loop on AsyncEnvless. No request goes out until the first iteration.
Example
from envless import envless
for version in envless.versions.iterate('api', 'production'):
if 'migration' in (version['note'] or ''):
print(version['id'])
breakimport asyncio
from envless import AsyncEnvless
async def main() -> None:
async with AsyncEnvless() as envless:
async for version in envless.versions.iterate('api', 'production'):
if 'migration' in (version['note'] or ''):
print(version['id'])
break
asyncio.run(main())Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
project | str | Yes | Project slug or project uniqueId. |
environment | str | Yes | Environment slug, since an environment uniqueId will not resolve here. |
product | str | No | Product slug used to disambiguate a project slug shared across products. |
limit | int | No | Page size fetched behind the scenes, clamped to 100. |
offset | int | No | Row to start streaming from. |
timeout | float | No | Seconds each attempt of this call may take, the response body included, before it raises EnvlessNetworkError with is_timeout set. Overrides the client's timeout for this call, and 0 turns the limit off. |
Returns
An iterator that yields VersionResource values until the pages run out.
Reads the versions collection. list returns one page as a dict with items and pagination, list_all collects every page into a list, and iterate yields one item at a time, fetching the next page only when the loop reaches it. On AsyncEnvless, iterate is an async iterator for async for.
Worth knowing
- The offset advances by the number of rows actually received, so publishing a version mid walk shifts the window and can repeat a row.
- On the Free plan only the latest version is listed; the older ones are stored but need Dev or above to be read, and reading one there is 402
plan.upgrade_required.
Required scopes
versions:read
Underlying endpoint
GET /projects/{slug}/environments/{environmentSlug}/versions
Request and response schema, every error code, and a live playground.
In TypeScript
envless.versions.iterate()
The same method in @goenvless/sdk, with the same request, retries and errors.