Skip to content

Commit

Permalink
release(go-sdk): v0.4.0 (#369)
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmyjames authored May 30, 2024
2 parents 346acb1 + 15b192e commit 4838603
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 9 deletions.
13 changes: 13 additions & 0 deletions config/clients/go/CHANGELOG.md.mustache
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Changelog

## v0.4.0

### [0.4.0](https://{{gitHost}}/{{gitUserId}}/{{gitRepoId}}/compare/v0.3.7...v0.4.0) (2024-05-30)
- feat!: remove store ID from API config, allow store ID override per-request (see README for additional documentation and examples)
- fix: only retry on client credential requests that are 429 or 5x

BREAKING CHANGE:

This version removes the `StoreId` from the API client configuration. Instead, the `StoreId` parameter
must now be passed to each of the API methods that require a store ID.

**If you are using `api_open_fga.go` directly, you will now need to pass the `StoreId` parameter.**

## v0.3.7

### [0.3.7](https://{{gitHost}}/{{gitUserId}}/{{gitRepoId}}/compare/v0.3.6...v0.3.7) (2024-05-08)
Expand Down
2 changes: 1 addition & 1 deletion config/clients/go/config.overrides.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"sdkId": "go",
"gitRepoId": "go-sdk",
"packageName": "openfga",
"packageVersion": "0.3.7",
"packageVersion": "0.4.0",
"packageDescription": "Go SDK for OpenFGA",
"packageDetailedDescription": "This is an autogenerated Go SDK for OpenFGA. It provides a wrapper around the [OpenFGA API definition](https://openfga.dev/api).",
"fossaComplianceNoticeId": "41c01c64-f74a-414a-9e39-7aeca87bc47b",
Expand Down
58 changes: 50 additions & 8 deletions config/clients/go/template/README_calling_api.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@ Get information about the current store.

[API Documentation]({{apiDocsUrl}}/docs/api#/Stores/GetStore)

> Requires a client initialized with a storeId

```golang
store, err := fgaClient.GetStore(context.Background()).Execute()
options := ClientGetStoreOptions{
// You can rely on the store id set in the configuration or override it for this specific request
StoreId: {{packageName}}.PtrString("01FQH7V8BEG3GPQW93KTRFR8JB"),
}
store, err := fgaClient.GetStore(context.Background()).Options(options)Execute()
if err != nil {
// handle error
}
Expand All @@ -60,10 +62,12 @@ Delete a store.

[API Documentation]({{apiDocsUrl}}/docs/api#/Stores/DeleteStore)

> Requires a client initialized with a storeId

```golang
_, err := fgaClient.DeleteStore(context.Background()).Execute()
options := ClientDeleteStoreOptions{
// You can rely on the store id set in the configuration or override it for this specific request
StoreId: {{packageName}}.PtrString("01FQH7V8BEG3GPQW93KTRFR8JB"),
}
_, err := fgaClient.DeleteStore(context.Background()).Options(options).Execute()
if err != nil {
// handle error
}
Expand All @@ -80,6 +84,8 @@ Read all authorization models in the store.
options := ClientReadAuthorizationModelsOptions{
PageSize: {{packageName}}.PtrInt32(10),
ContinuationToken: {{packageName}}.PtrString("..."),
// You can rely on the store id set in the configuration or override it for this specific request
StoreId: {{packageName}}.PtrString("01FQH7V8BEG3GPQW93KTRFR8JB"),
}
data, err := fgaClient.ReadAuthorizationModels(context.Background()).Options(options).Execute()

Expand Down Expand Up @@ -137,7 +143,11 @@ body := ClientWriteAuthorizationModelRequest{
},
}},
}
data, err := fgaClient.WriteAuthorizationModel(context.Background()).Body(body).Execute()
options := ClientWriteAuthorizationModelOptions{
// You can rely on the store id set in the configuration or override it for this specific request
StoreId: {{packageName}}.PtrString("01FQH7V8BEG3GPQW93KTRFR8JB"),
}
data, err := fgaClient.WriteAuthorizationModel(context.Background()).Options(options).Body(body).Execute()

