def iterate(
project,
limit: nil,
offset: nil,
search: nil,
order: nil,
product: nil,
timeout: nil,
&block
)def iterate: (
String project,
?limit: Integer?,
?offset: Integer?,
?search: (String | Symbol)?,
?order: ("name" | "asc" | "desc")?,
?product: (String | Symbol)?,
?timeout: seconds?
) -> Enumerator[environment_summary_resource, nil]
| (
String project,
?limit: Integer?,
?offset: Integer?,
?search: (String | Symbol)?,
?order: ("name" | "asc" | "desc")?,
?product: (String | Symbol)?,
?timeout: seconds?
) { (environment_summary_resource) -> void } -> nilYields 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
require "envless/sdk"
Envless.environments.iterate("api") do |environment|
puts environment[:slug]
endParameters
| Parameter | Type | Required | Description |
|---|---|---|---|
project | String | Yes | Project slug or uniqueId that owns the environments. |
product: | String | Symbol | No | Product slug that disambiguates an ambiguous project slug. |
limit: | Integer | No | Page size used for each underlying request, capped at 100. |
offset: | Integer | No | Row to start the walk from. |
search: | String | Symbol | No | Case insensitive substring match on the environment name or slug. |
order: | "name" | "asc" | "desc" | No | asc or desc sorts by creation time, oldest or newest first. Anything else, or nothing, sorts by name. |
timeout: | Integer | Float | Rational | No | Seconds each attempt of this call may take, redirects and the response body included, before it raises Envless::NetworkError with timeout? set. Overrides the client's timeout for this call, and 0 turns the limit off. |
Returns
An Enumerator that yields environment_summary_resource values, one per environment.
Reads the environments collection. list returns one page as an Envless::Page with items and pagination, list_all collects every page into an array, and iterate yields one item at a time to a block, fetching the next page only when it gets there. Without a block, iterate returns an Enumerator.
Worth knowing
- Without a block this returns an
Enumerator: 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.