ManagementTransport
in package
The single wire path every one of the 147 §27 management operations goes through (CONTRACT.md §27.8).
§27.8 requires the generated layer to sit on the SDK's EXISTING request path rather
than open a second one. It is built on the same Guzzle client that carries
AuthMiddleware and RefreshMiddleware, so
§3 CSRF, the §4 cookie jar, the §5 X-Tenant-ID header, §6 TLS and §9 single-flight
refresh apply to all 147 by construction — not by 147 opportunities to forget one.
What this class adds on top of that path is only what §27 asks for:
- Rule 1 — no session means no wire call. self::requireSession() throws before a request is built, so an unauthenticated management call cannot reach the server at all, let alone be counted against it.
- Rule 8 — only
GETis retried. APOST/PATCH/PUT/DELETEthat failed may well have been applied, and §16's helper cannot tell. - Rule 10 — nothing is cached. Every call is a wire call; an administrative read that answers from a stale copy is worse than a slow one.
- Rule 11 — telemetry carries the path TEMPLATE (
/api/v1/users/{user_id}), never the substituted path, so identifiers never reach a metrics label and cardinality stays bounded. - §27.5 — a Sensitive in a request body is unwrapped on the way out. This is the one place in the SDK where that happens, and it happens explicitly rather than by serializer configuration (see self::encodeBody()).
Table of Contents
Methods
- __construct() : mixed
- send() : array<string|int, mixed>|null
- Issues one management operation and returns its decoded body.
- sendPage() : Page<string|int, mixed>
- Issues a paginated list operation and returns one {@see Page} (§27.4 rule 4).
- walk() : Generator<int, mixed>
- Walks every page of a paginated operation, yielding items one at a time.
Methods
__construct()
public
__construct(Client $http, Session $session, TelemetryDispatcher $telemetry[, bool $retryEnabled = true ]) : mixed
Parameters
- $http : Client
-
The full production stack (auth + refresh middleware) — §27.8's "existing request path".
- $session : Session
-
Consulted for rule 1's session check.
- $telemetry : TelemetryDispatcher
-
§19 dispatcher; one event pair per attempt.
- $retryEnabled : bool = true
-
§16.1 disable switch, honoured as-is.
send()
Issues one management operation and returns its decoded body.
public
send(string $operation, string $method, string $pathTemplate[, array<string, string> $pathValues = [] ][, array<string, mixed> $query = [] ][, array<string, mixed>|null $body = null ]) : array<string|int, mixed>|null
Parameters
- $operation : string
-
Canonical name (
users.get), used for §19 labels. - $method : string
-
HTTP method, uppercase.
- $pathTemplate : string
-
The
{placeholder}form — what telemetry sees. - $pathValues : array<string, string> = []
-
Substituted into the template, URL-encoded.
- $query : array<string, mixed> = []
-
Query parameters; nulls are dropped.
- $body : array<string, mixed>|null = null
-
Request body, or
nullfor none.
Return values
array<string|int, mixed>|null —The decoded body, or null for a 204/empty response.
sendPage()
Issues a paginated list operation and returns one {@see Page} (§27.4 rule 4).
public
sendPage(string $operation, string $pathTemplate, array<string, string> $pathValues, array<string, mixed> $query, PageRequest $page, callable(array<string, mixed>): mixed $decode) : Page<string|int, mixed>
total is read from the server's own count field, never from
count($items) — the two differ on every page but the last, and deriving one from
the other is how a client silently processes only the first page.
Parameters
- $operation : string
-
Canonical name, for §19 labels.
- $pathTemplate : string
-
The
{placeholder}form. - $pathValues : array<string, string>
-
Substituted into the template.
- $query : array<string, mixed>
-
Extra query parameters beyond paging.
- $page : PageRequest
- $decode : callable(array<string, mixed>): mixed
-
Maps one raw item to its model.
Return values
Page<string|int, mixed>walk()
Walks every page of a paginated operation, yielding items one at a time.
public
static walk(callable(PageRequest): Page<string|int, mixed> $fetch[, PageRequest|null $start = null ]) : Generator<int, mixed>
Stops on the first EMPTY page, per §27.4 rule 4 — NOT on the first short page. A server is free to return fewer items than asked for (a filter applied after paging, a deleted row) without that meaning the collection has ended, and treating a short page as the end silently truncates the walk.
Parameters
- $fetch : callable(PageRequest): Page<string|int, mixed>
-
Fetches one page.
- $start : PageRequest|null = null