Categorygithub.com/openfga/go-sdk
modulepackage
0.6.1
Repository: https://github.com/openfga/go-sdk.git
Documentation: pkg.go.dev

# README

Go SDK for OpenFGA

Go Reference Release License FOSSA Status Join our community Twitter

This is an autogenerated Go SDK for OpenFGA. It provides a wrapper around the OpenFGA API definition.

Table of Contents

About

OpenFGA is an open source Fine-Grained Authorization solution inspired by Google's Zanzibar paper. It was created by the FGA team at Auth0 based on Auth0 Fine-Grained Authorization (FGA), available under a permissive license (Apache-2) and welcomes community contributions.

OpenFGA is designed to make it easy for application builders to model their permission layer, and to add and integrate fine-grained authorization into their applications. OpenFGA’s design is optimized for reliability and low latency at a high scale.

Resources

Installation

To install:

go get -u github.com/openfga/go-sdk

In your code, import the module and use it:

import "github.com/openfga/go-sdk"

func Main() {
	configuration, err := openfga.NewConfiguration(openfga.Configuration{})
}

You can then run

go mod tidy

to update go.mod and go.sum if you are using them.

Getting Started

Initializing the API Client

Learn how to initialize your SDK

We strongly recommend you initialize the OpenFgaClient only once and then re-use it throughout your app, otherwise you will incur the cost of having to re-initialize multiple times or at every request, the cost of reduced connection pooling and re-use, and would be particularly costly in the client credentials flow, as that flow will be preformed on every request.

The openfgaClient will by default retry API requests up to 15 times on 429 and 5xx errors.

No Credentials

import (
    . "github.com/openfga/go-sdk/client"
    "os"
)

func main() {
    fgaClient, err := NewSdkClient(&ClientConfiguration{
        ApiUrl:  os.Getenv("FGA_API_URL"), // required, e.g. https://api.fga.example
        StoreId: os.Getenv("FGA_STORE_ID"), // not needed when calling `CreateStore` or `ListStores`
        AuthorizationModelId: os.Getenv("FGA_MODEL_ID"), // optional, recommended to be set for production
    })

	if err != nil {
        // .. Handle error
    }
}

API Token

import (
    . "github.com/openfga/go-sdk/client"
    "github.com/openfga/go-sdk/credentials"
    "os"
)

func main() {
    fgaClient, err := NewSdkClient(&ClientConfiguration{
        ApiUrl:      os.Getenv("FGA_API_URL"), // required, e.g. https://api.fga.example
        StoreId:     os.Getenv("FGA_STORE_ID"), // not needed when calling `CreateStore` or `ListStores`
        AuthorizationModelId: os.Getenv("FGA_MODEL_ID"), // optional, recommended to be set for production
        Credentials: &credentials.Credentials{
            Method: credentials.CredentialsMethodApiToken,
            Config: &credentials.Config{
                ApiToken: os.Getenv("FGA_API_TOKEN"), // will be passed as the "Authorization: Bearer ${ApiToken}" request header
            },
        },
    })

    if err != nil {
        // .. Handle error
    }
}

Auth0 Client Credentials

import (
    openfga "github.com/openfga/go-sdk"
    . "github.com/openfga/go-sdk/client"
    "github.com/openfga/go-sdk/credentials"
    "os"
)

func main() {
    fgaClient, err := NewSdkClient(&ClientConfiguration{
        ApiUrl:               os.Getenv("FGA_API_URL"), // required, e.g. https://api.fga.example
        StoreId:              os.Getenv("FGA_STORE_ID"), // not needed when calling `CreateStore` or `ListStores`
        AuthorizationModelId: os.Getenv("FGA_MODEL_ID"), // optional, recommended to be set for production
        Credentials: &credentials.Credentials{
            Method: credentials.CredentialsMethodClientCredentials,
            Config: &credentials.Config{
                ClientCredentialsClientId:       os.Getenv("FGA_CLIENT_ID"),
                ClientCredentialsClientSecret:   os.Getenv("FGA_CLIENT_SECRET"),
                ClientCredentialsApiAudience:    os.Getenv("FGA_API_AUDIENCE"),
                ClientCredentialsApiTokenIssuer: os.Getenv("FGA_API_TOKEN_ISSUER"),
            },
        },
    })

    if err != nil {
        // .. Handle error
    }
}

OAuth2 Client Credentials

import (
    openfga "github.com/openfga/go-sdk"
    . "github.com/openfga/go-sdk/client"
    "github.com/openfga/go-sdk/credentials"
    "os"
)

func main() {
    fgaClient, err := NewSdkClient(&ClientConfiguration{
        ApiUrl:               os.Getenv("FGA_API_URL"), // required, e.g. https://api.fga.example
        StoreId:              os.Getenv("FGA_STORE_ID"), // not needed when calling `CreateStore` or `ListStores`
        AuthorizationModelId: os.Getenv("FGA_MODEL_ID"), // optional, recommended to be set for production
        Credentials: &credentials.Credentials{
            Method: credentials.CredentialsMethodClientCredentials,
            Config: &credentials.Config{
                ClientCredentialsClientId:       os.Getenv("FGA_CLIENT_ID"),
                ClientCredentialsClientSecret:   os.Getenv("FGA_CLIENT_SECRET"),
                ClientCredentialsScopes:         os.Getenv("FGA_API_SCOPES"), // optional space separated scopes
                ClientCredentialsApiTokenIssuer: os.Getenv("FGA_API_TOKEN_ISSUER"),
            },
        },
    })

    if err != nil {
        // .. Handle error
    }
}

Get your Store ID

You need your store id to call the OpenFGA API (unless it is to call the CreateStore or ListStores methods).

If your server is configured with authentication enabled, you also need to have your credentials ready.

Calling the API

Stores

List Stores

Get a paginated list of stores.

API Documentation

options := ClientListStoresOptions{
  PageSize:          openfga.PtrInt32(10),
  ContinuationToken: openfga.PtrString("..."),
}
stores, err := fgaClient.ListStores(context.Background()).Options(options).Execute()

// stores = [{ "id": "01FQH7V8BEG3GPQW93KTRFR8JB", "name": "FGA Demo Store", "created_at": "2022-01-01T00:00:00.000Z", "updated_at": "2022-01-01T00:00:00.000Z" }]
Create Store

Create and initialize a store.

API Documentation

