OpenFgaApi

November 19, 2025 ยท View on GitHub

All URIs are relative to http://localhost

MethodHTTP requestDescription
batchCheckPOST /stores/{store_id}/batch-checkSend a list of `check` operations in a single request
batchCheckWithHttpInfoPOST /stores/{store_id}/batch-checkSend a list of `check` operations in a single request
checkPOST /stores/{store_id}/checkCheck whether a user is authorized to access an object
checkWithHttpInfoPOST /stores/{store_id}/checkCheck whether a user is authorized to access an object
createStorePOST /storesCreate a store
createStoreWithHttpInfoPOST /storesCreate a store
deleteStoreDELETE /stores/{store_id}Delete a store
deleteStoreWithHttpInfoDELETE /stores/{store_id}Delete a store
expandPOST /stores/{store_id}/expandExpand all relationships in userset tree format, and following userset rewrite rules. Useful to reason about and debug a certain relationship
expandWithHttpInfoPOST /stores/{store_id}/expandExpand all relationships in userset tree format, and following userset rewrite rules. Useful to reason about and debug a certain relationship
getStoreGET /stores/{store_id}Get a store
getStoreWithHttpInfoGET /stores/{store_id}Get a store
listObjectsPOST /stores/{store_id}/list-objectsList all objects of the given type that the user has a relation with
listObjectsWithHttpInfoPOST /stores/{store_id}/list-objectsList all objects of the given type that the user has a relation with
listStoresGET /storesList all stores
listStoresWithHttpInfoGET /storesList all stores
listUsersPOST /stores/{store_id}/list-usersList the users matching the provided filter who have a certain relation to a particular type.
listUsersWithHttpInfoPOST /stores/{store_id}/list-usersList the users matching the provided filter who have a certain relation to a particular type.
readPOST /stores/{store_id}/readGet tuples from the store that matches a query, without following userset rewrite rules
readWithHttpInfoPOST /stores/{store_id}/readGet tuples from the store that matches a query, without following userset rewrite rules
readAssertionsGET /stores/{store_id}/assertions/{authorization_model_id}Read assertions for an authorization model ID
readAssertionsWithHttpInfoGET /stores/{store_id}/assertions/{authorization_model_id}Read assertions for an authorization model ID
readAuthorizationModelGET /stores/{store_id}/authorization-models/{id}Return a particular version of an authorization model
readAuthorizationModelWithHttpInfoGET /stores/{store_id}/authorization-models/{id}Return a particular version of an authorization model
readAuthorizationModelsGET /stores/{store_id}/authorization-modelsReturn all the authorization models for a particular store
readAuthorizationModelsWithHttpInfoGET /stores/{store_id}/authorization-modelsReturn all the authorization models for a particular store
readChangesGET /stores/{store_id}/changesReturn a list of all the tuple changes
readChangesWithHttpInfoGET /stores/{store_id}/changesReturn a list of all the tuple changes
streamedListObjectsPOST /stores/{store_id}/streamed-list-objectsStream all objects of the given type that the user has a relation with
streamedListObjectsWithHttpInfoPOST /stores/{store_id}/streamed-list-objectsStream all objects of the given type that the user has a relation with
writePOST /stores/{store_id}/writeAdd or delete tuples from the store
writeWithHttpInfoPOST /stores/{store_id}/writeAdd or delete tuples from the store
writeAssertionsPUT /stores/{store_id}/assertions/{authorization_model_id}Upsert assertions for an authorization model ID
writeAssertionsWithHttpInfoPUT /stores/{store_id}/assertions/{authorization_model_id}Upsert assertions for an authorization model ID
writeAuthorizationModelPOST /stores/{store_id}/authorization-modelsCreate a new authorization model
writeAuthorizationModelWithHttpInfoPOST /stores/{store_id}/authorization-modelsCreate a new authorization model

batchCheck

CompletableFuture batchCheck(storeId, body)

Send a list of `check` operations in a single request

The `BatchCheck` API functions nearly identically to `Check`, but instead of checking a single user-object relationship BatchCheck accepts a list of relationships to check and returns a map containing `BatchCheckItem` response for each check it received. An associated `correlation_id` is required for each check in the batch. This ID is used to correlate a check to the appropriate response. It is a string consisting of only alphanumeric characters or hyphens with a maximum length of 36 characters. This `correlation_id` is used to map the result of each check to the item which was checked, so it must be unique for each item in the batch. We recommend using a UUID or ULID as the `correlation_id`, but you can use whatever unique identifier you need as long as it matches this regex pattern: `^[\w\d-]{1,36}$` NOTE: The maximum number of checks that can be passed in the `BatchCheck` API is configurable via the OPENFGA_MAX_CHECKS_PER_BATCH_CHECK environment variable. If `BatchCheck` is called using the SDK, the SDK can split the batch check requests for you. For more details on how `Check` functions, see the docs for `/check`. ### Examples #### A BatchCheckRequest ```json { "checks": [ { "tuple_key": { "object": "document:2021-budget" "relation": "reader", "user": "user:anne", }, "contextual_tuples": {...} "context": {} "correlation_id": "01JA8PM3QM7VBPGB8KMPK8SBD5" }, { "tuple_key": { "object": "document:2021-budget" "relation": "reader", "user": "user:bob", }, "contextual_tuples": {...} "context": {} "correlation_id": "01JA8PMM6A90NV5ET0F28CYSZQ" } ] } ``` Below is a possible response to the above request. Note that the result map's keys are the `correlation_id` values from the checked items in the request: ```json { "result": { "01JA8PMM6A90NV5ET0F28CYSZQ": { "allowed": false, "error": {"message": ""} }, "01JA8PM3QM7VBPGB8KMPK8SBD5": { "allowed": true, "error": {"message": ""} } } ```

Example

// Import classes:
import dev.openfga.sdk.api.client.ApiClient;
import dev.openfga.sdk.api.client.ApiException;
import dev.openfga.sdk.api.configuration.Configuration;
import dev.openfga.sdk.api.client.models.*;
import dev.openfga.sdk.api.OpenFgaApi;
import java.util.concurrent.CompletableFuture;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("http://localhost");

        OpenFgaApi apiInstance = new OpenFgaApi(defaultClient);
        String storeId = "storeId_example"; // String | 
        BatchCheckRequest body = new BatchCheckRequest(); // BatchCheckRequest | 
        try {
            CompletableFuture<BatchCheckResponse> result = apiInstance.batchCheck(storeId, body);
            System.out.println(result.get());
        } catch (ApiException e) {
            System.err.println("Exception when calling OpenFgaApi#batchCheck");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

NameTypeDescriptionNotes
storeIdString
bodyBatchCheckRequest

Return type

CompletableFuture<BatchCheckResponse>

Authorization

No authorization required

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200A successful response.-
400Request failed due to invalid input.-
401Not authenticated.-
403Forbidden.-
404Request failed due to incorrect path.-
409Request was aborted due a transaction conflict.-
422Request timed out due to excessive request throttling.-
500Request failed due to internal server error.-

batchCheckWithHttpInfo

CompletableFuture<ApiResponse> batchCheck batchCheckWithHttpInfo(storeId, body)

Send a list of `check` operations in a single request

The `BatchCheck` API functions nearly identically to `Check`, but instead of checking a single user-object relationship BatchCheck accepts a list of relationships to check and returns a map containing `BatchCheckItem` response for each check it received. An associated `correlation_id` is required for each check in the batch. This ID is used to correlate a check to the appropriate response. It is a string consisting of only alphanumeric characters or hyphens with a maximum length of 36 characters. This `correlation_id` is used to map the result of each check to the item which was checked, so it must be unique for each item in the batch. We recommend using a UUID or ULID as the `correlation_id`, but you can use whatever unique identifier you need as long as it matches this regex pattern: `^[\w\d-]{1,36}$` NOTE: The maximum number of checks that can be passed in the `BatchCheck` API is configurable via the OPENFGA_MAX_CHECKS_PER_BATCH_CHECK environment variable. If `BatchCheck` is called using the SDK, the SDK can split the batch check requests for you. For more details on how `Check` functions, see the docs for `/check`. ### Examples #### A BatchCheckRequest ```json { &quot;checks&quot;: [ { &quot;tuple_key&quot;: { &quot;object&quot;: &quot;document:2021-budget&quot; &quot;relation&quot;: &quot;reader&quot;, &quot;user&quot;: &quot;user:anne&quot;, }, &quot;contextual_tuples&quot;: {...} &quot;context&quot;: {} &quot;correlation_id&quot;: &quot;01JA8PM3QM7VBPGB8KMPK8SBD5&quot; }, { &quot;tuple_key&quot;: { &quot;object&quot;: &quot;document:2021-budget&quot; &quot;relation&quot;: &quot;reader&quot;, &quot;user&quot;: &quot;user:bob&quot;, }, &quot;contextual_tuples&quot;: {...} &quot;context&quot;: {} &quot;correlation_id&quot;: &quot;01JA8PMM6A90NV5ET0F28CYSZQ&quot; } ] } ``` Below is a possible response to the above request. Note that the result map's keys are the `correlation_id` values from the checked items in the request: ```json { &quot;result&quot;: { &quot;01JA8PMM6A90NV5ET0F28CYSZQ&quot;: { &quot;allowed&quot;: false, &quot;error&quot;: {&quot;message&quot;: &quot;&quot;} }, &quot;01JA8PM3QM7VBPGB8KMPK8SBD5&quot;: { &quot;allowed&quot;: true, &quot;error&quot;: {&quot;message&quot;: &quot;&quot;} } } ```

Example

// Import classes:
import dev.openfga.sdk.api.client.ApiClient;
import dev.openfga.sdk.api.client.ApiException;
import dev.openfga.sdk.api.client.ApiResponse;
import dev.openfga.sdk.api.configuration.Configuration;
import dev.openfga.sdk.api.client.models.*;
import dev.openfga.sdk.api.OpenFgaApi;
import java.util.concurrent.CompletableFuture;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("http://localhost");

        OpenFgaApi apiInstance = new OpenFgaApi(defaultClient);
        String storeId = "storeId_example"; // String | 
        BatchCheckRequest body = new BatchCheckRequest(); // BatchCheckRequest | 
        try {
            CompletableFuture<ApiResponse<BatchCheckResponse>> response = apiInstance.batchCheckWithHttpInfo(storeId, body);
            System.out.println("Status code: " + response.get().getStatusCode());
            System.out.println("Response headers: " + response.get().getHeaders());
            System.out.println("Response body: " + response.get().getData());
        } catch (InterruptedException | ExecutionException e) {
            ApiException apiException = (ApiException)e.getCause();
            System.err.println("Exception when calling OpenFgaApi#batchCheck");
            System.err.println("Status code: " + apiException.getCode());
            System.err.println("Response headers: " + apiException.getResponseHeaders());
            System.err.println("Reason: " + apiException.getResponseBody());
            e.printStackTrace();
        } catch (ApiException e) {
            System.err.println("Exception when calling OpenFgaApi#batchCheck");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            System.err.println("Reason: " + e.getResponseBody());
            e.printStackTrace();
        }
    }
}

Parameters

NameTypeDescriptionNotes
storeIdString
bodyBatchCheckRequest

Return type

CompletableFuture<ApiResponse<BatchCheckResponse>>

Authorization

No authorization required

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200A successful response.-
400Request failed due to invalid input.-
401Not authenticated.-
403Forbidden.-
404Request failed due to incorrect path.-
409Request was aborted due a transaction conflict.-
422Request timed out due to excessive request throttling.-
500Request failed due to internal server error.-

check

CompletableFuture check(storeId, body)

Check whether a user is authorized to access an object

