API Requests CreateAuthorizationModelRequest - evansims/openfga-php GitHub Wiki

Request for creating a new authorization model in OpenFGA. Authorization models define the permission structure for your application, including object types, relationships, and how permissions are computed. Models are immutable once created and identified by a unique ID.

Table of Contents


Namespace

OpenFGA\Requests


Source

View source code


Implements


Related Classes


Methods

getConditions

public function getConditions(): ?OpenFGA\Models\Collections\ConditionsInterface

Get the conditional rules for the authorization model. Returns a collection of conditions that define dynamic authorization logic based on runtime context. Conditions allow for sophisticated access control scenarios such as time-based access, location restrictions, resource attributes, or custom business logic. Conditions are referenced by name within type definitions and evaluated at permission check time using contextual data provided in authorization requests. They enable attribute-based access control (ABAC) patterns within the relationship-based authorization framework.

View source


Returns

ConditionsInterface | null — Collection of conditional rules for dynamic authorization, or null if no conditions are defined


getRequest

public function getRequest(Psr\Http\Message\StreamFactoryInterface $streamFactory): OpenFGA\Network\RequestContext

Build a request context for HTTP execution. Transforms the request object into a standardized HTTP request context that can be executed by the OpenFGA HTTP client. This method handles all aspects of request preparation including parameter serialization, URL construction, header configuration, and body stream creation. The method validates that all required parameters are present and properly formatted, serializes complex objects to JSON, constructs the appropriate API endpoint URL, and creates the necessary HTTP message body streams.

View source


Parameters

Name Type Description
$streamFactory StreamFactoryInterface PSR-7 stream factory for creating request body streams from serialized data

Returns

RequestContext — The prepared request context containing HTTP method, URL, headers, and body ready for execution


getSchemaVersion

public function getSchemaVersion(): OpenFGA\Models\Enums\SchemaVersion

Get the schema version for the authorization model. Specifies which version of the OpenFGA modeling language should be used to interpret the authorization model definition. Different schema versions support different features and syntax, allowing OpenFGA to evolve while maintaining backward compatibility. The schema version determines: - Available relationship operators and syntax - Supported conditional expression features - Type definition validation rules - API compatibility and behavior

View source


Returns

SchemaVersion — The modeling language schema version for this authorization model


getStore

public function getStore(): string

Get the store ID where the authorization model will be created. Identifies the OpenFGA store that will contain the new authorization model. Each store can have multiple model versions, allowing you to evolve your authorization schema over time while maintaining access to previous versions for consistency and rollback scenarios.

View source


Returns

string — The store ID where the authorization model will be created


getTypeDefinitions

public function getTypeDefinitions(): OpenFGA\Models\Collections\TypeDefinitionsInterface

Get the type definitions for the authorization model. Returns a collection of type definitions that specify the object types and their allowed relationships within the authorization model. Type definitions form the core schema that defines what objects exist in your system and how they can be related to users and other objects. Each type definition includes: - Object type name (for example "document," "folder," "organization") - Allowed relationships (for example "owner," "editor," "viewer") - Relationship inheritance and computation rules - References to conditional logic for dynamic authorization

View source


Returns

TypeDefinitionsInterface — Collection of object type definitions that define the authorization schema

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