def iterate(
*,
limit: int | None = None,
offset: int | None = None,
timeout: float | None = None,
) -> Iterator[WorkspaceResource]def iterate(
*,
limit: int | None = None,
offset: int | None = None,
timeout: float | None = None,
) -> AsyncIterator[WorkspaceResource]Returns an iterator that yields workspaces individually and fetches the next page only when the current one runs out. Breaking out of the loop stops the requests, which makes this the cheapest way to find one workspace by slug or plan.
The generator defaults to the maximum page size of 100 and caps anything larger, so limit only ever makes pages smaller. Each page is a separate request, so a membership added while you are mid walk may or may not appear.
Example
from envless import envless
for workspace in envless.workspaces.iterate():
if workspace['slug'] == 'billing':
print(workspace['id'], workspace['plan'])
breakimport asyncio
from envless import AsyncEnvless
async def main() -> None:
async with AsyncEnvless() as envless:
async for workspace in envless.workspaces.iterate():
if workspace['slug'] == 'billing':
print(workspace['id'], workspace['plan'])
break
asyncio.run(main())Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
limit | int | No | Page size per request, capped at 100 and defaulting to 100. |
offset | int | No | Row the walk starts at, advancing by the number of items each page returns. |
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
Iterator[WorkspaceResource] yielding one workspace per step.
Reads the workspaces 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 generator is lazy, so no request is sent until you start consuming it.
Required scopes
workspace:read
Underlying endpoint
GET /workspaces
Request and response schema, every error code, and a live playground.
In TypeScript
envless.workspaces.iterate()
The same method in @goenvless/sdk, with the same request, retries and errors.