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


Namespace

OpenFGA\Requests


Source

View source code


Implements


Related Classes


Methods

getDeletes

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.

View source


Returns

TupleKeysInterface | null — Collection of relationship tuples to remove, or null if no deletions are requested


getMaxParallelRequests

public function getMaxParallelRequests(): int

Get the maximum number of parallel requests for non-transactional mode.

View source


Returns

int — Maximum parallel requests (1 for sequential processing)


getMaxRetries

public function getMaxRetries(): int

Get the maximum number of retries for failed chunks in non-transactional mode.

View source


Returns

int — Maximum retry attempts


getMaxTuplesPerChunk

public function getMaxTuplesPerChunk(): int

Get the maximum number of tuples per chunk for non-transactional mode.

View source


Returns

int — Maximum tuples per chunk (up to 100)


getModel

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.

View source


Returns

string — The authorization model ID for validating tuple operations


getRequest

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.

View source


Parameters

Name Type Description
$streamFactory StreamFactoryInterface PSR-7 stream factory for creating request body streams from serialized data

Returns

RequestContext — The prepared request context containing HTTP method, URL, headers, and body ready for execution


getRetryDelaySeconds

public function getRetryDelaySeconds(): float

Get the retry delay in seconds for non-transactional mode.

View source


Returns

float — Retry delay in seconds


getStopOnFirstError

public function getStopOnFirstError(): bool

Check if non-transactional processing should stop on first error.

View source


Returns

bool — True to stop on first error, false to continue


getStore

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.

View source


Returns

string — The store ID containing the authorization data to modify


getWrites

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.

View source


Returns

TupleKeysInterface | null — Collection of relationship tuples to add, or null if no writes are requested


isTransactional

public function isTransactional(): bool

Check if this request should be executed in transactional mode.

View source


Returns

bool — True for transactional mode, false for non-transactional

⚠️ **GitHub.com Fallback** ⚠️