Workspaces

Envless.workspaces.iterate

Stream workspaces one at a time

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

Returns an Enumerator that yields workspaces individually and fetches the next page only when the current one runs out. Breaking out of the loop stops the requests, which makes this the cheapest way to find one workspace by slug or plan.

The Enumerator defaults to the maximum page size of 100 and caps anything larger, so limit only ever makes pages smaller. Each page is a separate request, so a membership added while you are mid walk may or may not appear.

Example

ruby
require "envless/sdk"

Envless.workspaces.iterate do |workspace|
  if workspace[:slug] == "billing"
    puts "#{workspace[:id]} #{workspace[:plan]}"
    break
  end
end

Parameters

ParameterTypeRequiredDescription
limit:IntegerNoPage size per request, capped at 100 and defaulting to 100.
offset:IntegerNoRow the walk starts at, advancing by the number of items each page returns.
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

Enumerator[workspace_resource, nil] yielding one workspace per step.

Reads the workspaces 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 Enumerator is lazy, so no request is sent until you start consuming it.

Required scopes

workspace:read

Underlying endpoint

GET /workspaces

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

In TypeScript

envless.workspaces.iterate()

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