The Check API returns whether a given user has a relationship with a given object in a given store. The `user` field of the request can be a specific target, such as `user:anne`, or a userset (set of users) such as `group:marketing#member` or a type-bound public access `user:*`. To arrive at a result, the API uses: an authorization model, explicit tuples written through the Write API, contextual tuples present in the request, and implicit tuples that exist by virtue of applying set theory (such as `document:2021-budget#viewer@document:2021-budget#viewer`; the set of users who are viewers of `document:2021-budget` are the set of users who are the viewers of `document:2021-budget`). 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. By default, the Check API caches results for a short time to optimize performance. You may specify a value of `HIGHER_CONSISTENCY` for the optional `consistency` parameter in the body to inform the server that higher conisistency is preferred at the expense of increased latency. Consideration should be given to the increased latency if requesting higher consistency. The response will return whether the relationship exists in the field `allowed`. Some exceptions apply, but in general, if a Check API responds with `{allowed: true}`, then you can expect the equivalent ListObjects query to return the object, and viceversa. For example, if `Check(user:anne, reader, document:2021-budget)` responds with `{allowed: true}`, then `ListObjects(user:anne, reader, document)` may include `document:2021-budget` in the response. ## Examples ### Querying with contextual tuples 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 { &quot;user&quot;: &quot;user:anne&quot;, &quot;relation&quot;: &quot;member&quot;, &quot;object&quot;: &quot;time_slot:office_hours&quot; } ``` the Check API can be used with the following request body: ```json { &quot;tuple_key&quot;: { &quot;user&quot;: &quot;user:anne&quot;, &quot;relation&quot;: &quot;reader&quot;, &quot;object&quot;: &quot;document:2021-budget&quot; }, &quot;contextual_tuples&quot;: { &quot;tuple_keys&quot;: [ { &quot;user&quot;: &quot;user:anne&quot;, &quot;relation&quot;: &quot;member&quot;, &quot;object&quot;: &quot;time_slot:office_hours&quot; } ] }, &quot;authorization_model_id&quot;: &quot;01G50QVV17PECNVAHX1GG4Y5NC&quot; } ``` ### Querying usersets Some Checks will always return `true`, even without any tuples. For example, for the following authorization model ```python model schema 1.1 type user type document relations define reader: [user] ``` the following query ```json { &quot;tuple_key&quot;: { &quot;user&quot;: &quot;document:2021-budget#reader&quot;, &quot;relation&quot;: &quot;reader&quot;, &quot;object&quot;: &quot;document:2021-budget&quot; } } ``` will always return `{ &quot;allowed&quot;: true }`. This is because usersets are self-defining: the userset `document:2021-budget#reader` will always have the `reader` relation with `document:2021-budget`. ### Querying usersets with difference in the model A Check for a userset can yield results that must be treated carefully if the model involves difference. For example, for the following authorization model ```python model schema 1.1 type user type group relations define member: [user] type document relations define blocked: [user] define reader: [group#member] but not blocked ``` the following query ```json { &quot;tuple_key&quot;: { &quot;user&quot;: &quot;group:finance#member&quot;, &quot;relation&quot;: &quot;reader&quot;, &quot;object&quot;: &quot;document:2021-budget&quot; }, &quot;contextual_tuples&quot;: { &quot;tuple_keys&quot;: [ { &quot;user&quot;: &quot;user:anne&quot;, &quot;relation&quot;: &quot;member&quot;, &quot;object&quot;: &quot;group:finance&quot; }, { &quot;user&quot;: &quot;group:finance#member&quot;, &quot;relation&quot;: &quot;reader&quot;, &quot;object&quot;: &quot;document:2021-budget&quot; }, { &quot;user&quot;: &quot;user:anne&quot;, &quot;relation&quot;: &quot;blocked&quot;, &quot;object&quot;: &quot;document:2021-budget&quot; } ] }, } ``` will return `{ &quot;allowed&quot;: true }`, even though a specific user of the userset `group:finance#member` does not have the `reader` relationship with the given object. ### Requesting higher consistency By default, the Check API caches results for a short time to optimize performance. You may request higher consistency to inform the server that higher consistency should be preferred at the expense of increased latency. Care should be taken when requesting higher consistency due to the increased latency. ```json { &quot;tuple_key&quot;: { &quot;user&quot;: &quot;group:finance#member&quot;, &quot;relation&quot;: &quot;reader&quot;, &quot;object&quot;: &quot;document:2021-budget&quot; }, &quot;consistency&quot;: &quot;HIGHER_CONSISTENCY&quot; } ```

Example

// Import classes:
import dev.openfga.sdk.api.client.ApiClient;
import dev.openfga.sdk.api.client.ApiException;
import dev.openfga.sdk.api.configuration.Configuration;
import dev.openfga.sdk.api.client.models.*;
import dev.openfga.sdk.api.OpenFgaApi;
import java.util.concurrent.CompletableFuture;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("http://localhost");

        OpenFgaApi apiInstance = new OpenFgaApi(defaultClient);
        String storeId = "storeId_example"; // String | 
        CheckRequest body = new CheckRequest(); // CheckRequest | 
        try {
            CompletableFuture<CheckResponse> result = apiInstance.check(storeId, body);
            System.out.println(result.get());
        } catch (ApiException e) {
            System.err.println("Exception when calling OpenFgaApi#check");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

NameTypeDescriptionNotes
storeIdString
bodyCheckRequest

Return type

CompletableFuture<CheckResponse>

Authorization

No authorization required

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200A successful response.-
400Request failed due to invalid input.-
401Not authenticated.-
403Forbidden.-
404Request failed due to incorrect path.-
409Request was aborted due a transaction conflict.-
422Request timed out due to excessive request throttling.-
500Request failed due to internal server error.-

checkWithHttpInfo

CompletableFuture<ApiResponse> check checkWithHttpInfo(storeId, body)

Check whether a user is authorized to access an object

The Check API returns whether a given user has a relationship with a given object in a given store. The `user` field of the request can be a specific target, such as `user:anne`, or a userset (set of users) such as `group:marketing#member` or a type-bound public access `user:*`. To arrive at a result, the API uses: an authorization model, explicit tuples written through the Write API, contextual tuples present in the request, and implicit tuples that exist by virtue of applying set theory (such as `document:2021-budget#viewer@document:2021-budget#viewer`; the set of users who are viewers of `document:2021-budget` are the set of users who are the viewers of `document:2021-budget`). 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. By default, the Check API caches results for a short time to optimize performance. You may specify a value of `HIGHER_CONSISTENCY` for the optional `consistency` parameter in the body to inform the server that higher conisistency is preferred at the expense of increased latency. Consideration should be given to the increased latency if requesting higher consistency. The response will return whether the relationship exists in the field `allowed`. Some exceptions apply, but in general, if a Check API responds with `{allowed: true}`, then you can expect the equivalent ListObjects query to return the object, and viceversa. For example, if `Check(user:anne, reader, document:2021-budget)` responds with `{allowed: true}`, then `ListObjects(user:anne, reader, document)` may include `document:2021-budget` in the response. ## Examples ### Querying with contextual tuples 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 { &quot;user&quot;: &quot;user:anne&quot;, &quot;relation&quot;: &quot;member&quot;, &quot;object&quot;: &quot;time_slot:office_hours&quot; } ``` the Check API can be used with the following request body: ```json { &quot;tuple_key&quot;: { &quot;user&quot;: &quot;user:anne&quot;, &quot;relation&quot;: &quot;reader&quot;, &quot;object&quot;: &quot;document:2021-budget&quot; }, &quot;contextual_tuples&quot;: { &quot;tuple_keys&quot;: [ { &quot;user&quot;: &quot;user:anne&quot;, &quot;relation&quot;: &quot;member&quot;, &quot;object&quot;: &quot;time_slot:office_hours&quot; } ] }, &quot;authorization_model_id&quot;: &quot;01G50QVV17PECNVAHX1GG4Y5NC&quot; } ``` ### Querying usersets Some Checks will always return `true`, even without any tuples. For example, for the following authorization model ```python model schema 1.1 type user type document relations define reader: [user] ``` the following query ```json { &quot;tuple_key&quot;: { &quot;user&quot;: &quot;document:2021-budget#reader&quot;, &quot;relation&quot;: &quot;reader&quot;, &quot;object&quot;: &quot;document:2021-budget&quot; } } ``` will always return `{ &quot;allowed&quot;: true }`. This is because usersets are self-defining: the userset `document:2021-budget#reader` will always have the `reader` relation with `document:2021-budget`. ### Querying usersets with difference in the model A Check for a userset can yield results that must be treated carefully if the model involves difference. For example, for the following authorization model ```python model schema 1.1 type user type group relations define member: [user] type document relations define blocked: [user] define reader: [group#member] but not blocked ``` the following query ```json { &quot;tuple_key&quot;: { &quot;user&quot;: &quot;group:finance#member&quot;, &quot;relation&quot;: &quot;reader&quot;, &quot;object&quot;: &quot;document:2021-budget&quot; }, &quot;contextual_tuples&quot;: { &quot;tuple_keys&quot;: [ { &quot;user&quot;: &quot;user:anne&quot;, &quot;relation&quot;: &quot;member&quot;, &quot;object&quot;: &quot;group:finance&quot; }, { &quot;user&quot;: &quot;group:finance#member&quot;, &quot;relation&quot;: &quot;reader&quot;, &quot;object&quot;: &quot;document:2021-budget&quot; }, { &quot;user&quot;: &quot;user:anne&quot;, &quot;relation&quot;: &quot;blocked&quot;, &quot;object&quot;: &quot;document:2021-budget&quot; } ] }, } ``` will return `{ &quot;allowed&quot;: true }`, even though a specific user of the userset `group:finance#member` does not have the `reader` relationship with the given object. ### Requesting higher consistency By default, the Check API caches results for a short time to optimize performance. You may request higher consistency to inform the server that higher consistency should be preferred at the expense of increased latency. Care should be taken when requesting higher consistency due to the increased latency. ```json { &quot;tuple_key&quot;: { &quot;user&quot;: &quot;group:finance#member&quot;, &quot;relation&quot;: &quot;reader&quot;, &quot;object&quot;: &quot;document:2021-budget&quot; }, &quot;consistency&quot;: &quot;HIGHER_CONSISTENCY&quot; } ```

Example

// Import classes:
import dev.openfga.sdk.api.client.ApiClient;
import dev.openfga.sdk.api.client.ApiException;
import dev.openfga.sdk.api.client.ApiResponse;
import dev.openfga.sdk.api.configuration.Configuration;
import dev.openfga.sdk.api.client.models.*;
import dev.openfga.sdk.api.OpenFgaApi;
import java.util.concurrent.CompletableFuture;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("http://localhost");

        OpenFgaApi apiInstance = new OpenFgaApi(defaultClient);
        String storeId = "storeId_example"; // String | 
        CheckRequest body = new CheckRequest(); // CheckRequest | 
        try {
            CompletableFuture<ApiResponse<CheckResponse>> response = apiInstance.checkWithHttpInfo(storeId, body);
            System.out.println("Status code: " + response.get().getStatusCode());
            System.out.println("Response headers: " + response.get().getHeaders());
            System.out.println("Response body: " + response.get().getData());
        } catch (InterruptedException | ExecutionException e) {
            ApiException apiException = (ApiException)e.getCause();
            System.err.println("Exception when calling OpenFgaApi#check");
            System.err.println("Status code: " + apiException.getCode());
            System.err.println("Response headers: " + apiException.getResponseHeaders());
            System.err.println("Reason: " + apiException.getResponseBody());
            e.printStackTrace();
        } catch (ApiException e) {
            System.err.println("Exception when calling OpenFgaApi#check");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            System.err.println("Reason: " + e.getResponseBody());
            e.printStackTrace();
        }
    }
}

Parameters

NameTypeDescriptionNotes
storeIdString
bodyCheckRequest

Return type

CompletableFuture<ApiResponse<CheckResponse>>

Authorization

No authorization required

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200A successful response.-
400Request failed due to invalid input.-
401Not authenticated.-
403Forbidden.-
404Request failed due to incorrect path.-
409Request was aborted due a transaction conflict.-
422Request timed out due to excessive request throttling.-
500Request failed due to internal server error.-

createStore

CompletableFuture createStore(body)

Create a store

Create a unique OpenFGA store which will be used to store authorization models and relationship tuples.

Example

// Import classes:
import dev.openfga.sdk.api.client.ApiClient;
import dev.openfga.sdk.api.client.ApiException;
import dev.openfga.sdk.api.configuration.Configuration;
import dev.openfga.sdk.api.client.models.*;
import dev.openfga.sdk.api.OpenFgaApi;
import java.util.concurrent.CompletableFuture;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("http://localhost");

        OpenFgaApi apiInstance = new OpenFgaApi(defaultClient);
        CreateStoreRequest body = new CreateStoreRequest(); // CreateStoreRequest | 
        try {
            CompletableFuture<CreateStoreResponse> result = apiInstance.createStore(body);
            System.out.println(result.get());
        } catch (ApiException e) {
            System.err.println("Exception when calling OpenFgaApi#createStore");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

NameTypeDescriptionNotes
bodyCreateStoreRequest

Return type

CompletableFuture<CreateStoreResponse>

Authorization

No authorization required

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
201A successful response.-
400Request failed due to invalid input.-
401Not authenticated.-
403Forbidden.-
404Request failed due to incorrect path.-
409Request was aborted due a transaction conflict.-
422Request timed out due to excessive request throttling.-
500Request failed due to internal server error.-

createStoreWithHttpInfo

CompletableFuture<ApiResponse> createStore createStoreWithHttpInfo(body)

Create a store

Create a unique OpenFGA store which will be used to store authorization models and relationship tuples.

Example

// Import classes:
import dev.openfga.sdk.api.client.ApiClient;
import dev.openfga.sdk.api.client.ApiException;
import dev.openfga.sdk.api.client.ApiResponse;
import dev.openfga.sdk.api.configuration.Configuration;
import dev.openfga.sdk.api.client.models.*;
import dev.openfga.sdk.api.OpenFgaApi;
import java.util.concurrent.CompletableFuture;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("http://localhost");

        OpenFgaApi apiInstance = new OpenFgaApi(defaultClient);
        CreateStoreRequest body = new CreateStoreRequest(); // CreateStoreRequest | 
        try {
            CompletableFuture<ApiResponse<CreateStoreResponse>> response = apiInstance.createStoreWithHttpInfo(body);
            System.out.println("Status code: " + response.get().getStatusCode());
            System.out.println("Response headers: " + response.get().getHeaders());
            System.out.println("Response body: " + response.get().getData());
        } catch (InterruptedException | ExecutionException e) {
            ApiException apiException = (ApiException)e.getCause();
            System.err.println("Exception when calling OpenFgaApi#createStore");
            System.err.println("Status code: " + apiException.getCode());
            System.err.println("Response headers: " + apiException.getResponseHeaders());
            System.err.println("Reason: " + apiException.getResponseBody());
            e.printStackTrace();
        } catch (ApiException e) {
            System.err.println("Exception when calling OpenFgaApi#createStore");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            System.err.println("Reason: " + e.getResponseBody());
            e.printStackTrace();
        }
    }
}

