Versions

Envless.versions.iterate

Stream versions one row at a time

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

Yields 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

ruby
require "envless/sdk"

Envless.versions.iterate("api", "production") do |version|
  next unless version[:note]&.include?("migration")

  puts version[:id]
  break
end

Parameters

ParameterTypeRequiredDescription
projectStringYesProject slug or project uniqueId.
environmentStringYesEnvironment slug, since an environment uniqueId will not resolve here.
product:String | SymbolNoProduct slug used to disambiguate a project slug shared across products.
limit:IntegerNoPage size fetched behind the scenes, clamped to 100.
offset:IntegerNoRow to start streaming from.
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 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.