Skip to content

Commit 3b7f094

Browse files
authored
Removing excluded users from ListUsers response (#108)
Initial commit of removing excluded users
1 parent 97c03bc commit 3b7f094

File tree

9 files changed

+12
-312
lines changed

9 files changed

+12
-312
lines changed

.openapi-generator/FILES

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ docs/Node.md
5757
docs/Nodes.md
5858
docs/NotFoundErrorCode.md
5959
docs/NullValue.md
60-
docs/ObjectOrUserset.md
6160
docs/ObjectRelation.md
6261
docs/OpenFgaApi.md
6362
docs/PathUnknownErrorMessageResponse.md
@@ -147,7 +146,6 @@ model_node.go
147146
model_nodes.go
148147
model_not_found_error_code.go
149148
model_null_value.go
150-
model_object_or_userset.go
151149
model_object_relation.go
152150
model_path_unknown_error_message_response.go
153151
model_read_assertions_response.go

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ userFilters := []openfga.UserTypeFilter{{ Type: "user" }}
823823
// userFilters := []openfga.UserTypeFilter{{ Type: "team", Relation: openfga.PtrString("member") }}
824824

825825
requestBody := ClientListUsersRequest{
826-
Object: openfga.Object{
826+
Object: openfga.FgaObject{
827827
Type: "document",
828828
Id: "roadmap",
829829
},
@@ -846,7 +846,6 @@ data, err := fgaClient.ListRelations(context.Background()).
846846
Execute()
847847

848848
// response.users = [{object: {type: "user", id: "81684243-9356-4421-8fbf-a4f8d36aa31b"}}, {userset: { type: "user" }}, ...]
849-
// response.excluded_users = [ {object: {type: "user", id: "4a455e27-d15a-4434-82e0-136f9c2aa4cf"}}, ... ]
850849
```
851850

852851
### Assertions
@@ -990,7 +989,6 @@ Class | Method | HTTP request | Description
990989
- [Nodes](docs/Nodes.md)
991990
- [NotFoundErrorCode](docs/NotFoundErrorCode.md)
992991
- [NullValue](docs/NullValue.md)
993-
- [ObjectOrUserset](docs/ObjectOrUserset.md)
994992
- [ObjectRelation](docs/ObjectRelation.md)
995993
- [PathUnknownErrorMessageResponse](docs/PathUnknownErrorMessageResponse.md)
996994
- [ReadAssertionsResponse](docs/ReadAssertionsResponse.md)

api_open_fga.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,9 @@ type OpenFgaApi interface {
304304
You may also specify `contextual_tuples` that will be treated as regular tuples. Each of these tuples may have an associated `condition`.
305305
You may also provide a `context` object that will be used to evaluate the conditioned tuples in the system. It is strongly recommended to provide a value for all the input parameters of all the conditions, to ensure that all tuples be evaluated correctly.
306306
The response will contain the related users in an array in the "users" field of the response. These results may include specific objects, usersets
307-
or type-bound public access. Each of these types of results is encoded in its own type and not represented as a string.In certain cases of negation via the `but not` operator, some results are marked as excluded from the main set of results. These exclusions
308-
are returned in the `excluded_users` property and should be handled appropriately at the point of implementation.The number of users in the response array will be limited by the execution timeout specified in the flag OPENFGA_LIST_USERS_DEADLINE and by the upper bound specified in the flag OPENFGA_LIST_USERS_MAX_RESULTS, whichever is hit first.
307+
or type-bound public access. Each of these types of results is encoded in its own type and not represented as a string.In cases where a type-bound public acces result is returned (e.g. `user:*`), it cannot be inferred that all subjects
308+
of that type have a relation to the object; it is possible that negations exist and checks should still be queried
309+
on individual subjects to ensure access to that document.The number of users in the response array will be limited by the execution timeout specified in the flag OPENFGA_LIST_USERS_DEADLINE and by the upper bound specified in the flag OPENFGA_LIST_USERS_MAX_RESULTS, whichever is hit first.
309310
The returned users will not be sorted, and therefore two identical calls may yield different sets of users.
310311
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
311312
* @param storeId
@@ -2708,8 +2709,9 @@ An `authorization_model_id` may be specified in the body. If it is not specified
27082709
You may also specify `contextual_tuples` that will be treated as regular tuples. Each of these tuples may have an associated `condition`.
27092710
You may also provide a `context` object that will be used to evaluate the conditioned tuples in the system. It is strongly recommended to provide a value for all the input parameters of all the conditions, to ensure that all tuples be evaluated correctly.
27102711
The response will contain the related users in an array in the "users" field of the response. These results may include specific objects, usersets
2711-
or type-bound public access. Each of these types of results is encoded in its own type and not represented as a string.In certain cases of negation via the `but not` operator, some results are marked as excluded from the main set of results. These exclusions
2712-
are returned in the `excluded_users` property and should be handled appropriately at the point of implementation.The number of users in the response array will be limited by the execution timeout specified in the flag OPENFGA_LIST_USERS_DEADLINE and by the upper bound specified in the flag OPENFGA_LIST_USERS_MAX_RESULTS, whichever is hit first.
2712+
or type-bound public access. Each of these types of results is encoded in its own type and not represented as a string.In cases where a type-bound public acces result is returned (e.g. `user:*`), it cannot be inferred that all subjects
2713+
of that type have a relation to the object; it is possible that negations exist and checks should still be queried
2714+
on individual subjects to ensure access to that document.The number of users in the response array will be limited by the execution timeout specified in the flag OPENFGA_LIST_USERS_DEADLINE and by the upper bound specified in the flag OPENFGA_LIST_USERS_MAX_RESULTS, whichever is hit first.
27132715
The returned users will not be sorted, and therefore two identical calls may yield different sets of users.
27142716
- @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
27152717
- @param storeId

api_open_fga_test.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,7 @@ func TestOpenFgaApi(t *testing.T) {
885885
test := TestDefinition{
886886
Name: "ListUsers",
887887
// A real API would not return all these for the filter provided, these are just for test purposes
888-
JsonResponse: `{"excluded_users":null,"users":[{"object":{"id":"81684243-9356-4421-8fbf-a4f8d36aa31b","type":"user"}},{"userset":{"id":"fga","relation":"member","type":"team"}},{"wildcard":{"type":"user"}}]}`,
888+
JsonResponse: `{"users":[{"object":{"id":"81684243-9356-4421-8fbf-a4f8d36aa31b","type":"user"}},{"userset":{"id":"fga","relation":"member","type":"team"}},{"wildcard":{"type":"user"}}]}`,
889889
ResponseStatus: http.StatusOK,
890890
Method: http.MethodPost,
891891
RequestPath: "list-users",
@@ -964,10 +964,6 @@ func TestOpenFgaApi(t *testing.T) {
964964
if got.Users[2].GetWildcard().Type != expectedResponse.Users[2].GetWildcard().Type {
965965
t.Fatalf("OpenFga%v().Execute() = %v, want %v (%v)", test.Name, got.Users[2], expectedResponse.Users[2], "wildcard: { type: \"user\" }")
966966
}
967-
968-
if len(got.ExcludedUsers) != len(expectedResponse.ExcludedUsers) {
969-
t.Fatalf("OpenFga%v().Execute() = %v, want %v", test.Name, got.GetExcludedUsers(), expectedResponse.GetExcludedUsers())
970-
}
971967
})
972968

973969
t.Run("Check with 400 error", func(t *testing.T) {

client/client_test.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2441,7 +2441,7 @@ func TestOpenFgaClient(t *testing.T) {
24412441
test := TestDefinition{
24422442
Name: "ListUsers",
24432443
// A real API would not return all these for the filter provided, these are just for test purposes
2444-
JsonResponse: `{"excluded_users":null,"users":[{"object":{"id":"81684243-9356-4421-8fbf-a4f8d36aa31b","type":"user"}},{"userset":{"id":"fga","relation":"member","type":"team"}},{"wildcard":{"type":"user"}}]}`,
2444+
JsonResponse: `{"users":[{"object":{"id":"81684243-9356-4421-8fbf-a4f8d36aa31b","type":"user"}},{"userset":{"id":"fga","relation":"member","type":"team"}},{"wildcard":{"type":"user"}}]}`,
24452445
ResponseStatus: http.StatusOK,
24462446
Method: http.MethodPost,
24472447
RequestPath: "list-users",
@@ -2518,10 +2518,6 @@ func TestOpenFgaClient(t *testing.T) {
25182518
t.Fatalf("OpenFga%v().Execute() = %v, want %v (%v)", test.Name, got.Users[2], expectedResponse.Users[2], "wildcard: { type: \"user\" }")
25192519
}
25202520

2521-
if len(got.ExcludedUsers) != len(expectedResponse.ExcludedUsers) {
2522-
t.Fatalf("OpenFga%v().Execute() = %v, want %v", test.Name, got.GetExcludedUsers(), expectedResponse.GetExcludedUsers())
2523-
}
2524-
25252521
// ListUsers without options should work
25262522
_, err = fgaClient.ListUsers(context.Background()).Body(requestBody).Execute()
25272523
if err != nil {

docs/ListUsersResponse.md

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@
55
Name | Type | Description | Notes
66
------------ | ------------- | ------------- | -------------
77
**Users** | [**[]User**](User.md) | |
8-
**ExcludedUsers** | [**[]ObjectOrUserset**](ObjectOrUserset.md) | |
98

109
## Methods
1110

1211
### NewListUsersResponse
1312

14-
`func NewListUsersResponse(users []User, excludedUsers []ObjectOrUserset, ) *ListUsersResponse`
13+
`func NewListUsersResponse(users []User, ) *ListUsersResponse`
1514

1615
NewListUsersResponse instantiates a new ListUsersResponse object
1716
This constructor will assign default values to properties that have it defined,
@@ -46,26 +45,6 @@ and a boolean to check if the value has been set.
4645
SetUsers sets Users field to given value.
4746

4847

49-
### GetExcludedUsers
50-
51-
`func (o *ListUsersResponse) GetExcludedUsers() []ObjectOrUserset`
52-
53-
GetExcludedUsers returns the ExcludedUsers field if non-nil, zero value otherwise.
54-
55-
### GetExcludedUsersOk
56-
57-
`func (o *ListUsersResponse) GetExcludedUsersOk() (*[]ObjectOrUserset, bool)`
58-
59-
GetExcludedUsersOk returns a tuple with the ExcludedUsers field if it's non-nil, zero value otherwise
60-
and a boolean to check if the value has been set.
61-
62-
### SetExcludedUsers
63-
64-
`func (o *ListUsersResponse) SetExcludedUsers(v []ObjectOrUserset)`
65-
66-
SetExcludedUsers sets ExcludedUsers field to given value.
67-
68-
6948

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

docs/ObjectOrUserset.md

Lines changed: 0 additions & 82 deletions
This file was deleted.

model_list_users_response.go

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,16 @@ import (
2020

2121
// ListUsersResponse struct for ListUsersResponse
2222
type ListUsersResponse struct {
23-
Users []User `json:"users"yaml:"users"`
24-
ExcludedUsers []ObjectOrUserset `json:"excluded_users"yaml:"excluded_users"`
23+
Users []User `json:"users"yaml:"users"`
2524
}
2625

2726
// NewListUsersResponse instantiates a new ListUsersResponse object
2827
// This constructor will assign default values to properties that have it defined,
2928
// and makes sure properties required by API are set, but the set of arguments
3029
// will change when the set of required properties is changed
31-
func NewListUsersResponse(users []User, excludedUsers []ObjectOrUserset) *ListUsersResponse {
30+
func NewListUsersResponse(users []User) *ListUsersResponse {
3231
this := ListUsersResponse{}
3332
this.Users = users
34-
this.ExcludedUsers = excludedUsers
3533
return &this
3634
}
3735

@@ -67,34 +65,9 @@ func (o *ListUsersResponse) SetUsers(v []User) {
6765
o.Users = v
6866
}
6967

70-
// GetExcludedUsers returns the ExcludedUsers field value
71-
func (o *ListUsersResponse) GetExcludedUsers() []ObjectOrUserset {
72-
if o == nil {
73-
var ret []ObjectOrUserset
74-
return ret
75-
}
76-
77-
return o.ExcludedUsers
78-
}
79-
80-
// GetExcludedUsersOk returns a tuple with the ExcludedUsers field value
81-
// and a boolean to check if the value has been set.
82-
func (o *ListUsersResponse) GetExcludedUsersOk() (*[]ObjectOrUserset, bool) {
83-
if o == nil {
84-
return nil, false
85-
}
86-
return &o.ExcludedUsers, true
87-
}
88-
89-
// SetExcludedUsers sets field value
90-
func (o *ListUsersResponse) SetExcludedUsers(v []ObjectOrUserset) {
91-
o.ExcludedUsers = v
92-
}
93-
9468
func (o ListUsersResponse) MarshalJSON() ([]byte, error) {
9569
toSerialize := map[string]interface{}{}
9670
toSerialize["users"] = o.Users
97-
toSerialize["excluded_users"] = o.ExcludedUsers
9871
var b bytes.Buffer
9972
enc := json.NewEncoder(&b)
10073
enc.SetEscapeHTML(false)

0 commit comments

Comments
 (0)