Parameters

NameTypeDescriptionNotes
bodyCreateStoreRequest

Return type

CompletableFuture<ApiResponse<CreateStoreResponse>>

Authorization

No authorization required

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
201A successful response.-
400Request failed due to invalid input.-
401Not authenticated.-
403Forbidden.-
404Request failed due to incorrect path.-
409Request was aborted due a transaction conflict.-
422Request timed out due to excessive request throttling.-
500Request failed due to internal server error.-

deleteStore

CompletableFuture deleteStore(storeId)

Delete a store

Delete an OpenFGA store. This does not delete the data associated with the store, like tuples or authorization models.

Example

// Import classes:
import dev.openfga.sdk.api.client.ApiClient;
import dev.openfga.sdk.api.client.ApiException;
import dev.openfga.sdk.api.configuration.Configuration;
import dev.openfga.sdk.api.client.models.*;
import dev.openfga.sdk.api.OpenFgaApi;
import java.util.concurrent.CompletableFuture;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("http://localhost");

        OpenFgaApi apiInstance = new OpenFgaApi(defaultClient);
        String storeId = "storeId_example"; // String | 
        try {
            CompletableFuture<Void> result = apiInstance.deleteStore(storeId);
        } catch (ApiException e) {
            System.err.println("Exception when calling OpenFgaApi#deleteStore");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

NameTypeDescriptionNotes
storeIdString

Return type

CompletableFuture (empty response body)

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
204A successful response.-
400Request failed due to invalid input.-
401Not authenticated.-
403Forbidden.-
404Request failed due to incorrect path.-
409Request was aborted due a transaction conflict.-
422Request timed out due to excessive request throttling.-
500Request failed due to internal server error.-

deleteStoreWithHttpInfo

CompletableFuture<ApiResponse> deleteStore deleteStoreWithHttpInfo(storeId)

Delete a store

Delete an OpenFGA store. This does not delete the data associated with the store, like tuples or authorization models.

Example

// Import classes:
import dev.openfga.sdk.api.client.ApiClient;
import dev.openfga.sdk.api.client.ApiException;
import dev.openfga.sdk.api.client.ApiResponse;
import dev.openfga.sdk.api.configuration.Configuration;
import dev.openfga.sdk.api.client.models.*;
import dev.openfga.sdk.api.OpenFgaApi;
import java.util.concurrent.CompletableFuture;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("http://localhost");

        OpenFgaApi apiInstance = new OpenFgaApi(defaultClient);
        String storeId = "storeId_example"; // String | 
        try {
            CompletableFuture<ApiResponse<Void>> response = apiInstance.deleteStoreWithHttpInfo(storeId);
            System.out.println("Status code: " + response.get().getStatusCode());
            System.out.println("Response headers: " + response.get().getHeaders());
        } catch (InterruptedException | ExecutionException e) {
            ApiException apiException = (ApiException)e.getCause();
            System.err.println("Exception when calling OpenFgaApi#deleteStore");
            System.err.println("Status code: " + apiException.getCode());
            System.err.println("Response headers: " + apiException.getResponseHeaders());
            System.err.println("Reason: " + apiException.getResponseBody());
            e.printStackTrace();
        } catch (ApiException e) {
            System.err.println("Exception when calling OpenFgaApi#deleteStore");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            System.err.println("Reason: " + e.getResponseBody());
            e.printStackTrace();
        }
    }
}

Parameters

NameTypeDescriptionNotes
storeIdString

Return type

CompletableFuture<ApiResponse>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
204A successful response.-
400Request failed due to invalid input.-
401Not authenticated.-
403Forbidden.-
404Request failed due to incorrect path.-
409Request was aborted due a transaction conflict.-
422Request timed out due to excessive request throttling.-
500Request failed due to internal server error.-

expand

CompletableFuture expand(storeId, body)

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. 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`. 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 { &quot;tuple_key&quot;: { &quot;object&quot;: &quot;document:2021-budget&quot;, &quot;relation&quot;: &quot;reader&quot; }, &quot;authorization_model_id&quot;: &quot;01G50QVV17PECNVAHX1GG4Y5NC&quot; } ``` OpenFGA's response will be a userset tree of the users and usersets that have read access to the document. ```json { &quot;tree&quot;:{ &quot;root&quot;:{ &quot;type&quot;:&quot;document:2021-budget#reader&quot;, &quot;union&quot;:{ &quot;nodes&quot;:[ { &quot;type&quot;:&quot;document:2021-budget#reader&quot;, &quot;leaf&quot;:{ &quot;users&quot;:{ &quot;users&quot;:[ &quot;user:bob&quot; ] } } }, { &quot;type&quot;:&quot;document:2021-budget#reader&quot;, &quot;leaf&quot;:{ &quot;computed&quot;:{ &quot;userset&quot;:&quot;document:2021-budget#writer&quot; } } } ] } } } } ``` The caller can then call expand API for the `writer` relationship for the `document:2021-budget`. ### Expand Request with Contextual Tuples Given the model ```python model schema 1.1 type user type folder relations define owner: [user] type document relations define parent: [folder] define viewer: [user] or writer define writer: [user] or owner from parent ``` and the initial tuples ```json [{ &quot;user&quot;: &quot;user:bob&quot;, &quot;relation&quot;: &quot;owner&quot;, &quot;object&quot;: &quot;folder:1&quot; }] ``` To expand all `writers` of `document:1` when `document:1` is put in `folder:1`, the first call could be ```json { &quot;tuple_key&quot;: { &quot;object&quot;: &quot;document:1&quot;, &quot;relation&quot;: &quot;writer&quot; }, &quot;contextual_tuples&quot;: { &quot;tuple_keys&quot;: [ { &quot;user&quot;: &quot;folder:1&quot;, &quot;relation&quot;: &quot;parent&quot;, &quot;object&quot;: &quot;document:1&quot; } ] } } ``` this returns: ```json { &quot;tree&quot;: { &quot;root&quot;: { &quot;name&quot;: &quot;document:1#writer&quot;, &quot;union&quot;: { &quot;nodes&quot;: [ { &quot;name&quot;: &quot;document:1#writer&quot;, &quot;leaf&quot;: { &quot;users&quot;: { &quot;users&quot;: [] } } }, { &quot;name&quot;: &quot;document:1#writer&quot;, &quot;leaf&quot;: { &quot;tupleToUserset&quot;: { &quot;tupleset&quot;: &quot;document:1#parent&quot;, &quot;computed&quot;: [ { &quot;userset&quot;: &quot;folder:1#owner&quot; } ] } } } ] } } } } ``` This tells us that the `owner` of `folder:1` may also be a writer. So our next call could be to find the `owners` of `folder:1` ```json { &quot;tuple_key&quot;: { &quot;object&quot;: &quot;folder:1&quot;, &quot;relation&quot;: &quot;owner&quot; } } ``` which gives ```json { &quot;tree&quot;: { &quot;root&quot;: { &quot;name&quot;: &quot;folder:1#owner&quot;, &quot;leaf&quot;: { &quot;users&quot;: { &quot;users&quot;: [ &quot;user:bob&quot; ] } } } } } ```

Example

// Import classes:
import dev.openfga.sdk.api.client.ApiClient;
import dev.openfga.sdk.api.client.ApiException;
import dev.openfga.sdk.api.configuration.Configuration;
import dev.openfga.sdk.api.client.models.*;
import dev.openfga.sdk.api.OpenFgaApi;
import java.util.concurrent.CompletableFuture;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("http://localhost");

        OpenFgaApi apiInstance = new OpenFgaApi(defaultClient);
        String storeId = "storeId_example"; // String | 
        ExpandRequest body = new ExpandRequest(); // ExpandRequest | 
        try {
            CompletableFuture<ExpandResponse> result = apiInstance.expand(storeId, body);
            System.out.println(result.get());
        } catch (ApiException e) {
            System.err.println("Exception when calling OpenFgaApi#expand");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

NameTypeDescriptionNotes
storeIdString
bodyExpandRequest

Return type

CompletableFuture<ExpandResponse>

Authorization

No authorization required

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200A successful response.-
400Request failed due to invalid input.-
401Not authenticated.-
403Forbidden.-
404Request failed due to incorrect path.-
409Request was aborted due a transaction conflict.-
422Request timed out due to excessive request throttling.-
500Request failed due to internal server error.-

expandWithHttpInfo

CompletableFuture<ApiResponse> expand expandWithHttpInfo(storeId, body)

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. 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`. 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 { &quot;tuple_key&quot;: { &quot;object&quot;: &quot;document:2021-budget&quot;, &quot;relation&quot;: &quot;reader&quot; }, &quot;authorization_model_id&quot;: &quot;01G50QVV17PECNVAHX1GG4Y5NC&quot; } ``` OpenFGA's response will be a userset tree of the users and usersets that have read access to the document. ```json { &quot;tree&quot;:{ &quot;root&quot;:{ &quot;type&quot;:&quot;document:2021-budget#reader&quot;, &quot;union&quot;:{ &quot;nodes&quot;:[ { &quot;type&quot;:&quot;document:2021-budget#reader&quot;, &quot;leaf&quot;:{ &quot;users&quot;:{ &quot;users&quot;:[ &quot;user:bob&quot; ] } } }, { &quot;type&quot;:&quot;document:2021-budget#reader&quot;, &quot;leaf&quot;:{ &quot;computed&quot;:{ &quot;userset&quot;:&quot;document:2021-budget#writer&quot; } } } ] } } } } ``` The caller can then call expand API for the `writer` relationship for the `document:2021-budget`. ### Expand Request with Contextual Tuples Given the model ```python model schema 1.1 type user type folder relations define owner: [user] type document relations define parent: [folder] define viewer: [user] or writer define writer: [user] or owner from parent ``` and the initial tuples ```json [{ &quot;user&quot;: &quot;user:bob&quot;, &quot;relation&quot;: &quot;owner&quot;, &quot;object&quot;: &quot;folder:1&quot; }] ``` To expand all `writers` of `document:1` when `document:1` is put in `folder:1`, the first call could be ```json { &quot;tuple_key&quot;: { &quot;object&quot;: &quot;document:1&quot;, &quot;relation&quot;: &quot;writer&quot; }, &quot;contextual_tuples&quot;: { &quot;tuple_keys&quot;: [ { &quot;user&quot;: &quot;folder:1&quot;, &quot;relation&quot;: &quot;parent&quot;, &quot;object&quot;: &quot;document:1&quot; } ] } } ``` this returns: ```json { &quot;tree&quot;: { &quot;root&quot;: { &quot;name&quot;: &quot;document:1#writer&quot;, &quot;union&quot;: { &quot;nodes&quot;: [ { &quot;name&quot;: &quot;document:1#writer&quot;, &quot;leaf&quot;: { &quot;users&quot;: { &quot;users&quot;: [] } } }, { &quot;name&quot;: &quot;document:1#writer&quot;, &quot;leaf&quot;: { &quot;tupleToUserset&quot;: { &quot;tupleset&quot;: &quot;document:1#parent&quot;, &quot;computed&quot;: [ { &quot;userset&quot;: &quot;folder:1#owner&quot; } ] } } } ] } } } } ``` This tells us that the `owner` of `folder:1` may also be a writer. So our next call could be to find the `owners` of `folder:1` ```json { &quot;tuple_key&quot;: { &quot;object&quot;: &quot;folder:1&quot;, &quot;relation&quot;: &quot;owner&quot; } } ``` which gives ```json { &quot;tree&quot;: { &quot;root&quot;: { &quot;name&quot;: &quot;folder:1#owner&quot;, &quot;leaf&quot;: { &quot;users&quot;: { &quot;users&quot;: [ &quot;user:bob&quot; ] } } } } } ```

Example

// Import classes:
import dev.openfga.sdk.api.client.ApiClient;
import dev.openfga.sdk.api.client.ApiException;
import dev.openfga.sdk.api.client.ApiResponse;
import dev.openfga.sdk.api.configuration.Configuration;
import dev.openfga.sdk.api.client.models.*;
import dev.openfga.sdk.api.OpenFgaApi;
import java.util.concurrent.CompletableFuture;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("http://localhost");

        OpenFgaApi apiInstance = new OpenFgaApi(defaultClient);
        String storeId = "storeId_example"; // String | 
        ExpandRequest body = new ExpandRequest(); // ExpandRequest | 
        try {
            CompletableFuture<ApiResponse<ExpandResponse>> response = apiInstance.expandWithHttpInfo(storeId, body);
            System.out.println("Status code: " + response.get().getStatusCode());
            System.out.println("Response headers: " + response.get().getHeaders());
            System.out.println("Response body: " + response.get().getData());
        } catch (InterruptedException | ExecutionException e) {
            ApiException apiException = (ApiException)e.getCause();
            System.err.println("Exception when calling OpenFgaApi#expand");
            System.err.println("Status code: " + apiException.getCode());
            System.err.println("Response headers: " + apiException.getResponseHeaders());
            System.err.println("Reason: " + apiException.getResponseBody());
            e.printStackTrace();
        } catch (ApiException e) {
            System.err.println("Exception when calling OpenFgaApi#expand");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            System.err.println("Reason: " + e.getResponseBody());
            e.printStackTrace();
        }
    }
}

