@@ -38,6 +38,7 @@ This is an autogenerated Go SDK for OpenFGA. It provides a wrapper around the [O
38
38
- [ Expand] ( #expand )
39
39
- [ List Objects] ( #list-objects )
40
40
- [ List Relations] ( #list-relations )
41
+ - [ List Users] ( #list-users )
41
42
- [ Assertions] ( #assertions )
42
43
- [ Read Assertions] ( #read-assertions )
43
44
- [ Write Assertions] ( #write-assertions )
@@ -114,7 +115,7 @@ func main() {
114
115
fgaClient , err := NewSdkClient (&ClientConfiguration{
115
116
ApiUrl: os.Getenv (" FGA_API_URL" ), // required, e.g. https://api.fga.example
116
117
StoreId: os.Getenv (" FGA_STORE_ID" ), // not needed when calling `CreateStore` or `ListStores`
117
- AuthorizationModelId: os.Getenv (" FGA_AUTHORIZATION_MODEL_ID " ), // optional, recommended to be set for production
118
+ AuthorizationModelId: os.Getenv (" FGA_MODEL_ID " ), // optional, recommended to be set for production
118
119
})
119
120
120
121
if err != nil {
@@ -136,7 +137,7 @@ func main() {
136
137
fgaClient , err := NewSdkClient (&ClientConfiguration{
137
138
ApiUrl: os.Getenv (" FGA_API_URL" ), // required, e.g. https://api.fga.example
138
139
StoreId: os.Getenv (" FGA_STORE_ID" ), // not needed when calling `CreateStore` or `ListStores`
139
- AuthorizationModelId: os.Getenv (" FGA_AUTHORIZATION_MODEL_ID " ), // optional, recommended to be set for production
140
+ AuthorizationModelId: os.Getenv (" FGA_MODEL_ID " ), // optional, recommended to be set for production
140
141
Credentials: &credentials.Credentials {
141
142
Method: credentials.CredentialsMethodApiToken ,
142
143
Config: &credentials.Config {
@@ -165,7 +166,7 @@ func main() {
165
166
fgaClient , err := NewSdkClient (&ClientConfiguration{
166
167
ApiUrl: os.Getenv (" FGA_API_URL" ), // required, e.g. https://api.fga.example
167
168
StoreId: os.Getenv (" FGA_STORE_ID" ), // not needed when calling `CreateStore` or `ListStores`
168
- AuthorizationModelId: os.Getenv (" FGA_AUTHORIZATION_MODEL_ID " ), // optional, recommended to be set for production
169
+ AuthorizationModelId: os.Getenv (" FGA_MODEL_ID " ), // optional, recommended to be set for production
169
170
Credentials: &credentials.Credentials {
170
171
Method: credentials.CredentialsMethodClientCredentials ,
171
172
Config: &credentials.Config {
@@ -197,7 +198,7 @@ func main() {
197
198
fgaClient , err := NewSdkClient (&ClientConfiguration{
198
199
ApiUrl: os.Getenv (" FGA_API_URL" ), // required, e.g. https://api.fga.example
199
200
StoreId: os.Getenv (" FGA_STORE_ID" ), // not needed when calling `CreateStore` or `ListStores`
200
- AuthorizationModelId: os.Getenv (" FGA_AUTHORIZATION_MODEL_ID " ), // optional, recommended to be set for production
201
+ AuthorizationModelId: os.Getenv (" FGA_MODEL_ID " ), // optional, recommended to be set for production
201
202
Credentials: &credentials.Credentials {
202
203
Method: credentials.CredentialsMethodClientCredentials ,
203
204
Config: &credentials.Config {
@@ -762,6 +763,50 @@ data, err := fgaClient.ListRelations(context.Background()).
762
763
// data.Relations = ["can_view", "can_edit"]
763
764
```
764
765
766
+ ##### List Users
767
+
768
+ List the users who have a certain relation to a particular type.
769
+
770
+ [ API Documentation] ( https://openfga.dev/api/service#/Relationship%20Queries/ListUsers )
771
+
772
+ ``` golang
773
+ options := ClientListRelationsOptions {
774
+ // You can rely on the model id set in the configuration or override it for this specific request
775
+ AuthorizationModelId : openfga.PtrString (" 01GAHCE4YVKPQEKZQHT2R89MQV" ),
776
+ }
777
+
778
+ // Only a single filter is allowed by the API for the time being
779
+ userFilters := []openfga.UserTypeFilter {{ Type: " user" }}
780
+ // user filters can also be of the form
781
+ // userFilters := []openfga.UserTypeFilter{{ Type: "team", Relation: openfga.PtrString("member") }}
782
+
783
+ requestBody := ClientListUsersRequest {
784
+ Object : openfga.Object {
785
+ Type: " document" ,
786
+ Id: " roadmap" ,
787
+ },
788
+ Relation : " can_read" ,
789
+ UserFilters : userFilters,
790
+ ContextualTuples : []ClientContextualTupleKey {{
791
+ User: " user:81684243-9356-4421-8fbf-a4f8d36aa31b" ,
792
+ Relation: " editor" ,
793
+ Object: " folder:product" ,
794
+ }, {
795
+ User: " folder:product" ,
796
+ Relation: " parent" ,
797
+ Object: " document:roadmap" ,
798
+ }},
799
+ Context : &map [string ]interface {}{" ViewCount" : 100 },
800
+ }
801
+ data , err := fgaClient.ListRelations (context.Background ()).
802
+ Body (requestBody).
803
+ Options (options).
804
+ Execute ()
805
+
806
+ // response.users = [{object: {type: "user", id: "81684243-9356-4421-8fbf-a4f8d36aa31b"}}, {userset: { type: "user" }}, ...]
807
+ // response.excluded_users = [ {object: {type: "user", id: "4a455e27-d15a-4434-82e0-136f9c2aa4cf"}}, ... ]
808
+ ```
809
+
765
810
### Assertions
766
811
767
812
#### Read Assertions
@@ -826,7 +871,7 @@ func main() {
826
871
fgaClient , err := NewSdkClient (&ClientConfiguration{
827
872
ApiUrl: os.Getenv (" FGA_API_URL" ), // required, e.g. https://api.fga.example
828
873
StoreId: os.Getenv (" FGA_STORE_ID" ), // not needed when calling `CreateStore` or `ListStores`
829
- AuthorizationModelId: os.Getenv (" FGA_AUTHORIZATION_MODEL_ID " ), // optional, recommended to be set for production
874
+ AuthorizationModelId: os.Getenv (" FGA_MODEL_ID " ), // optional, recommended to be set for production
830
875
RetryParams: &openfga.RetryParams {
831
876
MaxRetry: 3 , // retry up to 3 times on API requests
832
877
MinWaitInMs: 250 , // wait a minimum of 250 milliseconds between requests
@@ -849,6 +894,7 @@ Class | Method | HTTP request | Description
849
894
*OpenFgaApi* | [**GetStore**](docs/OpenFgaApi.md #getstore) | **Get** /stores/{store_id} | Get a store
850
895
*OpenFgaApi* | [**ListObjects**](docs/OpenFgaApi.md #listobjects) | **Post** /stores/{store_id}/list-objects | List all objects of the given type that the user has a relation with
851
896
*OpenFgaApi* | [**ListStores**](docs/OpenFgaApi.md #liststores) | **Get** /stores | List all stores
897
+ *OpenFgaApi* | [**ListUsers**](docs/OpenFgaApi.md #listusers) | **Post** /stores/{store_id}/list-users | List all users of the given type that the object has a relation with
852
898
*OpenFgaApi* | [**Read**](docs/OpenFgaApi.md #read) | **Post** /stores/{store_id}/read | Get tuples from the store that matches a query, without following userset rewrite rules
853
899
*OpenFgaApi* | [**ReadAssertions**](docs/OpenFgaApi.md #readassertions) | **Get** /stores/{store_id}/assertions/{authorization_model_id} | Read assertions for an authorization model ID
854
900
*OpenFgaApi* | [**ReadAuthorizationModel**](docs/OpenFgaApi.md #readauthorizationmodel) | **Get** /stores/{store_id}/authorization-models/{id} | Return a particular version of an authorization model
@@ -881,18 +927,22 @@ Class | Method | HTTP request | Description
881
927
- [ExpandRequest](docs/ExpandRequest.md )
882
928
- [ExpandRequestTupleKey](docs/ExpandRequestTupleKey.md )
883
929
- [ExpandResponse](docs/ExpandResponse.md )
930
+ - [FgaObject](docs/FgaObject.md )
884
931
- [GetStoreResponse](docs/GetStoreResponse.md )
885
932
- [InternalErrorCode](docs/InternalErrorCode.md )
886
933
- [InternalErrorMessageResponse](docs/InternalErrorMessageResponse.md )
887
934
- [Leaf](docs/Leaf.md )
888
935
- [ListObjectsRequest](docs/ListObjectsRequest.md )
889
936
- [ListObjectsResponse](docs/ListObjectsResponse.md )
890
937
- [ListStoresResponse](docs/ListStoresResponse.md )
938
+ - [ListUsersRequest](docs/ListUsersRequest.md )
939
+ - [ListUsersResponse](docs/ListUsersResponse.md )
891
940
- [Metadata](docs/Metadata.md )
892
941
- [Node](docs/Node.md )
893
942
- [Nodes](docs/Nodes.md )
894
943
- [NotFoundErrorCode](docs/NotFoundErrorCode.md )
895
944
- [NullValue](docs/NullValue.md )
945
+ - [ObjectOrUserset](docs/ObjectOrUserset.md )
896
946
- [ObjectRelation](docs/ObjectRelation.md )
897
947
- [PathUnknownErrorMessageResponse](docs/PathUnknownErrorMessageResponse.md )
898
948
- [ReadAssertionsResponse](docs/ReadAssertionsResponse.md )
@@ -916,11 +966,17 @@ Class | Method | HTTP request | Description
916
966
- [TupleToUserset](docs/TupleToUserset.md )
917
967
- [TypeDefinition](docs/TypeDefinition.md )
918
968
- [TypeName](docs/TypeName.md )
969
+ - [TypedWildcard](docs/TypedWildcard.md )
970
+ - [UnprocessableContentErrorCode](docs/UnprocessableContentErrorCode.md )
971
+ - [UnprocessableContentMessageResponse](docs/UnprocessableContentMessageResponse.md )
972
+ - [User](docs/User.md )
973
+ - [UserTypeFilter](docs/UserTypeFilter.md )
919
974
- [Users](docs/Users.md )
920
975
- [Userset](docs/Userset.md )
921
976
- [UsersetTree](docs/UsersetTree.md )
922
977
- [UsersetTreeDifference](docs/UsersetTreeDifference.md )
923
978
- [UsersetTreeTupleToUserset](docs/UsersetTreeTupleToUserset.md )
979
+ - [UsersetUser](docs/UsersetUser.md )
924
980
- [Usersets](docs/Usersets.md )
925
981
- [ValidationErrorMessageResponse](docs/ValidationErrorMessageResponse.md )
926
982
- [WriteAssertionsRequest](docs/WriteAssertionsRequest.md )
0 commit comments