body := ClientCreateStoreRequest{Name: "FGA Demo"}
store, err := fgaClient.CreateStore(context.Background()).Body(body).Execute()
if err != nil {
    // handle error
}

// store.Id = "01FQH7V8BEG3GPQW93KTRFR8JB"

// store store.Id in database
// update the storeId of the current instance
fgaClient.SetStoreId(store.Id)
// continue calling the API normally, scoped to this store
Get Store

Get information about the current store.

API Documentation

options := ClientGetStoreOptions{
    // You can rely on the store id set in the configuration or override it for this specific request
    StoreId: openfga.PtrString("01FQH7V8BEG3GPQW93KTRFR8JB"), 
}
store,  err := fgaClient.GetStore(context.Background()).Options(options)Execute()
if err != nil {
    // handle error
}

// store = { "id": "01FQH7V8BEG3GPQW93KTRFR8JB", "name": "FGA Demo Store", "created_at": "2022-01-01T00:00:00.000Z", "updated_at": "2022-01-01T00:00:00.000Z" }
Delete Store

Delete a store.

API Documentation

options := ClientDeleteStoreOptions{
    // You can rely on the store id set in the configuration or override it for this specific request
    StoreId: openfga.PtrString("01FQH7V8BEG3GPQW93KTRFR8JB"), 
}
_,  err := fgaClient.DeleteStore(context.Background()).Options(options).Execute()
if err != nil {
    // handle error
}

Authorization Models

Read Authorization Models

Read all authorization models in the store.

API Documentation

options := ClientReadAuthorizationModelsOptions{
    PageSize: openfga.PtrInt32(10),
    ContinuationToken: openfga.PtrString("..."),
    // You can rely on the store id set in the configuration or override it for this specific request
    StoreId: openfga.PtrString("01FQH7V8BEG3GPQW93KTRFR8JB"),
}
data, err := fgaClient.ReadAuthorizationModels(context.Background()).Options(options).Execute()

// data.AuthorizationModels = [
// { Id: "01GXSA8YR785C4FYS3C0RTG7B1", SchemaVersion: "1.1", TypeDefinitions: [...] },
// { Id: "01GXSBM5PVYHCJNRNKXMB4QZTW", SchemaVersion: "1.1", TypeDefinitions: [...] }];
Write Authorization Model

Create a new authorization model.

API Documentation

Note: To learn how to build your authorization model, check the Docs at https://openfga.dev/docs.

Learn more about the OpenFGA configuration language.

You can use the OpenFGA Syntax Transformer to convert between the friendly DSL and the JSON authorization model.

body := ClientWriteAuthorizationModelRequest{
  SchemaVersion: "1.1",
  TypeDefinitions: []openfga.TypeDefinition{
    {Type: "user", Relations: &map[string]openfga.Userset{}},
    {
      Type: "document",
      Relations: &map[string]openfga.Userset{
        "writer": {
          This: &map[string]interface{}{},
        },
        "viewer": {Union: &openfga.Usersets{
          Child: &[]openfga.Userset{
            {This: &map[string]interface{}{}},
            {ComputedUserset: &openfga.ObjectRelation{
              Object:   openfga.PtrString(""),
              Relation: openfga.PtrString("writer"),
            }},
          },
        }},
      },
      Metadata: &openfga.Metadata{
        Relations: &map[string]openfga.RelationMetadata{
          "writer": {
            DirectlyRelatedUserTypes: &[]openfga.RelationReference{
              {Type: "user"},
            },
          },
          "viewer": {
            DirectlyRelatedUserTypes: &[]openfga.RelationReference{
              {Type: "user"},
            },
          },
        },
      },
    }},
}
options := ClientWriteAuthorizationModelOptions{
    // You can rely on the store id set in the configuration or override it for this specific request
    StoreId: openfga.PtrString("01FQH7V8BEG3GPQW93KTRFR8JB"), 
}
data, err := fgaClient.WriteAuthorizationModel(context.Background()).Options(options).Body(body).Execute()

fmt.Printf("%s", data.AuthorizationModelId) // 01GXSA8YR785C4FYS3C0RTG7B1
Read a Single Authorization Model

Read a particular authorization model.

API Documentation

options := ClientReadAuthorizationModelOptions{
    // You can rely on the model id set in the configuration or override it for this specific request
    AuthorizationModelId: openfga.PtrString(modelId),
    // You can rely on the store id set in the configuration or override it for this specific request
    StoreId: openfga.PtrString("01FQH7V8BEG3GPQW93KTRFR8JB"), 
}
data, err := fgaClient.ReadAuthorizationModel(context.Background()).Options(options).Execute()

// data = {"authorization_model":{"id":"01GXSA8YR785C4FYS3C0RTG7B1","schema_version":"1.1","type_definitions":[{"type":"document","relations":{"writer":{"this":{}},"viewer":{ ... }}},{"type":"user"}]}} // JSON

fmt.Printf("%s", data.AuthorizationModel.Id) // 01GXSA8YR785C4FYS3C0RTG7B1
Read the Latest Authorization Model

Reads the latest authorization model (note: this ignores the model id in configuration).

API Documentation

options := ClientReadLatestAuthorizationModelOptions{
    // You can rely on the model id set in the configuration or override it for this specific request
    AuthorizationModelId: openfga.PtrString(modelId),
    // You can rely on the store id set in the configuration or override it for this specific request
    StoreId: openfga.PtrString("01FQH7V8BEG3GPQW93KTRFR8JB"), 
}
data, err := fgaClient.ReadLatestAuthorizationModel(context.Background()).Options(options)Execute()

// data.AuthorizationModel.Id = "01GXSA8YR785C4FYS3C0RTG7B1"
// data.AuthorizationModel.SchemaVersion = "1.1"
// data.AuthorizationModel.TypeDefinitions = [{ "type": "document", "relations": { ... } }, { "type": "user", "relations": { ... }}]

fmt.Printf("%s", (*data.AuthorizationModel).GetId()) // 01GXSA8YR785C4FYS3C0RTG7B1

Relationship Tuples

Read Relationship Tuple Changes (Watch)

Reads the list of historical relationship tuple writes and deletes.

API Documentation