Parameters

NameTypeDescriptionNotes
storeIdString
bodyExpandRequest

Return type

CompletableFuture<ApiResponse<ExpandResponse>>

Authorization

No authorization required

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200A successful response.-
400Request failed due to invalid input.-
401Not authenticated.-
403Forbidden.-
404Request failed due to incorrect path.-
409Request was aborted due a transaction conflict.-
422Request timed out due to excessive request throttling.-
500Request failed due to internal server error.-

getStore

CompletableFuture getStore(storeId)

Get a store

Returns an OpenFGA store by its identifier

Example

// Import classes:
import dev.openfga.sdk.api.client.ApiClient;
import dev.openfga.sdk.api.client.ApiException;
import dev.openfga.sdk.api.configuration.Configuration;
import dev.openfga.sdk.api.client.models.*;
import dev.openfga.sdk.api.OpenFgaApi;
import java.util.concurrent.CompletableFuture;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("http://localhost");

        OpenFgaApi apiInstance = new OpenFgaApi(defaultClient);
        String storeId = "storeId_example"; // String | 
        try {
            CompletableFuture<GetStoreResponse> result = apiInstance.getStore(storeId);
            System.out.println(result.get());
        } catch (ApiException e) {
            System.err.println("Exception when calling OpenFgaApi#getStore");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

NameTypeDescriptionNotes
storeIdString

Return type

CompletableFuture<GetStoreResponse>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200A successful response.-
400Request failed due to invalid input.-
401Not authenticated.-
403Forbidden.-
404Request failed due to incorrect path.-
409Request was aborted due a transaction conflict.-
422Request timed out due to excessive request throttling.-
500Request failed due to internal server error.-

getStoreWithHttpInfo

CompletableFuture<ApiResponse> getStore getStoreWithHttpInfo(storeId)

Get a store

Returns an OpenFGA store by its identifier

Example

// Import classes:
import dev.openfga.sdk.api.client.ApiClient;
import dev.openfga.sdk.api.client.ApiException;
import dev.openfga.sdk.api.client.ApiResponse;
import dev.openfga.sdk.api.configuration.Configuration;
import dev.openfga.sdk.api.client.models.*;
import dev.openfga.sdk.api.OpenFgaApi;
import java.util.concurrent.CompletableFuture;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("http://localhost");

        OpenFgaApi apiInstance = new OpenFgaApi(defaultClient);
        String storeId = "storeId_example"; // String | 
        try {
            CompletableFuture<ApiResponse<GetStoreResponse>> response = apiInstance.getStoreWithHttpInfo(storeId);
            System.out.println("Status code: " + response.get().getStatusCode());
            System.out.println("Response headers: " + response.get().getHeaders());
            System.out.println("Response body: " + response.get().getData());
        } catch (InterruptedException | ExecutionException e) {
            ApiException apiException = (ApiException)e.getCause();
            System.err.println("Exception when calling OpenFgaApi#getStore");
            System.err.println("Status code: " + apiException.getCode());
            System.err.println("Response headers: " + apiException.getResponseHeaders());
            System.err.println("Reason: " + apiException.getResponseBody());
            e.printStackTrace();
        } catch (ApiException e) {
            System.err.println("Exception when calling OpenFgaApi#getStore");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            System.err.println("Reason: " + e.getResponseBody());
            e.printStackTrace();
        }
    }
}

Parameters

NameTypeDescriptionNotes
storeIdString

Return type

CompletableFuture<ApiResponse<GetStoreResponse>>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200A successful response.-
400Request failed due to invalid input.-
401Not authenticated.-
403Forbidden.-
404Request failed due to incorrect path.-
409Request was aborted due a transaction conflict.-
422Request timed out due to excessive request throttling.-
500Request failed due to internal server error.-

listObjects

CompletableFuture listObjects(storeId, 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. To arrive at a result, the API uses: an authorization model, explicit tuples written through the Write API, contextual tuples present in the request, and implicit tuples that exist by virtue of applying set theory (such as `document:2021-budget#viewer@document:2021-budget#viewer`; the set of users who are viewers of `document:2021-budget` are the set of users who are the viewers of `document:2021-budget`). 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. By default, the Check API caches results for a short time to optimize performance. You may specify a value of `HIGHER_CONSISTENCY` for the optional `consistency` parameter in the body to inform the server that higher conisistency is preferred at the expense of increased latency. Consideration should be given to the increased latency if requesting higher consistency. The response will contain the related objects in an array in the &quot;objects&quot; field of the response and they will be strings in the object format `<type>:<id>` (e.g. &quot;document:roadmap&quot;). 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.

Example

// Import classes:
import dev.openfga.sdk.api.client.ApiClient;
import dev.openfga.sdk.api.client.ApiException;
import dev.openfga.sdk.api.configuration.Configuration;
import dev.openfga.sdk.api.client.models.*;
import dev.openfga.sdk.api.OpenFgaApi;
import java.util.concurrent.CompletableFuture;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("http://localhost");

        OpenFgaApi apiInstance = new OpenFgaApi(defaultClient);
        String storeId = "storeId_example"; // String | 
        ListObjectsRequest body = new ListObjectsRequest(); // ListObjectsRequest | 
        try {
            CompletableFuture<ListObjectsResponse> result = apiInstance.listObjects(storeId, body);
            System.out.println(result.get());
        } catch (ApiException e) {
            System.err.println("Exception when calling OpenFgaApi#listObjects");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

NameTypeDescriptionNotes
storeIdString
bodyListObjectsRequest

Return type

CompletableFuture<ListObjectsResponse>

Authorization

No authorization required

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200A successful response.-
400Request failed due to invalid input.-
401Not authenticated.-
403Forbidden.-
404Request failed due to incorrect path.-
409Request was aborted due a transaction conflict.-
422Request timed out due to excessive request throttling.-
500Request failed due to internal server error.-

listObjectsWithHttpInfo

CompletableFuture<ApiResponse> listObjects listObjectsWithHttpInfo(storeId, 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. To arrive at a result, the API uses: an authorization model, explicit tuples written through the Write API, contextual tuples present in the request, and implicit tuples that exist by virtue of applying set theory (such as `document:2021-budget#viewer@document:2021-budget#viewer`; the set of users who are viewers of `document:2021-budget` are the set of users who are the viewers of `document:2021-budget`). 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. By default, the Check API caches results for a short time to optimize performance. You may specify a value of `HIGHER_CONSISTENCY` for the optional `consistency` parameter in the body to inform the server that higher conisistency is preferred at the expense of increased latency. Consideration should be given to the increased latency if requesting higher consistency. The response will contain the related objects in an array in the &quot;objects&quot; field of the response and they will be strings in the object format `<type>:<id>` (e.g. &quot;document:roadmap&quot;). 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.

Example

// Import classes:
import dev.openfga.sdk.api.client.ApiClient;
import dev.openfga.sdk.api.client.ApiException;
import dev.openfga.sdk.api.client.ApiResponse;
import dev.openfga.sdk.api.configuration.Configuration;
import dev.openfga.sdk.api.client.models.*;
import dev.openfga.sdk.api.OpenFgaApi;
import java.util.concurrent.CompletableFuture;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("http://localhost");

        OpenFgaApi apiInstance = new OpenFgaApi(defaultClient);
        String storeId = "storeId_example"; // String | 
        ListObjectsRequest body = new ListObjectsRequest(); // ListObjectsRequest | 
        try {
            CompletableFuture<ApiResponse<ListObjectsResponse>> response = apiInstance.listObjectsWithHttpInfo(storeId, body);
            System.out.println("Status code: " + response.get().getStatusCode());
            System.out.println("Response headers: " + response.get().getHeaders());
            System.out.println("Response body: " + response.get().getData());
        } catch (InterruptedException | ExecutionException e) {
            ApiException apiException = (ApiException)e.getCause();
            System.err.println("Exception when calling OpenFgaApi#listObjects");
            System.err.println("Status code: " + apiException.getCode());
            System.err.println("Response headers: " + apiException.getResponseHeaders());
            System.err.println("Reason: " + apiException.getResponseBody());
            e.printStackTrace();
        } catch (ApiException e) {
            System.err.println("Exception when calling OpenFgaApi#listObjects");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            System.err.println("Reason: " + e.getResponseBody());
            e.printStackTrace();
        }
    }
}

Parameters

NameTypeDescriptionNotes
storeIdString
bodyListObjectsRequest

Return type

CompletableFuture<ApiResponse<ListObjectsResponse>>

Authorization

No authorization required

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200A successful response.-
400Request failed due to invalid input.-
401Not authenticated.-
403Forbidden.-
404Request failed due to incorrect path.-
409Request was aborted due a transaction conflict.-
422Request timed out due to excessive request throttling.-
500Request failed due to internal server error.-

listStores

CompletableFuture listStores(pageSize, continuationToken, name)

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.

Example

// Import classes:
import dev.openfga.sdk.api.client.ApiClient;
import dev.openfga.sdk.api.client.ApiException;
import dev.openfga.sdk.api.configuration.Configuration;
import dev.openfga.sdk.api.client.models.*;
import dev.openfga.sdk.api.OpenFgaApi;
import java.util.concurrent.CompletableFuture;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("http://localhost");

        OpenFgaApi apiInstance = new OpenFgaApi(defaultClient);
        Integer pageSize = 56; // Integer | 
        String continuationToken = "continuationToken_example"; // String | 
        String name = "name_example"; // String | The name parameter instructs the API to only include results that match that name.Multiple results may be returned. Only exact matches will be returned; substring matches and regexes will not be evaluated
        try {
            CompletableFuture<ListStoresResponse> result = apiInstance.listStores(pageSize, continuationToken, name);
            System.out.println(result.get());
        } catch (ApiException e) {
            System.err.println("Exception when calling OpenFgaApi#listStores");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

NameTypeDescriptionNotes
pageSizeInteger[optional]
continuationTokenString[optional]
nameStringThe name parameter instructs the API to only include results that match that name.Multiple results may be returned. Only exact matches will be returned; substring matches and regexes will not be evaluated[optional]

Return type

CompletableFuture<ListStoresResponse>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200A successful response.-
400Request failed due to invalid input.-
401Not authenticated.-
403Forbidden.-
404Request failed due to incorrect path.-
409Request was aborted due a transaction conflict.-
422Request timed out due to excessive request throttling.-
500Request failed due to internal server error.-

listStoresWithHttpInfo

CompletableFuture<ApiResponse> listStores listStoresWithHttpInfo(pageSize, continuationToken, name)

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.

Example

// Import classes:
import dev.openfga.sdk.api.client.ApiClient;
import dev.openfga.sdk.api.client.ApiException;
import dev.openfga.sdk.api.client.ApiResponse;
import dev.openfga.sdk.api.configuration.Configuration;
import dev.openfga.sdk.api.client.models.*;
import dev.openfga.sdk.api.OpenFgaApi;
import java.util.concurrent.CompletableFuture;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("http://localhost");

        OpenFgaApi apiInstance = new OpenFgaApi(defaultClient);
        Integer pageSize = 56; // Integer | 
        String continuationToken = "continuationToken_example"; // String | 
        String name = "name_example"; // String | The name parameter instructs the API to only include results that match that name.Multiple results may be returned. Only exact matches will be returned; substring matches and regexes will not be evaluated
        try {
            CompletableFuture<ApiResponse<ListStoresResponse>> response = apiInstance.listStoresWithHttpInfo(pageSize, continuationToken, name);
            System.out.println("Status code: " + response.get().getStatusCode());
            System.out.println("Response headers: " + response.get().getHeaders());
            System.out.println("Response body: " + response.get().getData());
        } catch (InterruptedException | ExecutionException e) {
            ApiException apiException = (ApiException)e.getCause();
            System.err.println("Exception when calling OpenFgaApi#listStores");
            System.err.println("Status code: " + apiException.getCode());
            System.err.println("Response headers: " + apiException.getResponseHeaders());
            System.err.println("Reason: " + apiException.getResponseBody());
            e.printStackTrace();
        } catch (ApiException e) {
            System.err.println("Exception when calling OpenFgaApi#listStores");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            System.err.println("Reason: " + e.getResponseBody());
            e.printStackTrace();
        }
    }
}

Parameters

NameTypeDescriptionNotes
pageSizeInteger[optional]
continuationTokenString[optional]
nameStringThe name parameter instructs the API to only include results that match that name.Multiple results may be returned. Only exact matches will be returned; substring matches and regexes will not be evaluated[optional]

Return type

CompletableFuture<ApiResponse<ListStoresResponse>>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200A successful response.-
400Request failed due to invalid input.-
401Not authenticated.-
403Forbidden.-
404Request failed due to incorrect path.-
409Request was aborted due a transaction conflict.-
422Request timed out due to excessive request throttling.-
500Request failed due to internal server error.-

