Products

$envless->products->access->iterate()

Stream member grants one at a time

php
/** @return \Generator<int, ProductAccessEntry, mixed, void> */
public function iterate(
    string $slug,
    ?int $limit = null,
    ?int $offset = null,
    int|float|null $timeout = null,
): \Generator

A Generator over the grants on a product, yielding one entry at a time and requesting the next page only when the current one is exhausted.

Like $envless->products->access->listAll() it yields entries only, so the product isPrivate flag is not reachable from here. Grants added or removed while you iterate can shift the offset window and cause an entry to repeat or be skipped.

Example

php
use Envless\Envless;

$envless = new Envless();

foreach ($envless->products->access->iterate('billing') as $grant) {
    echo $grant['id'], ' ', $grant['user']['email'] ?? '', PHP_EOL;
}

Parameters

ParameterTypeRequiredDescription
$slugstringYesProduct slug, or the product uniqueId when the value is UUID shaped.
$limitintNoPage size for each underlying request, capped at 100.
$offsetintNoRow to start the walk from.
$timeoutint|floatNoSeconds each attempt of this call may take, the response body included, before it throws Envless\Exception\NetworkException with isTimeout() true. Overrides the client's timeout for this call, and 0 turns the limit off.

Returns

An Generator<int, ProductAccessEntry> that yields each grant in turn.

Reads the access collection. list returns one page as an Envless\Result\ProductAccessPage with items and pagination, listAll collects every page into an array, and iterate returns a Generator that yields one item at a time, fetching the next page only when the loop gets there.

Worth knowing

  • Revoking inside the loop mutates the collection you are walking, so collect the ids first and revoke afterwards.

Required scopes

product-access:read

Underlying endpoint

GET /products/{slug}/access

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

In TypeScript

envless.products.access.iterate()

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