API Models BatchTupleOperation - evansims/openfga-php GitHub Wiki

Represents a batch tuple operation containing both writes and deletes. This model organizes tuple operations for batch processing, allowing you to specify both tuples to write and tuples to delete in a single operation. The batch processor will automatically chunk these operations to respect API limits while maintaining the grouping of related changes.

Table of Contents


Namespace

OpenFGA\Models


Source

View source code


Implements


Related Classes


Constants

Name Value Description
MAX_TUPLES_PER_REQUEST 100 Maximum number of tuples allowed per API request.
OPENAPI_MODEL BatchTupleOperation


Methods

chunk

public function chunk(int $chunkSize = 100): array

Split this operation into smaller chunks that respect API limits. If the operation doesn't require chunking, returns an array containing only this operation. Otherwise, splits the writes and deletes across multiple operations to stay within the specified chunk size.

View source


Parameters

Name Type Description
$chunkSize int Maximum tuples per chunk (default: API limit)

Returns

array — Array of operations, each within the chunk size


getDeletes

public function getDeletes(): ?OpenFGA\Models\Collections\TupleKeysInterface

Get the tuples to delete in this operation.

View source


Returns

TupleKeysInterface | null — Collection of tuples to delete, or null if none


getTotalOperations

public function getTotalOperations(): int

Get the total number of operations (writes + deletes).

View source


Returns

int — Total count of tuples to be processed


getWrites

public function getWrites(): ?OpenFGA\Models\Collections\TupleKeysInterface

Get the tuples to write in this operation.

View source


Returns

TupleKeysInterface | null — Collection of tuples to write, or null if none


isEmpty

public function isEmpty(): bool

Check if this operation is empty (no writes or deletes).

View source


Returns

bool — True if no operations are defined


jsonSerialize

public function jsonSerialize(): array<string, mixed>

View source


Returns

array&lt;string, mixed&gt;


requiresChunking

public function requiresChunking(int $chunkSize = 100): bool

Check if this operation requires chunking due to size limits.

View source


Parameters

Name Type Description
$chunkSize int Maximum tuples per chunk (default: API limit)

Returns

bool — True if the operation exceeds the specified chunk size


schema

Implements Models\BatchTupleOperationInterface

public function schema(): SchemaInterface

Get the JSON schema for this model.

View source


Returns

SchemaInterface — The schema definition

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