listUsers

CompletableFuture listUsers(storeId, body)

List the users matching the provided filter who have a certain relation to a particular type.

The ListUsers API returns a list of all the users of a specific type that have a relation to a given object. To arrive at a result, the API uses: an authorization model, explicit tuples written through the Write API, contextual tuples present in the request, and implicit tuples that exist by virtue of applying set theory (such as `document:2021-budget#viewer@document:2021-budget#viewer`; the set of users who are viewers of `document:2021-budget` are the set of users who are the viewers of `document:2021-budget`). 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 users in an array in the &quot;users&quot; field of the response. These results may include specific objects, usersets or type-bound public access. Each of these types of results is encoded in its own type and not represented as a string.In cases where a type-bound public access result is returned (e.g. `user:*`), it cannot be inferred that all subjects of that type have a relation to the object; it is possible that negations exist and checks should still be queried on individual subjects to ensure access to that document.The number of users in the response array will be limited by the execution timeout specified in the flag OPENFGA_LIST_USERS_DEADLINE and by the upper bound specified in the flag OPENFGA_LIST_USERS_MAX_RESULTS, whichever is hit first. The returned users will not be sorted, and therefore two identical calls may yield different sets of users.

Example

// Import classes:
import dev.openfga.sdk.api.client.ApiClient;
import dev.openfga.sdk.api.client.ApiException;
import dev.openfga.sdk.api.configuration.Configuration;
import dev.openfga.sdk.api.client.models.*;
import dev.openfga.sdk.api.OpenFgaApi;
import java.util.concurrent.CompletableFuture;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("http://localhost");

        OpenFgaApi apiInstance = new OpenFgaApi(defaultClient);
        String storeId = "storeId_example"; // String | 
        ListUsersRequest body = new ListUsersRequest(); // ListUsersRequest | 
        try {
            CompletableFuture<ListUsersResponse> result = apiInstance.listUsers(storeId, body);
            System.out.println(result.get());
        } catch (ApiException e) {
            System.err.println("Exception when calling OpenFgaApi#listUsers");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

NameTypeDescriptionNotes
storeIdString
bodyListUsersRequest

Return type

CompletableFuture<ListUsersResponse>

Authorization

No authorization required

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200A successful response.-
400Request failed due to invalid input.-
401Not authenticated.-
403Forbidden.-
404Request failed due to incorrect path.-
409Request was aborted due a transaction conflict.-
422Request timed out due to excessive request throttling.-
500Request failed due to internal server error.-

listUsersWithHttpInfo

CompletableFuture<ApiResponse> listUsers listUsersWithHttpInfo(storeId, body)

List the users matching the provided filter who have a certain relation to a particular type.

The ListUsers API returns a list of all the users of a specific type that have a relation to a given object. To arrive at a result, the API uses: an authorization model, explicit tuples written through the Write API, contextual tuples present in the request, and implicit tuples that exist by virtue of applying set theory (such as `document:2021-budget#viewer@document:2021-budget#viewer`; the set of users who are viewers of `document:2021-budget` are the set of users who are the viewers of `document:2021-budget`). 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 users in an array in the &quot;users&quot; field of the response. These results may include specific objects, usersets or type-bound public access. Each of these types of results is encoded in its own type and not represented as a string.In cases where a type-bound public access result is returned (e.g. `user:*`), it cannot be inferred that all subjects of that type have a relation to the object; it is possible that negations exist and checks should still be queried on individual subjects to ensure access to that document.The number of users in the response array will be limited by the execution timeout specified in the flag OPENFGA_LIST_USERS_DEADLINE and by the upper bound specified in the flag OPENFGA_LIST_USERS_MAX_RESULTS, whichever is hit first. The returned users will not be sorted, and therefore two identical calls may yield different sets of users.

Example

// Import classes:
import dev.openfga.sdk.api.client.ApiClient;
import dev.openfga.sdk.api.client.ApiException;
import dev.openfga.sdk.api.client.ApiResponse;
import dev.openfga.sdk.api.configuration.Configuration;
import dev.openfga.sdk.api.client.models.*;
import dev.openfga.sdk.api.OpenFgaApi;
import java.util.concurrent.CompletableFuture;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("http://localhost");

        OpenFgaApi apiInstance = new OpenFgaApi(defaultClient);
        String storeId = "storeId_example"; // String | 
        ListUsersRequest body = new ListUsersRequest(); // ListUsersRequest | 
        try {
            CompletableFuture<ApiResponse<ListUsersResponse>> response = apiInstance.listUsersWithHttpInfo(storeId, body);
            System.out.println("Status code: " + response.get().getStatusCode());
            System.out.println("Response headers: " + response.get().getHeaders());
            System.out.println("Response body: " + response.get().getData());
        } catch (InterruptedException | ExecutionException e) {
            ApiException apiException = (ApiException)e.getCause();
            System.err.println("Exception when calling OpenFgaApi#listUsers");
            System.err.println("Status code: " + apiException.getCode());
            System.err.println("Response headers: " + apiException.getResponseHeaders());
            System.err.println("Reason: " + apiException.getResponseBody());
            e.printStackTrace();
        } catch (ApiException e) {
            System.err.println("Exception when calling OpenFgaApi#listUsers");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            System.err.println("Reason: " + e.getResponseBody());
            e.printStackTrace();
        }
    }
}

Parameters

NameTypeDescriptionNotes
storeIdString
bodyListUsersRequest

Return type

CompletableFuture<ApiResponse<ListUsersResponse>>

Authorization

No authorization required

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200A successful response.-
400Request failed due to invalid input.-
401Not authenticated.-
403Forbidden.-
404Request failed due to incorrect path.-
409Request was aborted due a transaction conflict.-
422Request timed out due to excessive request throttling.-
500Request failed due to internal server error.-

read

