API Repositories ModelRepositoryInterface - evansims/openfga-php GitHub Wiki
Repository contract for authorization model operations. This interface defines the contract for managing authorization models within an OpenFGA store. Authorization models define the permission structure for your application - the types of objects, the relationships between them, and the rules that govern access. Models are immutable once created; to update permissions, you create a new model version. All methods return Result objects following the Result pattern, allowing for consistent error handling without exceptions.
OpenFGA\Repositories
public function create(
TypeDefinitionsInterface $typeDefinitions,
SchemaVersion $schemaVersion = OpenFGA\Models\Enums\SchemaVersion::V1_1,
ConditionsInterface|null $conditions = NULL,
): FailureInterface|SuccessInterface
Create a new authorization model in the store. Creates an immutable authorization model that defines your application's permission structure. The model includes type definitions for objects and the relationships between them, and optionally conditions for dynamic permissions.
Name | Type | Description |
---|---|---|
$typeDefinitions |
TypeDefinitionsInterface |
Object types and their relationship definitions |
$schemaVersion |
SchemaVersion |
The schema version for the model (defaults to 1.1) |
$conditions |
ConditionsInterface | null
|
Optional conditions for dynamic permissions |
FailureInterface
| SuccessInterface
— Success with the created AuthorizationModelInterface, or Failure with error details
public function get(string $modelId): FailureInterface|SuccessInterface
Get a specific authorization model by ID. Retrieves the complete authorization model including all type definitions, relationships, and conditions. Models are immutable, so the returned model will never change once created.
Name | Type | Description |
---|---|---|
$modelId |
string |
The unique identifier of the authorization model |
FailureInterface
| SuccessInterface
— Success with the AuthorizationModelInterface, or Failure with error details
public function list(
int|null $pageSize = NULL,
string|null $continuationToken = NULL,
): FailureInterface|SuccessInterface
List authorization models in the store. Returns a paginated list of authorization models, ordered by creation time (newest first). Use pagination parameters to retrieve large lists efficiently.
Name | Type | Description |
---|---|---|
$pageSize |
int | null
|
Maximum number of models to return (1-100) |
$continuationToken |
string | null
|
Token from previous response for pagination |
FailureInterface
| SuccessInterface
— Success with AuthorizationModelsInterface collection, or Failure with error details