All URIs are relative to http://localhost
Method | HTTP request | Description |
---|---|---|
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 |
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 |
CheckResponse Check(ctx).Body(body).Execute()
Check whether a user is authorized to access an object
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)
}
Name | Type | Description | Notes |
---|---|---|---|
ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. |
Other parameters are passed through a pointer to a apiCheckRequest struct via the builder pattern
Name | Type | Description | Notes |
---|---|---|---|
body | CheckRequest |
No authorization required
- Content-Type: application/json
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
CreateStoreResponse CreateStore(ctx).Body(body).Execute()
Create a store
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)
}
Other parameters are passed through a pointer to a apiCreateStoreRequest struct via the builder pattern
Name | Type | Description | Notes |
---|---|---|---|
body | CreateStoreRequest |
No authorization required
- Content-Type: application/json
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
DeleteStore(ctx).Execute()
Delete a store
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
}
}
}
Name | Type | Description | Notes |
---|---|---|---|
ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. |
Other parameters are passed through a pointer to a apiDeleteStoreRequest struct via the builder pattern
Name | Type | Description | Notes |
---|
(empty response body)
No authorization required
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
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
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)
}
Name | Type | Description | Notes |
---|---|---|---|
ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. |
Other parameters are passed through a pointer to a apiExpandRequest struct via the builder pattern
Name | Type | Description | Notes |
---|---|---|---|
body | ExpandRequest |
No authorization required
- Content-Type: application/json
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
GetStoreResponse GetStore(ctx).Execute()
Get a store
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)
}
Name | Type | Description | Notes |
---|---|---|---|
ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. |
Other parameters are passed through a pointer to a apiGetStoreRequest struct via the builder pattern
Name | Type | Description | Notes |
---|
No authorization required
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
ListObjectsResponse ListObjects(ctx).Body(body).Execute()
List all objects of the given type that the user has a relation with
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)
}
Name | Type | Description | Notes |
---|---|---|---|
ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. |
Other parameters are passed through a pointer to a apiListObjectsRequest struct via the builder pattern
Name | Type | Description | Notes |
---|---|---|---|
body | ListObjectsRequest |
No authorization required
- Content-Type: application/json
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
ListStoresResponse ListStores(ctx).PageSize(pageSize).ContinuationToken(continuationToken).Execute()
List all stores
package main
import (
"context"
"fmt"
"os"
openfga "github.com/openfga/go-sdk"
)
func main() {
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.ListStores(context.Background()).PageSize(pageSize).ContinuationToken(continuationToken).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)
}
Other parameters are passed through a pointer to a apiListStoresRequest struct via the builder pattern
Name | Type | Description | Notes |
---|---|---|---|
pageSize | int32 | ||
continuationToken | string |
No authorization required
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
ListUsersResponse ListUsers(ctx).Body(body).Execute()
List the users matching the provided filter who have a certain relation to a particular type.
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)
}
Name | Type | Description | Notes |
---|---|---|---|
ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. |
Other parameters are passed through a pointer to a apiListUsersRequest struct via the builder pattern
Name | Type | Description | Notes |
---|---|---|---|
body | ListUsersRequest |
No authorization required
- Content-Type: application/json
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
ReadResponse Read(ctx).Body(body).Execute()
Get tuples from the store that matches a query, without following userset rewrite rules
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)
}
Name | Type | Description | Notes |
---|---|---|---|
ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. |
Other parameters are passed through a pointer to a apiReadRequest struct via the builder pattern
Name | Type | Description | Notes |
---|---|---|---|
body | ReadRequest |
No authorization required
- Content-Type: application/json
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
ReadAssertionsResponse ReadAssertions(ctx, authorizationModelId).Execute()
Read assertions for an authorization model ID
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)
}
Name | Type | Description | Notes |
---|---|---|---|
ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. | |
authorizationModelId | string |
Other parameters are passed through a pointer to a apiReadAssertionsRequest struct via the builder pattern
Name | Type | Description | Notes |
---|
No authorization required
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
ReadAuthorizationModelResponse ReadAuthorizationModel(ctx, id).Execute()
Return a particular version of an authorization model
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)
}
Name | Type | Description | Notes |
---|---|---|---|
ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. | |
id | string |
Other parameters are passed through a pointer to a apiReadAuthorizationModelRequest struct via the builder pattern
Name | Type | Description | Notes |
---|
ReadAuthorizationModelResponse
No authorization required
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
ReadAuthorizationModelsResponse ReadAuthorizationModels(ctx).PageSize(pageSize).ContinuationToken(continuationToken).Execute()
Return all the authorization models for a particular store
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)
}
Name | Type | Description | Notes |
---|---|---|---|
ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. |
Other parameters are passed through a pointer to a apiReadAuthorizationModelsRequest struct via the builder pattern
Name | Type | Description | Notes |
---|---|---|---|
pageSize | int32 | ||
continuationToken | string |
ReadAuthorizationModelsResponse
No authorization required
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
ReadChangesResponse ReadChanges(ctx).Type_(type_).PageSize(pageSize).ContinuationToken(continuationToken).Execute()
Return a list of all the tuple changes
package main
import (
"context"
"fmt"
"os"
openfga "github.com/openfga/go-sdk"
)
func main() {
type_ := "type__example" // string | (optional)
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.ReadChanges(context.Background()).Type_(type_).PageSize(pageSize).ContinuationToken(continuationToken).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)
}
Name | Type | Description | Notes |
---|---|---|---|
ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. |
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 |
No authorization required
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
map[string]interface{} Write(ctx).Body(body).Execute()
Add or delete tuples from the store
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)
}
Name | Type | Description | Notes |
---|---|---|---|
ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. |
Other parameters are passed through a pointer to a apiWriteRequest struct via the builder pattern
Name | Type | Description | Notes |
---|---|---|---|
body | WriteRequest |
map[string]interface{}
No authorization required
- Content-Type: application/json
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
WriteAssertions(ctx, authorizationModelId).Body(body).Execute()
Upsert assertions for an authorization model ID
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
}
}
}
Name | Type | Description | Notes |
---|---|---|---|
ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. | |
authorizationModelId | string |
Other parameters are passed through a pointer to a apiWriteAssertionsRequest struct via the builder pattern
Name | Type | Description | Notes |
---|---|---|---|
body | WriteAssertionsRequest |
(empty response body)
No authorization required
- Content-Type: application/json
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
WriteAuthorizationModelResponse WriteAuthorizationModel(ctx).Body(body).Execute()
Create a new authorization model
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)
}
Name | Type | Description | Notes |
---|---|---|---|
ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. |
Other parameters are passed through a pointer to a apiWriteAuthorizationModelRequest struct via the builder pattern
Name | Type | Description | Notes |
---|---|---|---|
body | WriteAuthorizationModelRequest |
WriteAuthorizationModelResponse
No authorization required
- Content-Type: application/json
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]