CompletableFuture read(storeId, 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. 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. If tuple_key.user is specified, it needs to be a full object (e.g., `type:user_id`). ## 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 { &quot;tuple_key&quot;: { &quot;user&quot;: &quot;user:bob&quot;, &quot;relation&quot;: &quot;reader&quot;, &quot;object&quot;: &quot;document:&quot; } } ``` The API will return tuples and a continuation token, something like ```json { &quot;tuples&quot;: [ { &quot;key&quot;: { &quot;user&quot;: &quot;user:bob&quot;, &quot;relation&quot;: &quot;reader&quot;, &quot;object&quot;: &quot;document:2021-budget&quot; }, &quot;timestamp&quot;: &quot;2021-10-06T15:32:11.128Z&quot; } ], &quot;continuation_token&quot;: &quot;eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ==&quot; } ``` 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 { &quot;tuple_key&quot;: { &quot;object&quot;: &quot;document:2021-budget&quot;, &quot;relation&quot;: &quot;reader&quot; } } ``` The API will return something like ```json { &quot;tuples&quot;: [ { &quot;key&quot;: { &quot;user&quot;: &quot;user:bob&quot;, &quot;relation&quot;: &quot;reader&quot;, &quot;object&quot;: &quot;document:2021-budget&quot; }, &quot;timestamp&quot;: &quot;2021-10-06T15:32:11.128Z&quot; } ], &quot;continuation_token&quot;: &quot;eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ==&quot; } ``` 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 { &quot;tuple_key&quot;: { &quot;object&quot;: &quot;document:2021-budget&quot; } } ``` The API will return something like ```json { &quot;tuples&quot;: [ { &quot;key&quot;: { &quot;user&quot;: &quot;user:anne&quot;, &quot;relation&quot;: &quot;writer&quot;, &quot;object&quot;: &quot;document:2021-budget&quot; }, &quot;timestamp&quot;: &quot;2021-10-05T13:42:12.356Z&quot; }, { &quot;key&quot;: { &quot;user&quot;: &quot;user:bob&quot;, &quot;relation&quot;: &quot;reader&quot;, &quot;object&quot;: &quot;document:2021-budget&quot; }, &quot;timestamp&quot;: &quot;2021-10-06T15:32:11.128Z&quot; } ], &quot;continuation_token&quot;: &quot;eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ==&quot; } ``` This means that `document:2021-budget` has 1 `reader` (`user:bob`) and 1 `writer` (`user:anne`).

Example

// Import classes:
import dev.openfga.sdk.api.client.ApiClient;
import dev.openfga.sdk.api.client.ApiException;
import dev.openfga.sdk.api.configuration.Configuration;
import dev.openfga.sdk.api.client.models.*;
import dev.openfga.sdk.api.OpenFgaApi;
import java.util.concurrent.CompletableFuture;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("http://localhost");

        OpenFgaApi apiInstance = new OpenFgaApi(defaultClient);
        String storeId = "storeId_example"; // String | 
        ReadRequest body = new ReadRequest(); // ReadRequest | 
        try {
            CompletableFuture<ReadResponse> result = apiInstance.read(storeId, body);
            System.out.println(result.get());
        } catch (ApiException e) {
            System.err.println("Exception when calling OpenFgaApi#read");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

NameTypeDescriptionNotes
storeIdString
bodyReadRequest

Return type

CompletableFuture<ReadResponse>

Authorization

No authorization required

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200A successful response.-
400Request failed due to invalid input.-
401Not authenticated.-
403Forbidden.-
404Request failed due to incorrect path.-
409Request was aborted due a transaction conflict.-
422Request timed out due to excessive request throttling.-
500Request failed due to internal server error.-

readWithHttpInfo

CompletableFuture<ApiResponse> read readWithHttpInfo(storeId, 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. 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. If tuple_key.user is specified, it needs to be a full object (e.g., `type:user_id`). ## 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 { &quot;tuple_key&quot;: { &quot;user&quot;: &quot;user:bob&quot;, &quot;relation&quot;: &quot;reader&quot;, &quot;object&quot;: &quot;document:&quot; } } ``` The API will return tuples and a continuation token, something like ```json { &quot;tuples&quot;: [ { &quot;key&quot;: { &quot;user&quot;: &quot;user:bob&quot;, &quot;relation&quot;: &quot;reader&quot;, &quot;object&quot;: &quot;document:2021-budget&quot; }, &quot;timestamp&quot;: &quot;2021-10-06T15:32:11.128Z&quot; } ], &quot;continuation_token&quot;: &quot;eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ==&quot; } ``` 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 { &quot;tuple_key&quot;: { &quot;object&quot;: &quot;document:2021-budget&quot;, &quot;relation&quot;: &quot;reader&quot; } } ``` The API will return something like ```json { &quot;tuples&quot;: [ { &quot;key&quot;: { &quot;user&quot;: &quot;user:bob&quot;, &quot;relation&quot;: &quot;reader&quot;, &quot;object&quot;: &quot;document:2021-budget&quot; }, &quot;timestamp&quot;: &quot;2021-10-06T15:32:11.128Z&quot; } ], &quot;continuation_token&quot;: &quot;eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ==&quot; } ``` 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 { &quot;tuple_key&quot;: { &quot;object&quot;: &quot;document:2021-budget&quot; } } ``` The API will return something like ```json { &quot;tuples&quot;: [ { &quot;key&quot;: { &quot;user&quot;: &quot;user:anne&quot;, &quot;relation&quot;: &quot;writer&quot;, &quot;object&quot;: &quot;document:2021-budget&quot; }, &quot;timestamp&quot;: &quot;2021-10-05T13:42:12.356Z&quot; }, { &quot;key&quot;: { &quot;user&quot;: &quot;user:bob&quot;, &quot;relation&quot;: &quot;reader&quot;, &quot;object&quot;: &quot;document:2021-budget&quot; }, &quot;timestamp&quot;: &quot;2021-10-06T15:32:11.128Z&quot; } ], &quot;continuation_token&quot;: &quot;eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ==&quot; } ``` This means that `document:2021-budget` has 1 `reader` (`user:bob`) and 1 `writer` (`user:anne`).

Example

// Import classes:
import dev.openfga.sdk.api.client.ApiClient;
import dev.openfga.sdk.api.client.ApiException;
import dev.openfga.sdk.api.client.ApiResponse;
import dev.openfga.sdk.api.configuration.Configuration;
import dev.openfga.sdk.api.client.models.*;
import dev.openfga.sdk.api.OpenFgaApi;
import java.util.concurrent.CompletableFuture;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("http://localhost");

        OpenFgaApi apiInstance = new OpenFgaApi(defaultClient);
        String storeId = "storeId_example"; // String | 
        ReadRequest body = new ReadRequest(); // ReadRequest | 
        try {
            CompletableFuture<ApiResponse<ReadResponse>> response = apiInstance.readWithHttpInfo(storeId, body);
            System.out.println("Status code: " + response.get().getStatusCode());
            System.out.println("Response headers: " + response.get().getHeaders());
            System.out.println("Response body: " + response.get().getData());
        } catch (InterruptedException | ExecutionException e) {
            ApiException apiException = (ApiException)e.getCause();
            System.err.println("Exception when calling OpenFgaApi#read");
            System.err.println("Status code: " + apiException.getCode());
            System.err.println("Response headers: " + apiException.getResponseHeaders());
            System.err.println("Reason: " + apiException.getResponseBody());
            e.printStackTrace();
        } catch (ApiException e) {
            System.err.println("Exception when calling OpenFgaApi#read");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            System.err.println("Reason: " + e.getResponseBody());
            e.printStackTrace();
        }
    }
}

Parameters

NameTypeDescriptionNotes
storeIdString
bodyReadRequest

Return type

CompletableFuture<ApiResponse<ReadResponse>>

Authorization

No authorization required

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200A successful response.-
400Request failed due to invalid input.-
401Not authenticated.-
403Forbidden.-
404Request failed due to incorrect path.-
409Request was aborted due a transaction conflict.-
422Request timed out due to excessive request throttling.-
500Request failed due to internal server error.-

readAssertions

CompletableFuture readAssertions(storeId, 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.

Example

// Import classes:
import dev.openfga.sdk.api.client.ApiClient;
import dev.openfga.sdk.api.client.ApiException;
import dev.openfga.sdk.api.configuration.Configuration;
import dev.openfga.sdk.api.client.models.*;
import dev.openfga.sdk.api.OpenFgaApi;
import java.util.concurrent.CompletableFuture;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("http://localhost");

        OpenFgaApi apiInstance = new OpenFgaApi(defaultClient);
        String storeId = "storeId_example"; // String | 
        String authorizationModelId = "authorizationModelId_example"; // String | 
        try {
            CompletableFuture<ReadAssertionsResponse> result = apiInstance.readAssertions(storeId, authorizationModelId);
            System.out.println(result.get());
        } catch (ApiException e) {
            System.err.println("Exception when calling OpenFgaApi#readAssertions");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

NameTypeDescriptionNotes
storeIdString
authorizationModelIdString

Return type

CompletableFuture<ReadAssertionsResponse>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200A successful response.-
400Request failed due to invalid input.-
401Not authenticated.-
403Forbidden.-
404Request failed due to incorrect path.-
409Request was aborted due a transaction conflict.-
422Request timed out due to excessive request throttling.-
500Request failed due to internal server error.-

readAssertionsWithHttpInfo

CompletableFuture<ApiResponse> readAssertions readAssertionsWithHttpInfo(storeId, 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.

Example

// Import classes:
import dev.openfga.sdk.api.client.ApiClient;
import dev.openfga.sdk.api.client.ApiException;
import dev.openfga.sdk.api.client.ApiResponse;
import dev.openfga.sdk.api.configuration.Configuration;
import dev.openfga.sdk.api.client.models.*;
import dev.openfga.sdk.api.OpenFgaApi;
import java.util.concurrent.CompletableFuture;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("http://localhost");

        OpenFgaApi apiInstance = new OpenFgaApi(defaultClient);
        String storeId = "storeId_example"; // String | 
        String authorizationModelId = "authorizationModelId_example"; // String | 
        try {
            CompletableFuture<ApiResponse<ReadAssertionsResponse>> response = apiInstance.readAssertionsWithHttpInfo(storeId, authorizationModelId);
            System.out.println("Status code: " + response.get().getStatusCode());
            System.out.println("Response headers: " + response.get().getHeaders());
            System.out.println("Response body: " + response.get().getData());
        } catch (InterruptedException | ExecutionException e) {
            ApiException apiException = (ApiException)e.getCause();
            System.err.println("Exception when calling OpenFgaApi#readAssertions");
            System.err.println("Status code: " + apiException.getCode());
            System.err.println("Response headers: " + apiException.getResponseHeaders());
            System.err.println("Reason: " + apiException.getResponseBody());
            e.printStackTrace();
        } catch (ApiException e) {
            System.err.println("Exception when calling OpenFgaApi#readAssertions");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            System.err.println("Reason: " + e.getResponseBody());
            e.printStackTrace();
        }
    }
}

Parameters

NameTypeDescriptionNotes
storeIdString
authorizationModelIdString

Return type

CompletableFuture<ApiResponse<ReadAssertionsResponse>>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200A successful response.-
400Request failed due to invalid input.-
401Not authenticated.-
403Forbidden.-
404Request failed due to incorrect path.-
409Request was aborted due a transaction conflict.-
422Request timed out due to excessive request throttling.-
500Request failed due to internal server error.-

readAuthorizationModel

CompletableFuture readAuthorizationModel(storeId, id)

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 { &quot;authorization_model&quot;:{ &quot;id&quot;:&quot;01G5JAVJ41T49E9TT3SKVS7X1J&quot;, &quot;type_definitions&quot;:[ { &quot;type&quot;:&quot;user&quot; }, { &quot;type&quot;:&quot;document&quot;, &quot;relations&quot;:{ &quot;reader&quot;:{ &quot;union&quot;:{ &quot;child&quot;:[ { &quot;this&quot;:{} }, { &quot;computedUserset&quot;:{ &quot;object&quot;:&quot;&quot;, &quot;relation&quot;:&quot;writer&quot; } } ] } }, &quot;writer&quot;:{ &quot;this&quot;:{} } } } ] } } ``` In the above example, there are 2 types (`user` and `document`). The `document` type has 2 relations (`writer` and `reader`).

Example

// Import classes:
import dev.openfga.sdk.api.client.ApiClient;
import dev.openfga.sdk.api.client.ApiException;
import dev.openfga.sdk.api.configuration.Configuration;
import dev.openfga.sdk.api.client.models.*;
import dev.openfga.sdk.api.OpenFgaApi;
import java.util.concurrent.CompletableFuture;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("http://localhost");

        OpenFgaApi apiInstance = new OpenFgaApi(defaultClient);
        String storeId = "storeId_example"; // String | 
        String id = "id_example"; // String | 
        try {
            CompletableFuture<ReadAuthorizationModelResponse> result = apiInstance.readAuthorizationModel(storeId, id);
            System.out.println(result.get());
        } catch (ApiException e) {
            System.err.println("Exception when calling OpenFgaApi#readAuthorizationModel");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

NameTypeDescriptionNotes
storeIdString
idString

Return type

CompletableFuture<ReadAuthorizationModelResponse>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200A successful response.-
400Request failed due to invalid input.-
401Not authenticated.-
403Forbidden.-
404Request failed due to incorrect path.-
409Request was aborted due a transaction conflict.-
422Request timed out due to excessive request throttling.-
500Request failed due to internal server error.-

readAuthorizationModelWithHttpInfo

CompletableFuture<ApiResponse> readAuthorizationModel readAuthorizationModelWithHttpInfo(storeId, id)

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 { &quot;authorization_model&quot;:{ &quot;id&quot;:&quot;01G5JAVJ41T49E9TT3SKVS7X1J&quot;, &quot;type_definitions&quot;:[ { &quot;type&quot;:&quot;user&quot; }, { &quot;type&quot;:&quot;document&quot;, &quot;relations&quot;:{ &quot;reader&quot;:{ &quot;union&quot;:{ &quot;child&quot;:[ { &quot;this&quot;:{} }, { &quot;computedUserset&quot;:{ &quot;object&quot;:&quot;&quot;, &quot;relation&quot;:&quot;writer&quot; } } ] } }, &quot;writer&quot;:{ &quot;this&quot;:{} } } } ] } } ``` In the above example, there are 2 types (`user` and `document`). The `document` type has 2 relations (`writer` and `reader`).

Example

// Import classes:
import dev.openfga.sdk.api.client.ApiClient;
import dev.openfga.sdk.api.client.ApiException;
import dev.openfga.sdk.api.client.ApiResponse;
import dev.openfga.sdk.api.configuration.Configuration;
import dev.openfga.sdk.api.client.models.*;
import dev.openfga.sdk.api.OpenFgaApi;
import java.util.concurrent.CompletableFuture;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("http://localhost");

        OpenFgaApi apiInstance = new OpenFgaApi(defaultClient);
        String storeId = "storeId_example"; // String | 
        String id = "id_example"; // String | 
        try {
            CompletableFuture<ApiResponse<ReadAuthorizationModelResponse>> response = apiInstance.readAuthorizationModelWithHttpInfo(storeId, id);
            System.out.println("Status code: " + response.get().getStatusCode());
            System.out.println("Response headers: " + response.get().getHeaders());
            System.out.println("Response body: " + response.get().getData());
        } catch (InterruptedException | ExecutionException e) {
            ApiException apiException = (ApiException)e.getCause();
            System.err.println("Exception when calling OpenFgaApi#readAuthorizationModel");
            System.err.println("Status code: " + apiException.getCode());
            System.err.println("Response headers: " + apiException.getResponseHeaders());
            System.err.println("Reason: " + apiException.getResponseBody());
            e.printStackTrace();
        } catch (ApiException e) {
            System.err.println("Exception when calling OpenFgaApi#readAuthorizationModel");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            System.err.println("Reason: " + e.getResponseBody());
            e.printStackTrace();
        }
    }
}

Parameters

NameTypeDescriptionNotes
storeIdString
idString

Return type

CompletableFuture<ApiResponse<ReadAuthorizationModelResponse>>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200A successful response.-
400Request failed due to invalid input.-
401Not authenticated.-
403Forbidden.-
404Request failed due to incorrect path.-
409Request was aborted due a transaction conflict.-
422Request timed out due to excessive request throttling.-
500Request failed due to internal server error.-

readAuthorizationModels

CompletableFuture readAuthorizationModels(storeId, pageSize, continuationToken)

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 { &quot;authorization_models&quot;: [ { &quot;id&quot;: &quot;01G50QVV17PECNVAHX1GG4Y5NC&quot;, &quot;type_definitions&quot;: [...] }, { &quot;id&quot;: &quot;01G4ZW8F4A07AKQ8RHSVG9RW04&quot;, &quot;type_definitions&quot;: [...] }, ], &quot;continuation_token&quot;: &quot;eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ==&quot; } ``` If there are no more authorization models available, the `continuation_token` field will be empty ```json { &quot;authorization_models&quot;: [ { &quot;id&quot;: &quot;01G50QVV17PECNVAHX1GG4Y5NC&quot;, &quot;type_definitions&quot;: [...] }, { &quot;id&quot;: &quot;01G4ZW8F4A07AKQ8RHSVG9RW04&quot;, &quot;type_definitions&quot;: [...] }, ], &quot;continuation_token&quot;: &quot;&quot; } ```

Example

// Import classes:
import dev.openfga.sdk.api.client.ApiClient;
import dev.openfga.sdk.api.client.ApiException;
import dev.openfga.sdk.api.configuration.Configuration;
import dev.openfga.sdk.api.client.models.*;
import dev.openfga.sdk.api.OpenFgaApi;
import java.util.concurrent.CompletableFuture;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("http://localhost");

        OpenFgaApi apiInstance = new OpenFgaApi(defaultClient);
        String storeId = "storeId_example"; // String | 
        Integer pageSize = 56; // Integer | 
        String continuationToken = "continuationToken_example"; // String | 
        try {
            CompletableFuture<ReadAuthorizationModelsResponse> result = apiInstance.readAuthorizationModels(storeId, pageSize, continuationToken);
            System.out.println(result.get());
        } catch (ApiException e) {
            System.err.println("Exception when calling OpenFgaApi#readAuthorizationModels");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

NameTypeDescriptionNotes
storeIdString
pageSizeInteger[optional]
continuationTokenString[optional]

Return type

CompletableFuture<ReadAuthorizationModelsResponse>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200A successful response.-
400Request failed due to invalid input.-
401Not authenticated.-
403Forbidden.-
404Request failed due to incorrect path.-
409Request was aborted due a transaction conflict.-
422Request timed out due to excessive request throttling.-
500Request failed due to internal server error.-

readAuthorizationModelsWithHttpInfo

CompletableFuture<ApiResponse> readAuthorizationModels readAuthorizationModelsWithHttpInfo(storeId, pageSize, continuationToken)

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 { &quot;authorization_models&quot;: [ { &quot;id&quot;: &quot;01G50QVV17PECNVAHX1GG4Y5NC&quot;, &quot;type_definitions&quot;: [...] }, { &quot;id&quot;: &quot;01G4ZW8F4A07AKQ8RHSVG9RW04&quot;, &quot;type_definitions&quot;: [...] }, ], &quot;continuation_token&quot;: &quot;eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ==&quot; } ``` If there are no more authorization models available, the `continuation_token` field will be empty ```json { &quot;authorization_models&quot;: [ { &quot;id&quot;: &quot;01G50QVV17PECNVAHX1GG4Y5NC&quot;, &quot;type_definitions&quot;: [...] }, { &quot;id&quot;: &quot;01G4ZW8F4A07AKQ8RHSVG9RW04&quot;, &quot;type_definitions&quot;: [...] }, ], &quot;continuation_token&quot;: &quot;&quot; } ```

Example