body := ClientReadChangesRequest{
    Type: "document",
}
options := ClientReadChangesOptions{
    PageSize: openfga.PtrInt32(10),
    ContinuationToken: openfga.PtrString("eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ=="),
    // You can rely on the store id set in the configuration or override it for this specific request
    StoreId: openfga.PtrString("01FQH7V8BEG3GPQW93KTRFR8JB"), 
}
data, err := fgaClient.ReadChanges(context.Background()).Body(body).Options(options).Execute()

// data.ContinuationToken = ...
// data.Changes = [
//   { TupleKey: { User, Relation, Object }, Operation: TupleOperation.WRITE, Timestamp: ... },
//   { TupleKey: { User, Relation, Object }, Operation: TupleOperation.DELETE, Timestamp: ... }
// ]
Read Relationship Tuples

Reads the relationship tuples stored in the database. It does not evaluate nor exclude invalid tuples according to the authorization model.

API Documentation

// Find if a relationship tuple stating that a certain user is a viewer of a certain document
body := ClientReadRequest{
    User:     openfga.PtrString("user:81684243-9356-4421-8fbf-a4f8d36aa31b"),
    Relation: openfga.PtrString("viewer"),
    Object:   openfga.PtrString("document:roadmap"),
}

// Find all relationship tuples where a certain user has a relationship as any relation to a certain document
body := ClientReadRequest{
    User:     openfga.PtrString("user:81684243-9356-4421-8fbf-a4f8d36aa31b"),
    Object:   openfga.PtrString("document:roadmap"),
}

// Find all relationship tuples where a certain user is a viewer of any document
body := ClientReadRequest{
    User:     openfga.PtrString("user:81684243-9356-4421-8fbf-a4f8d36aa31b"),
    Relation: openfga.PtrString("viewer"),
    Object:   openfga.PtrString("document:"),
}

// Find all relationship tuples where any user has a relationship as any relation with a particular document
body := ClientReadRequest{
    Object:   openfga.PtrString("document:roadmap"),
}

// Read all stored relationship tuples
body := ClientReadRequest{}

options := ClientReadOptions{
    PageSize: openfga.PtrInt32(10),
    ContinuationToken: openfga.PtrString("eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ=="),
    // You can rely on the store id set in the configuration or override it for this specific request
    StoreId: openfga.PtrString("01FQH7V8BEG3GPQW93KTRFR8JB"), 
}
data, err := fgaClient.Read(context.Background()).Body(requestBody).Options(options).Execute()

// In all the above situations, the response will be of the form:
// data = { Tuples: [{ Key: { User, Relation, Object }, Timestamp }, ...]}
Write (Create and Delete) Relationship Tuples

Create and/or delete relationship tuples to update the system state.

API Documentation

Transaction mode (default)

By default, write runs in a transaction mode where any invalid operation (deleting a non-existing tuple, creating an existing tuple, one of the tuples was invalid) or a server error will fail the entire operation.

body := ClientWriteRequest{
    Writes: []ClientTupleKey{ {
        User:     "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
        Relation: "viewer",
        Object:   "document:roadmap",
    }, {
        User:     "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
        Relation: "viewer",
        Object:   "document:budget",
    } },
    Deletes: []ClientTupleKeyWithoutCondition{ {
        User:     "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
        Relation: "writer",
        Object:   "document:roadmap",
    } }
}

options := ClientWriteOptions{
    // You can rely on the model id set in the configuration or override it for this specific request
    AuthorizationModelId: openfga.PtrString("01GAHCE4YVKPQEKZQHT2R89MQV"),
    // You can rely on the store id set in the configuration or override it for this specific request
    StoreId: openfga.PtrString("01FQH7V8BEG3GPQW93KTRFR8JB"), 
}
data, err := fgaClient.Write(context.Background()).Body(body).Options(options).Execute()

Convenience WriteTuples and DeleteTuples methods are also available.

Non-transaction mode

The SDK will split the writes into separate chunks and send them in separate requests. Each chunk is a transaction. By default, each chunk is set to 1, but you may override that.

body := ClientWriteRequest{
    Writes: []ClientTupleKey{ {
        User:     "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
        Relation: "viewer",
        Object:   "document:roadmap",
    }, {
        User:     "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
        Relation: "viewer",
        Object:   "document:budget",
    } },
	  Deletes: []ClientTupleKeyWithoutCondition{ {
      User:     "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
      Relation: "writer",
      Object:   "document:roadmap",
    } }
}

options := ClientWriteOptions{
    // You can rely on the model id set in the configuration or override it for this specific request
    AuthorizationModelId: openfga.PtrString("01GAHCE4YVKPQEKZQHT2R89MQV"),
    // You can rely on the store id set in the configuration or override it for this specific request
    StoreId: openfga.PtrString("01FQH7V8BEG3GPQW93KTRFR8JB"), 
    Transaction: &TransactionOptions{
        Disable: true,
        MaxParallelRequests: 5, // Maximum number of requests to issue in parallel
        MaxPerChunk: 1, // Maximum number of requests to be sent in a transaction in a particular chunk
    },
}
data, err := fgaClient.Write(context.Background()).Body(body).Options(options).Execute()

// data.Writes = [{
//   TupleKey: { User, Relation, Object },
//   Status: "CLIENT_WRITE_STATUS_SUCCESS
//   HttpResponse: ... // http response"
// }, {
//   TupleKey: { User, Relation, Object },
//   Status: "CLIENT_WRITE_STATUS_FAILURE
//   HttpResponse: ... // http response"
//   Error: ...
// }]
// data.Deletes = [{
//   TupleKey: { User, Relation, Object },
//   Status: "CLIENT_WRITE_STATUS_SUCCESS
//   HttpResponse: ... // http response"
// }]

Relationship Queries

Check

Check if a user has a particular relation with an object.

API Documentation

Provide a tuple and ask the OpenFGA API to check for a relationship

body := ClientCheckRequest{
    User:     "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
    Relation: "viewer",
    Object:   "document:roadmap",
    ContextualTuples: []ClientTupleKey{ {
        User:     "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
        Relation: "editor",
        Object:   "document:roadmap",
    } },
}

options := ClientCheckOptions{
    AuthorizationModelId: openfga.PtrString("01GAHCE4YVKPQEKZQHT2R89MQV"),
    // You can rely on the store id set in the configuration or override it for this specific request
    StoreId: openfga.PtrString("01FQH7V8BEG3GPQW93KTRFR8JB"), 
}
data, err := fgaClient.Check(context.Background()).Body(body).Options(options).Execute()

// data = {"allowed":true,"resolution":""} // in JSON

