def iterate(
project,
environment,
limit: nil,
offset: nil,
product: nil,
timeout: nil,
&block
)def iterate: (
String project,
String environment,
?limit: Integer?,
?offset: Integer?,
?product: (String | Symbol)?,
?timeout: seconds?
) -> Enumerator[variable_resource, nil]
| (
String project,
String environment,
?limit: Integer?,
?offset: Integer?,
?product: (String | Symbol)?,
?timeout: seconds?
) { (variable_resource) -> void } -> nilReturns an Enumerator that yields variables one at a time and fetches the next page only when the current one is exhausted. Nothing is requested until you start consuming it, so calling it without a block or a loop does no work.
Breaking out of the loop ends the walk and no further requests are made. The Enumerator advances offset by the number of items it actually received, so a concurrent write between pages can shift rows and make the walk skip or repeat one. When you need a consistent picture, read with list_all and send every row to apply as the baseline, which turns a concurrent change into a 409 instead of a silent skip.
Example
require "envless/sdk"
Envless.variables.iterate("api", "production") do |variable|
puts "#{variable[:name]} #{variable[:updatedAt]}"
endParameters
| Parameter | Type | Required | Description |
|---|---|---|---|
project | String | Yes | Project slug the environment belongs to. |
environment | String | Yes | Environment slug to read variables from. |
limit: | Integer | No | Page size for each underlying request, clamped to 100. |
offset: | Integer | No | Offset the walk starts from, defaults to 0. |
product: | String | Symbol | No | Product slug, needed when the project slug is not unique in the workspace. |
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
Enumerator[variable_resource, nil] yielding one variable per iteration.
Reads the variables 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
- Memory stays flat at one page, which is the reason to pick this over
list_allfor large environments.
Required scopes
variables:read
Underlying endpoint
GET /projects/{slug}/environments/{environmentSlug}/variables
Request and response schema, every error code, and a live playground.
In TypeScript
envless.variables.iterate()
The same method in @goenvless/sdk, with the same request, retries and errors.