// Import classes:
import dev.openfga.sdk.api.client.ApiClient;
import dev.openfga.sdk.api.client.ApiException;
import dev.openfga.sdk.api.client.ApiResponse;
import dev.openfga.sdk.api.configuration.Configuration;
import dev.openfga.sdk.api.client.models.*;
import dev.openfga.sdk.api.OpenFgaApi;
import java.util.concurrent.CompletableFuture;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("http://localhost");

        OpenFgaApi apiInstance = new OpenFgaApi(defaultClient);
        String storeId = "storeId_example"; // String | 
        Integer pageSize = 56; // Integer | 
        String continuationToken = "continuationToken_example"; // String | 
        try {
            CompletableFuture<ApiResponse<ReadAuthorizationModelsResponse>> response = apiInstance.readAuthorizationModelsWithHttpInfo(storeId, pageSize, continuationToken);
            System.out.println("Status code: " + response.get().getStatusCode());
            System.out.println("Response headers: " + response.get().getHeaders());
            System.out.println("Response body: " + response.get().getData());
        } catch (InterruptedException | ExecutionException e) {
            ApiException apiException = (ApiException)e.getCause();
            System.err.println("Exception when calling OpenFgaApi#readAuthorizationModels");
            System.err.println("Status code: " + apiException.getCode());
            System.err.println("Response headers: " + apiException.getResponseHeaders());
            System.err.println("Reason: " + apiException.getResponseBody());
            e.printStackTrace();
        } catch (ApiException e) {
            System.err.println("Exception when calling OpenFgaApi#readAuthorizationModels");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            System.err.println("Reason: " + e.getResponseBody());
            e.printStackTrace();
        }
    }
}

Parameters

NameTypeDescriptionNotes
storeIdString
pageSizeInteger[optional]
continuationTokenString[optional]

Return type

CompletableFuture<ApiResponse<ReadAuthorizationModelsResponse>>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200A successful response.-
400Request failed due to invalid input.-
401Not authenticated.-
403Forbidden.-
404Request failed due to incorrect path.-
409Request was aborted due a transaction conflict.-
422Request timed out due to excessive request throttling.-
500Request failed due to internal server error.-

readChanges

CompletableFuture readChanges(storeId, type, pageSize, continuationToken, startTime)

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.

Example

// Import classes:
import dev.openfga.sdk.api.client.ApiClient;
import dev.openfga.sdk.api.client.ApiException;
import dev.openfga.sdk.api.configuration.Configuration;
import dev.openfga.sdk.api.client.models.*;
import dev.openfga.sdk.api.OpenFgaApi;
import java.util.concurrent.CompletableFuture;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("http://localhost");

        OpenFgaApi apiInstance = new OpenFgaApi(defaultClient);
        String storeId = "storeId_example"; // String | 
        String type = "type_example"; // String | 
        Integer pageSize = 56; // Integer | 
        String continuationToken = "continuationToken_example"; // String | 
        OffsetDateTime startTime = OffsetDateTime.now(); // OffsetDateTime | Start date and time of changes to read. Format: ISO 8601 timestamp (e.g., 2022-01-01T00:00:00Z) If a continuation_token is provided along side start_time, the continuation_token will take precedence over start_time.
        try {
            CompletableFuture<ReadChangesResponse> result = apiInstance.readChanges(storeId, type, pageSize, continuationToken, startTime);
            System.out.println(result.get());
        } catch (ApiException e) {
            System.err.println("Exception when calling OpenFgaApi#readChanges");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

NameTypeDescriptionNotes
storeIdString
typeString[optional]
pageSizeInteger[optional]
continuationTokenString[optional]
startTimeOffsetDateTimeStart date and time of changes to read. Format: ISO 8601 timestamp (e.g., 2022-01-01T00:00:00Z) If a continuation_token is provided along side start_time, the continuation_token will take precedence over start_time.[optional]

Return type

CompletableFuture<ReadChangesResponse>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200A successful response.-
400Request failed due to invalid input.-
401Not authenticated.-
403Forbidden.-
404Request failed due to incorrect path.-
409Request was aborted due a transaction conflict.-
422Request timed out due to excessive request throttling.-
500Request failed due to internal server error.-

readChangesWithHttpInfo

CompletableFuture<ApiResponse> readChanges readChangesWithHttpInfo(storeId, type, pageSize, continuationToken, startTime)

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.

Example

// Import classes:
import dev.openfga.sdk.api.client.ApiClient;
import dev.openfga.sdk.api.client.ApiException;
import dev.openfga.sdk.api.client.ApiResponse;
import dev.openfga.sdk.api.configuration.Configuration;
import dev.openfga.sdk.api.client.models.*;
import dev.openfga.sdk.api.OpenFgaApi;
import java.util.concurrent.CompletableFuture;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("http://localhost");

        OpenFgaApi apiInstance = new OpenFgaApi(defaultClient);
        String storeId = "storeId_example"; // String | 
        String type = "type_example"; // String | 
        Integer pageSize = 56; // Integer | 
        String continuationToken = "continuationToken_example"; // String | 
        OffsetDateTime startTime = OffsetDateTime.now(); // OffsetDateTime | Start date and time of changes to read. Format: ISO 8601 timestamp (e.g., 2022-01-01T00:00:00Z) If a continuation_token is provided along side start_time, the continuation_token will take precedence over start_time.
        try {
            CompletableFuture<ApiResponse<ReadChangesResponse>> response = apiInstance.readChangesWithHttpInfo(storeId, type, pageSize, continuationToken, startTime);
            System.out.println("Status code: " + response.get().getStatusCode());
            System.out.println("Response headers: " + response.get().getHeaders());
            System.out.println("Response body: " + response.get().getData());
        } catch (InterruptedException | ExecutionException e) {
            ApiException apiException = (ApiException)e.getCause();
            System.err.println("Exception when calling OpenFgaApi#readChanges");
            System.err.println("Status code: " + apiException.getCode());
            System.err.println("Response headers: " + apiException.getResponseHeaders());
            System.err.println("Reason: " + apiException.getResponseBody());
            e.printStackTrace();
        } catch (ApiException e) {
            System.err.println("Exception when calling OpenFgaApi#readChanges");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            System.err.println("Reason: " + e.getResponseBody());
            e.printStackTrace();
        }
    }
}

Parameters

NameTypeDescriptionNotes
storeIdString
typeString[optional]
pageSizeInteger[optional]
continuationTokenString[optional]
startTimeOffsetDateTimeStart date and time of changes to read. Format: ISO 8601 timestamp (e.g., 2022-01-01T00:00:00Z) If a continuation_token is provided along side start_time, the continuation_token will take precedence over start_time.[optional]

Return type

CompletableFuture<ApiResponse<ReadChangesResponse>>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200A successful response.-
400Request failed due to invalid input.-
401Not authenticated.-
403Forbidden.-
404Request failed due to incorrect path.-
409Request was aborted due a transaction conflict.-
422Request timed out due to excessive request throttling.-
500Request failed due to internal server error.-

streamedListObjects

CompletableFuture streamedListObjects(storeId, body)

Stream all objects of the given type that the user has a relation with

The Streamed ListObjects API is very similar to the the ListObjects API, with two differences: 1. Instead of collecting all objects before returning a response, it streams them to the client as they are collected. 2. The number of results returned is only limited by the execution timeout specified in the flag OPENFGA_LIST_OBJECTS_DEADLINE.

Example

// Import classes:
import dev.openfga.sdk.api.client.ApiClient;
import dev.openfga.sdk.api.client.ApiException;
import dev.openfga.sdk.api.configuration.Configuration;
import dev.openfga.sdk.api.client.models.*;
import dev.openfga.sdk.api.OpenFgaApi;
import java.util.concurrent.CompletableFuture;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("http://localhost");

        OpenFgaApi apiInstance = new OpenFgaApi(defaultClient);
        String storeId = "storeId_example"; // String | 
        ListObjectsRequest body = new ListObjectsRequest(); // ListObjectsRequest | 
        try {
            CompletableFuture<StreamResultOfStreamedListObjectsResponse> result = apiInstance.streamedListObjects(storeId, body);
            System.out.println(result.get());
        } catch (ApiException e) {
            System.err.println("Exception when calling OpenFgaApi#streamedListObjects");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

NameTypeDescriptionNotes
storeIdString
bodyListObjectsRequest

Return type

CompletableFuture<StreamResultOfStreamedListObjectsResponse>

Authorization

No authorization required

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200A successful response.(streaming responses)-
400Request failed due to invalid input.-
401Not authenticated.-
403Forbidden.-
404Request failed due to incorrect path.-
409Request was aborted due a transaction conflict.-
422Request timed out due to excessive request throttling.-
500Request failed due to internal server error.-

streamedListObjectsWithHttpInfo

CompletableFuture<ApiResponse> streamedListObjects streamedListObjectsWithHttpInfo(storeId, body)

Stream all objects of the given type that the user has a relation with

The Streamed ListObjects API is very similar to the the ListObjects API, with two differences: 1. Instead of collecting all objects before returning a response, it streams them to the client as they are collected. 2. The number of results returned is only limited by the execution timeout specified in the flag OPENFGA_LIST_OBJECTS_DEADLINE.

Example

// Import classes:
import dev.openfga.sdk.api.client.ApiClient;
import dev.openfga.sdk.api.client.ApiException;
import dev.openfga.sdk.api.client.ApiResponse;
import dev.openfga.sdk.api.configuration.Configuration;
import dev.openfga.sdk.api.client.models.*;
import dev.openfga.sdk.api.OpenFgaApi;
import java.util.concurrent.CompletableFuture;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("http://localhost");

        OpenFgaApi apiInstance = new OpenFgaApi(defaultClient);
        String storeId = "storeId_example"; // String | 
        ListObjectsRequest body = new ListObjectsRequest(); // ListObjectsRequest | 
        try {
            CompletableFuture<ApiResponse<StreamResultOfStreamedListObjectsResponse>> response = apiInstance.streamedListObjectsWithHttpInfo(storeId, body);
            System.out.println("Status code: " + response.get().getStatusCode());
            System.out.println("Response headers: " + response.get().getHeaders());
            System.out.println("Response body: " + response.get().getData());
        } catch (InterruptedException | ExecutionException e) {
            ApiException apiException = (ApiException)e.getCause();
            System.err.println("Exception when calling OpenFgaApi#streamedListObjects");
            System.err.println("Status code: " + apiException.getCode());
            System.err.println("Response headers: " + apiException.getResponseHeaders());
            System.err.println("Reason: " + apiException.getResponseBody());
            e.printStackTrace();
        } catch (ApiException e) {
            System.err.println("Exception when calling OpenFgaApi#streamedListObjects");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            System.err.println("Reason: " + e.getResponseBody());
            e.printStackTrace();
        }
    }
}

Parameters

NameTypeDescriptionNotes
storeIdString
bodyListObjectsRequest

Return type

CompletableFuture<ApiResponse<StreamResultOfStreamedListObjectsResponse>>

Authorization

No authorization required

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200A successful response.(streaming responses)-
400Request failed due to invalid input.-
401Not authenticated.-
403Forbidden.-
404Request failed due to incorrect path.-
409Request was aborted due a transaction conflict.-
422Request timed out due to excessive request throttling.-
500Request failed due to internal server error.-

write

CompletableFuture write(storeId, body)

Add or delete tuples from the store

The Write API will transactionally 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 by default: 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. To allow writes when an identical tuple already exists in the database, set `&quot;on_duplicate&quot;: &quot;ignore&quot;` on the `writes` object. To allow deletes when a tuple was already removed from the database, set `&quot;on_missing&quot;: &quot;ignore&quot;` on the `deletes` object. If a Write request contains both idempotent (ignore) and non-idempotent (error) operations, the most restrictive action (error) will take precedence. If a condition fails for a sub-request with an error flag, the entire transaction will be rolled back. This gives developers explicit control over the atomicity of the requests. The API will not allow you to write tuples such as `document:2021-budget#viewer@document:2021-budget#viewer`, because they are implicit. 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 { &quot;writes&quot;: { &quot;tuple_keys&quot;: [ { &quot;user&quot;: &quot;user:anne&quot;, &quot;relation&quot;: &quot;writer&quot;, &quot;object&quot;: &quot;document:2021-budget&quot; } ], &quot;on_duplicate&quot;: &quot;ignore&quot; }, &quot;authorization_model_id&quot;: &quot;01G50QVV17PECNVAHX1GG4Y5NC&quot; } ``` ### Removing relationships To remove `user:bob` as a `reader` for `document:2021-budget`, call write API with the following ```json { &quot;deletes&quot;: { &quot;tuple_keys&quot;: [ { &quot;user&quot;: &quot;user:bob&quot;, &quot;relation&quot;: &quot;reader&quot;, &quot;object&quot;: &quot;document:2021-budget&quot; } ], &quot;on_missing&quot;: &quot;ignore&quot; } } ```

Example

// Import classes:
import dev.openfga.sdk.api.client.ApiClient;
import dev.openfga.sdk.api.client.ApiException;
import dev.openfga.sdk.api.configuration.Configuration;
import dev.openfga.sdk.api.client.models.*;
import dev.openfga.sdk.api.OpenFgaApi;
import java.util.concurrent.CompletableFuture;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("http://localhost");

        OpenFgaApi apiInstance = new OpenFgaApi(defaultClient);
        String storeId = "storeId_example"; // String | 
        WriteRequest body = new WriteRequest(); // WriteRequest | 
        try {
            CompletableFuture<Object> result = apiInstance.write(storeId, body);
            System.out.println(result.get());
        } catch (ApiException e) {
            System.err.println("Exception when calling OpenFgaApi#write");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

NameTypeDescriptionNotes
storeIdString
bodyWriteRequest

Return type

CompletableFuture<Object>

Authorization

No authorization required

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200A successful response.-
400Request failed due to invalid input.-
401Not authenticated.-
403Forbidden.-
404Request failed due to incorrect path.-
409Request was aborted due a transaction conflict.-
422Request timed out due to excessive request throttling.-
500Request failed due to internal server error.-

writeWithHttpInfo

CompletableFuture<ApiResponse> write writeWithHttpInfo(storeId, body)

Add or delete tuples from the store

The Write API will transactionally 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 by default: 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. To allow writes when an identical tuple already exists in the database, set `&quot;on_duplicate&quot;: &quot;ignore&quot;` on the `writes` object. To allow deletes when a tuple was already removed from the database, set `&quot;on_missing&quot;: &quot;ignore&quot;` on the `deletes` object. If a Write request contains both idempotent (ignore) and non-idempotent (error) operations, the most restrictive action (error) will take precedence. If a condition fails for a sub-request with an error flag, the entire transaction will be rolled back. This gives developers explicit control over the atomicity of the requests. The API will not allow you to write tuples such as `document:2021-budget#viewer@document:2021-budget#viewer`, because they are implicit. 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 { &quot;writes&quot;: { &quot;tuple_keys&quot;: [ { &quot;user&quot;: &quot;user:anne&quot;, &quot;relation&quot;: &quot;writer&quot;, &quot;object&quot;: &quot;document:2021-budget&quot; } ], &quot;on_duplicate&quot;: &quot;ignore&quot; }, &quot;authorization_model_id&quot;: &quot;01G50QVV17PECNVAHX1GG4Y5NC&quot; } ``` ### Removing relationships To remove `user:bob` as a `reader` for `document:2021-budget`, call write API with the following ```json { &quot;deletes&quot;: { &quot;tuple_keys&quot;: [ { &quot;user&quot;: &quot;user:bob&quot;, &quot;relation&quot;: &quot;reader&quot;, &quot;object&quot;: &quot;document:2021-budget&quot; } ], &quot;on_missing&quot;: &quot;ignore&quot; } } ```

