API Requests WriteTuplesRequest - evansims/openfga-php GitHub Wiki
Request for writing and deleting relationship tuples in OpenFGA. This request enables batch creation and deletion of relationship tuples, supporting both transactional (all-or-nothing) and non-transactional (independent operations) modes. Transactional mode ensures atomic changes, while non-transactional mode allows for parallel processing with detailed success/failure tracking.
Table of Contents
OpenFGA\Requests
- WriteTuplesResponse (response)
- WriteTuplesRequestInterface (interface)
public function chunk(int $chunkSize): array<WriteTuplesRequest>Split this request into smaller chunks for non-transactional processing.
| Name | Type | Description |
|---|---|---|
$chunkSize |
int |
Maximum tuples per chunk (1-100) |
array<[WriteTuplesRequest](WriteTuplesRequest)> — Array of chunked requests
public function getDeletes(): ?OpenFGA\Models\Collections\TupleKeysInterfaceGet the relationship tuples to delete from the store. Returns a collection of relationship tuples that should be removed from the authorization store. Each tuple represents a permission or relationship that will be revoked. The deletion is atomic with any write operations specified in the same request.
TupleKeysInterface | null — Collection of relationship tuples to remove, or null if no deletions are requested
public function getMaxParallelRequests(): intGet the maximum number of parallel requests for non-transactional mode.
int — Maximum parallel requests (1 for sequential processing)
public function getMaxRetries(): intGet the maximum number of retries for failed chunks in non-transactional mode.
int — Maximum retry attempts
public function getMaxTuplesPerChunk(): intGet the maximum number of tuples per chunk for non-transactional mode.
int — Maximum tuples per chunk (up to 100)
public function getModel(): stringGet the authorization model ID to use for tuple validation. Specifies which version of the authorization model should be used to validate the relationship tuples being written or deleted. This ensures that all tuples conform to the expected schema and relationship types defined in the model.
string — The authorization model ID for validating tuple operations
public function getRequest(Psr\Http\Message\StreamFactoryInterface $streamFactory): OpenFGA\Network\RequestContextBuild a request context for HTTP execution. Transforms the request object into a standardized HTTP request context that can be executed by the OpenFGA HTTP client. This method handles all aspects of request preparation including parameter serialization, URL construction, header configuration, and body stream creation. The method validates that all required parameters are present and properly formatted, serializes complex objects to JSON, constructs the appropriate API endpoint URL, and creates the necessary HTTP message body streams.
| Name | Type | Description |
|---|---|---|
$streamFactory |
StreamFactoryInterface |
PSR-7 stream factory for creating request body streams from serialized data |
RequestContext — The prepared request context containing HTTP method, URL, headers, and body ready for execution
public function getRetryDelaySeconds(): floatGet the retry delay in seconds for non-transactional mode.
float — Retry delay in seconds
public function getStopOnFirstError(): boolCheck if non-transactional processing should stop on first error.
bool — True to stop on first error, false to continue
public function getStore(): stringGet the store ID where tuples will be written. Identifies the OpenFGA store that contains the authorization data to be modified. All write and delete operations will be performed within the context of this specific store.
string — The store ID containing the authorization data to modify
public function getTotalOperations(): intGet the total number of tuple operations in this request.
int — Total count of write and delete operations
public function getWrites(): ?OpenFGA\Models\Collections\TupleKeysInterfaceGet the relationship tuples to write to the store. Returns a collection of relationship tuples that should be added to the authorization store. Each tuple represents a new permission or relationship that will be granted. The write operation is atomic with any delete operations specified in the same request.
TupleKeysInterface | null — Collection of relationship tuples to add, or null if no writes are requested
public function isEmpty(): boolCheck if this request contains any operations.
bool — True if the request has no operations
public function isTransactional(): boolCheck if this request should be executed in transactional mode.
bool — True for transactional mode, false for non-transactional