Members

Envless.members.iterate

Stream workspace members one row at a time

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

Yields members individually and fetches the next page only once the current one is drained. Use it when you want to stop at the first match instead of loading the whole set.

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, and breaking out of the loop leaves the remaining pages unfetched.

Example

ruby
require "envless/sdk"

Envless.members.iterate do |member|
  if member.dig(:user, :email) == "dev@example.com"
    puts "#{member[:id]} #{member.dig(:role, :name)}"
    break
  end
end

Parameters

ParameterTypeRequiredDescription
limit:IntegerNoPage size fetched behind the scenes, clamped to 100.
offset:IntegerNoRow to start streaming from.
search:String | SymbolNoCase insensitive substring match on the member name, email or role name.
role_id:String | SymbolNoOnly members holding this role, by the role id from roles.list.
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 member_resource values until the pages run out.

Reads the members 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 members added mid walk can shift the window.
  • Most workspaces fit inside one page of 100, in which case this makes a single request and ends.

Required scopes

members:read

Underlying endpoint

GET /members

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

In TypeScript

envless.members.iterate()

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