Skip to content

Commit

Permalink
release(dotnet-sdk): v0.3.0 with conditions support (#259)
Browse files Browse the repository at this point in the history
  • Loading branch information
rhamzeh authored Dec 20, 2023
2 parents 27776f3 + dcc9005 commit d51e8f3
Show file tree
Hide file tree
Showing 38 changed files with 1,129 additions and 327 deletions.
11 changes: 1 addition & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Main config
OPENFGA_DOCKER_TAG = v1.4.0-rc1
OPENFGA_DOCKER_TAG = v1.4.0
OPEN_API_URL = https://raw.githubusercontent.com/openfga/api/main/docs/openapiv2/apidocs.swagger.json
OPENAPI_GENERATOR_CLI_DOCKER_TAG = v6.4.0
NODE_DOCKER_TAG = 20-alpine
Expand All @@ -14,12 +14,9 @@ CONFIG_DIR = ${PWD}/config
CLIENTS_OUTPUT_DIR = ${PWD}/clients
DOCS_CACHE_DIR = ${PWD}/docs/openapi
TMP_DIR = $(shell mktemp -d "$${TMPDIR:-/tmp}/tmp.XXXXX")
dotnet_package_version = $(shell cat ./clients/fga-dotnet-sdk/VERSION.txt)
CURRENT_UID := $(shell id -u)
CURRENT_GID := $(shell id -g)

dotnet_publish_api_key=

all: test-all-clients

## Refresh Docker Images
Expand All @@ -33,11 +30,6 @@ pull-docker-images:
docker pull busybox:${BUSYBOX_DOCKER_TAG}
docker pull gradle:${GRADLE_DOCKER_TAG}

## Publishing
publish-client-dotnet: build-client-dotnet
## See: https://docs.microsoft.com/en-us/nuget/quickstart/create-and-publish-a-package-using-the-dotnet-cli
make run-in-docker sdk_language=dotnet image=mcr.microsoft.com/dotnet/sdk:${DOTNET_DOCKER_TAG} command="/bin/sh -c 'dotnet nuget push src/OpenFga.Sdk/bin/Release/OpenFga.Sdk.${dotnet_package_version}.nupkg --api-key ${dotnet_publish_api_key} --source https://api.nuget.org/v3/index.json'"

## Building and Testing
.PHONY: test
test: test-all-clients
Expand Down Expand Up @@ -100,7 +92,6 @@ test-client-dotnet: build-client-dotnet
build-client-dotnet:
rm -rf ${CLIENTS_OUTPUT_DIR}/fga-dotnet-sdk/src/OpenFga.Sdk.Test
make build-client sdk_language=dotnet tmpdir=${TMP_DIR}
make run-in-docker sdk_language=dotnet image=busybox:${BUSYBOX_DOCKER_TAG} command="/bin/sh -c 'patch -p1 /module/src/OpenFga.Sdk/Api/OpenFgaApi.cs /config/clients/dotnet/patches/add-missing-first-param.patch'"

make run-in-docker sdk_language=dotnet image=mcr.microsoft.com/dotnet/sdk:${DOTNET_DOCKER_TAG} command="/bin/sh -c 'dotnet build --configuration Release'"
# For some reason the first round of formatting fails with an error - running it again produces the correct result
Expand Down
55 changes: 55 additions & 0 deletions config/clients/dotnet/CHANGELOG.md.mustache
Original file line number Diff line number Diff line change
@@ -1,5 +1,60 @@
# Changelog

## v0.3.0

### [0.3.0](https://{{gitHost}}/{{gitUserId}}/{{gitRepoId}}/compare/v0.2.5...v0.3.0) (2023-12-20)
- feat!: initial support for conditions
- feat!: allow overriding storeId per request (#33)
- feat: support specifying a port and path for the API (You can now set the `ApiUrl` to something like: `https://api.fga.exampleL8080/some_path`)
- feat: validate that store id and auth model id in ulid format (#23)
- fix: exception when using the same configuration with multiple clients (#26)
- fix: `OpenFgaClient.ReadLatestAuthorizationModel` can now return a null if no model has ever been created in that store
- fix: `OpenFgaClient.Read` and `OpenFgaClient.ReadChanges` now allow a null body
- chore!: use latest API interfaces
- chore: dependency updates

BREAKING CHANGES:
Note: This release comes with substantial breaking changes, especially to the interfaces due to the protobuf changes in the last release.

While the http interfaces did not break (you can still use `v0.2.5` SDK with a `v1.3.8+` server),
the grpc interface did and this caused a few changes in the interfaces of the SDK.

If you are using `OpenFgaClient`, the changes required should be smaller, if you are using `OpenFgaApi` a bit more changes will be needed.

You will have to modify some parts of your code, but we hope this will be to the better as a lot of the parameters are now correctly marked as required,
and so the Pointer-to-String conversion is no longer needed.

Some of the changes to expect:

- When initializing a client, please use `ApiUrl`. The separate `ApiScheme` and `ApiHost` fields have been deprecated
```csharp
var configuration = new ClientConfiguration() {
ApiUrl = Environment.GetEnvironmentVariable("FGA_API_URL"), // required, e.g. https://api.fga.example
StoreId = Environment.GetEnvironmentVariable("FGA_STORE_ID"), // not needed when calling `CreateStore` or `ListStores`
AuthorizationModelId = Environment.GetEnvironmentVariable("FGA_AUTHORIZATION_MODEL_ID"), // Optional, can be overridden per request
};
var fgaClient = new OpenFgaClient(configuration);
```
- `OpenFgaApi` now requires `storeId` as first param when needed
- `Configuration` no longer accepts `storeId` (`ClientConfiguration` is not affected)
- The following request interfaces changed:
- `CheckRequest`: the `TupleKey` field is now of interface `CheckRequestTupleKey`, you can also now pass in `Context`
- `ExpandRequest`: the `TupleKey` field is now of interface `ExpandRequestTupleKey`
- `ReadRequest`: the `TupleKey` field is now of interface `ReadRequestTupleKey`
- `WriteRequest`: now takes `WriteRequestWrites` and `WriteRequestDeletes`, the latter of which accepts `TupleKeyWithoutCondition`
- And more
- The following interfaces had fields that were pointers are are now the direct value:
- `CreateStoreResponse`
- `GetStoreResponse`
- `ListStoresResponse`
- `ListObjectsResponse`
- `ReadChangesResponse`
- `ReadResponse`
- `AuthorizationModel`
- And more

Take a look at https://{{gitHost}}/{{gitUserId}}/{{gitRepoId}}/commit/fa43463ded102df3f660bae6d741e1a8c1dea090 for more model changes.

## v0.2.5

### [0.2.5](https://{{gitHost}}/{{gitUserId}}/{{gitRepoId}}/compare/v0.2.4...v0.2.5) (2023-12-01)
Expand Down
18 changes: 17 additions & 1 deletion config/clients/dotnet/config.overrides.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"packageGuid": "b8d9e3e9-0156-4948-9de7-5e0d3f9c4d9e",
"testPackageGuid": "d119dfae-509a-4eba-a973-645b739356fc",
"packageName": "OpenFga.Sdk",
"packageVersion": "0.2.5",
"packageVersion": "0.3.0",
"licenseUrl": "https://github.com/openfga/dotnet-sdk/blob/main/LICENSE",
"fossaComplianceNoticeId": "f8ac2ec4-84fc-44f4-a617-5800cd3d180e",
"termsOfService": "",
Expand Down Expand Up @@ -162,10 +162,18 @@
"destinationFilename": "src/OpenFga.Sdk/Client/Model/ClientRequestOptsWithAuthZModelId.cs",
"templateType": "SupportingFiles"
},
"Client/Model/ClientRequestOptsWithStoreId.mustache": {
"destinationFilename": "src/OpenFga.Sdk/Client/Model/ClientRequestOptsWithStoreId.cs",
"templateType": "SupportingFiles"
},
"Client/Model/ClientTupleKey.mustache": {
"destinationFilename": "src/OpenFga.Sdk/Client/Model/ClientTupleKey.cs",
"templateType": "SupportingFiles"
},
"Client/Model/ClientTupleKeyWithoutCondition.mustache": {
"destinationFilename": "src/OpenFga.Sdk/Client/Model/ClientTupleKeyWithoutCondition.cs",
"templateType": "SupportingFiles"
},
"Client/Model/ClientWriteAssertionsOptions.mustache": {
"destinationFilename": "src/OpenFga.Sdk/Client/Model/ClientWriteAssertionsOptions.cs",
"templateType": "SupportingFiles"
Expand Down Expand Up @@ -198,6 +206,10 @@
"destinationFilename": "src/OpenFga.Sdk/Client/Model/RetryParams.cs",
"templateType": "SupportingFiles"
},
"Client/Model/StoreIdOptions.mustache": {
"destinationFilename": "src/OpenFga.Sdk/Client/Model/StoreIdOptions.cs",
"templateType": "SupportingFiles"
},
"Configuration_Configuration.mustache": {
"destinationFilename": "src/OpenFga.Sdk/Configuration/Configuration.cs",
"templateType": "SupportingFiles"
Expand Down Expand Up @@ -266,6 +278,10 @@
"destinationFilename": ".fossa.yml",
"templateType": "SupportingFiles"
},
"example/Makefile": {},
"example/README.md": {},
"example/Example1/Example1.cs": {},
"example/Example1/Example1.csproj": {},
"assets/FGAIcon.png": {},
".editorconfig": {}
}
Expand Down
27 changes: 0 additions & 27 deletions config/clients/dotnet/patches/add-missing-first-param.patch

This file was deleted.

Loading

0 comments on commit d51e8f3

Please sign in to comment.