\OpenFgaApi
November 18, 2025 ยท View on GitHub
All URIs are relative to http://localhost
| Method | HTTP request | Description |
|---|---|---|
| BatchCheck | Post /stores/{store_id}/batch-check | Send a list of `check` operations in a single request |
| Check | Post /stores/{store_id}/check | Check whether a user is authorized to access an object |
| CreateStore | Post /stores | Create a store |
| DeleteStore | Delete /stores/{store_id} | Delete a store |
| Expand | Post /stores/{store_id}/expand | Expand all relationships in userset tree format, and following userset rewrite rules. Useful to reason about and debug a certain relationship |
| GetStore | Get /stores/{store_id} | Get a store |
| ListObjects | Post /stores/{store_id}/list-objects | List all objects of the given type that the user has a relation with |
| ListStores | Get /stores | List all stores |
| ListUsers | Post /stores/{store_id}/list-users | List the users matching the provided filter who have a certain relation to a particular type. |
| Read | Post /stores/{store_id}/read | Get tuples from the store that matches a query, without following userset rewrite rules |
| ReadAssertions | Get /stores/{store_id}/assertions/{authorization_model_id} | Read assertions for an authorization model ID |
| ReadAuthorizationModel | Get /stores/{store_id}/authorization-models/{id} | Return a particular version of an authorization model |
| ReadAuthorizationModels | Get /stores/{store_id}/authorization-models | Return all the authorization models for a particular store |
| ReadChanges | Get /stores/{store_id}/changes | Return a list of all the tuple changes |
| StreamedListObjects | Post /stores/{store_id}/streamed-list-objects | Stream all objects of the given type that the user has a relation with |
| Write | Post /stores/{store_id}/write | Add or delete tuples from the store |
| WriteAssertions | Put /stores/{store_id}/assertions/{authorization_model_id} | Upsert assertions for an authorization model ID |
| WriteAuthorizationModel | Post /stores/{store_id}/authorization-models | Create a new authorization model |
BatchCheck
BatchCheckResponse BatchCheck(ctx).Body(body).Execute()
Send a list of check operations in a single request
Example
package main
import (
"context"
"fmt"
"os"
openfga "github.com/openfga/go-sdk"
)
func main() {
body := *openapiclient.NewBatchCheckRequest([]openapiclient.BatchCheckItem{*openapiclient.NewBatchCheckItem(*openapiclient.NewCheckRequestTupleKey("user:anne", "reader", "document:2021-budget"), "1cd93d8c-8e45-43c6-9a15-cbb3c7f394bc")}) // BatchCheckRequest |
configuration, err := openfga.NewConfiguration(openfga.Configuration{
ApiUrl: os.Getenv("FGA_API_URL"), // required, e.g. https://api.fga.example
StoreId: os.Getenv("OPENFGA_STORE_ID"), // not needed when calling `CreateStore` or `ListStores`
})
if err != nil {
// .. Handle error
}
apiClient := openfga.NewAPIClient(configuration)
resp, r, err := apiClient.OpenFgaApi.BatchCheck(context.Background()).Body(body).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `OpenFgaApi.BatchCheck``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
switch v := err.(type) {
case FgaApiAuthenticationError:
// Handle authentication error
case FgaApiValidationError:
// Handle parameter validation error
case FgaApiNotFoundError:
// Handle not found error
case FgaApiInternalError:
// Handle API internal error
case FgaApiRateLimitError:
// Exponential backoff in handling rate limit error
default:
// Handle unknown/undefined error
}
}
// response from `BatchCheck`: BatchCheckResponse
fmt.Fprintf(os.Stdout, "Response from `OpenFgaApi.BatchCheck`: %v\n", resp)
}
Path Parameters
| Name | Type | Description | Notes |
|---|---|---|---|
| ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. |
Other Parameters
Other parameters are passed through a pointer to a apiBatchCheckRequest struct via the builder pattern
| Name | Type | Description | Notes |
|---|---|---|---|
| body | BatchCheckRequest |
Return type
Authorization
No authorization required
HTTP request headers
- Content-Type: application/json
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
Check
CheckResponse Check(ctx).Body(body).Execute()
Check whether a user is authorized to access an object
Example
package main
import (
"context"
"fmt"
"os"
openfga "github.com/openfga/go-sdk"
)
func main() {
body := *openapiclient.NewCheckRequest(*openapiclient.NewCheckRequestTupleKey("user:anne", "reader", "document:2021-budget")) // CheckRequest |
configuration, err := openfga.NewConfiguration(openfga.Configuration{
ApiUrl: os.Getenv("FGA_API_URL"), // required, e.g. https://api.fga.example
StoreId: os.Getenv("OPENFGA_STORE_ID"), // not needed when calling `CreateStore` or `ListStores`
})
if err != nil {
// .. Handle error
}
apiClient := openfga.NewAPIClient(configuration)
resp, r, err := apiClient.OpenFgaApi.Check(context.Background()).Body(body).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `OpenFgaApi.Check``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
switch v := err.(type) {
case FgaApiAuthenticationError:
// Handle authentication error
case FgaApiValidationError:
// Handle parameter validation error
case FgaApiNotFoundError:
// Handle not found error
case FgaApiInternalError:
// Handle API internal error
case FgaApiRateLimitError:
// Exponential backoff in handling rate limit error
default:
// Handle unknown/undefined error
}
}
// response from `Check`: CheckResponse
fmt.Fprintf(os.Stdout, "Response from `OpenFgaApi.Check`: %v\n", resp)
}
Path Parameters
| Name | Type | Description | Notes |
|---|---|---|---|
| ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. |
Other Parameters
Other parameters are passed through a pointer to a apiCheckRequest struct via the builder pattern
| Name | Type | Description | Notes |
|---|---|---|---|
| body | CheckRequest |
Return type
Authorization
No authorization required
HTTP request headers
- Content-Type: application/json
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
CreateStore
CreateStoreResponse CreateStore(ctx).Body(body).Execute()
Create a store
Example
package main
import (
"context"
"fmt"
"os"
openfga "github.com/openfga/go-sdk"
)
func main() {
configuration, err := openfga.NewConfiguration(openfga.Configuration{
ApiUrl: os.Getenv("FGA_API_URL"), // required, e.g. https://api.fga.example
StoreId: os.Getenv("OPENFGA_STORE_ID"), // not needed when calling `CreateStore` or `ListStores`
})
if err != nil {
// .. Handle error
}
apiClient := openfga.NewAPIClient(configuration)
resp, r, err := apiClient.OpenFgaApi.CreateStore(context.Background()).Body(body).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `OpenFgaApi.CreateStore``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
switch v := err.(type) {
case FgaApiAuthenticationError:
// Handle authentication error
case FgaApiValidationError:
// Handle parameter validation error
case FgaApiNotFoundError:
// Handle not found error
case FgaApiInternalError:
// Handle API internal error
case FgaApiRateLimitError:
// Exponential backoff in handling rate limit error
default:
// Handle unknown/undefined error
}
}
// response from `CreateStore`: CreateStoreResponse
fmt.Fprintf(os.Stdout, "Response from `OpenFgaApi.CreateStore`: %v\n", resp)
}
Path Parameters
Other Parameters
Other parameters are passed through a pointer to a apiCreateStoreRequest struct via the builder pattern
| Name | Type | Description | Notes |
|---|---|---|---|
| body | CreateStoreRequest |
Return type
Authorization
No authorization required
HTTP request headers
- Content-Type: application/json
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
DeleteStore
DeleteStore(ctx).Execute()
Delete a store
Example
package main
import (
"context"
"fmt"
"os"
openfga "github.com/openfga/go-sdk"
)
func main() {
configuration, err := openfga.NewConfiguration(openfga.Configuration{
ApiUrl: os.Getenv("FGA_API_URL"), // required, e.g. https://api.fga.example
StoreId: os.Getenv("OPENFGA_STORE_ID"), // not needed when calling `CreateStore` or `ListStores`
})
if err != nil {
// .. Handle error
}
apiClient := openfga.NewAPIClient(configuration)
resp, r, err := apiClient.OpenFgaApi.DeleteStore(context.Background()).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `OpenFgaApi.DeleteStore``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
switch v := err.(type) {
case FgaApiAuthenticationError:
// Handle authentication error
case FgaApiValidationError:
// Handle parameter validation error
case FgaApiNotFoundError:
// Handle not found error
case FgaApiInternalError:
// Handle API internal error
case FgaApiRateLimitError:
// Exponential backoff in handling rate limit error
default:
// Handle unknown/undefined error
}
}
}
Path Parameters
| Name | Type | Description | Notes |
|---|---|---|---|
| ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. |
Other Parameters
Other parameters are passed through a pointer to a apiDeleteStoreRequest struct via the builder pattern
| Name | Type | Description | Notes |
|---|
Return type
(empty response body)
Authorization
No authorization required
HTTP request headers
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
Expand
ExpandResponse Expand(ctx).Body(body).Execute()
Expand all relationships in userset tree format, and following userset rewrite rules. Useful to reason about and debug a certain relationship
Example
package main
import (
"context"
"fmt"
"os"
openfga "github.com/openfga/go-sdk"
)
func main() {
body := *openapiclient.NewExpandRequest(*openapiclient.NewExpandRequestTupleKey("reader", "document:2021-budget")) // ExpandRequest |
configuration, err := openfga.NewConfiguration(openfga.Configuration{
ApiUrl: os.Getenv("FGA_API_URL"), // required, e.g. https://api.fga.example
StoreId: os.Getenv("OPENFGA_STORE_ID"), // not needed when calling `CreateStore` or `ListStores`
})
if err != nil {
// .. Handle error
}
apiClient := openfga.NewAPIClient(configuration)
resp, r, err := apiClient.OpenFgaApi.Expand(context.Background()).Body(body).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `OpenFgaApi.Expand``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
switch v := err.(type) {
case FgaApiAuthenticationError:
// Handle authentication error
case FgaApiValidationError:
// Handle parameter validation error
case FgaApiNotFoundError:
// Handle not found error
case FgaApiInternalError:
// Handle API internal error
case FgaApiRateLimitError:
// Exponential backoff in handling rate limit error
default:
// Handle unknown/undefined error
}
}
// response from `Expand`: ExpandResponse
fmt.Fprintf(os.Stdout, "Response from `OpenFgaApi.Expand`: %v\n", resp)
}
Path Parameters
| Name | Type | Description | Notes |
|---|---|---|---|
| ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. |
Other Parameters
Other parameters are passed through a pointer to a apiExpandRequest struct via the builder pattern
| Name | Type | Description | Notes |
|---|---|---|---|
| body | ExpandRequest |
Return type
Authorization
No authorization required
HTTP request headers
- Content-Type: application/json
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
GetStore
GetStoreResponse GetStore(ctx).Execute()
Get a store
Example
package main
import (
"context"
"fmt"
"os"
openfga "github.com/openfga/go-sdk"
)
func main() {
configuration, err := openfga.NewConfiguration(openfga.Configuration{
ApiUrl: os.Getenv("FGA_API_URL"), // required, e.g. https://api.fga.example
StoreId: os.Getenv("OPENFGA_STORE_ID"), // not needed when calling `CreateStore` or `ListStores`
})
if err != nil {
// .. Handle error
}
apiClient := openfga.NewAPIClient(configuration)
resp, r, err := apiClient.OpenFgaApi.GetStore(context.Background()).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `OpenFgaApi.GetStore``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
switch v := err.(type) {
case FgaApiAuthenticationError:
// Handle authentication error
case FgaApiValidationError:
// Handle parameter validation error
case FgaApiNotFoundError:
// Handle not found error
case FgaApiInternalError:
// Handle API internal error
case FgaApiRateLimitError:
// Exponential backoff in handling rate limit error
default:
// Handle unknown/undefined error
}
}
// response from `GetStore`: GetStoreResponse
fmt.Fprintf(os.Stdout, "Response from `OpenFgaApi.GetStore`: %v\n", resp)
}
Path Parameters
| Name | Type | Description | Notes |
|---|---|---|---|
| ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. |
Other Parameters
Other parameters are passed through a pointer to a apiGetStoreRequest struct via the builder pattern
| Name | Type | Description | Notes |
|---|
Return type
Authorization
No authorization required
HTTP request headers
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
ListObjects
ListObjectsResponse ListObjects(ctx).Body(body).Execute()
List all objects of the given type that the user has a relation with
Example
package main
import (
"context"
"fmt"
"os"
openfga "github.com/openfga/go-sdk"
)
func main() {
body := *openapiclient.NewListObjectsRequest("document", "reader", "user:anne") // ListObjectsRequest |
configuration, err := openfga.NewConfiguration(openfga.Configuration{
ApiUrl: os.Getenv("FGA_API_URL"), // required, e.g. https://api.fga.example
StoreId: os.Getenv("OPENFGA_STORE_ID"), // not needed when calling `CreateStore` or `ListStores`
})
if err != nil {
// .. Handle error
}
apiClient := openfga.NewAPIClient(configuration)
resp, r, err := apiClient.OpenFgaApi.ListObjects(context.Background()).Body(body).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `OpenFgaApi.ListObjects``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
switch v := err.(type) {
case FgaApiAuthenticationError:
// Handle authentication error
case FgaApiValidationError:
// Handle parameter validation error
case FgaApiNotFoundError:
// Handle not found error
case FgaApiInternalError:
// Handle API internal error
case FgaApiRateLimitError:
// Exponential backoff in handling rate limit error
default:
// Handle unknown/undefined error
}
}
// response from `ListObjects`: ListObjectsResponse
fmt.Fprintf(os.Stdout, "Response from `OpenFgaApi.ListObjects`: %v\n", resp)
}
Path Parameters
| Name | Type | Description | Notes |
|---|---|---|---|
| ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. |
Other Parameters
Other parameters are passed through a pointer to a apiListObjectsRequest struct via the builder pattern
| Name | Type | Description | Notes |
|---|---|---|---|
| body | ListObjectsRequest |
Return type
Authorization
No authorization required
HTTP request headers
- Content-Type: application/json
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
ListStores
ListStoresResponse ListStores(ctx).PageSize(pageSize).ContinuationToken(continuationToken).Name(name).Execute()
List all stores
Example
package main
import (
"context"
"fmt"
"os"
openfga "github.com/openfga/go-sdk"
)
func main() {
continuationToken := "continuationToken_example" // string | (optional)
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 (optional)
configuration, err := openfga.NewConfiguration(openfga.Configuration{
ApiUrl: os.Getenv("FGA_API_URL"), // required, e.g. https://api.fga.example
StoreId: os.Getenv("OPENFGA_STORE_ID"), // not needed when calling `CreateStore` or `ListStores`
})
if err != nil {
// .. Handle error
}
apiClient := openfga.NewAPIClient(configuration)
resp, r, err := apiClient.OpenFgaApi.ListStores(context.Background()).PageSize(pageSize).ContinuationToken(continuationToken).Name(name).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `OpenFgaApi.ListStores``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
switch v := err.(type) {
case FgaApiAuthenticationError:
// Handle authentication error
case FgaApiValidationError:
// Handle parameter validation error
case FgaApiNotFoundError:
// Handle not found error
case FgaApiInternalError:
// Handle API internal error
case FgaApiRateLimitError:
// Exponential backoff in handling rate limit error
default:
// Handle unknown/undefined error
}
}
// response from `ListStores`: ListStoresResponse
fmt.Fprintf(os.Stdout, "Response from `OpenFgaApi.ListStores`: %v\n", resp)
}
Path Parameters
Other Parameters
Other parameters are passed through a pointer to a apiListStoresRequest struct via the builder pattern
| Name | Type | Description | Notes |
|---|---|---|---|
| pageSize | int32 | ||
| continuationToken | string | ||
| name | 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 |
Return type
Authorization
No authorization required
HTTP request headers
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
ListUsers
ListUsersResponse ListUsers(ctx).Body(body).Execute()
List the users matching the provided filter who have a certain relation to a particular type.
Example
package main
import (
"context"
"fmt"
"os"
openfga "github.com/openfga/go-sdk"
)
func main() {
body := *openapiclient.NewListUsersRequest(*openapiclient.NewFgaObject("document", "0bcdf6fa-a6aa-4730-a8eb-9cf172ff16d9"), "reader", []openapiclient.UserTypeFilter{*openapiclient.NewUserTypeFilter("group")}) // ListUsersRequest |
configuration, err := openfga.NewConfiguration(openfga.Configuration{
ApiUrl: os.Getenv("FGA_API_URL"), // required, e.g. https://api.fga.example
StoreId: os.Getenv("OPENFGA_STORE_ID"), // not needed when calling `CreateStore` or `ListStores`
})
if err != nil {
// .. Handle error
}
apiClient := openfga.NewAPIClient(configuration)
resp, r, err := apiClient.OpenFgaApi.ListUsers(context.Background()).Body(body).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `OpenFgaApi.ListUsers``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
switch v := err.(type) {
case FgaApiAuthenticationError:
// Handle authentication error
case FgaApiValidationError:
// Handle parameter validation error
case FgaApiNotFoundError:
// Handle not found error
case FgaApiInternalError:
// Handle API internal error
case FgaApiRateLimitError:
// Exponential backoff in handling rate limit error
default:
// Handle unknown/undefined error
}
}
// response from `ListUsers`: ListUsersResponse
fmt.Fprintf(os.Stdout, "Response from `OpenFgaApi.ListUsers`: %v\n", resp)
}
Path Parameters
| Name | Type | Description | Notes |
|---|---|---|---|
| ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. |
Other Parameters
Other parameters are passed through a pointer to a apiListUsersRequest struct via the builder pattern
| Name | Type | Description | Notes |
|---|---|---|---|
| body | ListUsersRequest |
Return type
Authorization
No authorization required
HTTP request headers
- Content-Type: application/json
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
Read
ReadResponse Read(ctx).Body(body).Execute()
Get tuples from the store that matches a query, without following userset rewrite rules
Example
package main
import (
"context"
"fmt"
"os"
openfga "github.com/openfga/go-sdk"
)
func main() {
body := *openapiclient.NewReadRequest() // ReadRequest |
configuration, err := openfga.NewConfiguration(openfga.Configuration{
ApiUrl: os.Getenv("FGA_API_URL"), // required, e.g. https://api.fga.example
StoreId: os.Getenv("OPENFGA_STORE_ID"), // not needed when calling `CreateStore` or `ListStores`
})
if err != nil {
// .. Handle error
}
apiClient := openfga.NewAPIClient(configuration)
resp, r, err := apiClient.OpenFgaApi.Read(context.Background()).Body(body).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `OpenFgaApi.Read``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
switch v := err.(type) {
case FgaApiAuthenticationError:
// Handle authentication error
case FgaApiValidationError:
// Handle parameter validation error
case FgaApiNotFoundError:
// Handle not found error
case FgaApiInternalError:
// Handle API internal error
case FgaApiRateLimitError:
// Exponential backoff in handling rate limit error
default:
// Handle unknown/undefined error
}
}
// response from `Read`: ReadResponse
fmt.Fprintf(os.Stdout, "Response from `OpenFgaApi.Read`: %v\n", resp)
}
Path Parameters
| Name | Type | Description | Notes |
|---|---|---|---|
| ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. |
Other Parameters
Other parameters are passed through a pointer to a apiReadRequest struct via the builder pattern
| Name | Type | Description | Notes |
|---|---|---|---|
| body | ReadRequest |
Return type
Authorization
No authorization required
HTTP request headers
- Content-Type: application/json
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
ReadAssertions
ReadAssertionsResponse ReadAssertions(ctx, authorizationModelId).Execute()
Read assertions for an authorization model ID
Example
package main
import (
"context"
"fmt"
"os"
openfga "github.com/openfga/go-sdk"
)
func main() {
authorizationModelId := "authorizationModelId_example" // string |
configuration, err := openfga.NewConfiguration(openfga.Configuration{
ApiUrl: os.Getenv("FGA_API_URL"), // required, e.g. https://api.fga.example
StoreId: os.Getenv("OPENFGA_STORE_ID"), // not needed when calling `CreateStore` or `ListStores`
})
if err != nil {
// .. Handle error
}
apiClient := openfga.NewAPIClient(configuration)
resp, r, err := apiClient.OpenFgaApi.ReadAssertions(context.Background(), authorizationModelId).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `OpenFgaApi.ReadAssertions``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
switch v := err.(type) {
case FgaApiAuthenticationError:
// Handle authentication error
case FgaApiValidationError:
// Handle parameter validation error
case FgaApiNotFoundError:
// Handle not found error
case FgaApiInternalError:
// Handle API internal error
case FgaApiRateLimitError:
// Exponential backoff in handling rate limit error
default:
// Handle unknown/undefined error
}
}
// response from `ReadAssertions`: ReadAssertionsResponse
fmt.Fprintf(os.Stdout, "Response from `OpenFgaApi.ReadAssertions`: %v\n", resp)
}
Path Parameters
| Name | Type | Description | Notes |
|---|---|---|---|
| ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. | |
| authorizationModelId | string |
Other Parameters
Other parameters are passed through a pointer to a apiReadAssertionsRequest struct via the builder pattern
| Name | Type | Description | Notes |
|---|
Return type
Authorization
No authorization required
HTTP request headers
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
ReadAuthorizationModel
ReadAuthorizationModelResponse ReadAuthorizationModel(ctx, id).Execute()
Return a particular version of an authorization model
Example
package main
import (
"context"
"fmt"
"os"
openfga "github.com/openfga/go-sdk"
)
func main() {
id := "id_example" // string |
configuration, err := openfga.NewConfiguration(openfga.Configuration{
ApiUrl: os.Getenv("FGA_API_URL"), // required, e.g. https://api.fga.example
StoreId: os.Getenv("OPENFGA_STORE_ID"), // not needed when calling `CreateStore` or `ListStores`
})
if err != nil {
// .. Handle error
}
apiClient := openfga.NewAPIClient(configuration)
resp, r, err := apiClient.OpenFgaApi.ReadAuthorizationModel(context.Background(), id).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `OpenFgaApi.ReadAuthorizationModel``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
switch v := err.(type) {
case FgaApiAuthenticationError:
// Handle authentication error
case FgaApiValidationError:
// Handle parameter validation error
case FgaApiNotFoundError:
// Handle not found error
case FgaApiInternalError:
// Handle API internal error
case FgaApiRateLimitError:
// Exponential backoff in handling rate limit error
default:
// Handle unknown/undefined error
}
}
// response from `ReadAuthorizationModel`: ReadAuthorizationModelResponse
fmt.Fprintf(os.Stdout, "Response from `OpenFgaApi.ReadAuthorizationModel`: %v\n", resp)
}
Path Parameters
| Name | Type | Description | Notes |
|---|---|---|---|
| ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. | |
| id | string |
Other Parameters
Other parameters are passed through a pointer to a apiReadAuthorizationModelRequest struct via the builder pattern
| Name | Type | Description | Notes |
|---|
Return type
ReadAuthorizationModelResponse
Authorization
No authorization required
HTTP request headers
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
ReadAuthorizationModels
ReadAuthorizationModelsResponse ReadAuthorizationModels(ctx).PageSize(pageSize).ContinuationToken(continuationToken).Execute()
Return all the authorization models for a particular store
Example
package main
import (
"context"
"fmt"
"os"
openfga "github.com/openfga/go-sdk"
)
func main() {
pageSize := int32(56) // int32 | (optional)
continuationToken := "continuationToken_example" // string | (optional)
configuration, err := openfga.NewConfiguration(openfga.Configuration{
ApiUrl: os.Getenv("FGA_API_URL"), // required, e.g. https://api.fga.example
StoreId: os.Getenv("OPENFGA_STORE_ID"), // not needed when calling `CreateStore` or `ListStores`
})
if err != nil {
// .. Handle error
}
apiClient := openfga.NewAPIClient(configuration)
resp, r, err := apiClient.OpenFgaApi.ReadAuthorizationModels(context.Background()).PageSize(pageSize).ContinuationToken(continuationToken).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `OpenFgaApi.ReadAuthorizationModels``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
switch v := err.(type) {
case FgaApiAuthenticationError:
// Handle authentication error
case FgaApiValidationError:
// Handle parameter validation error
case FgaApiNotFoundError:
// Handle not found error
case FgaApiInternalError:
// Handle API internal error
case FgaApiRateLimitError:
// Exponential backoff in handling rate limit error
default:
// Handle unknown/undefined error
}
}
// response from `ReadAuthorizationModels`: ReadAuthorizationModelsResponse
fmt.Fprintf(os.Stdout, "Response from `OpenFgaApi.ReadAuthorizationModels`: %v\n", resp)
}
Path Parameters
| Name | Type | Description | Notes |
|---|---|---|---|
| ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. |
Other Parameters
Other parameters are passed through a pointer to a apiReadAuthorizationModelsRequest struct via the builder pattern
| Name | Type | Description | Notes |
|---|---|---|---|
| pageSize | int32 | ||
| continuationToken | string |
Return type
ReadAuthorizationModelsResponse
Authorization
No authorization required
HTTP request headers
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
ReadChanges
ReadChangesResponse ReadChanges(ctx).Type_(type_).PageSize(pageSize).ContinuationToken(continuationToken).StartTime(startTime).Execute()
Return a list of all the tuple changes
Example
package main
import (
"context"
"fmt"
"os"
"time"
openfga "github.com/openfga/go-sdk"
)
func main() {
type_ := "type__example" // string | (optional)
pageSize := int32(56) // int32 | (optional)
continuationToken := "continuationToken_example" // string | (optional)
startTime := time.Now() // time.Time | 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. (optional)
configuration, err := openfga.NewConfiguration(openfga.Configuration{
ApiUrl: os.Getenv("FGA_API_URL"), // required, e.g. https://api.fga.example
StoreId: os.Getenv("OPENFGA_STORE_ID"), // not needed when calling `CreateStore` or `ListStores`
})
if err != nil {
// .. Handle error
}
apiClient := openfga.NewAPIClient(configuration)
resp, r, err := apiClient.OpenFgaApi.ReadChanges(context.Background()).Type_(type_).PageSize(pageSize).ContinuationToken(continuationToken).StartTime(startTime).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `OpenFgaApi.ReadChanges``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
switch v := err.(type) {
case FgaApiAuthenticationError:
// Handle authentication error
case FgaApiValidationError:
// Handle parameter validation error
case FgaApiNotFoundError:
// Handle not found error
case FgaApiInternalError:
// Handle API internal error
case FgaApiRateLimitError:
// Exponential backoff in handling rate limit error
default:
// Handle unknown/undefined error
}
}
// response from `ReadChanges`: ReadChangesResponse
fmt.Fprintf(os.Stdout, "Response from `OpenFgaApi.ReadChanges`: %v\n", resp)
}
Path Parameters
| Name | Type | Description | Notes |
|---|---|---|---|
| ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. |
Other Parameters
Other parameters are passed through a pointer to a apiReadChangesRequest struct via the builder pattern
| Name | Type | Description | Notes |
|---|---|---|---|
| type_ | string | ||
| pageSize | int32 | ||
| continuationToken | string | ||
| startTime | time.Time | 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. |
Return type
Authorization
No authorization required
HTTP request headers
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
StreamedListObjects
StreamResultOfStreamedListObjectsResponse StreamedListObjects(ctx).Body(body).Execute()
Stream all objects of the given type that the user has a relation with
Example
package main
import (
"context"
"fmt"
"os"
openfga "github.com/openfga/go-sdk"
)
func main() {
body := *openapiclient.NewListObjectsRequest("document", "reader", "user:anne") // ListObjectsRequest |
configuration, err := openfga.NewConfiguration(openfga.Configuration{
ApiUrl: os.Getenv("FGA_API_URL"), // required, e.g. https://api.fga.example
StoreId: os.Getenv("OPENFGA_STORE_ID"), // not needed when calling `CreateStore` or `ListStores`
})
if err != nil {
// .. Handle error
}
apiClient := openfga.NewAPIClient(configuration)
resp, r, err := apiClient.OpenFgaApi.StreamedListObjects(context.Background()).Body(body).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `OpenFgaApi.StreamedListObjects``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
switch v := err.(type) {
case FgaApiAuthenticationError:
// Handle authentication error
case FgaApiValidationError:
// Handle parameter validation error
case FgaApiNotFoundError:
// Handle not found error
case FgaApiInternalError:
// Handle API internal error
case FgaApiRateLimitError:
// Exponential backoff in handling rate limit error
default:
// Handle unknown/undefined error
}
}
// response from `StreamedListObjects`: StreamResultOfStreamedListObjectsResponse
fmt.Fprintf(os.Stdout, "Response from `OpenFgaApi.StreamedListObjects`: %v\n", resp)
}
Path Parameters
| Name | Type | Description | Notes |
|---|---|---|---|
| ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. |
Other Parameters
Other parameters are passed through a pointer to a apiStreamedListObjectsRequest struct via the builder pattern
| Name | Type | Description | Notes |
|---|---|---|---|
| body | ListObjectsRequest |
Return type
StreamResultOfStreamedListObjectsResponse
Authorization
No authorization required
HTTP request headers
- Content-Type: application/json
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
Write
map[string]interface{} Write(ctx).Body(body).Execute()
Add or delete tuples from the store
Example
package main
import (
"context"
"fmt"
"os"
openfga "github.com/openfga/go-sdk"
)
func main() {
body := *openapiclient.NewWriteRequest() // WriteRequest |
configuration, err := openfga.NewConfiguration(openfga.Configuration{
ApiUrl: os.Getenv("FGA_API_URL"), // required, e.g. https://api.fga.example
StoreId: os.Getenv("OPENFGA_STORE_ID"), // not needed when calling `CreateStore` or `ListStores`
})
if err != nil {
// .. Handle error
}
apiClient := openfga.NewAPIClient(configuration)
resp, r, err := apiClient.OpenFgaApi.Write(context.Background()).Body(body).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `OpenFgaApi.Write``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
switch v := err.(type) {
case FgaApiAuthenticationError:
// Handle authentication error
case FgaApiValidationError:
// Handle parameter validation error
case FgaApiNotFoundError:
// Handle not found error
case FgaApiInternalError:
// Handle API internal error
case FgaApiRateLimitError:
// Exponential backoff in handling rate limit error
default:
// Handle unknown/undefined error
}
}
// response from `Write`: map[string]interface{}
fmt.Fprintf(os.Stdout, "Response from `OpenFgaApi.Write`: %v\n", resp)
}
Path Parameters
| Name | Type | Description | Notes |
|---|---|---|---|
| ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. |
Other Parameters
Other parameters are passed through a pointer to a apiWriteRequest struct via the builder pattern
| Name | Type | Description | Notes |
|---|---|---|---|
| body | WriteRequest |
Return type
map[string]interface{}
Authorization
No authorization required
HTTP request headers
- Content-Type: application/json
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
WriteAssertions
WriteAssertions(ctx, authorizationModelId).Body(body).Execute()
Upsert assertions for an authorization model ID
Example
package main
import (
"context"
"fmt"
"os"
openfga "github.com/openfga/go-sdk"
)
func main() {
authorizationModelId := "authorizationModelId_example" // string |
body := *openapiclient.NewWriteAssertionsRequest([]openapiclient.Assertion{*openapiclient.NewAssertion(*openapiclient.NewAssertionTupleKey("document:2021-budget", "reader", "user:anne"), false)}) // WriteAssertionsRequest |
configuration, err := openfga.NewConfiguration(openfga.Configuration{
ApiUrl: os.Getenv("FGA_API_URL"), // required, e.g. https://api.fga.example
StoreId: os.Getenv("OPENFGA_STORE_ID"), // not needed when calling `CreateStore` or `ListStores`
})
if err != nil {
// .. Handle error
}
apiClient := openfga.NewAPIClient(configuration)
resp, r, err := apiClient.OpenFgaApi.WriteAssertions(context.Background(), authorizationModelId).Body(body).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `OpenFgaApi.WriteAssertions``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
switch v := err.(type) {
case FgaApiAuthenticationError:
// Handle authentication error
case FgaApiValidationError:
// Handle parameter validation error
case FgaApiNotFoundError:
// Handle not found error
case FgaApiInternalError:
// Handle API internal error
case FgaApiRateLimitError:
// Exponential backoff in handling rate limit error
default:
// Handle unknown/undefined error
}
}
}
Path Parameters
| Name | Type | Description | Notes |
|---|---|---|---|
| ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. | |
| authorizationModelId | string |
Other Parameters
Other parameters are passed through a pointer to a apiWriteAssertionsRequest struct via the builder pattern
| Name | Type | Description | Notes |
|---|---|---|---|
| body | WriteAssertionsRequest |
Return type
(empty response body)
Authorization
No authorization required
HTTP request headers
- Content-Type: application/json
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
WriteAuthorizationModel
WriteAuthorizationModelResponse WriteAuthorizationModel(ctx).Body(body).Execute()
Create a new authorization model
Example
package main
import (
"context"
"fmt"
"os"
openfga "github.com/openfga/go-sdk"
)
func main() {
body := *openapiclient.NewWriteAuthorizationModelRequest([]openapiclient.TypeDefinition{*openapiclient.NewTypeDefinition("document")}, "SchemaVersion_example") // WriteAuthorizationModelRequest |
configuration, err := openfga.NewConfiguration(openfga.Configuration{
ApiUrl: os.Getenv("FGA_API_URL"), // required, e.g. https://api.fga.example
StoreId: os.Getenv("OPENFGA_STORE_ID"), // not needed when calling `CreateStore` or `ListStores`
})
if err != nil {
// .. Handle error
}
apiClient := openfga.NewAPIClient(configuration)
resp, r, err := apiClient.OpenFgaApi.WriteAuthorizationModel(context.Background()).Body(body).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `OpenFgaApi.WriteAuthorizationModel``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
switch v := err.(type) {
case FgaApiAuthenticationError:
// Handle authentication error
case FgaApiValidationError:
// Handle parameter validation error
case FgaApiNotFoundError:
// Handle not found error
case FgaApiInternalError:
// Handle API internal error
case FgaApiRateLimitError:
// Exponential backoff in handling rate limit error
default:
// Handle unknown/undefined error
}
}
// response from `WriteAuthorizationModel`: WriteAuthorizationModelResponse
fmt.Fprintf(os.Stdout, "Response from `OpenFgaApi.WriteAuthorizationModel`: %v\n", resp)
}
Path Parameters
| Name | Type | Description | Notes |
|---|---|---|---|
| ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. |
Other Parameters
Other parameters are passed through a pointer to a apiWriteAuthorizationModelRequest struct via the builder pattern
| Name | Type | Description | Notes |
|---|---|---|---|
| body | WriteAuthorizationModelRequest |
Return type
WriteAuthorizationModelResponse
Authorization
No authorization required
HTTP request headers
- Content-Type: application/json
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]