def iterate(
limit: nil,
offset: nil,
search: nil,
order: nil,
product: nil,
timeout: nil,
&block
)def iterate: (
?limit: Integer?,
?offset: Integer?,
?search: (String | Symbol)?,
?order: ("name" | "asc" | "desc")?,
?product: (String | Symbol)?,
?timeout: seconds?
) -> Enumerator[project_resource, nil]
| (
?limit: Integer?,
?offset: Integer?,
?search: (String | Symbol)?,
?order: ("name" | "asc" | "desc")?,
?product: (String | Symbol)?,
?timeout: seconds?
) { (project_resource) -> void } -> nilYields 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
require "envless/sdk"
Envless.projects.iterate(product: "billing") do |project|
puts project[:slug]
endParameters
| Parameter | Type | Required | Description |
|---|---|---|---|
product: | String | Symbol | No | Product slug or product uniqueId to restrict the stream to one product. |
limit: | Integer | No | Page size fetched behind the scenes, clamped to 100. |
offset: | Integer | No | Row to start streaming from. |
search: | String | Symbol | No | Case insensitive substring match against project name and slug. |
order: | "name" | "asc" | "desc" | No | Defaults to name, which sorts A to Z. Pass asc for oldest first or desc for newest first on createdAt. |
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 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_allwhen 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.