Environments

envless.environments.iterate()

Stream environments page by page

def iterate(
    project: str,
    *,
    limit: int | None = None,
    offset: int | None = None,
    search: str | None = None,
    order: str | None = None,
    product: str | None = None,
    timeout: float | None = None,
) -> Iterator[EnvironmentSummaryResource]

Yields environments one at a time and fetches the next page only when the current one is exhausted, so breaking out of the loop stops the remaining requests. Page size follows limit up to 100 and offset picks the starting row.

The walk advances its offset by the number of rows it just consumed, so creating or deleting environments in the same project mid-loop can skip a row or hand you one twice. Neither this nor list_all is a snapshot: both walk offsets, so a create or delete between pages can shift a row. Every yielded value is the summary shape, which carries exposed and updatedAt alongside the identifiers.

Example

from envless import envless

for environment in envless.environments.iterate('api'):
    print(environment['slug'])

Parameters

ParameterTypeRequiredDescription
projectstrYesProject slug or uniqueId that owns the environments.
productstrNoProduct slug that disambiguates an ambiguous project slug.
limitintNoPage size used for each underlying request, capped at 100.
offsetintNoRow to start the walk from.
searchstrNoCase insensitive substring match on the environment name or slug.
orderstrNoasc or desc sorts by creation time, oldest or newest first. Anything else, or nothing, sorts by name.
timeoutfloatNoSeconds 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 EnvironmentSummaryResource values, one per environment.

Reads the environments 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

  • This returns a generator: no request is sent until the loop pulls the first value.

Required scopes

environments:read

Underlying endpoint

GET /projects/{slug}/environments

Request and response schema, every error code, and a live playground.

In TypeScript

envless.environments.iterate()

The same method in @goenvless/sdk, with the same request, retries and errors.