fmt.Printf("%t", data.GetAllowed()) // True

Batch Check

Run a set of checks. Batch Check will return allowed: false if it encounters an error, and will return the error in the body. If 429s or 5xxs are encountered, the underlying check will retry up to 15 times before giving up.

options := ClientBatchCheckOptions{
    // You can rely on the model id set in the configuration or override it for this specific request
    AuthorizationModelId: openfga.PtrString("01GAHCE4YVKPQEKZQHT2R89MQV"),
    // You can rely on the store id set in the configuration or override it for this specific request
    StoreId: openfga.PtrString("01FQH7V8BEG3GPQW93KTRFR8JB"), 
    MaxParallelRequests: openfga.PtrInt32(5), // Max number of requests to issue in parallel, defaults to 10
}

body := ClientBatchCheckBody{ {
    User:     "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
    Relation: "viewer",
    Object:   "document:roadmap",
    ContextualTuples: []ClientTupleKey{ {
        User:     "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
        Relation: "editor",
        Object:   "document:roadmap",
    } },
}, {
    User:     "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
    Relation: "admin",
    Object:   "document:roadmap",
    ContextualTuples: []ClientTupleKey{ {
        User:     "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
        Relation: "editor",
        Object:   "document:roadmap",
    } },
}, {
    User:     "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
    Relation: "creator",
    Object:   "document:roadmap",
}, {
    User:     "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
    Relation: "deleter",
    Object:   "document:roadmap",
} }

data, err := fgaClient.BatchCheck(context.Background()).Body(requestBody).Options(options).Execute()

/*
data = [{
  Allowed: false,
  Request: {
    User: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
    Relation: "viewer",
    Object: "document:roadmap",
    ContextualTuples: [{
      User: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
      Relation: "editor",
      Object: "document:roadmap"
    }]
  },
  HttpResponse: ...
}, {
  Allowed: false,
  Request: {
    User: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
    Relation: "admin",
    Object: "document:roadmap",
    ContextualTuples: [{
      User: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
      Relation: "editor",
      Object: "document:roadmap"
    }]
  },
  HttpResponse: ...
}, {
  Allowed: false,
  Request: {
    User: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
    Relation: "creator",
    Object: "document:roadmap",
  },
  HttpResponse: ...,
  Error: <FgaError ...>
}, {
  Allowed: true,
  Request: {
    User: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
    Relation: "deleter",
    Object: "document:roadmap",
  }},
  HttpResponse: ...,
]
*/
Expand

Expands the relationships in userset tree format.

API Documentation

options := ClientExpandOptions{
    // You can rely on the model id set in the configuration or override it for this specific request
    AuthorizationModelId: openfga.PtrString("01GAHCE4YVKPQEKZQHT2R89MQV"),
    // You can rely on the store id set in the configuration or override it for this specific request
    StoreId: openfga.PtrString("01FQH7V8BEG3GPQW93KTRFR8JB"), 
}
body := ClientExpandRequest{
    Relation: "viewer",
    Object:   "document:roadmap",
}
data, err := fgaClient.Expand(context.Background()).Body(requestBody).Options(options).Execute()

// data.Tree.Root = {"name":"document:roadmap#viewer","leaf":{"users":{"users":["user:81684243-9356-4421-8fbf-a4f8d36aa31b","user:f52a4f7a-054d-47ff-bb6e-3ac81269988f"]}}}

List Objects

List the objects of a particular type a user has access to.

API Documentation

options := ClientListObjectsOptions{
    // You can rely on the model id set in the configuration or override it for this specific request
    AuthorizationModelId: openfga.PtrString("01GAHCE4YVKPQEKZQHT2R89MQV"),
    // You can rely on the store id set in the configuration or override it for this specific request
    StoreId: openfga.PtrString("01FQH7V8BEG3GPQW93KTRFR8JB"), 
}
body := ClientListObjectsRequest{
    User:     "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
    Relation: "can_read",
    Type:     "document",
    ContextualTuples: []ClientTupleKey{ {
        User:     "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
        Relation: "editor",
        Object:   "folder:product",
    }, {
        User:     "folder:product",
        Relation: "parent",
        Object:   "document:roadmap",
    } },
}
data, err := fgaClient.ListObjects(context.Background()).
  Body(requestBody).
  Options(options).
  Execute()

// data.Objects = ["document:roadmap"]

List Relations

List the relations a user has on an object.

options := ClientListRelationsOptions{
    // You can rely on the model id set in the configuration or override it for this specific request
    AuthorizationModelId: openfga.PtrString("01GAHCE4YVKPQEKZQHT2R89MQV"),
    // You can rely on the store id set in the configuration or override it for this specific request
    StoreId: openfga.PtrString("01FQH7V8BEG3GPQW93KTRFR8JB"), 
    // Max number of requests to issue in parallel, defaults to 10
    MaxParallelRequests: openfga.PtrInt32(5),
}
body := ClientListRelationsRequest{
    User:      "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
    Object:    "document:roadmap",
    Relations: []string{"can_view", "can_edit", "can_delete", "can_rename"},
    ContextualTuples: []ClientTupleKey{ {
        User:     "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
        Relation: "editor",
        Object:   "document:roadmap",
    } },
}
data, err := fgaClient.ListRelations(context.Background()).
  Body(requestBody).
  Options(options).
  Execute()

// data.Relations = ["can_view", "can_edit"]
List Users

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

API Documentation

options := ClientListRelationsOptions{
    // You can rely on the model id set in the configuration or override it for this specific request
    AuthorizationModelId: openfga.PtrString("01GAHCE4YVKPQEKZQHT2R89MQV"),
    // You can rely on the store id set in the configuration or override it for this specific request
    StoreId: openfga.PtrString("01FQH7V8BEG3GPQW93KTRFR8JB"), 
    // Max number of requests to issue in parallel, defaults to 10
    MaxParallelRequests: openfga.PtrInt32(5),
}

// Only a single filter is allowed by the API for the time being
userFilters := []openfga.UserTypeFilter{{ Type: "user" }}
// user filters can also be of the form
// userFilters := []openfga.UserTypeFilter{{ Type: "team", Relation: openfga.PtrString("member") }}