fmt.Printf("%s", data.AuthorizationModelId) // 01GXSA8YR785C4FYS3C0RTG7B1
```
Expand All @@ -152,6 +162,8 @@ Read a particular authorization model.
options := ClientReadAuthorizationModelOptions{
// You can rely on the model id set in the configuration or override it for this specific request
AuthorizationModelId: {{packageName}}.PtrString(modelId),
// You can rely on the store id set in the configuration or override it for this specific request
StoreId: {{packageName}}.PtrString("01FQH7V8BEG3GPQW93KTRFR8JB"),
}
data, err := fgaClient.ReadAuthorizationModel(context.Background()).Options(options).Execute()

Expand All @@ -167,7 +179,13 @@ Reads the latest authorization model (note: this ignores the model id in configu
[API Documentation]({{apiDocsUrl}}#/Authorization%20Models/ReadAuthorizationModel)

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

// data.AuthorizationModel.Id = "01GXSA8YR785C4FYS3C0RTG7B1"
// data.AuthorizationModel.SchemaVersion = "1.1"
Expand All @@ -191,6 +209,8 @@ body := ClientReadChangesRequest{
options := ClientReadChangesOptions{
PageSize: {{packageName}}.PtrInt32(10),
ContinuationToken: {{packageName}}.PtrString("eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ=="),
// You can rely on the store id set in the configuration or override it for this specific request
StoreId: {{packageName}}.PtrString("01FQH7V8BEG3GPQW93KTRFR8JB"),
}
data, err := fgaClient.ReadChanges(context.Background()).Body(body).Options(options).Execute()

Expand Down Expand Up @@ -239,6 +259,8 @@ body := ClientReadRequest{}
options := ClientReadOptions{
PageSize: {{packageName}}.PtrInt32(10),
ContinuationToken: {{packageName}}.PtrString("eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ=="),
// You can rely on the store id set in the configuration or override it for this specific request
StoreId: {{packageName}}.PtrString("01FQH7V8BEG3GPQW93KTRFR8JB"),
}
data, err := fgaClient.Read(context.Background()).Body(requestBody).Options(options).Execute()

Expand Down Expand Up @@ -277,6 +299,8 @@ body := ClientWriteRequest{
options := ClientWriteOptions{
// You can rely on the model id set in the configuration or override it for this specific request
AuthorizationModelId: {{packageName}}.PtrString("01GAHCE4YVKPQEKZQHT2R89MQV"),
// You can rely on the store id set in the configuration or override it for this specific request
StoreId: {{packageName}}.PtrString("01FQH7V8BEG3GPQW93KTRFR8JB"),
}
data, err := fgaClient.Write(context.Background()).Body(body).Options(options).Execute()
```
Expand Down Expand Up @@ -308,6 +332,8 @@ body := ClientWriteRequest{
options := ClientWriteOptions{
// You can rely on the model id set in the configuration or override it for this specific request
AuthorizationModelId: {{packageName}}.PtrString("01GAHCE4YVKPQEKZQHT2R89MQV"),
// You can rely on the store id set in the configuration or override it for this specific request
StoreId: {{packageName}}.PtrString("01FQH7V8BEG3GPQW93KTRFR8JB"),
Transaction: &TransactionOptions{
Disable: true,
MaxParallelRequests: 5, // Maximum number of requests to issue in parallel
Expand Down Expand Up @@ -357,6 +383,8 @@ body := ClientCheckRequest{

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

Expand All @@ -375,6 +403,8 @@ If 429s or 5xxs are encountered, the underlying check will retry up to 15 times
options := ClientBatchCheckOptions{
// You can rely on the model id set in the configuration or override it for this specific request
AuthorizationModelId: {{packageName}}.PtrString("01GAHCE4YVKPQEKZQHT2R89MQV"),
// You can rely on the store id set in the configuration or override it for this specific request
StoreId: {{packageName}}.PtrString("01FQH7V8BEG3GPQW93KTRFR8JB"),
MaxParallelRequests: {{packageName}}.PtrInt32(5), // Max number of requests to issue in parallel, defaults to 10
}

Expand Down Expand Up @@ -466,6 +496,8 @@ Expands the relationships in userset tree format.
options := ClientExpandOptions{
// You can rely on the model id set in the configuration or override it for this specific request
AuthorizationModelId: {{packageName}}.PtrString("01GAHCE4YVKPQEKZQHT2R89MQV"),
// You can rely on the store id set in the configuration or override it for this specific request
StoreId: {{packageName}}.PtrString("01FQH7V8BEG3GPQW93KTRFR8JB"),
}
body := ClientExpandRequest{
Relation: "viewer",
Expand All @@ -486,6 +518,8 @@ List the objects of a particular type a user has access to.
options := ClientListObjectsOptions{
// You can rely on the model id set in the configuration or override it for this specific request
AuthorizationModelId: {{packageName}}.PtrString("01GAHCE4YVKPQEKZQHT2R89MQV"),
// You can rely on the store id set in the configuration or override it for this specific request
StoreId: {{packageName}}.PtrString("01FQH7V8BEG3GPQW93KTRFR8JB"),
}
body := ClientListObjectsRequest{
User: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
Expand Down Expand Up @@ -517,6 +551,8 @@ 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: {{packageName}}.PtrString("01GAHCE4YVKPQEKZQHT2R89MQV"),
// You can rely on the store id set in the configuration or override it for this specific request
StoreId: {{packageName}}.PtrString("01FQH7V8BEG3GPQW93KTRFR8JB"),
// Max number of requests to issue in parallel, defaults to 10
MaxParallelRequests: openfga.PtrInt32(5),
}
Expand Down Expand Up @@ -548,6 +584,8 @@ List the users who have a certain relation to a particular type.
options := ClientListRelationsOptions{
// You can rely on the model id set in the configuration or override it for this specific request
AuthorizationModelId: {{packageName}}.PtrString("01GAHCE4YVKPQEKZQHT2R89MQV"),
// You can rely on the store id set in the configuration or override it for this specific request
StoreId: {{packageName}}.PtrString("01FQH7V8BEG3GPQW93KTRFR8JB"),
// Max number of requests to issue in parallel, defaults to 10
MaxParallelRequests: openfga.PtrInt32(5),
}
Expand Down Expand Up @@ -598,6 +636,8 @@ Read assertions for a particular authorization model.
options := ClientReadAssertionsOptions{
// You can rely on the model id set in the configuration or override it for this specific request
AuthorizationModelId: {{packageName}}.PtrString("01GAHCE4YVKPQEKZQHT2R89MQV"),
// You can rely on the store id set in the configuration or override it for this specific request
StoreId: {{packageName}}.PtrString("01FQH7V8BEG3GPQW93KTRFR8JB"),
}
data, err := fgaClient.ReadAssertions(context.Background()).
Options(options).
Expand All @@ -614,6 +654,8 @@ Update the assertions for a particular authorization model.
options := ClientWriteAssertionsOptions{
// You can rely on the model id set in the configuration or override it for this specific request
AuthorizationModelId: {{packageName}}.PtrString("01GAHCE4YVKPQEKZQHT2R89MQV"),
// You can rely on the store id set in the configuration or override it for this specific request
StoreId:{{packageName}}.PtrString("01FQH7V8BEG3GPQW93KTRFR8JB"),
}
requestBody := ClientWriteAssertionsRequest{
ClientAssertion{
Expand Down

0 comments on commit 4838603

Please sign in to comment.