API Repositories HttpTupleRepository - evansims/openfga-php GitHub Wiki

HTTP implementation of the tuple repository. This repository handles tuple operations via HTTP requests to the OpenFGA API. It converts domain objects to API requests, sends them via the HTTP service, and transforms responses back to domain objects. Supports both transactional and non-transactional tuple operations with proper error handling.

Table of Contents


Namespace

OpenFGA\Repositories


Source

View source code


Implements


Methods

delete

public function delete(
    OpenFGA\Models\StoreInterface $store,
    OpenFGA\Models\AuthorizationModelInterface $model,
    OpenFGA\Models\Collections\TupleKeysInterface $tuples,
    bool $transactional = true,
    array $options = [],
): OpenFGA\Results\FailureInterface|OpenFGA\Results\SuccessInterface

Delete relationship tuples from the store. Removes existing relationship tuples from the store. Like write operations, supports both transactional and non-transactional modes with the same constraints and options.

View source


Parameters

Name Type Description
$store StoreInterface The store containing the tuples
$model AuthorizationModelInterface The authorization model to validate against
$tuples TupleKeysInterface The tuples to delete
$transactional bool Whether to use transactional mode (default: true)
$options array

Returns

FailureInterface | SuccessInterface — Success with WriteTuplesResponse containing operation results, or Failure with error details


listChanges

public function listChanges(
    OpenFGA\Models\StoreInterface $store,
    ?string $type = NULL,
    ?DateTimeImmutable $startTime = NULL,
    ?string $continuationToken = NULL,
    ?int $pageSize = NULL,
): OpenFGA\Results\FailureInterface|OpenFGA\Results\SuccessInterface

List changes to relationship tuples over time. Retrieves a chronological log of tuple changes (writes and deletes) within the store. Useful for auditing, synchronization, or understanding how relationships evolved. Results can be filtered by object type and time range.

View source


Parameters

Name Type Description
$store StoreInterface The store to query
$type string | null Filter by object type (for example "document")
$startTime DateTimeImmutable | null Filter changes after this time
$continuationToken string | null Token from previous response for pagination
$pageSize int | null Maximum number of changes to return

Returns

FailureInterface | SuccessInterface — Success with ListTupleChangesResponse containing change history, or Failure with error details


read

public function read(
    OpenFGA\Models\StoreInterface $store,
    OpenFGA\Models\TupleKeyInterface $filter,
    ?string $continuationToken = NULL,
    ?int $pageSize = NULL,
): OpenFGA\Results\FailureInterface|OpenFGA\Results\SuccessInterface

Read relationship tuples from the store. Retrieves tuples matching the specified filter criteria. The filter uses partial matching - you can specify any combination of user, relation, and object to narrow results. Results are paginated for efficient retrieval of large datasets.

View source


Parameters

Name Type Description
$store StoreInterface The store containing the tuples
$filter TupleKeyInterface Filter criteria for tuple matching
$continuationToken string | null Token from previous response for pagination
$pageSize int | null Maximum number of tuples to return (1-100)

Returns

FailureInterface | SuccessInterface — Success with ReadTuplesResponse containing matching tuples, or Failure with error details


write

public function write(
    OpenFGA\Models\StoreInterface $store,
    OpenFGA\Models\AuthorizationModelInterface $model,
    OpenFGA\Models\Collections\TupleKeysInterface $tuples,
    bool $transactional = true,
    array $options = [],
): OpenFGA\Results\FailureInterface|OpenFGA\Results\SuccessInterface

Write relationship tuples to the store. Creates new relationship tuples in the store. Supports both transactional mode (all-or-nothing, limited to 100 tuples) and non-transactional mode for larger batches with configurable parallelism and retry behavior.

View source


Parameters

Name Type Description
$store StoreInterface The store to write tuples to
$model AuthorizationModelInterface The authorization model to validate against
$tuples TupleKeysInterface The tuples to write
$transactional bool Whether to use transactional mode (default: true)
$options array

Returns

FailureInterface | SuccessInterface — Success with WriteTuplesResponse containing operation results, or Failure with error details


writeAndDelete

public function writeAndDelete(
    StoreInterface $store,
    AuthorizationModelInterface $model,
    TupleKeysInterface|null $writes = NULL,
    TupleKeysInterface|null $deletes = NULL,
    bool $transactional = true,
    array<string, mixed> $options = [],
): FailureInterface|SuccessInterface

Write and delete tuples in a single operation.

View source


Parameters

Name Type Description
$store StoreInterface The store to operate on
$model AuthorizationModelInterface The authorization model to validate against
$writes TupleKeysInterface | null Tuples to write (optional)
$deletes TupleKeysInterface | null Tuples to delete (optional)
$transactional bool Whether to use transactional mode
$options array&lt;string, mixed&gt;

Returns

FailureInterface | SuccessInterface — Result of the operation

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