requestBody := ClientListUsersRequest{
    Object: openfga.FgaObject{
        Type: "document",
        Id:   "roadmap",
    },
    Relation: "can_read",
    UserFilters: userFilters,
    ContextualTuples: []ClientContextualTupleKey{{
        User:     "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
        Relation: "editor",
        Object:   "folder:product",
    }, {
        User:     "folder:product",
        Relation: "parent",
        Object:   "document:roadmap",
    }},
    Context: &map[string]interface{}{"ViewCount": 100},
}
data, err := fgaClient.ListRelations(context.Background()).
  Body(requestBody).
  Options(options).
  Execute()

// response.users = [{object: {type: "user", id: "81684243-9356-4421-8fbf-a4f8d36aa31b"}}, {userset: { type: "user" }}, ...]

Assertions

Read Assertions

Read assertions for a particular authorization model.

API Documentation

options := ClientReadAssertionsOptions{
    // You can rely on the model id set in the configuration or override it for this specific request
    AuthorizationModelId: openfga.PtrString("01GAHCE4YVKPQEKZQHT2R89MQV"),
    // You can rely on the store id set in the configuration or override it for this specific request
    StoreId: openfga.PtrString("01FQH7V8BEG3GPQW93KTRFR8JB"), 
}
data, err := fgaClient.ReadAssertions(context.Background()).
  Options(options).
  Execute()

Write Assertions

Update the assertions for a particular authorization model.

API Documentation

options := ClientWriteAssertionsOptions{
    // You can rely on the model id set in the configuration or override it for this specific request
    AuthorizationModelId: openfga.PtrString("01GAHCE4YVKPQEKZQHT2R89MQV"),
    // You can rely on the store id set in the configuration or override it for this specific request
    StoreId:openfga.PtrString("01FQH7V8BEG3GPQW93KTRFR8JB"), 
}
requestBody := ClientWriteAssertionsRequest{
    ClientAssertion{
        User:        "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
        Relation:    "can_view",
        Object:      "document:roadmap",
        Expectation: true,
    },
}
data, err := fgaClient.WriteAssertions(context.Background()).
  Body(requestBody).
  Options(options).
  Execute()

Retries

If a network request fails with a 429 or 5xx error from the server, the SDK will automatically retry the request up to 15 times with a minimum wait time of 100 milliseconds between each attempt.

To customize this behavior, create an openfga.RetryParams struct and assign values to the MaxRetry and MinWaitInMs fields. MaxRetry determines the maximum number of retries (up to 15), while MinWaitInMs sets the minimum wait time between retries in milliseconds.

Apply your custom retry values by passing this struct to the ClientConfiguration struct's RetryParams parameter.

import (
	"os"

	openfga "github.com/openfga/go-sdk"
	. "github.com/openfga/go-sdk/client"
)

func main() {
	fgaClient, err := NewSdkClient(&ClientConfiguration{
		ApiUrl:               os.Getenv("FGA_API_URL"),                // required, e.g. https://api.fga.example
		StoreId:              os.Getenv("FGA_STORE_ID"),               // not needed when calling `CreateStore` or `ListStores`
		AuthorizationModelId: os.Getenv("FGA_MODEL_ID"), // optional, recommended to be set for production
		RetryParams: &openfga.RetryParams{
			MaxRetry:    3,   // retry up to 3 times on API requests
			MinWaitInMs: 250, // wait a minimum of 250 milliseconds between requests
		},
	})

	if err != nil {
		// .. Handle error
	}
}

API Endpoints

ClassMethodHTTP requestDescription
OpenFgaApiCheckPost /stores/{store_id}/checkCheck whether a user is authorized to access an object
OpenFgaApiCreateStorePost /storesCreate a store
OpenFgaApiDeleteStoreDelete /stores/{store_id}Delete a store
OpenFgaApiExpandPost /stores/{store_id}/expandExpand all relationships in userset tree format, and following userset rewrite rules. Useful to reason about and debug a certain relationship
OpenFgaApiGetStoreGet /stores/{store_id}Get a store
OpenFgaApiListObjectsPost /stores/{store_id}/list-objectsList all objects of the given type that the user has a relation with
OpenFgaApiListStoresGet /storesList all stores
OpenFgaApiListUsersPost /stores/{store_id}/list-usersList the users matching the provided filter who have a certain relation to a particular type.
OpenFgaApiReadPost /stores/{store_id}/readGet tuples from the store that matches a query, without following userset rewrite rules
OpenFgaApiReadAssertionsGet /stores/{store_id}/assertions/{authorization_model_id}Read assertions for an authorization model ID
OpenFgaApiReadAuthorizationModelGet /stores/{store_id}/authorization-models/{id}Return a particular version of an authorization model
OpenFgaApiReadAuthorizationModelsGet /stores/{store_id}/authorization-modelsReturn all the authorization models for a particular store
OpenFgaApiReadChangesGet /stores/{store_id}/changesReturn a list of all the tuple changes
OpenFgaApiWritePost /stores/{store_id}/writeAdd or delete tuples from the store
OpenFgaApiWriteAssertionsPut /stores/{store_id}/assertions/{authorization_model_id}Upsert assertions for an authorization model ID
OpenFgaApiWriteAuthorizationModelPost /stores/{store_id}/authorization-modelsCreate a new authorization model

Models

OpenTelemetry

This SDK supports producing metrics that can be consumed as part of an OpenTelemetry setup. For more information, please see the documentation

Contributing

Issues

If you have found a bug or if you have a feature request, please report them on the sdk-generator repo issues section. Please do not report security vulnerabilities on the public GitHub issue tracker.

Pull Requests

All changes made to this repo will be overwritten on the next generation, so we kindly ask that you send all pull requests related to the SDKs to the sdk-generator repo instead.

Author

OpenFGA

License

This project is licensed under the Apache-2.0 license. See the LICENSE file for more info.

The code in this repo was auto generated by OpenAPI Generator from a template based on the go template, licensed under the Apache License 2.0.

This repo bundles some code from the golang.org/x/oauth2 package. You can find the code here and corresponding BSD-3 License.

# Packages

No description provided by the author
No description provided by the author
Package oauth2 provides support for making OAuth2 authorized and authenticated HTTP requests, as specified in RFC 6749.
No description provided by the author

# Functions

