Versions

Envless.versions.iterate_entries

Stream version entries one at a time

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

Yields version entries individually, fetching the next page only once the current one is drained. Use it to rotate a large environment without holding its whole encrypted history in memory.

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). reencrypt_entries rewrites only value and defaultValue and never adds or removes rows, so writing back mid stream does not shift the window. Publishing a version mid walk does shift it, because the new entries land in the same flat set.

Example

ruby
require "envless/sdk"

entries = Envless.versions.iterate_entries("api", "production")
batch = entries.filter_map { |entry| entry[:id] if entry[:value] }

puts batch.size

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_entry_resource values until the pages run out.

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

  • Buffer the yielded entries and write them back in batches. One reencrypt_entries call per entry works but costs a request each.
  • Freeze publishing while a rotation walk is in flight, otherwise a new version adds entries encrypted under the old key after you have already passed that offset.

Required scopes

versions:read and variables:read

Underlying endpoint

GET /projects/{slug}/environments/{environmentSlug}/versions/entries

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

In TypeScript

envless.versions.iterateEntries()

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