Variables

Envless.variables.list_all

Collect every variable in an environment

def list_all(
  project,
  environment,
  limit: nil,
  offset: nil,
  product: nil,
  timeout: nil
)

Walks every page and returns a single array of the live variables in an environment. Requests run one after another until hasMore turns false, so a large environment costs one round trip per 100 variables and the entire set is held in memory at once.

limit: is the page size here, not a total cap, and it is clamped to 100. offset: sets where the walk starts, so a non-zero value silently drops the variables before it.

There is no partial result. An error midway through the walk discards the pages already fetched, so budget for the whole thing succeeding or nothing.

Example

ruby
require "envless/sdk"

variables = Envless.variables.list_all("api", "production")

puts variables.size

Parameters

ParameterTypeRequiredDescription
projectStringYesProject slug the environment belongs to.
environmentStringYesEnvironment slug to read variables from.
limit:IntegerNoPage size for each underlying request, clamped to 100.
offset:IntegerNoOffset the walk starts from, defaults to 0.
product:String | SymbolNoProduct slug, needed when the project slug is not unique in the workspace.
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

Array[variable_resource] with every live variable in the environment, values still ciphertext.

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

  • Use this to build the baseline for apply, since the drift check needs every live variable and not just a page.

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.listAll()

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