CacheExpires helper function to determine remaining time before repeating a request.
DefaultRetryParams returns the default retry parameters.
No description provided by the author
No description provided by the author
NewAbortedMessageResponse instantiates a new AbortedMessageResponse object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewAbortedMessageResponseWithDefaults instantiates a new AbortedMessageResponse object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewAny instantiates a new Any object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewAnyWithDefaults instantiates a new Any object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewAPIClient creates a new API client.
NewAPIResponse returns a new APIResponse object.
NewAPIResponseWithError returns a new APIResponse object with the provided error message.
NewAssertion instantiates a new Assertion object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewAssertionTupleKey instantiates a new AssertionTupleKey object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewAssertionTupleKeyWithDefaults instantiates a new AssertionTupleKey object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewAssertionWithDefaults instantiates a new Assertion object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewAuthorizationModel instantiates a new AuthorizationModel object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewAuthorizationModelWithDefaults instantiates a new AuthorizationModel object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewCheckRequest instantiates a new CheckRequest object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewCheckRequestTupleKey instantiates a new CheckRequestTupleKey object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewCheckRequestTupleKeyWithDefaults instantiates a new CheckRequestTupleKey object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewCheckRequestWithDefaults instantiates a new CheckRequest object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewCheckResponse instantiates a new CheckResponse object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewCheckResponseWithDefaults instantiates a new CheckResponse object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewComputed instantiates a new Computed object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewComputedWithDefaults instantiates a new Computed object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewCondition instantiates a new Condition object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewConditionMetadata instantiates a new ConditionMetadata object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewConditionMetadataWithDefaults instantiates a new ConditionMetadata object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewConditionParamTypeRef instantiates a new ConditionParamTypeRef object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewConditionParamTypeRefWithDefaults instantiates a new ConditionParamTypeRef object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewConditionWithDefaults instantiates a new Condition object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewConfiguration returns a new Configuration object.
NewConsistencyPreferenceFromValue returns a pointer to a valid ConsistencyPreference for the value passed as argument, or an error if the value passed is not allowed by the enum.
NewContextualTupleKeys instantiates a new ContextualTupleKeys object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewContextualTupleKeysWithDefaults instantiates a new ContextualTupleKeys object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewCreateStoreRequest instantiates a new CreateStoreRequest object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewCreateStoreRequestWithDefaults instantiates a new CreateStoreRequest object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewCreateStoreResponse instantiates a new CreateStoreResponse object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewCreateStoreResponseWithDefaults instantiates a new CreateStoreResponse object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewDifference instantiates a new Difference object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewDifferenceWithDefaults instantiates a new Difference object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewErrorCodeFromValue returns a pointer to a valid ErrorCode for the value passed as argument, or an error if the value passed is not allowed by the enum.
NewExpandRequest instantiates a new ExpandRequest object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewExpandRequestTupleKey instantiates a new ExpandRequestTupleKey object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewExpandRequestTupleKeyWithDefaults instantiates a new ExpandRequestTupleKey object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewExpandRequestWithDefaults instantiates a new ExpandRequest object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewExpandResponse instantiates a new ExpandResponse object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewExpandResponseWithDefaults instantiates a new ExpandResponse object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewFgaObject instantiates a new FgaObject object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewFgaObjectWithDefaults instantiates a new FgaObject object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewGetStoreResponse instantiates a new GetStoreResponse object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewGetStoreResponseWithDefaults instantiates a new GetStoreResponse object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewInternalErrorCodeFromValue returns a pointer to a valid InternalErrorCode for the value passed as argument, or an error if the value passed is not allowed by the enum.
NewInternalErrorMessageResponse instantiates a new InternalErrorMessageResponse object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewInternalErrorMessageResponseWithDefaults instantiates a new InternalErrorMessageResponse object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewLeaf instantiates a new Leaf object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewLeafWithDefaults instantiates a new Leaf object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewListObjectsRequest instantiates a new ListObjectsRequest object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewListObjectsRequestWithDefaults instantiates a new ListObjectsRequest object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewListObjectsResponse instantiates a new ListObjectsResponse object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewListObjectsResponseWithDefaults instantiates a new ListObjectsResponse object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewListStoresResponse instantiates a new ListStoresResponse object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewListStoresResponseWithDefaults instantiates a new ListStoresResponse object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewListUsersRequest instantiates a new ListUsersRequest object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewListUsersRequestWithDefaults instantiates a new ListUsersRequest object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewListUsersResponse instantiates a new ListUsersResponse object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewListUsersResponseWithDefaults instantiates a new ListUsersResponse object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewMetadata instantiates a new Metadata object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewMetadataWithDefaults instantiates a new Metadata object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewNode instantiates a new Node object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewNodes instantiates a new Nodes object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewNodesWithDefaults instantiates a new Nodes object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewNodeWithDefaults instantiates a new Node object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewNotFoundErrorCodeFromValue returns a pointer to a valid NotFoundErrorCode for the value passed as argument, or an error if the value passed is not allowed by the enum.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NewNullValueFromValue returns a pointer to a valid NullValue for the value passed as argument, or an error if the value passed is not allowed by the enum.
NewObjectRelation instantiates a new ObjectRelation object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewObjectRelationWithDefaults instantiates a new ObjectRelation object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewPathUnknownErrorMessageResponse instantiates a new PathUnknownErrorMessageResponse object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewPathUnknownErrorMessageResponseWithDefaults instantiates a new PathUnknownErrorMessageResponse object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewReadAssertionsResponse instantiates a new ReadAssertionsResponse object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewReadAssertionsResponseWithDefaults instantiates a new ReadAssertionsResponse object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewReadAuthorizationModelResponse instantiates a new ReadAuthorizationModelResponse object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewReadAuthorizationModelResponseWithDefaults instantiates a new ReadAuthorizationModelResponse object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewReadAuthorizationModelsResponse instantiates a new ReadAuthorizationModelsResponse object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewReadAuthorizationModelsResponseWithDefaults instantiates a new ReadAuthorizationModelsResponse object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewReadChangesResponse instantiates a new ReadChangesResponse object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewReadChangesResponseWithDefaults instantiates a new ReadChangesResponse object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewReadRequest instantiates a new ReadRequest object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewReadRequestTupleKey instantiates a new ReadRequestTupleKey object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewReadRequestTupleKeyWithDefaults instantiates a new ReadRequestTupleKey object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewReadRequestWithDefaults instantiates a new ReadRequest object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewReadResponse instantiates a new ReadResponse object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewReadResponseWithDefaults instantiates a new ReadResponse object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewRelationMetadata instantiates a new RelationMetadata object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewRelationMetadataWithDefaults instantiates a new RelationMetadata object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewRelationReference instantiates a new RelationReference object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewRelationReferenceWithDefaults instantiates a new RelationReference object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewRelationshipCondition instantiates a new RelationshipCondition object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewRelationshipConditionWithDefaults instantiates a new RelationshipCondition object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewSourceInfo instantiates a new SourceInfo object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewSourceInfoWithDefaults instantiates a new SourceInfo object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewStatus instantiates a new Status object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewStatusWithDefaults instantiates a new Status object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewStore instantiates a new Store object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewStoreWithDefaults instantiates a new Store object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewTuple instantiates a new Tuple object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewTupleChange instantiates a new TupleChange object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewTupleChangeWithDefaults instantiates a new TupleChange object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewTupleKey instantiates a new TupleKey object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewTupleKeyWithDefaults instantiates a new TupleKey object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewTupleKeyWithoutCondition instantiates a new TupleKeyWithoutCondition object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewTupleKeyWithoutConditionWithDefaults instantiates a new TupleKeyWithoutCondition object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewTupleOperationFromValue returns a pointer to a valid TupleOperation for the value passed as argument, or an error if the value passed is not allowed by the enum.
NewTupleToUserset instantiates a new TupleToUserset object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewTupleToUsersetWithDefaults instantiates a new TupleToUserset object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewTupleWithDefaults instantiates a new Tuple object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewTypeDefinition instantiates a new TypeDefinition object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewTypeDefinitionWithDefaults instantiates a new TypeDefinition object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewTypedWildcard instantiates a new TypedWildcard object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewTypedWildcardWithDefaults instantiates a new TypedWildcard object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewTypeNameFromValue returns a pointer to a valid TypeName for the value passed as argument, or an error if the value passed is not allowed by the enum.
NewUnauthenticatedResponse instantiates a new UnauthenticatedResponse object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewUnauthenticatedResponseWithDefaults instantiates a new UnauthenticatedResponse object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewUnprocessableContentErrorCodeFromValue returns a pointer to a valid UnprocessableContentErrorCode for the value passed as argument, or an error if the value passed is not allowed by the enum.
NewUnprocessableContentMessageResponse instantiates a new UnprocessableContentMessageResponse object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewUnprocessableContentMessageResponseWithDefaults instantiates a new UnprocessableContentMessageResponse object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewUser instantiates a new User object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewUsers instantiates a new Users object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewUserset instantiates a new Userset object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewUsersets instantiates a new Usersets object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewUsersetsWithDefaults instantiates a new Usersets object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewUsersetTree instantiates a new UsersetTree object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewUsersetTreeDifference instantiates a new UsersetTreeDifference object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewUsersetTreeDifferenceWithDefaults instantiates a new UsersetTreeDifference object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewUsersetTreeTupleToUserset instantiates a new UsersetTreeTupleToUserset object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewUsersetTreeTupleToUsersetWithDefaults instantiates a new UsersetTreeTupleToUserset object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewUsersetTreeWithDefaults instantiates a new UsersetTree object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewUsersetUser instantiates a new UsersetUser object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewUsersetUserWithDefaults instantiates a new UsersetUser object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewUsersetWithDefaults instantiates a new Userset object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewUsersWithDefaults instantiates a new Users object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewUserTypeFilter instantiates a new UserTypeFilter object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewUserTypeFilterWithDefaults instantiates a new UserTypeFilter object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewUserWithDefaults instantiates a new User object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewValidationErrorMessageResponse instantiates a new ValidationErrorMessageResponse object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewValidationErrorMessageResponseWithDefaults instantiates a new ValidationErrorMessageResponse object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewWriteAssertionsRequest instantiates a new WriteAssertionsRequest object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewWriteAssertionsRequestWithDefaults instantiates a new WriteAssertionsRequest object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewWriteAuthorizationModelRequest instantiates a new WriteAuthorizationModelRequest object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewWriteAuthorizationModelRequestWithDefaults instantiates a new WriteAuthorizationModelRequest object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewWriteAuthorizationModelResponse instantiates a new WriteAuthorizationModelResponse object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewWriteAuthorizationModelResponseWithDefaults instantiates a new WriteAuthorizationModelResponse object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewWriteRequest instantiates a new WriteRequest object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewWriteRequestDeletes instantiates a new WriteRequestDeletes object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewWriteRequestDeletesWithDefaults instantiates a new WriteRequestDeletes object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewWriteRequestWithDefaults instantiates a new WriteRequest object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewWriteRequestWrites instantiates a new WriteRequestWrites object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewWriteRequestWritesWithDefaults instantiates a new WriteRequestWrites object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
PtrBool is a helper routine that returns a pointer to given boolean value.
PtrFloat32 is a helper routine that returns a pointer to given float value.
PtrFloat64 is a helper routine that returns a pointer to given float value.
PtrInt is a helper routine that returns a pointer to given integer value.
PtrInt32 is a helper routine that returns a pointer to given integer value.
PtrInt64 is a helper routine that returns a pointer to given integer value.
PtrString is a helper routine that returns a pointer to given string value.
PtrTime is helper routine that returns a pointer to given Time value.