Example

// Import classes:
import dev.openfga.sdk.api.client.ApiClient;
import dev.openfga.sdk.api.client.ApiException;
import dev.openfga.sdk.api.client.ApiResponse;
import dev.openfga.sdk.api.configuration.Configuration;
import dev.openfga.sdk.api.client.models.*;
import dev.openfga.sdk.api.OpenFgaApi;
import java.util.concurrent.CompletableFuture;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("http://localhost");

        OpenFgaApi apiInstance = new OpenFgaApi(defaultClient);
        String storeId = "storeId_example"; // String | 
        WriteRequest body = new WriteRequest(); // WriteRequest | 
        try {
            CompletableFuture<ApiResponse<Object>> response = apiInstance.writeWithHttpInfo(storeId, body);
            System.out.println("Status code: " + response.get().getStatusCode());
            System.out.println("Response headers: " + response.get().getHeaders());
            System.out.println("Response body: " + response.get().getData());
        } catch (InterruptedException | ExecutionException e) {
            ApiException apiException = (ApiException)e.getCause();
            System.err.println("Exception when calling OpenFgaApi#write");
            System.err.println("Status code: " + apiException.getCode());
            System.err.println("Response headers: " + apiException.getResponseHeaders());
            System.err.println("Reason: " + apiException.getResponseBody());
            e.printStackTrace();
        } catch (ApiException e) {
            System.err.println("Exception when calling OpenFgaApi#write");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            System.err.println("Reason: " + e.getResponseBody());
            e.printStackTrace();
        }
    }
}

Parameters

NameTypeDescriptionNotes
storeIdString
bodyWriteRequest

Return type

CompletableFuture<ApiResponse<Object>>

Authorization

No authorization required

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200A successful response.-
400Request failed due to invalid input.-
401Not authenticated.-
403Forbidden.-
404Request failed due to incorrect path.-
409Request was aborted due a transaction conflict.-
422Request timed out due to excessive request throttling.-
500Request failed due to internal server error.-

writeAssertions

CompletableFuture writeAssertions(storeId, authorizationModelId, 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. An assertion is an object that contains a tuple key, the expectation of whether a call to the Check API of that tuple key will return true or false, and optionally a list of contextual tuples.

Example

// Import classes:
import dev.openfga.sdk.api.client.ApiClient;
import dev.openfga.sdk.api.client.ApiException;
import dev.openfga.sdk.api.configuration.Configuration;
import dev.openfga.sdk.api.client.models.*;
import dev.openfga.sdk.api.OpenFgaApi;
import java.util.concurrent.CompletableFuture;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("http://localhost");

        OpenFgaApi apiInstance = new OpenFgaApi(defaultClient);
        String storeId = "storeId_example"; // String | 
        String authorizationModelId = "authorizationModelId_example"; // String | 
        WriteAssertionsRequest body = new WriteAssertionsRequest(); // WriteAssertionsRequest | 
        try {
            CompletableFuture<Void> result = apiInstance.writeAssertions(storeId, authorizationModelId, body);
        } catch (ApiException e) {
            System.err.println("Exception when calling OpenFgaApi#writeAssertions");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

NameTypeDescriptionNotes
storeIdString
authorizationModelIdString
bodyWriteAssertionsRequest

Return type

CompletableFuture (empty response body)

Authorization

No authorization required

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
204A successful response.-
400Request failed due to invalid input.-
401Not authenticated.-
403Forbidden.-
404Request failed due to incorrect path.-
409Request was aborted due a transaction conflict.-
422Request timed out due to excessive request throttling.-
500Request failed due to internal server error.-

writeAssertionsWithHttpInfo

CompletableFuture<ApiResponse> writeAssertions writeAssertionsWithHttpInfo(storeId, authorizationModelId, 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. An assertion is an object that contains a tuple key, the expectation of whether a call to the Check API of that tuple key will return true or false, and optionally a list of contextual tuples.

Example

// Import classes:
import dev.openfga.sdk.api.client.ApiClient;
import dev.openfga.sdk.api.client.ApiException;
import dev.openfga.sdk.api.client.ApiResponse;
import dev.openfga.sdk.api.configuration.Configuration;
import dev.openfga.sdk.api.client.models.*;
import dev.openfga.sdk.api.OpenFgaApi;
import java.util.concurrent.CompletableFuture;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("http://localhost");

        OpenFgaApi apiInstance = new OpenFgaApi(defaultClient);
        String storeId = "storeId_example"; // String | 
        String authorizationModelId = "authorizationModelId_example"; // String | 
        WriteAssertionsRequest body = new WriteAssertionsRequest(); // WriteAssertionsRequest | 
        try {
            CompletableFuture<ApiResponse<Void>> response = apiInstance.writeAssertionsWithHttpInfo(storeId, authorizationModelId, body);
            System.out.println("Status code: " + response.get().getStatusCode());
            System.out.println("Response headers: " + response.get().getHeaders());
        } catch (InterruptedException | ExecutionException e) {
            ApiException apiException = (ApiException)e.getCause();
            System.err.println("Exception when calling OpenFgaApi#writeAssertions");
            System.err.println("Status code: " + apiException.getCode());
            System.err.println("Response headers: " + apiException.getResponseHeaders());
            System.err.println("Reason: " + apiException.getResponseBody());
            e.printStackTrace();
        } catch (ApiException e) {
            System.err.println("Exception when calling OpenFgaApi#writeAssertions");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            System.err.println("Reason: " + e.getResponseBody());
            e.printStackTrace();
        }
    }
}

Parameters

NameTypeDescriptionNotes
storeIdString
authorizationModelIdString
bodyWriteAssertionsRequest

Return type

CompletableFuture<ApiResponse>

Authorization

No authorization required

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
204A successful response.-
400Request failed due to invalid input.-
401Not authenticated.-
403Forbidden.-
404Request failed due to incorrect path.-
409Request was aborted due a transaction conflict.-
422Request timed out due to excessive request throttling.-
500Request failed due to internal server error.-

writeAuthorizationModel

CompletableFuture writeAuthorizationModel(storeId, body)

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 { &quot;type_definitions&quot;:[ { &quot;type&quot;:&quot;user&quot; }, { &quot;type&quot;:&quot;document&quot;, &quot;relations&quot;:{ &quot;reader&quot;:{ &quot;union&quot;:{ &quot;child&quot;:[ { &quot;this&quot;:{} }, { &quot;computedUserset&quot;:{ &quot;object&quot;:&quot;&quot;, &quot;relation&quot;:&quot;writer&quot; } } ] } }, &quot;writer&quot;:{ &quot;this&quot;:{} } } } ] } ``` OpenFGA's response will include the version id for this authorization model, which will look like ``` {&quot;authorization_model_id&quot;: &quot;01G50QVV17PECNVAHX1GG4Y5NC&quot;} ```

Example

// Import classes:
import dev.openfga.sdk.api.client.ApiClient;
import dev.openfga.sdk.api.client.ApiException;
import dev.openfga.sdk.api.configuration.Configuration;
import dev.openfga.sdk.api.client.models.*;
import dev.openfga.sdk.api.OpenFgaApi;
import java.util.concurrent.CompletableFuture;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("http://localhost");

        OpenFgaApi apiInstance = new OpenFgaApi(defaultClient);
        String storeId = "storeId_example"; // String | 
        WriteAuthorizationModelRequest body = new WriteAuthorizationModelRequest(); // WriteAuthorizationModelRequest | 
        try {
            CompletableFuture<WriteAuthorizationModelResponse> result = apiInstance.writeAuthorizationModel(storeId, body);
            System.out.println(result.get());
        } catch (ApiException e) {
            System.err.println("Exception when calling OpenFgaApi#writeAuthorizationModel");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

NameTypeDescriptionNotes
storeIdString
bodyWriteAuthorizationModelRequest

Return type

CompletableFuture<WriteAuthorizationModelResponse>

Authorization

No authorization required

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
201A successful response.-
400Request failed due to invalid input.-
401Not authenticated.-
403Forbidden.-
404Request failed due to incorrect path.-
409Request was aborted due a transaction conflict.-
422Request timed out due to excessive request throttling.-
500Request failed due to internal server error.-

writeAuthorizationModelWithHttpInfo

CompletableFuture<ApiResponse> writeAuthorizationModel writeAuthorizationModelWithHttpInfo(storeId, body)

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 { &quot;type_definitions&quot;:[ { &quot;type&quot;:&quot;user&quot; }, { &quot;type&quot;:&quot;document&quot;, &quot;relations&quot;:{ &quot;reader&quot;:{ &quot;union&quot;:{ &quot;child&quot;:[ { &quot;this&quot;:{} }, { &quot;computedUserset&quot;:{ &quot;object&quot;:&quot;&quot;, &quot;relation&quot;:&quot;writer&quot; } } ] } }, &quot;writer&quot;:{ &quot;this&quot;:{} } } } ] } ``` OpenFGA's response will include the version id for this authorization model, which will look like ``` {&quot;authorization_model_id&quot;: &quot;01G50QVV17PECNVAHX1GG4Y5NC&quot;} ```

Example

// Import classes:
import dev.openfga.sdk.api.client.ApiClient;
import dev.openfga.sdk.api.client.ApiException;
import dev.openfga.sdk.api.client.ApiResponse;
import dev.openfga.sdk.api.configuration.Configuration;
import dev.openfga.sdk.api.client.models.*;
import dev.openfga.sdk.api.OpenFgaApi;
import java.util.concurrent.CompletableFuture;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("http://localhost");

        OpenFgaApi apiInstance = new OpenFgaApi(defaultClient);
        String storeId = "storeId_example"; // String | 
        WriteAuthorizationModelRequest body = new WriteAuthorizationModelRequest(); // WriteAuthorizationModelRequest | 
        try {
            CompletableFuture<ApiResponse<WriteAuthorizationModelResponse>> response = apiInstance.writeAuthorizationModelWithHttpInfo(storeId, body);
            System.out.println("Status code: " + response.get().getStatusCode());
            System.out.println("Response headers: " + response.get().getHeaders());
            System.out.println("Response body: " + response.get().getData());
        } catch (InterruptedException | ExecutionException e) {
            ApiException apiException = (ApiException)e.getCause();
            System.err.println("Exception when calling OpenFgaApi#writeAuthorizationModel");
            System.err.println("Status code: " + apiException.getCode());
            System.err.println("Response headers: " + apiException.getResponseHeaders());
            System.err.println("Reason: " + apiException.getResponseBody());
            e.printStackTrace();
        } catch (ApiException e) {
            System.err.println("Exception when calling OpenFgaApi#writeAuthorizationModel");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            System.err.println("Reason: " + e.getResponseBody());
            e.printStackTrace();
        }
    }
}

Parameters

NameTypeDescriptionNotes
storeIdString
bodyWriteAuthorizationModelRequest

Return type

CompletableFuture<ApiResponse<WriteAuthorizationModelResponse>>

Authorization

No authorization required

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
201A successful response.-
400Request failed due to invalid input.-
401Not authenticated.-
403Forbidden.-
404Request failed due to incorrect path.-
409Request was aborted due a transaction conflict.-
422Request timed out due to excessive request throttling.-
500Request failed due to internal server error.-