Package dev.openfga.sdk.api
Class OpenFgaApi
- java.lang.Object
-
- dev.openfga.sdk.api.OpenFgaApi
-
public class OpenFgaApi extends java.lang.ObjectA low-level API representation of an OpenFGA server.Most code should favor the simpler and higher-level
OpenFgaClientwhen calling an OpenFGA server.
-
-
Constructor Summary
Constructors Constructor Description OpenFgaApi(Configuration configuration)OpenFgaApi(Configuration configuration, ApiClient apiClient)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.concurrent.CompletableFuture<ApiResponse<CheckResponse>>check(java.lang.String storeId, CheckRequest body)Check whether a user is authorized to access an object The Check API queries to check if the user has a certain relationship with an object in a certain store.java.util.concurrent.CompletableFuture<ApiResponse<CheckResponse>>check(java.lang.String storeId, CheckRequest body, ConfigurationOverride configurationOverride)Check whether a user is authorized to access an object The Check API queries to check if the user has a certain relationship with an object in a certain store.java.util.concurrent.CompletableFuture<ApiResponse<CreateStoreResponse>>createStore(CreateStoreRequest body)Create a store Create a unique OpenFGA store which will be used to store authorization models and relationship tuples.java.util.concurrent.CompletableFuture<ApiResponse<CreateStoreResponse>>createStore(CreateStoreRequest body, ConfigurationOverride configurationOverride)Create a store Create a unique OpenFGA store which will be used to store authorization models and relationship tuples.java.util.concurrent.CompletableFuture<ApiResponse<java.lang.Void>>deleteStore(java.lang.String storeId)Delete a store Delete an OpenFGA store.java.util.concurrent.CompletableFuture<ApiResponse<java.lang.Void>>deleteStore(java.lang.String storeId, ConfigurationOverride configurationOverride)Delete a store Delete an OpenFGA store.java.util.concurrent.CompletableFuture<ApiResponse<ExpandResponse>>expand(java.lang.String storeId, ExpandRequest body)Expand all relationships in userset tree format, and following userset rewrite rules.java.util.concurrent.CompletableFuture<ApiResponse<ExpandResponse>>expand(java.lang.String storeId, ExpandRequest body, ConfigurationOverride configurationOverride)Expand all relationships in userset tree format, and following userset rewrite rules.java.util.concurrent.CompletableFuture<ApiResponse<GetStoreResponse>>getStore(java.lang.String storeId)Get a store Returns an OpenFGA store by its identifierjava.util.concurrent.CompletableFuture<ApiResponse<GetStoreResponse>>getStore(java.lang.String storeId, ConfigurationOverride configurationOverride)Get a store Returns an OpenFGA store by its identifierjava.util.concurrent.CompletableFuture<ApiResponse<ListObjectsResponse>>listObjects(java.lang.String storeId, ListObjectsRequest body)List all objects of the given type that the user has a relation with The ListObjects API returns a list of all the objects of the given type that the user has a relation with.java.util.concurrent.CompletableFuture<ApiResponse<ListObjectsResponse>>listObjects(java.lang.String storeId, ListObjectsRequest body, ConfigurationOverride configurationOverride)List all objects of the given type that the user has a relation with The ListObjects API returns a list of all the objects of the given type that the user has a relation with.java.util.concurrent.CompletableFuture<ApiResponse<ListStoresResponse>>listStores(java.lang.Integer pageSize, java.lang.String continuationToken)List all stores Returns a paginated list of OpenFGA stores and a continuation token to get additional stores.java.util.concurrent.CompletableFuture<ApiResponse<ListStoresResponse>>listStores(java.lang.Integer pageSize, java.lang.String continuationToken, ConfigurationOverride configurationOverride)List all stores Returns a paginated list of OpenFGA stores and a continuation token to get additional stores.java.util.concurrent.CompletableFuture<ApiResponse<ReadResponse>>read(java.lang.String storeId, ReadRequest body)Get tuples from the store that matches a query, without following userset rewrite rules The Read API will return the tuples for a certain store that match a query filter specified in the body of the request.java.util.concurrent.CompletableFuture<ApiResponse<ReadResponse>>read(java.lang.String storeId, ReadRequest body, ConfigurationOverride configurationOverride)Get tuples from the store that matches a query, without following userset rewrite rules The Read API will return the tuples for a certain store that match a query filter specified in the body of the request.java.util.concurrent.CompletableFuture<ApiResponse<ReadAssertionsResponse>>readAssertions(java.lang.String storeId, java.lang.String authorizationModelId)Read assertions for an authorization model ID The ReadAssertions API will return, for a given authorization model id, all the assertions stored for it.java.util.concurrent.CompletableFuture<ApiResponse<ReadAssertionsResponse>>readAssertions(java.lang.String storeId, java.lang.String authorizationModelId, ConfigurationOverride configurationOverride)Read assertions for an authorization model ID The ReadAssertions API will return, for a given authorization model id, all the assertions stored for it.java.util.concurrent.CompletableFuture<ApiResponse<ReadAuthorizationModelResponse>>readAuthorizationModel(java.lang.String storeId, java.lang.String id)Return a particular version of an authorization model The ReadAuthorizationModel API returns an authorization model by its identifier.java.util.concurrent.CompletableFuture<ApiResponse<ReadAuthorizationModelResponse>>readAuthorizationModel(java.lang.String storeId, java.lang.String id, ConfigurationOverride configurationOverride)Return a particular version of an authorization model The ReadAuthorizationModel API returns an authorization model by its identifier.java.util.concurrent.CompletableFuture<ApiResponse<ReadAuthorizationModelsResponse>>readAuthorizationModels(java.lang.String storeId, java.lang.Integer pageSize, java.lang.String continuationToken)Return all the authorization models for a particular store The ReadAuthorizationModels API will return all the authorization models for a certain store.java.util.concurrent.CompletableFuture<ApiResponse<ReadAuthorizationModelsResponse>>readAuthorizationModels(java.lang.String storeId, java.lang.Integer pageSize, java.lang.String continuationToken, ConfigurationOverride configurationOverride)Return all the authorization models for a particular store The ReadAuthorizationModels API will return all the authorization models for a certain store.java.util.concurrent.CompletableFuture<ApiResponse<ReadChangesResponse>>readChanges(java.lang.String storeId, java.lang.String type, java.lang.Integer pageSize, java.lang.String continuationToken)Return a list of all the tuple changes The ReadChanges API will return a paginated list of tuple changes (additions and deletions) that occurred in a given store, sorted by ascending time.java.util.concurrent.CompletableFuture<ApiResponse<ReadChangesResponse>>readChanges(java.lang.String storeId, java.lang.String type, java.lang.Integer pageSize, java.lang.String continuationToken, ConfigurationOverride configurationOverride)Return a list of all the tuple changes The ReadChanges API will return a paginated list of tuple changes (additions and deletions) that occurred in a given store, sorted by ascending time.java.util.concurrent.CompletableFuture<ApiResponse<java.lang.Object>>write(java.lang.String storeId, WriteRequest body)Add or delete tuples from the store The Write API will update the tuples for a certain store.java.util.concurrent.CompletableFuture<ApiResponse<java.lang.Object>>write(java.lang.String storeId, WriteRequest body, ConfigurationOverride configurationOverride)Add or delete tuples from the store The Write API will update the tuples for a certain store.java.util.concurrent.CompletableFuture<ApiResponse<java.lang.Void>>writeAssertions(java.lang.String storeId, java.lang.String authorizationModelId, WriteAssertionsRequest body)Upsert assertions for an authorization model ID The WriteAssertions API will upsert new assertions for an authorization model id, or overwrite the existing ones.java.util.concurrent.CompletableFuture<ApiResponse<java.lang.Void>>writeAssertions(java.lang.String storeId, java.lang.String authorizationModelId, WriteAssertionsRequest body, ConfigurationOverride configurationOverride)Upsert assertions for an authorization model ID The WriteAssertions API will upsert new assertions for an authorization model id, or overwrite the existing ones.java.util.concurrent.CompletableFuture<ApiResponse<WriteAuthorizationModelResponse>>writeAuthorizationModel(java.lang.String storeId, WriteAuthorizationModelRequest body)Create a new authorization model The WriteAuthorizationModel API will add a new authorization model to a store.java.util.concurrent.CompletableFuture<ApiResponse<WriteAuthorizationModelResponse>>writeAuthorizationModel(java.lang.String storeId, WriteAuthorizationModelRequest body, ConfigurationOverride configurationOverride)Create a new authorization model The WriteAuthorizationModel API will add a new authorization model to a store.
-
-
-
Constructor Detail
-
OpenFgaApi
public OpenFgaApi(Configuration configuration) throws FgaInvalidParameterException
- Throws:
FgaInvalidParameterException
-
OpenFgaApi
public OpenFgaApi(Configuration configuration, ApiClient apiClient) throws FgaInvalidParameterException
- Throws:
FgaInvalidParameterException
-
-
Method Detail
-
check
public java.util.concurrent.CompletableFuture<ApiResponse<CheckResponse>> check(java.lang.String storeId, CheckRequest body) throws ApiException, FgaInvalidParameterException
Check whether a user is authorized to access an object The Check API queries to check if the user has a certain relationship with an object in a certain store. A `contextual_tuples` object may also be included in the body of the request. This object contains one field `tuple_keys`, which is an array of tuple keys. Each of these tuples may have an associated `condition`. You may also provide an `authorization_model_id` in the body. This will be used to assert that the input `tuple_key` is valid for the model specified. If not specified, the assertion will be made against the latest authorization model ID. It is strongly recommended to specify authorization model id for better performance. You may also provide a `context` object that will be used to evaluate the conditioned tuples in the system. It is strongly recommended to provide a value for all the input parameters of all the conditions, to ensure that all tuples be evaluated correctly. The response will return whether the relationship exists in the field `allowed`. ## Example In order to check if user `user:anne` of type `user` has a `reader` relationship with object `document:2021-budget` given the following contextual tuple ```json { \"user\": \"user:anne\", \"relation\": \"member\", \"object\": \"time_slot:office_hours\" } ``` the Check API can be used with the following request body: ```json { \"tuple_key\": { \"user\": \"user:anne\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" }, \"contextual_tuples\": { \"tuple_keys\": [ { \"user\": \"user:anne\", \"relation\": \"member\", \"object\": \"time_slot:office_hours\" } ] }, \"authorization_model_id\": \"01G50QVV17PECNVAHX1GG4Y5NC\" } ``` OpenFGA's response will include `{ \"allowed\": true }` if there is a relationship and `{ \"allowed\": false }` if there isn't.- Parameters:
storeId- (required)body- (required)- Returns:
- CompletableFuture<ApiResponse<CheckResponse>>
- Throws:
ApiException- if fails to make API callFgaInvalidParameterException
-
check
public java.util.concurrent.CompletableFuture<ApiResponse<CheckResponse>> check(java.lang.String storeId, CheckRequest body, ConfigurationOverride configurationOverride) throws ApiException, FgaInvalidParameterException
Check whether a user is authorized to access an object The Check API queries to check if the user has a certain relationship with an object in a certain store. A `contextual_tuples` object may also be included in the body of the request. This object contains one field `tuple_keys`, which is an array of tuple keys. Each of these tuples may have an associated `condition`. You may also provide an `authorization_model_id` in the body. This will be used to assert that the input `tuple_key` is valid for the model specified. If not specified, the assertion will be made against the latest authorization model ID. It is strongly recommended to specify authorization model id for better performance. You may also provide a `context` object that will be used to evaluate the conditioned tuples in the system. It is strongly recommended to provide a value for all the input parameters of all the conditions, to ensure that all tuples be evaluated correctly. The response will return whether the relationship exists in the field `allowed`. ## Example In order to check if user `user:anne` of type `user` has a `reader` relationship with object `document:2021-budget` given the following contextual tuple ```json { \"user\": \"user:anne\", \"relation\": \"member\", \"object\": \"time_slot:office_hours\" } ``` the Check API can be used with the following request body: ```json { \"tuple_key\": { \"user\": \"user:anne\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" }, \"contextual_tuples\": { \"tuple_keys\": [ { \"user\": \"user:anne\", \"relation\": \"member\", \"object\": \"time_slot:office_hours\" } ] }, \"authorization_model_id\": \"01G50QVV17PECNVAHX1GG4Y5NC\" } ``` OpenFGA's response will include `{ \"allowed\": true }` if there is a relationship and `{ \"allowed\": false }` if there isn't.- Parameters:
storeId- (required)body- (required)configurationOverride- Override theConfigurationthis OpenFgaApi was constructed with- Returns:
- CompletableFuture<ApiResponse<CheckResponse>>
- Throws:
ApiException- if fails to make API callFgaInvalidParameterException
-
createStore
public java.util.concurrent.CompletableFuture<ApiResponse<CreateStoreResponse>> createStore(CreateStoreRequest body) throws ApiException, FgaInvalidParameterException
Create a store Create a unique OpenFGA store which will be used to store authorization models and relationship tuples.- Parameters:
body- (required)- Returns:
- CompletableFuture<ApiResponse<CreateStoreResponse>>
- Throws:
ApiException- if fails to make API callFgaInvalidParameterException
-
createStore
public java.util.concurrent.CompletableFuture<ApiResponse<CreateStoreResponse>> createStore(CreateStoreRequest body, ConfigurationOverride configurationOverride) throws ApiException, FgaInvalidParameterException
Create a store Create a unique OpenFGA store which will be used to store authorization models and relationship tuples.- Parameters:
body- (required)configurationOverride- Override theConfigurationthis OpenFgaApi was constructed with- Returns:
- CompletableFuture<ApiResponse<CreateStoreResponse>>
- Throws:
ApiException- if fails to make API callFgaInvalidParameterException
-
deleteStore
public java.util.concurrent.CompletableFuture<ApiResponse<java.lang.Void>> deleteStore(java.lang.String storeId) throws ApiException, FgaInvalidParameterException
Delete a store Delete an OpenFGA store. This does not delete the data associated with the store, like tuples or authorization models.- Parameters:
storeId- (required)- Returns:
- CompletableFuture<ApiResponse<Void>>
- Throws:
ApiException- if fails to make API callFgaInvalidParameterException
-
deleteStore
public java.util.concurrent.CompletableFuture<ApiResponse<java.lang.Void>> deleteStore(java.lang.String storeId, ConfigurationOverride configurationOverride) throws ApiException, FgaInvalidParameterException
Delete a store Delete an OpenFGA store. This does not delete the data associated with the store, like tuples or authorization models.- Parameters:
storeId- (required)configurationOverride- Override theConfigurationthis OpenFgaApi was constructed with- Returns:
- CompletableFuture<ApiResponse<Void>>
- Throws:
ApiException- if fails to make API callFgaInvalidParameterException
-
expand
public java.util.concurrent.CompletableFuture<ApiResponse<ExpandResponse>> expand(java.lang.String storeId, ExpandRequest body) throws ApiException, FgaInvalidParameterException
Expand all relationships in userset tree format, and following userset rewrite rules. Useful to reason about and debug a certain relationship The Expand API will return all users and usersets that have certain relationship with an object in a certain store. This is different from the `/stores/{store_id}/read` API in that both users and computed usersets are returned. Body parameters `tuple_key.object` and `tuple_key.relation` are all required. The response will return a tree whose leaves are the specific users and usersets. Union, intersection and difference operator are located in the intermediate nodes. ## Example To expand all users that have the `reader` relationship with object `document:2021-budget`, use the Expand API with the following request body ```json { \"tuple_key\": { \"object\": \"document:2021-budget\", \"relation\": \"reader\" }, \"authorization_model_id\": \"01G50QVV17PECNVAHX1GG4Y5NC\" } ``` OpenFGA's response will be a userset tree of the users and usersets that have read access to the document. ```json { \"tree\":{ \"root\":{ \"type\":\"document:2021-budget#reader\", \"union\":{ \"nodes\":[ { \"type\":\"document:2021-budget#reader\", \"leaf\":{ \"users\":{ \"users\":[ \"user:bob\" ] } } }, { \"type\":\"document:2021-budget#reader\", \"leaf\":{ \"computed\":{ \"userset\":\"document:2021-budget#writer\" } } } ] } } } } ``` The caller can then call expand API for the `writer` relationship for the `document:2021-budget`.- Parameters:
storeId- (required)body- (required)- Returns:
- CompletableFuture<ApiResponse<ExpandResponse>>
- Throws:
ApiException- if fails to make API callFgaInvalidParameterException
-
expand
public java.util.concurrent.CompletableFuture<ApiResponse<ExpandResponse>> expand(java.lang.String storeId, ExpandRequest body, ConfigurationOverride configurationOverride) throws ApiException, FgaInvalidParameterException
Expand all relationships in userset tree format, and following userset rewrite rules. Useful to reason about and debug a certain relationship The Expand API will return all users and usersets that have certain relationship with an object in a certain store. This is different from the `/stores/{store_id}/read` API in that both users and computed usersets are returned. Body parameters `tuple_key.object` and `tuple_key.relation` are all required. The response will return a tree whose leaves are the specific users and usersets. Union, intersection and difference operator are located in the intermediate nodes. ## Example To expand all users that have the `reader` relationship with object `document:2021-budget`, use the Expand API with the following request body ```json { \"tuple_key\": { \"object\": \"document:2021-budget\", \"relation\": \"reader\" }, \"authorization_model_id\": \"01G50QVV17PECNVAHX1GG4Y5NC\" } ``` OpenFGA's response will be a userset tree of the users and usersets that have read access to the document. ```json { \"tree\":{ \"root\":{ \"type\":\"document:2021-budget#reader\", \"union\":{ \"nodes\":[ { \"type\":\"document:2021-budget#reader\", \"leaf\":{ \"users\":{ \"users\":[ \"user:bob\" ] } } }, { \"type\":\"document:2021-budget#reader\", \"leaf\":{ \"computed\":{ \"userset\":\"document:2021-budget#writer\" } } } ] } } } } ``` The caller can then call expand API for the `writer` relationship for the `document:2021-budget`.- Parameters:
storeId- (required)body- (required)configurationOverride- Override theConfigurationthis OpenFgaApi was constructed with- Returns:
- CompletableFuture<ApiResponse<ExpandResponse>>
- Throws:
ApiException- if fails to make API callFgaInvalidParameterException
-
getStore
public java.util.concurrent.CompletableFuture<ApiResponse<GetStoreResponse>> getStore(java.lang.String storeId) throws ApiException, FgaInvalidParameterException
Get a store Returns an OpenFGA store by its identifier- Parameters:
storeId- (required)- Returns:
- CompletableFuture<ApiResponse<GetStoreResponse>>
- Throws:
ApiException- if fails to make API callFgaInvalidParameterException
-
getStore
public java.util.concurrent.CompletableFuture<ApiResponse<GetStoreResponse>> getStore(java.lang.String storeId, ConfigurationOverride configurationOverride) throws ApiException, FgaInvalidParameterException
Get a store Returns an OpenFGA store by its identifier- Parameters:
storeId- (required)configurationOverride- Override theConfigurationthis OpenFgaApi was constructed with- Returns:
- CompletableFuture<ApiResponse<GetStoreResponse>>
- Throws:
ApiException- if fails to make API callFgaInvalidParameterException
-
listObjects
public java.util.concurrent.CompletableFuture<ApiResponse<ListObjectsResponse>> listObjects(java.lang.String storeId, ListObjectsRequest body) throws ApiException, FgaInvalidParameterException
List all objects of the given type that the user has a relation with The ListObjects API returns a list of all the objects of the given type that the user has a relation with. To achieve this, both the store tuples and the authorization model are used. An `authorization_model_id` may be specified in the body. If it is not specified, the latest authorization model ID will be used. It is strongly recommended to specify authorization model id for better performance. You may also specify `contextual_tuples` that will be treated as regular tuples. Each of these tuples may have an associated `condition`. You may also provide a `context` object that will be used to evaluate the conditioned tuples in the system. It is strongly recommended to provide a value for all the input parameters of all the conditions, to ensure that all tuples be evaluated correctly. The response will contain the related objects in an array in the \"objects\" field of the response and they will be strings in the object format `<type>:<id>` (e.g. \"document:roadmap\"). The number of objects in the response array will be limited by the execution timeout specified in the flag OPENFGA_LIST_OBJECTS_DEADLINE and by the upper bound specified in the flag OPENFGA_LIST_OBJECTS_MAX_RESULTS, whichever is hit first. The objects given will not be sorted, and therefore two identical calls can give a given different set of objects.- Parameters:
storeId- (required)body- (required)- Returns:
- CompletableFuture<ApiResponse<ListObjectsResponse>>
- Throws:
ApiException- if fails to make API callFgaInvalidParameterException
-
listObjects
public java.util.concurrent.CompletableFuture<ApiResponse<ListObjectsResponse>> listObjects(java.lang.String storeId, ListObjectsRequest body, ConfigurationOverride configurationOverride) throws ApiException, FgaInvalidParameterException
List all objects of the given type that the user has a relation with The ListObjects API returns a list of all the objects of the given type that the user has a relation with. To achieve this, both the store tuples and the authorization model are used. An `authorization_model_id` may be specified in the body. If it is not specified, the latest authorization model ID will be used. It is strongly recommended to specify authorization model id for better performance. You may also specify `contextual_tuples` that will be treated as regular tuples. Each of these tuples may have an associated `condition`. You may also provide a `context` object that will be used to evaluate the conditioned tuples in the system. It is strongly recommended to provide a value for all the input parameters of all the conditions, to ensure that all tuples be evaluated correctly. The response will contain the related objects in an array in the \"objects\" field of the response and they will be strings in the object format `<type>:<id>` (e.g. \"document:roadmap\"). The number of objects in the response array will be limited by the execution timeout specified in the flag OPENFGA_LIST_OBJECTS_DEADLINE and by the upper bound specified in the flag OPENFGA_LIST_OBJECTS_MAX_RESULTS, whichever is hit first. The objects given will not be sorted, and therefore two identical calls can give a given different set of objects.- Parameters:
storeId- (required)body- (required)configurationOverride- Override theConfigurationthis OpenFgaApi was constructed with- Returns:
- CompletableFuture<ApiResponse<ListObjectsResponse>>
- Throws:
ApiException- if fails to make API callFgaInvalidParameterException
-
listStores
public java.util.concurrent.CompletableFuture<ApiResponse<ListStoresResponse>> listStores(java.lang.Integer pageSize, java.lang.String continuationToken) throws ApiException, FgaInvalidParameterException
List all stores Returns a paginated list of OpenFGA stores and a continuation token to get additional stores. The continuation token will be empty if there are no more stores.- Parameters:
pageSize- (optional)continuationToken- (optional)- Returns:
- CompletableFuture<ApiResponse<ListStoresResponse>>
- Throws:
ApiException- if fails to make API callFgaInvalidParameterException
-
listStores
public java.util.concurrent.CompletableFuture<ApiResponse<ListStoresResponse>> listStores(java.lang.Integer pageSize, java.lang.String continuationToken, ConfigurationOverride configurationOverride) throws ApiException, FgaInvalidParameterException
List all stores Returns a paginated list of OpenFGA stores and a continuation token to get additional stores. The continuation token will be empty if there are no more stores.- Parameters:
pageSize- (optional)continuationToken- (optional)configurationOverride- Override theConfigurationthis OpenFgaApi was constructed with- Returns:
- CompletableFuture<ApiResponse<ListStoresResponse>>
- Throws:
ApiException- if fails to make API callFgaInvalidParameterException
-
read
public java.util.concurrent.CompletableFuture<ApiResponse<ReadResponse>> read(java.lang.String storeId, ReadRequest body) throws ApiException, FgaInvalidParameterException
Get tuples from the store that matches a query, without following userset rewrite rules The Read API will return the tuples for a certain store that match a query filter specified in the body of the request. The API doesn't guarantee order by any field. It is different from the `/stores/{store_id}/expand` API in that it only returns relationship tuples that are stored in the system and satisfy the query. In the body: 1. `tuple_key` is optional. If not specified, it will return all tuples in the store. 2. `tuple_key.object` is mandatory if `tuple_key` is specified. It can be a full object (e.g., `type:object_id`) or type only (e.g., `type:`). 3. `tuple_key.user` is mandatory if tuple_key is specified in the case the `tuple_key.object` is a type only. ## Examples ### Query for all objects in a type definition To query for all objects that `user:bob` has `reader` relationship in the `document` type definition, call read API with body of ```json { \"tuple_key\": { \"user\": \"user:bob\", \"relation\": \"reader\", \"object\": \"document:\" } } ``` The API will return tuples and a continuation token, something like ```json { \"tuples\": [ { \"key\": { \"user\": \"user:bob\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" }, \"timestamp\": \"2021-10-06T15:32:11.128Z\" } ], \"continuation_token\": \"eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ==\" } ``` This means that `user:bob` has a `reader` relationship with 1 document `document:2021-budget`. Note that this API, unlike the List Objects API, does not evaluate the tuples in the store. The continuation token will be empty if there are no more tuples to query. ### Query for all stored relationship tuples that have a particular relation and object To query for all users that have `reader` relationship with `document:2021-budget`, call read API with body of ```json { \"tuple_key\": { \"object\": \"document:2021-budget\", \"relation\": \"reader\" } } ``` The API will return something like ```json { \"tuples\": [ { \"key\": { \"user\": \"user:bob\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" }, \"timestamp\": \"2021-10-06T15:32:11.128Z\" } ], \"continuation_token\": \"eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ==\" } ``` This means that `document:2021-budget` has 1 `reader` (`user:bob`). Note that, even if the model said that all `writers` are also `readers`, the API will not return writers such as `user:anne` because it only returns tuples and does not evaluate them. ### Query for all users with all relationships for a particular document To query for all users that have any relationship with `document:2021-budget`, call read API with body of ```json { \"tuple_key\": { \"object\": \"document:2021-budget\" } } ``` The API will return something like ```json { \"tuples\": [ { \"key\": { \"user\": \"user:anne\", \"relation\": \"writer\", \"object\": \"document:2021-budget\" }, \"timestamp\": \"2021-10-05T13:42:12.356Z\" }, { \"key\": { \"user\": \"user:bob\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" }, \"timestamp\": \"2021-10-06T15:32:11.128Z\" } ], \"continuation_token\": \"eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ==\" } ``` This means that `document:2021-budget` has 1 `reader` (`user:bob`) and 1 `writer` (`user:anne`).- Parameters:
storeId- (required)body- (required)- Returns:
- CompletableFuture<ApiResponse<ReadResponse>>
- Throws:
ApiException- if fails to make API callFgaInvalidParameterException
-
read
public java.util.concurrent.CompletableFuture<ApiResponse<ReadResponse>> read(java.lang.String storeId, ReadRequest body, ConfigurationOverride configurationOverride) throws ApiException, FgaInvalidParameterException
Get tuples from the store that matches a query, without following userset rewrite rules The Read API will return the tuples for a certain store that match a query filter specified in the body of the request. The API doesn't guarantee order by any field. It is different from the `/stores/{store_id}/expand` API in that it only returns relationship tuples that are stored in the system and satisfy the query. In the body: 1. `tuple_key` is optional. If not specified, it will return all tuples in the store. 2. `tuple_key.object` is mandatory if `tuple_key` is specified. It can be a full object (e.g., `type:object_id`) or type only (e.g., `type:`). 3. `tuple_key.user` is mandatory if tuple_key is specified in the case the `tuple_key.object` is a type only. ## Examples ### Query for all objects in a type definition To query for all objects that `user:bob` has `reader` relationship in the `document` type definition, call read API with body of ```json { \"tuple_key\": { \"user\": \"user:bob\", \"relation\": \"reader\", \"object\": \"document:\" } } ``` The API will return tuples and a continuation token, something like ```json { \"tuples\": [ { \"key\": { \"user\": \"user:bob\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" }, \"timestamp\": \"2021-10-06T15:32:11.128Z\" } ], \"continuation_token\": \"eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ==\" } ``` This means that `user:bob` has a `reader` relationship with 1 document `document:2021-budget`. Note that this API, unlike the List Objects API, does not evaluate the tuples in the store. The continuation token will be empty if there are no more tuples to query. ### Query for all stored relationship tuples that have a particular relation and object To query for all users that have `reader` relationship with `document:2021-budget`, call read API with body of ```json { \"tuple_key\": { \"object\": \"document:2021-budget\", \"relation\": \"reader\" } } ``` The API will return something like ```json { \"tuples\": [ { \"key\": { \"user\": \"user:bob\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" }, \"timestamp\": \"2021-10-06T15:32:11.128Z\" } ], \"continuation_token\": \"eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ==\" } ``` This means that `document:2021-budget` has 1 `reader` (`user:bob`). Note that, even if the model said that all `writers` are also `readers`, the API will not return writers such as `user:anne` because it only returns tuples and does not evaluate them. ### Query for all users with all relationships for a particular document To query for all users that have any relationship with `document:2021-budget`, call read API with body of ```json { \"tuple_key\": { \"object\": \"document:2021-budget\" } } ``` The API will return something like ```json { \"tuples\": [ { \"key\": { \"user\": \"user:anne\", \"relation\": \"writer\", \"object\": \"document:2021-budget\" }, \"timestamp\": \"2021-10-05T13:42:12.356Z\" }, { \"key\": { \"user\": \"user:bob\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" }, \"timestamp\": \"2021-10-06T15:32:11.128Z\" } ], \"continuation_token\": \"eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ==\" } ``` This means that `document:2021-budget` has 1 `reader` (`user:bob`) and 1 `writer` (`user:anne`).- Parameters:
storeId- (required)body- (required)configurationOverride- Override theConfigurationthis OpenFgaApi was constructed with- Returns:
- CompletableFuture<ApiResponse<ReadResponse>>
- Throws:
ApiException- if fails to make API callFgaInvalidParameterException
-
readAssertions
public java.util.concurrent.CompletableFuture<ApiResponse<ReadAssertionsResponse>> readAssertions(java.lang.String storeId, java.lang.String authorizationModelId) throws ApiException, FgaInvalidParameterException
Read assertions for an authorization model ID The ReadAssertions API will return, for a given authorization model id, all the assertions stored for it. An assertion is an object that contains a tuple key, and the expectation of whether a call to the Check API of that tuple key will return true or false.- Parameters:
storeId- (required)authorizationModelId- (required)- Returns:
- CompletableFuture<ApiResponse<ReadAssertionsResponse>>
- Throws:
ApiException- if fails to make API callFgaInvalidParameterException
-
readAssertions
public java.util.concurrent.CompletableFuture<ApiResponse<ReadAssertionsResponse>> readAssertions(java.lang.String storeId, java.lang.String authorizationModelId, ConfigurationOverride configurationOverride) throws ApiException, FgaInvalidParameterException
Read assertions for an authorization model ID The ReadAssertions API will return, for a given authorization model id, all the assertions stored for it. An assertion is an object that contains a tuple key, and the expectation of whether a call to the Check API of that tuple key will return true or false.- Parameters:
storeId- (required)authorizationModelId- (required)configurationOverride- Override theConfigurationthis OpenFgaApi was constructed with- Returns:
- CompletableFuture<ApiResponse<ReadAssertionsResponse>>
- Throws:
ApiException- if fails to make API callFgaInvalidParameterException
-
readAuthorizationModel
public java.util.concurrent.CompletableFuture<ApiResponse<ReadAuthorizationModelResponse>> readAuthorizationModel(java.lang.String storeId, java.lang.String id) throws ApiException, FgaInvalidParameterException
Return a particular version of an authorization model The ReadAuthorizationModel API returns an authorization model by its identifier. The response will return the authorization model for the particular version. ## Example To retrieve the authorization model with ID `01G5JAVJ41T49E9TT3SKVS7X1J` for the store, call the GET authorization-models by ID API with `01G5JAVJ41T49E9TT3SKVS7X1J` as the `id` path parameter. The API will return: ```json { \"authorization_model\":{ \"id\":\"01G5JAVJ41T49E9TT3SKVS7X1J\", \"type_definitions\":[ { \"type\":\"user\" }, { \"type\":\"document\", \"relations\":{ \"reader\":{ \"union\":{ \"child\":[ { \"this\":{} }, { \"computedUserset\":{ \"object\":\"\", \"relation\":\"writer\" } } ] } }, \"writer\":{ \"this\":{} } } } ] } } ``` In the above example, there are 2 types (`user` and `document`). The `document` type has 2 relations (`writer` and `reader`).- Parameters:
storeId- (required)id- (required)- Returns:
- CompletableFuture<ApiResponse<ReadAuthorizationModelResponse>>
- Throws:
ApiException- if fails to make API callFgaInvalidParameterException
-
readAuthorizationModel
public java.util.concurrent.CompletableFuture<ApiResponse<ReadAuthorizationModelResponse>> readAuthorizationModel(java.lang.String storeId, java.lang.String id, ConfigurationOverride configurationOverride) throws ApiException, FgaInvalidParameterException
Return a particular version of an authorization model The ReadAuthorizationModel API returns an authorization model by its identifier. The response will return the authorization model for the particular version. ## Example To retrieve the authorization model with ID `01G5JAVJ41T49E9TT3SKVS7X1J` for the store, call the GET authorization-models by ID API with `01G5JAVJ41T49E9TT3SKVS7X1J` as the `id` path parameter. The API will return: ```json { \"authorization_model\":{ \"id\":\"01G5JAVJ41T49E9TT3SKVS7X1J\", \"type_definitions\":[ { \"type\":\"user\" }, { \"type\":\"document\", \"relations\":{ \"reader\":{ \"union\":{ \"child\":[ { \"this\":{} }, { \"computedUserset\":{ \"object\":\"\", \"relation\":\"writer\" } } ] } }, \"writer\":{ \"this\":{} } } } ] } } ``` In the above example, there are 2 types (`user` and `document`). The `document` type has 2 relations (`writer` and `reader`).- Parameters:
storeId- (required)id- (required)configurationOverride- Override theConfigurationthis OpenFgaApi was constructed with- Returns:
- CompletableFuture<ApiResponse<ReadAuthorizationModelResponse>>
- Throws:
ApiException- if fails to make API callFgaInvalidParameterException
-
readAuthorizationModels
public java.util.concurrent.CompletableFuture<ApiResponse<ReadAuthorizationModelsResponse>> readAuthorizationModels(java.lang.String storeId, java.lang.Integer pageSize, java.lang.String continuationToken) throws ApiException, FgaInvalidParameterException
Return all the authorization models for a particular store The ReadAuthorizationModels API will return all the authorization models for a certain store. OpenFGA's response will contain an array of all authorization models, sorted in descending order of creation. ## Example Assume that a store's authorization model has been configured twice. To get all the authorization models that have been created in this store, call GET authorization-models. The API will return a response that looks like: ```json { \"authorization_models\": [ { \"id\": \"01G50QVV17PECNVAHX1GG4Y5NC\", \"type_definitions\": [...] }, { \"id\": \"01G4ZW8F4A07AKQ8RHSVG9RW04\", \"type_definitions\": [...] }, ], \"continuation_token\": \"eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ==\" } ``` If there are no more authorization models available, the `continuation_token` field will be empty ```json { \"authorization_models\": [ { \"id\": \"01G50QVV17PECNVAHX1GG4Y5NC\", \"type_definitions\": [...] }, { \"id\": \"01G4ZW8F4A07AKQ8RHSVG9RW04\", \"type_definitions\": [...] }, ], \"continuation_token\": \"\" } ```- Parameters:
storeId- (required)pageSize- (optional)continuationToken- (optional)- Returns:
- CompletableFuture<ApiResponse<ReadAuthorizationModelsResponse>>
- Throws:
ApiException- if fails to make API callFgaInvalidParameterException
-
readAuthorizationModels
public java.util.concurrent.CompletableFuture<ApiResponse<ReadAuthorizationModelsResponse>> readAuthorizationModels(java.lang.String storeId, java.lang.Integer pageSize, java.lang.String continuationToken, ConfigurationOverride configurationOverride) throws ApiException, FgaInvalidParameterException
Return all the authorization models for a particular store The ReadAuthorizationModels API will return all the authorization models for a certain store. OpenFGA's response will contain an array of all authorization models, sorted in descending order of creation. ## Example Assume that a store's authorization model has been configured twice. To get all the authorization models that have been created in this store, call GET authorization-models. The API will return a response that looks like: ```json { \"authorization_models\": [ { \"id\": \"01G50QVV17PECNVAHX1GG4Y5NC\", \"type_definitions\": [...] }, { \"id\": \"01G4ZW8F4A07AKQ8RHSVG9RW04\", \"type_definitions\": [...] }, ], \"continuation_token\": \"eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ==\" } ``` If there are no more authorization models available, the `continuation_token` field will be empty ```json { \"authorization_models\": [ { \"id\": \"01G50QVV17PECNVAHX1GG4Y5NC\", \"type_definitions\": [...] }, { \"id\": \"01G4ZW8F4A07AKQ8RHSVG9RW04\", \"type_definitions\": [...] }, ], \"continuation_token\": \"\" } ```- Parameters:
storeId- (required)pageSize- (optional)continuationToken- (optional)configurationOverride- Override theConfigurationthis OpenFgaApi was constructed with- Returns:
- CompletableFuture<ApiResponse<ReadAuthorizationModelsResponse>>
- Throws:
ApiException- if fails to make API callFgaInvalidParameterException
-
readChanges
public java.util.concurrent.CompletableFuture<ApiResponse<ReadChangesResponse>> readChanges(java.lang.String storeId, java.lang.String type, java.lang.Integer pageSize, java.lang.String continuationToken) throws ApiException, FgaInvalidParameterException
Return a list of all the tuple changes The ReadChanges API will return a paginated list of tuple changes (additions and deletions) that occurred in a given store, sorted by ascending time. The response will include a continuation token that is used to get the next set of changes. If there are no changes after the provided continuation token, the same token will be returned in order for it to be used when new changes are recorded. If the store never had any tuples added or removed, this token will be empty. You can use the `type` parameter to only get the list of tuple changes that affect objects of that type. When reading a write tuple change, if it was conditioned, the condition will be returned. When reading a delete tuple change, the condition will NOT be returned regardless of whether it was originally conditioned or not.- Parameters:
storeId- (required)type- (optional)pageSize- (optional)continuationToken- (optional)- Returns:
- CompletableFuture<ApiResponse<ReadChangesResponse>>
- Throws:
ApiException- if fails to make API callFgaInvalidParameterException
-
readChanges
public java.util.concurrent.CompletableFuture<ApiResponse<ReadChangesResponse>> readChanges(java.lang.String storeId, java.lang.String type, java.lang.Integer pageSize, java.lang.String continuationToken, ConfigurationOverride configurationOverride) throws ApiException, FgaInvalidParameterException
Return a list of all the tuple changes The ReadChanges API will return a paginated list of tuple changes (additions and deletions) that occurred in a given store, sorted by ascending time. The response will include a continuation token that is used to get the next set of changes. If there are no changes after the provided continuation token, the same token will be returned in order for it to be used when new changes are recorded. If the store never had any tuples added or removed, this token will be empty. You can use the `type` parameter to only get the list of tuple changes that affect objects of that type. When reading a write tuple change, if it was conditioned, the condition will be returned. When reading a delete tuple change, the condition will NOT be returned regardless of whether it was originally conditioned or not.- Parameters:
storeId- (required)type- (optional)pageSize- (optional)continuationToken- (optional)configurationOverride- Override theConfigurationthis OpenFgaApi was constructed with- Returns:
- CompletableFuture<ApiResponse<ReadChangesResponse>>
- Throws:
ApiException- if fails to make API callFgaInvalidParameterException
-
write
public java.util.concurrent.CompletableFuture<ApiResponse<java.lang.Object>> write(java.lang.String storeId, WriteRequest body) throws ApiException, FgaInvalidParameterException
Add or delete tuples from the store The Write API will update the tuples for a certain store. Tuples and type definitions allow OpenFGA to determine whether a relationship exists between an object and an user. In the body, `writes` adds new tuples and `deletes` removes existing tuples. When deleting a tuple, any `condition` specified with it is ignored. The API is not idempotent: if, later on, you try to add the same tuple key (even if the `condition` is different), or if you try to delete a non-existing tuple, it will throw an error. An `authorization_model_id` may be specified in the body. If it is, it will be used to assert that each written tuple (not deleted) is valid for the model specified. If it is not specified, the latest authorization model ID will be used. ## Example ### Adding relationships To add `user:anne` as a `writer` for `document:2021-budget`, call write API with the following ```json { \"writes\": { \"tuple_keys\": [ { \"user\": \"user:anne\", \"relation\": \"writer\", \"object\": \"document:2021-budget\" } ] }, \"authorization_model_id\": \"01G50QVV17PECNVAHX1GG4Y5NC\" } ``` ### Removing relationships To remove `user:bob` as a `reader` for `document:2021-budget`, call write API with the following ```json { \"deletes\": { \"tuple_keys\": [ { \"user\": \"user:bob\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" } ] } } ```- Parameters:
storeId- (required)body- (required)- Returns:
- CompletableFuture<ApiResponse<Object>>
- Throws:
ApiException- if fails to make API callFgaInvalidParameterException
-
write
public java.util.concurrent.CompletableFuture<ApiResponse<java.lang.Object>> write(java.lang.String storeId, WriteRequest body, ConfigurationOverride configurationOverride) throws ApiException, FgaInvalidParameterException
Add or delete tuples from the store The Write API will update the tuples for a certain store. Tuples and type definitions allow OpenFGA to determine whether a relationship exists between an object and an user. In the body, `writes` adds new tuples and `deletes` removes existing tuples. When deleting a tuple, any `condition` specified with it is ignored. The API is not idempotent: if, later on, you try to add the same tuple key (even if the `condition` is different), or if you try to delete a non-existing tuple, it will throw an error. An `authorization_model_id` may be specified in the body. If it is, it will be used to assert that each written tuple (not deleted) is valid for the model specified. If it is not specified, the latest authorization model ID will be used. ## Example ### Adding relationships To add `user:anne` as a `writer` for `document:2021-budget`, call write API with the following ```json { \"writes\": { \"tuple_keys\": [ { \"user\": \"user:anne\", \"relation\": \"writer\", \"object\": \"document:2021-budget\" } ] }, \"authorization_model_id\": \"01G50QVV17PECNVAHX1GG4Y5NC\" } ``` ### Removing relationships To remove `user:bob` as a `reader` for `document:2021-budget`, call write API with the following ```json { \"deletes\": { \"tuple_keys\": [ { \"user\": \"user:bob\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" } ] } } ```- Parameters:
storeId- (required)body- (required)configurationOverride- Override theConfigurationthis OpenFgaApi was constructed with- Returns:
- CompletableFuture<ApiResponse<Object>>
- Throws:
ApiException- if fails to make API callFgaInvalidParameterException
-
writeAssertions
public java.util.concurrent.CompletableFuture<ApiResponse<java.lang.Void>> writeAssertions(java.lang.String storeId, java.lang.String authorizationModelId, WriteAssertionsRequest body) throws ApiException, FgaInvalidParameterException
Upsert assertions for an authorization model ID The WriteAssertions API will upsert new assertions for an authorization model id, or overwrite the existing ones. An assertion is an object that contains a tuple key, and the expectation of whether a call to the Check API of that tuple key will return true or false.- Parameters:
storeId- (required)authorizationModelId- (required)body- (required)- Returns:
- CompletableFuture<ApiResponse<Void>>
- Throws:
ApiException- if fails to make API callFgaInvalidParameterException
-
writeAssertions
public java.util.concurrent.CompletableFuture<ApiResponse<java.lang.Void>> writeAssertions(java.lang.String storeId, java.lang.String authorizationModelId, WriteAssertionsRequest body, ConfigurationOverride configurationOverride) throws ApiException, FgaInvalidParameterException
Upsert assertions for an authorization model ID The WriteAssertions API will upsert new assertions for an authorization model id, or overwrite the existing ones. An assertion is an object that contains a tuple key, and the expectation of whether a call to the Check API of that tuple key will return true or false.- Parameters:
storeId- (required)authorizationModelId- (required)body- (required)configurationOverride- Override theConfigurationthis OpenFgaApi was constructed with- Returns:
- CompletableFuture<ApiResponse<Void>>
- Throws:
ApiException- if fails to make API callFgaInvalidParameterException
-
writeAuthorizationModel
public java.util.concurrent.CompletableFuture<ApiResponse<WriteAuthorizationModelResponse>> writeAuthorizationModel(java.lang.String storeId, WriteAuthorizationModelRequest body) throws ApiException, FgaInvalidParameterException
Create a new authorization model The WriteAuthorizationModel API will add a new authorization model to a store. Each item in the `type_definitions` array is a type definition as specified in the field `type_definition`. The response will return the authorization model's ID in the `id` field. ## Example To add an authorization model with `user` and `document` type definitions, call POST authorization-models API with the body: ```json { \"type_definitions\":[ { \"type\":\"user\" }, { \"type\":\"document\", \"relations\":{ \"reader\":{ \"union\":{ \"child\":[ { \"this\":{} }, { \"computedUserset\":{ \"object\":\"\", \"relation\":\"writer\" } } ] } }, \"writer\":{ \"this\":{} } } } ] } ``` OpenFGA's response will include the version id for this authorization model, which will look like ``` {\"authorization_model_id\": \"01G50QVV17PECNVAHX1GG4Y5NC\"} ```- Parameters:
storeId- (required)body- (required)- Returns:
- CompletableFuture<ApiResponse<WriteAuthorizationModelResponse>>
- Throws:
ApiException- if fails to make API callFgaInvalidParameterException
-
writeAuthorizationModel
public java.util.concurrent.CompletableFuture<ApiResponse<WriteAuthorizationModelResponse>> writeAuthorizationModel(java.lang.String storeId, WriteAuthorizationModelRequest body, ConfigurationOverride configurationOverride) throws ApiException, FgaInvalidParameterException
Create a new authorization model The WriteAuthorizationModel API will add a new authorization model to a store. Each item in the `type_definitions` array is a type definition as specified in the field `type_definition`. The response will return the authorization model's ID in the `id` field. ## Example To add an authorization model with `user` and `document` type definitions, call POST authorization-models API with the body: ```json { \"type_definitions\":[ { \"type\":\"user\" }, { \"type\":\"document\", \"relations\":{ \"reader\":{ \"union\":{ \"child\":[ { \"this\":{} }, { \"computedUserset\":{ \"object\":\"\", \"relation\":\"writer\" } } ] } }, \"writer\":{ \"this\":{} } } } ] } ``` OpenFGA's response will include the version id for this authorization model, which will look like ``` {\"authorization_model_id\": \"01G50QVV17PECNVAHX1GG4Y5NC\"} ```- Parameters:
storeId- (required)body- (required)configurationOverride- Override theConfigurationthis OpenFgaApi was constructed with- Returns:
- CompletableFuture<ApiResponse<WriteAuthorizationModelResponse>>
- Throws:
ApiException- if fails to make API callFgaInvalidParameterException
-
-