API Responses WriteTuplesResponse - evansims/openfga-php GitHub Wiki

Response for tuple writing operations supporting both transactional and non-transactional modes. This response handles results from both transactional writes (all-or-nothing) and non-transactional writes (independent operations with detailed tracking).

Table of Contents


Namespace

OpenFGA\Responses


Source

View source code


Implements


Related Classes


Methods

fromResponse

Implements Responses\WriteTuplesResponseInterface

public function fromResponse(
    HttpResponseInterface $response,
    HttpRequestInterface $request,
    SchemaValidatorInterface $validator,
): static

Create a response instance from an HTTP response. This method transforms a raw HTTP response from the OpenFGA API into a structured response object, validating and parsing the response data according to the expected schema. It handles both successful responses by parsing and validating the data, and error responses by throwing appropriate exceptions.

View source


Parameters

Name Type Description
$response HttpResponseInterface The raw HTTP response from the OpenFGA API
$request HttpRequestInterface The original HTTP request that generated this response
$validator SchemaValidatorInterface Schema validator for parsing and validating response data

Returns

static — The parsed and validated response instance containing the API response data


getErrors

public function getErrors(): array

Get all errors that occurred during processing.

View source


Returns

array — Array of exceptions from failed operations


getFailedChunks

public function getFailedChunks(): int

Get the number of failed chunks.

View source


Returns

int — The number of failed chunks


getFirstError

public function getFirstError(): ?Throwable

Get the first error that occurred.

View source


Returns

Throwable | null — The first error, or null if no errors


getSuccessRate

public function getSuccessRate(): float

Calculate the success rate of the operation.

View source


Returns

float — Success rate between 0.0 and 1.0


getSuccessfulChunks

public function getSuccessfulChunks(): int

Get the number of successfully processed chunks.

View source


Returns

int — The number of successful chunks


getTotalChunks

public function getTotalChunks(): int

Get the total number of chunks processed (non-transactional mode).

View source


Returns

int — The number of chunks, or 1 for transactional mode


getTotalOperations

public function getTotalOperations(): int

Get the total number of tuple operations processed.

View source


Returns

int — The total number of write and delete operations


isCompleteFailure

public function isCompleteFailure(): bool

Check if all operations failed.

View source


Returns

bool — True if all operations failed


isCompleteSuccess

public function isCompleteSuccess(): bool

Check if all operations completed successfully.

View source


Returns

bool — True if all operations succeeded


isPartialSuccess

public function isPartialSuccess(): bool

Check if some operations succeeded and some failed.

View source


Returns

bool — True if partial success (non-transactional mode only)


isTransactional

public function isTransactional(): bool

Check if the operation was executed in transactional mode.

View source


Returns

bool — True if transactional, false if non-transactional


throwOnFailure

public function throwOnFailure(): void

Throw an exception if any operations failed.

View source


Returns

void

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