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[version_resource, nil]
| (
String project,
String environment,
?limit: Integer?,
?offset: Integer?,
?product: (String | Symbol)?,
?timeout: seconds?
) { (version_resource) -> void } -> nilYields versions individually, fetching the next page only once the current one is drained. This is the right shape for scanning history for a particular label or note, because it stops fetching the moment you break.
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 goes out until the first iteration.
Example
require "envless/sdk"
Envless.versions.iterate("api", "production") do |version|
next unless version[:note]&.include?("migration")
puts version[:id]
break
endParameters
| Parameter | Type | Required | Description |
|---|---|---|---|
project | String | Yes | Project slug or project uniqueId. |
environment | String | Yes | Environment slug, since an environment uniqueId will not resolve here. |
product: | String | Symbol | No | Product slug used to disambiguate a project slug shared across products. |
limit: | Integer | No | Page size fetched behind the scenes, clamped to 100. |
offset: | Integer | No | Row to start streaming from. |
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 version_resource values until the pages run out.
Reads the versions 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 publishing a version mid walk shifts the window and can repeat a row.
- On the Free plan only the latest version is listed; the older ones are stored but need Dev or above to be read, and reading one there is 402
plan.upgrade_required.
Required scopes
versions:read
Underlying endpoint
GET /projects/{slug}/environments/{environmentSlug}/versions
Request and response schema, every error code, and a live playground.
In TypeScript
envless.versions.iterate()
The same method in @goenvless/sdk, with the same request, retries and errors.