Projects

Envless.projects.iterate

Stream projects one row at a time

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

Yields projects individually, fetching the next page only once the current one is drained. This keeps memory flat over large workspaces and lets you stop early.

Give it a block to walk every item, or leave the block off for an Enumerator you can stop early, such as with first(10). No request is issued until the first iteration, and breaking out of the loop leaves the remaining pages unfetched.

Example

ruby
require "envless/sdk"

Envless.projects.iterate(product: "billing") do |project|
  puts project[:slug]
end

Parameters

ParameterTypeRequiredDescription
product:String | SymbolNoProduct slug or product uniqueId to restrict the stream to one product.
limit:IntegerNoPage size fetched behind the scenes, clamped to 100.
offset:IntegerNoRow to start streaming from.
search:String | SymbolNoCase insensitive substring match against project name and slug.
order:"name" | "asc" | "desc"NoDefaults to name, which sorts A to Z. Pass asc for oldest first or desc for newest first on createdAt.
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 project_resource values until the pages run out.

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

  • The offset advances by the number of rows actually received, so projects created mid walk can shift the window.
  • Use this rather than list_all when you only need the first match, since it stops fetching the moment you break.

Required scopes

projects:read

Underlying endpoint

GET /projects

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

In TypeScript

envless.projects.iterate()

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