API Repositories HttpStoreRepository - evansims/openfga-php GitHub Wiki
HTTP implementation of the store repository. This repository provides a domain-focused abstraction for store operations, handling all HTTP communication through the injected HttpService. It converts domain objects to API requests, sends them via HTTP, and transforms responses back to domain objects while maintaining proper error handling. The repository encapsulates all HTTP-specific concerns including request/response transformation, pagination handling, and API error mapping. It follows the SDK's Result pattern to provide safe error handling without exceptions for control flow. ## Implementation Details - Uses HttpService for all HTTP operations - Validates responses using SchemaValidator - Transforms API responses to domain objects - Handles pagination for list operations - Provides consistent error handling via Result pattern
OpenFGA\Repositories
public function create(string $name): OpenFGA\Results\ResultInterface
Create a new store with the specified name. Creates a new OpenFGA store which serves as a container for authorization models and relationship tuples. Each store is isolated from others, allowing you to manage multiple authorization configurations in a single OpenFGA instance.
Name | Type | Description |
---|---|---|
$name |
string |
The name for the new store |
ResultInterface
— Success containing the created Store, or Failure with error details
public function delete(string $storeId): OpenFGA\Results\ResultInterface
Delete an existing store by ID. Permanently removes a store and all its associated data including authorization models and relationship tuples. This operation cannot be undone, so use with caution in production environments.
Name | Type | Description |
---|---|---|
$storeId |
string |
The ID of the store to delete |
ResultInterface
— Success with null value, or Failure with error details
public function get(string $storeId): OpenFGA\Results\ResultInterface
Get a store by ID. Retrieves the details of an existing store including its name and timestamps. Use this to verify a store exists or to get its current metadata.
Name | Type | Description |
---|---|---|
$storeId |
string |
The ID of the store to retrieve |
ResultInterface
— Success containing the Store, or Failure with error details
public function list(?string $continuationToken = NULL, ?int $pageSize = NULL): OpenFGA\Results\ResultInterface
List available stores with optional pagination. Retrieves a paginated list of all stores accessible to the authenticated client. Use the continuation token from a previous response to fetch subsequent pages when dealing with large numbers of stores.
Name | Type | Description |
---|---|---|
$continuationToken |
string | null
|
Token from previous response to get next page |
$pageSize |
int | null
|
Maximum number of stores to return (1-100) |
ResultInterface
— Success containing Stores collection, or Failure with error details