Environments

Envless.environments.iterate

Stream environments page by page

def iterate(
  project,
  limit: nil,
  offset: nil,
  search: nil,
  order: nil,
  product: nil,
  timeout: nil,
  &block
)

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

ruby
require "envless/sdk"

Envless.environments.iterate("api") do |environment|
  puts environment[:slug]
end

Parameters

ParameterTypeRequiredDescription
projectStringYesProject slug or uniqueId that owns the environments.
product:String | SymbolNoProduct slug that disambiguates an ambiguous project slug.
limit:IntegerNoPage size used for each underlying request, capped at 100.
offset:IntegerNoRow to start the walk from.
search:String | SymbolNoCase insensitive substring match on the environment name or slug.
order:"name" | "asc" | "desc"Noasc or desc sorts by creation time, oldest or newest first. Anything else, or nothing, sorts by name.
timeout:Integer | Float | RationalNoSeconds 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.