# Constants

List of ConsistencyPreference.
List of ConsistencyPreference.
List of ConsistencyPreference.
List of ErrorCode.
List of ErrorCode.
List of ErrorCode.
List of ErrorCode.
List of ErrorCode.
List of ErrorCode.
List of ErrorCode.
List of ErrorCode.
List of ErrorCode.
List of ErrorCode.
List of ErrorCode.
List of ErrorCode.
List of ErrorCode.
List of ErrorCode.
List of ErrorCode.
List of ErrorCode.
List of ErrorCode.
List of ErrorCode.
List of ErrorCode.
List of ErrorCode.
List of ErrorCode.
List of ErrorCode.
List of ErrorCode.
List of ErrorCode.
List of ErrorCode.
List of ErrorCode.
List of ErrorCode.
List of ErrorCode.
List of ErrorCode.
List of ErrorCode.
List of ErrorCode.
List of ErrorCode.
List of ErrorCode.
List of ErrorCode.
List of ErrorCode.
List of ErrorCode.
List of ErrorCode.
List of ErrorCode.
List of ErrorCode.
List of ErrorCode.
List of ErrorCode.
List of ErrorCode.
List of ErrorCode.
List of ErrorCode.
List of ErrorCode.
List of ErrorCode.
List of ErrorCode.
List of ErrorCode.
List of InternalErrorCode.
List of InternalErrorCode.
List of InternalErrorCode.
List of InternalErrorCode.
List of InternalErrorCode.
List of InternalErrorCode.
List of InternalErrorCode.
List of InternalErrorCode.
List of InternalErrorCode.
List of InternalErrorCode.
List of InternalErrorCode.
List of NotFoundErrorCode.
List of NotFoundErrorCode.
List of NotFoundErrorCode.
List of NotFoundErrorCode.
List of NullValue.
No description provided by the author
List of TupleOperation.
List of TupleOperation.
List of TypeName.
List of TypeName.
List of TypeName.
List of TypeName.
List of TypeName.
List of TypeName.
List of TypeName.
List of TypeName.
List of TypeName.
List of TypeName.
List of TypeName.
List of TypeName.
List of UnprocessableContentErrorCode.
List of UnprocessableContentErrorCode.

