Skip to content

Commit

Permalink
release: v0.2.0 with updated ListObjects response
Browse files Browse the repository at this point in the history
- Support for OpenFGA v0.3.0
- ListObjects response now includes object type [BREAKING]
- Fix models
- Update dependencies
  • Loading branch information
rhamzeh committed Dec 15, 2022
1 parent f264ab9 commit 3e5f0f2
Show file tree
Hide file tree
Showing 145 changed files with 203 additions and 151 deletions.
Empty file modified .editorconfig
100644 → 100755
Empty file.
Empty file modified .fossa.yml
100644 → 100755
Empty file.
Empty file modified .openapi-generator/FILES
100644 → 100755
Empty file.
Empty file modified .openapi-generator/VERSION
100644 → 100755
Empty file.
16 changes: 16 additions & 0 deletions CHANGELOG.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Changelog

## v0.2.0

### [0.2.0](https://github.com/openfga/dotnet-sdk/compare/v0.1.2...v0.2.0) (2022-12-14)

Updated to include support for [OpenFGA 0.3.0](https://github.com/openfga/openfga/releases/tag/v0.3.0)

Changes:
- [BREAKING] feat(list-objects)!: response has been changed to include the object type
e.g. response that was `{"object_ids":["roadmap"]}`, will now be `{"objects":["document:roadmap"]}`

Fixes:
- fix(models): update interfaces that had incorrectly optional fields to make them required

Chore:
- chore(deps): update dev dependencies

## v0.1.2

### [0.1.2](https://github.com/openfga/dotnet-sdk/compare/v0.1.1...v0.1.2) (2022-11-15)
Expand Down
Empty file modified CONTRIBUTING.md
100644 → 100755
Empty file.
Empty file modified LICENSE
100644 → 100755
Empty file.
Empty file modified NOTICE.txt
100644 → 100755
Empty file.
Empty file modified OpenFga.Sdk.sln
100644 → 100755
Empty file.
71 changes: 38 additions & 33 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -226,16 +226,20 @@ var store = await openFgaApi.DeleteStore();
> Learn more about [the OpenFGA configuration language](https://openfga.dev/docs/configuration-language).
```csharp
var relations = new Dictionary<string, Userset>()
var documentRelations = new Dictionary<string, Userset>()
{
{"writer", new Userset(_this: new object())},
{
"reader",
"viewer",
new Userset(union: new Usersets(new List<Userset>()
{new(new object(), new ObjectRelation("", "writer"))}))
}
};
var body = new WriteAuthorizationModelRequest(new List<TypeDefinition>() {new("repo", relations)});
var userRelations = new Dictionary<string, Userset>()
{
};

var body = new WriteAuthorizationModelRequest(new List<TypeDefinition>() {new("document", documentRelations), new("user", userRelations)});
var response = await openFgaApi.WriteAuthorizationModel(body);

// response.AuthorizationModelId = 1uHxCSuTP0VKPYSnkq1pbb1jeZw
Expand All @@ -250,7 +254,7 @@ string authorizationModelId = "1uHxCSuTP0VKPYSnkq1pbb1jeZw"; // Assuming `1uHxCS
var response = await openFgaApi.ReadAuthorizationModel(authorizationModelId);

// response.AuthorizationModel.Id = "1uHxCSuTP0VKPYSnkq1pbb1jeZw"
// response.AuthorizationModel.TypeDefinitions = [{ "type": "repo", "relations": { ... } }]
// response.AuthorizationModel.TypeDefinitions = [{ "type": "document", "relations": { ... } }, { "type": "user", "relations": { ... }}]
```

#### Read Authorization Model IDs
Expand All @@ -269,7 +273,7 @@ var response = await openFgaApi.ReadAuthorizationModels();

```csharp
var body =
new CheckRequest(tupleKey: new TupleKey("document:project-roadmap", "editor", "user:81684243-9356-4421-8fbf-a4f8d36aa31b"));
new CheckRequest{tupleKey: new TupleKey("document:roadmap", "viewer", "user:81684243-9356-4421-8fbf-a4f8d36aa31b"), AuthorizationModelId = "1uHxCSuTP0VKPYSnkq1pbb1jeZw"};
var response = await openFgaApi.Check(body);
// response.Allowed = true
```
Expand All @@ -279,8 +283,8 @@ var response = await openFgaApi.Check(body);
[API Documentation](https://openfga.dev/api/service#/Relationship%20Tuples/Write)

```csharp
var body = new WriteRequest(new TupleKeys(new List<TupleKey>
{new("document:project-roadmap", "editor", "user:81684243-9356-4421-8fbf-a4f8d36aa31b")}));
var body = new WriteRequest{Writes = new TupleKeys(new List<TupleKey>
{new("document:roadmap", "viewer", "user:81684243-9356-4421-8fbf-a4f8d36aa31b")}), AuthorizationModelId = "1uHxCSuTP0VKPYSnkq1pbb1jeZw"};
var response = await openFgaApi.Write(body);
```

Expand All @@ -289,8 +293,8 @@ var response = await openFgaApi.Write(body);
[API Documentation](https://openfga.dev/api/service#/Relationship%20Tuples/Write)

```csharp
var body = new WriteRequest(new TupleKeys(new List<TupleKey> { }),
new TupleKeys(new List<TupleKey> {new("document:project-roadmap", "editor", "user:81684243-9356-4421-8fbf-a4f8d36aa31b")}));
var body = new WriteRequest{Deletes = new TupleKeys(new List<TupleKey>
{new("document:roadmap", "viewer", "user:81684243-9356-4421-8fbf-a4f8d36aa31b")}), AuthorizationModelId = "1uHxCSuTP0VKPYSnkq1pbb1jeZw"};
var response = await openFgaApi.Write(body);
```

Expand All @@ -299,39 +303,41 @@ var response = await openFgaApi.Write(body);
[API Documentation](https://openfga.dev/api/service#/Relationship%20Queries/Expand)

```csharp
var body = new ExpandRequest(new TupleKey("document:project-roadmap", "editor"));
var body = new ExpandRequest{TupleKey = new TupleKey("document:roadmap", "viewer"), AuthorizationModelId = "1uHxCSuTP0VKPYSnkq1pbb1jeZw"};
var response = await openFgaApi.Expand(body);

// response.Tree.Root = {"name":"workspace:675bcac4-ad38-4fb1-a19a-94a5648c91d6#admin","leaf":{"users":{"users":["user:81684243-9356-4421-8fbf-a4f8d36aa31b","user:f52a4f7a-054d-47ff-bb6e-3ac81269988f"]}}}
// response.Tree.Root = {"name":"document:roadmap#viewer","leaf":{"users":{"users":["user:81684243-9356-4421-8fbf-a4f8d36aa31b","user:f52a4f7a-054d-47ff-bb6e-3ac81269988f"]}}}
```

#### Read Changes

[API Documentation](https://openfga.dev/api/service#/Relationship%20Tuples/Read)

```csharp
// Find if a relationship tuple stating that a certain user is an admin on a certain workspace
// Find if a relationship tuple stating that a certain user is a viewer of a certain document
var body = new ReadRequest(new TupleKey(
_object: "workspace:675bcac4-ad38-4fb1-a19a-94a5648c91d6",
relation: "admin",
user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b"));
_object: "document:roadmap",
relation: "viewer",
user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b");

// Find all relationship tuples where a certain user has a relationship as any relation to a certain workspace
// Find all relationship tuples where a certain user has a relationship as any relation to a certain document
var body = new ReadRequest(new TupleKey(
_object: "workspace:675bcac4-ad38-4fb1-a19a-94a5648c91d6",
_object: "document:roadmap",
user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b"));

// Find all relationship tuples where a certain user is an admin on any workspace
// Find all relationship tuples where a certain user is a viewer of any document
var body = new ReadRequest(new TupleKey(
_object: "workspace:",
relation: "admin",
_object: "document:",
relation: "viewer",
user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b"));

// Find all relationship tuples where any user has a relationship as any relation with a particular workspace
// Find all relationship tuples where any user has a relationship as any relation with a particular document
var body = new ReadRequest(new TupleKey(
_object: "workspace:675bcac4-ad38-4fb1-a19a-94a5648c91d6"));
_object: "document:roadmap"));

// Read all stored relationship tuples
body := ReadRequest()

var body = new ReadRequest(new TupleKey("document:project-roadmap", "editor", "user:81684243-9356-4421-8fbf-a4f8d36aa31b"));
var response = await openFgaApi.Read(body);

// In all the above situations, the response will be of the form:
Expand All @@ -343,16 +349,16 @@ var response = await openFgaApi.Read(body);
[API Documentation](https://openfga.dev/api/service#/Relationship%20Tuples/ReadChanges)
```csharp
var type = 'workspace';
var type = 'document';
var pageSize = 25;
var continuationToken = 'eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ==';

var response = await openFgaApi.ReadChanges(type, pageSize, continuationToken);

// response.continuation_token = ...
// response.changes = [
// { tuple_key: { user, relation, object }, operation: "write", timestamp: ... },
// { tuple_key: { user, relation, object }, operation: "delete", timestamp: ... }
// { tuple_key: { user, relation, object }, operation: "writer", timestamp: ... },
// { tuple_key: { user, relation, object }, operation: "viewer", timestamp: ... }
// ]
```

Expand All @@ -362,20 +368,19 @@ var response = await openFgaApi.ReadChanges(type, pageSize, continuationToken);
```csharp
var body = new ListObjectsRequest{
AuthorizationModelId = "01GAHCE4YVKPQEKZQHT2R89MQV",
User = "anne",
Relation = "can_read",
AuthorizationModelId = "1uHxCSuTP0VKPYSnkq1pbb1jeZw",
User = "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
Relation = "viewer",
Type = "document",
ContextualTuples = new ContextualTupleKeys() {
TupleKeys = new List<TupleKey> {
new("folder:product", "editor", "user:81684243-9356-4421-8fbf-a4f8d36aa31b"),
new("document:roadmap", "parent", "folder:product")
new("document:budget", "writer", "user:81684243-9356-4421-8fbf-a4f8d36aa31b")
}
}
};
var response = await openFgaApi.ListObjects(body);

// response.ObjectIds = ["roadmap"]
// response.Objects = ["document:roadmap"]
```


Expand All @@ -389,7 +394,7 @@ var response = await openFgaApi.ListObjects(body);
| [**Expand**](docs/OpenFgaApi.md#expand) | **POST** /stores/{store_id}/expand | Expand all relationships in userset tree format, and following userset rewrite rules. Useful to reason about and debug a certain relationship |
| [**GetStore**](docs/OpenFgaApi.md#getstore) | **GET** /stores/{store_id} | Get a store |
| [**ListObjects**](docs/OpenFgaApi.md#listobjects) | **POST** /stores/{store_id}/list-objects | [EXPERIMENTAL] Get all object ids of the given type that the user has a relation with |
| [**ListStores**](docs/OpenFgaApi.md#liststores) | **GET** /stores | Get all stores |
| [**ListStores**](docs/OpenFgaApi.md#liststores) | **GET** /stores | List all stores |
| [**Read**](docs/OpenFgaApi.md#read) | **POST** /stores/{store_id}/read | Get tuples from the store that matches a query, without following userset rewrite rules |
| [**ReadAssertions**](docs/OpenFgaApi.md#readassertions) | **GET** /stores/{store_id}/assertions/{authorization_model_id} | Read assertions for an authorization model ID |
| [**ReadAuthorizationModel**](docs/OpenFgaApi.md#readauthorizationmodel) | **GET** /stores/{store_id}/authorization-models/{id} | Return a particular version of an authorization model |
Expand Down
Empty file modified assets/FGAIcon.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified docs/Any.md
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion docs/Assertion.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**TupleKey** | [**TupleKey**](TupleKey.md) | | [optional]
**TupleKey** | [**TupleKey**](TupleKey.md) | |
**Expectation** | **bool** | |

[[Back to Model list]](../README.md#models) [[Back to API list]](../README.md#api-endpoints) [[Back to README]](../README.md)
Expand Down
Empty file modified docs/AuthorizationModel.md
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion docs/CheckRequest.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**TupleKey** | [**TupleKey**](TupleKey.md) | | [optional]
**TupleKey** | [**TupleKey**](TupleKey.md) | |
**ContextualTuples** | [**ContextualTupleKeys**](ContextualTupleKeys.md) | | [optional]
**AuthorizationModelId** | **string** | | [optional]
**Trace** | **bool** | Defaults to false. Making it true has performance implications. | [optional] [readonly]
Expand Down
Empty file modified docs/CheckResponse.md
100644 → 100755
Empty file.
Empty file modified docs/Computed.md
100644 → 100755
Empty file.
Empty file modified docs/ContextualTupleKeys.md
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion docs/CreateStoreRequest.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**Name** | **string** | | [optional]
**Name** | **string** | |

[[Back to Model list]](../README.md#models) [[Back to API list]](../README.md#api-endpoints) [[Back to README]](../README.md)

Empty file modified docs/CreateStoreResponse.md
100644 → 100755
Empty file.
4 changes: 2 additions & 2 deletions docs/Difference.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**Base** | [**Userset**](Userset.md) | | [optional]
**Subtract** | [**Userset**](Userset.md) | | [optional]
**Base** | [**Userset**](Userset.md) | |
**Subtract** | [**Userset**](Userset.md) | |

[[Back to Model list]](../README.md#models) [[Back to API list]](../README.md#api-endpoints) [[Back to README]](../README.md)

Empty file modified docs/ErrorCode.md
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion docs/ExpandRequest.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**TupleKey** | [**TupleKey**](TupleKey.md) | | [optional]
**TupleKey** | [**TupleKey**](TupleKey.md) | |
**AuthorizationModelId** | **string** | | [optional]

[[Back to Model list]](../README.md#models) [[Back to API list]](../README.md#api-endpoints) [[Back to README]](../README.md)
Expand Down
Empty file modified docs/ExpandResponse.md
100644 → 100755
Empty file.
Empty file modified docs/GetStoreResponse.md
100644 → 100755
Empty file.
Empty file modified docs/InternalErrorCode.md
100644 → 100755
Empty file.
Empty file modified docs/InternalErrorMessageResponse.md
100644 → 100755
Empty file.
Empty file modified docs/Leaf.md
100644 → 100755
Empty file.
6 changes: 3 additions & 3 deletions docs/ListObjectsRequest.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**AuthorizationModelId** | **string** | | [optional]
**Type** | **string** | | [optional]
**Relation** | **string** | | [optional]
**User** | **string** | | [optional]
**Type** | **string** | |
**Relation** | **string** | |
**User** | **string** | |
**ContextualTuples** | [**ContextualTupleKeys**](ContextualTupleKeys.md) | | [optional]

[[Back to Model list]](../README.md#models) [[Back to API list]](../README.md#api-endpoints) [[Back to README]](../README.md)
Expand Down
2 changes: 1 addition & 1 deletion docs/ListObjectsResponse.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**ObjectIds** | **List&lt;string&gt;** | | [optional]
**Objects** | **List&lt;string&gt;** | | [optional]

[[Back to Model list]](../README.md#models) [[Back to API list]](../README.md#api-endpoints) [[Back to README]](../README.md)

Empty file modified docs/ListStoresResponse.md
100644 → 100755
Empty file.
Empty file modified docs/Metadata.md
100644 → 100755
Empty file.
Empty file modified docs/Node.md
100644 → 100755
Empty file.
Empty file modified docs/Nodes.md
100644 → 100755
Empty file.
Empty file modified docs/NotFoundErrorCode.md
100644 → 100755
Empty file.
Empty file modified docs/ObjectRelation.md
100644 → 100755
Empty file.
Loading

0 comments on commit 3e5f0f2

Please sign in to comment.