API Requests WriteTuplesRequestInterface - evansims/openfga-php GitHub Wiki
Interface for writing relationship tuples to an OpenFGA store. This interface defines the contract for requests that modify relationship data in OpenFGA stores. It supports both adding new relationships (writes) and removing existing relationships (deletes) in a single atomic operation. Write operations are transactional, meaning either all changes succeed or all changes are rolled back. This ensures data consistency when making multiple related changes to the authorization graph. The request allows you to: - Add new relationship tuples to establish permissions - Remove existing relationship tuples to revoke permissions - Perform both operations atomically in a single request - Specify which authorization model version to use for validation
Table of Contents
OpenFGA\Requests
- WriteTuplesResponseInterface (response)
- WriteTuplesRequest (implementation)
public function getDeletes(): TupleKeysInterface|null
Get 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(): int
Get the maximum number of parallel requests for non-transactional mode.
int
— Maximum parallel requests (1 for sequential processing)
public function getMaxRetries(): int
Get the maximum number of retries for failed chunks in non-transactional mode.
int
— Maximum retry attempts
public function getMaxTuplesPerChunk(): int
Get the maximum number of tuples per chunk for non-transactional mode.
int
— Maximum tuples per chunk (up to 100)
public function getModel(): string
Get 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(StreamFactoryInterface $streamFactory): RequestContext
Build 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(): float
Get the retry delay in seconds for non-transactional mode.
float
— Retry delay in seconds
public function getStopOnFirstError(): bool
Check if non-transactional processing should stop on first error.
bool
— True to stop on first error, false to continue
public function getStore(): string
Get 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 getWrites(): TupleKeysInterface|null
Get 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 isTransactional(): bool
Check if this request should be executed in transactional mode.
bool
— True for transactional mode, false for non-transactional