# Structs

AbortedMessageResponse struct for AbortedMessageResponse.
Any struct for Any.
No description provided by the author
APIClient manages communication with the OpenFGA API v1.x In most cases there should be only one, shared, APIClient.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
APIResponse stores the API response returned by the server.
No description provided by the author
No description provided by the author
No description provided by the author
Assertion struct for Assertion.
AssertionTupleKey struct for AssertionTupleKey.
AuthorizationModel struct for AuthorizationModel.
CheckRequest struct for CheckRequest.
CheckRequestTupleKey struct for CheckRequestTupleKey.
CheckResponse struct for CheckResponse.
Computed struct for Computed.
Condition struct for Condition.
ConditionMetadata struct for ConditionMetadata.
ConditionParamTypeRef struct for ConditionParamTypeRef.
Configuration stores the configuration of the API client.
ContextualTupleKeys struct for ContextualTupleKeys.
CreateStoreRequest struct for CreateStoreRequest.
CreateStoreResponse struct for CreateStoreResponse.
Difference struct for Difference.
ErrorResponse defines the error that will be asserted by FGA API.
ExpandRequest struct for ExpandRequest.
ExpandRequestTupleKey struct for ExpandRequestTupleKey.
ExpandResponse struct for ExpandResponse.
FgaApiAuthenticationError is raised when API has errors due to invalid authentication.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
FgaObject Object represents an OpenFGA Object.
GenericOpenAPIError Provides access to the body, error and model on returned errors.
GetStoreResponse struct for GetStoreResponse.
InternalErrorMessageResponse struct for InternalErrorMessageResponse.
Leaf A leaf node contains either - a set of users (which may be individual users, or usersets referencing other relations) - a computed node, which is the result of a computed userset value in the authorization model - a tupleToUserset nodes, containing the result of expanding a tupleToUserset value in a authorization model.
ListObjectsRequest struct for ListObjectsRequest.
ListObjectsResponse struct for ListObjectsResponse.
ListStoresResponse struct for ListStoresResponse.
ListUsersRequest struct for ListUsersRequest.
ListUsersResponse struct for ListUsersResponse.
Metadata struct for Metadata.
Node struct for Node.
Nodes struct for Nodes.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
ObjectRelation struct for ObjectRelation.
PathUnknownErrorMessageResponse struct for PathUnknownErrorMessageResponse.
ReadAssertionsResponse struct for ReadAssertionsResponse.
ReadAuthorizationModelResponse struct for ReadAuthorizationModelResponse.
ReadAuthorizationModelsResponse struct for ReadAuthorizationModelsResponse.
ReadChangesResponse struct for ReadChangesResponse.
ReadRequest struct for ReadRequest.
ReadRequestTupleKey struct for ReadRequestTupleKey.
ReadResponse struct for ReadResponse.
RelationMetadata struct for RelationMetadata.
RelationReference RelationReference represents a relation of a particular object type (e.g.
RelationshipCondition struct for RelationshipCondition.
RetryParams configures configuration for retry in case of HTTP too many request.
SourceInfo struct for SourceInfo.
Status struct for Status.
Store struct for Store.
Tuple struct for Tuple.
TupleChange struct for TupleChange.
TupleKey struct for TupleKey.
TupleKeyWithoutCondition struct for TupleKeyWithoutCondition.
TupleToUserset struct for TupleToUserset.
TypeDefinition struct for TypeDefinition.
TypedWildcard Type bound public access.
UnauthenticatedResponse struct for UnauthenticatedResponse.
UnprocessableContentMessageResponse struct for UnprocessableContentMessageResponse.
User User.
Users struct for Users.
Userset struct for Userset.
Usersets struct for Usersets.
UsersetTree A UsersetTree contains the result of an Expansion.
UsersetTreeDifference struct for UsersetTreeDifference.
UsersetTreeTupleToUserset struct for UsersetTreeTupleToUserset.
UsersetUser Userset.
UserTypeFilter struct for UserTypeFilter.
ValidationErrorMessageResponse struct for ValidationErrorMessageResponse.
WriteAssertionsRequest struct for WriteAssertionsRequest.
WriteAuthorizationModelRequest struct for WriteAuthorizationModelRequest.
WriteAuthorizationModelResponse struct for WriteAuthorizationModelResponse.
WriteRequest struct for WriteRequest.
WriteRequestDeletes struct for WriteRequestDeletes.
WriteRequestWrites struct for WriteRequestWrites.

# Interfaces

No description provided by the author

# Type aliases

ConsistencyPreference - UNSPECIFIED: Default if not set.
ErrorCode the model 'ErrorCode'.
InternalErrorCode the model 'InternalErrorCode'.
NotFoundErrorCode the model 'NotFoundErrorCode'.
NullValue `NullValue` is a singleton enumeration to represent the null value for the `Value` type union.
OpenFgaApiService OpenFgaApi service.
TupleOperation the model 'TupleOperation'.
TypeName the model 'TypeName'.
UnprocessableContentErrorCode the model 'UnprocessableContentErrorCode'.