def list_all(
limit: nil,
offset: nil,
search: nil,
sort_by: nil,
timeout: nil
)def list_all: (
?limit: Integer?,
?offset: Integer?,
?search: (String | Symbol)?,
?sort_by: ("updated" | "created" | "name")?,
?timeout: seconds?
) -> Array[role_resource]Walks every page and returns the flattened array. Because a workspace is capped at 25 custom roles, this is a single request in practice and is the convenient way to build a name to id map before inviting members.
The trap is limit:: it sets the page size used while walking, not a cap on how many roles come back. Asking for a limit of 5 still returns every role, in more round trips. System roles lead the array, so do not rely on index position to find a custom role.
Example
require "envless/sdk"
roles = Envless.roles.list_all
viewer = roles.find { |role| role[:systemKey] == "viewer" }
puts viewer&.fetch(:id)Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
limit: | Integer | No | Page size used while walking, clamped to 100. |
offset: | Integer | No | Row to start the walk from. |
search: | String | Symbol | No | Case insensitive substring match against role name and description. |
sort_by: | "updated" | "created" | "name" | No | Order within each group: name (the default) is A to Z, updated and created are newest first. System roles always come first. |
timeout: | Integer | Float | Rational | No | Seconds 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[role_resource] holding every role in the workspace, system roles first.
Reads the roles 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
- Page size defaults to the API maximum of 100 and is clamped there, so a larger limit buys nothing.
- Match system roles on
systemKey, which isowner,adminorviewer, rather than onname, since names are display text.
Required scopes
roles:read
Underlying endpoint
GET /roles
Request and response schema, every error code, and a live playground.
In TypeScript
envless.roles.listAll()
The same method in @goenvless/sdk, with the same request, retries and errors.