Skip to content

Commit

Permalink
fix: changes to required fields
Browse files Browse the repository at this point in the history
  • Loading branch information
rhamzeh committed Oct 13, 2023
1 parent c7b028b commit d6dd179
Show file tree
Hide file tree
Showing 51 changed files with 649 additions and 1,223 deletions.
6 changes: 4 additions & 2 deletions api_open_fga.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,8 @@ type OpenFgaApi interface {
}
```
This means that `user:bob` has a `reader` relationship with 1 document `document:2021-budget`. Note that this API, unlike the List Objects API, does not evaluate the tuples in the store.
The continuation token will be empty if there are no more tuples to query.### Query for all stored relationship tuples that have a particular relation and object
The continuation token will be empty if there are no more tuples to query.
### Query for all stored relationship tuples that have a particular relation and object
To query for all users that have `reader` relationship with `document:2021-budget`, call read API with body of
```json
{
Expand Down Expand Up @@ -2573,7 +2574,8 @@ The API will return tuples and a continuation token, something like
```
This means that `user:bob` has a `reader` relationship with 1 document `document:2021-budget`. Note that this API, unlike the List Objects API, does not evaluate the tuples in the store.
The continuation token will be empty if there are no more tuples to query.### Query for all stored relationship tuples that have a particular relation and object
The continuation token will be empty if there are no more tuples to query.
### Query for all stored relationship tuples that have a particular relation and object
To query for all users that have `reader` relationship with `document:2021-budget`, call read API with body of
```json
Expand Down
32 changes: 16 additions & 16 deletions api_open_fga_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,14 @@ func TestOpenFgaApiConfiguration(t *testing.T) {
defer httpmock.DeactivateAndReset()
httpmock.RegisterResponder("GET", fmt.Sprintf("%s://%s/stores/%s/authorization-models", configuration.ApiScheme, configuration.ApiHost, configuration.StoreId),
func(req *http.Request) (*http.Response, error) {
resp, err := httpmock.NewJsonResponse(200, ReadAuthorizationModelsResponse{AuthorizationModels: &[]AuthorizationModel{
resp, err := httpmock.NewJsonResponse(200, ReadAuthorizationModelsResponse{AuthorizationModels: []AuthorizationModel{
{
Id: PtrString("01GXSA8YR785C4FYS3C0RTG7B1"),
TypeDefinitions: &[]TypeDefinition{},
TypeDefinitions: []TypeDefinition{},
},
{
Id: PtrString("01GXSBM5PVYHCJNRNKXMB4QZTW"),
TypeDefinitions: &[]TypeDefinition{},
TypeDefinitions: []TypeDefinition{},
},
}})
if err != nil {
Expand Down Expand Up @@ -249,14 +249,14 @@ func TestOpenFgaApiConfiguration(t *testing.T) {
defer httpmock.DeactivateAndReset()
httpmock.RegisterResponder("GET", fmt.Sprintf("%s://%s/stores/%s/authorization-models", configuration.ApiScheme, configuration.ApiHost, configuration.StoreId),
func(req *http.Request) (*http.Response, error) {
resp, err := httpmock.NewJsonResponse(200, ReadAuthorizationModelsResponse{AuthorizationModels: &[]AuthorizationModel{
resp, err := httpmock.NewJsonResponse(200, ReadAuthorizationModelsResponse{AuthorizationModels: []AuthorizationModel{
{
Id: PtrString("01GXSA8YR785C4FYS3C0RTG7B1"),
TypeDefinitions: &[]TypeDefinition{},
TypeDefinitions: []TypeDefinition{},
},
{
Id: PtrString("01GXSBM5PVYHCJNRNKXMB4QZTW"),
TypeDefinitions: &[]TypeDefinition{},
TypeDefinitions: []TypeDefinition{},
},
}})
if err != nil {
Expand Down Expand Up @@ -313,14 +313,14 @@ func TestOpenFgaApiConfiguration(t *testing.T) {
defer httpmock.DeactivateAndReset()
httpmock.RegisterResponder("GET", fmt.Sprintf("%s://%s/stores/%s/authorization-models", configuration.ApiScheme, configuration.ApiHost, configuration.StoreId),
func(req *http.Request) (*http.Response, error) {
resp, err := httpmock.NewJsonResponse(200, ReadAuthorizationModelsResponse{AuthorizationModels: &[]AuthorizationModel{
resp, err := httpmock.NewJsonResponse(200, ReadAuthorizationModelsResponse{AuthorizationModels: []AuthorizationModel{
{
Id: PtrString("01GXSA8YR785C4FYS3C0RTG7B1"),
TypeDefinitions: &[]TypeDefinition{},
TypeDefinitions: []TypeDefinition{},
},
{
Id: PtrString("01GXSBM5PVYHCJNRNKXMB4QZTW"),
TypeDefinitions: &[]TypeDefinition{},
TypeDefinitions: []TypeDefinition{},
},
}})
if err != nil {
Expand Down Expand Up @@ -447,12 +447,12 @@ func TestOpenFgaApi(t *testing.T) {
t.Fatalf("OpenFga%v().Execute() = %v, want %v", test.Name, response.StatusCode, test.ResponseStatus)
}

if len(*got.AuthorizationModels) != 1 {
if len(got.AuthorizationModels) != 1 {
t.Fatalf("%v", err)
}

if *((*got.AuthorizationModels)[0].Id) != *((*expectedResponse.AuthorizationModels)[0].Id) {
t.Fatalf("OpenFga%v().Execute() = %v, want %v", test.Name, *((*got.AuthorizationModels)[0].Id), *((*expectedResponse.AuthorizationModels)[0].Id))
if *(got.AuthorizationModels[0].Id) != *(expectedResponse.AuthorizationModels[0].Id) {
t.Fatalf("OpenFga%v().Execute() = %v, want %v", test.Name, *(got.AuthorizationModels[0].Id), *(expectedResponse.AuthorizationModels[0].Id))
}
})

Expand All @@ -472,7 +472,7 @@ func TestOpenFgaApi(t *testing.T) {
This: &map[string]interface{}{},
},
"viewer": {Union: &Usersets{
Child: &[]Userset{
Child: []Userset{
{This: &map[string]interface{}{}},
{ComputedUserset: &ObjectRelation{
Object: PtrString(""),
Expand Down Expand Up @@ -798,7 +798,7 @@ func TestOpenFgaApi(t *testing.T) {
t.Fatalf("%v", err)
}

if len(*got.Tuples) != len(*expectedResponse.Tuples) {
if len(got.Tuples) != len(expectedResponse.Tuples) {
t.Fatalf("OpenFga%v().Execute() = %v, want %v", test.Name, string(responseJson), test.JsonResponse)
}
})
Expand Down Expand Up @@ -846,7 +846,7 @@ func TestOpenFgaApi(t *testing.T) {
t.Fatalf("%v", err)
}

if len(*got.Changes) != len(*expectedResponse.Changes) {
if len(got.Changes) != len(expectedResponse.Changes) {
t.Fatalf("OpenFga%v().Execute() = %v, want %v", test.Name, string(responseJson), test.JsonResponse)
}
})
Expand Down Expand Up @@ -910,7 +910,7 @@ func TestOpenFgaApi(t *testing.T) {
t.Fatalf("%v", err)
}

if len(*got.Objects) != len(*expectedResponse.Objects) || (*got.Objects)[0] != (*expectedResponse.Objects)[0] {
if len(got.Objects) != len(expectedResponse.Objects) || (got.Objects)[0] != (expectedResponse.Objects)[0] {
t.Fatalf("OpenFga%v().Execute() = %v, want %v", test.Name, string(responseJson), test.JsonResponse)
}
})
Expand Down
6 changes: 3 additions & 3 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ func (request *SdkClientWriteAuthorizationModelRequest) GetContext() _context.Co
func (client *OpenFgaClient) WriteAuthorizationModelExecute(request SdkClientWriteAuthorizationModelRequestInterface) (*ClientWriteAuthorizationModelResponse, error) {
data, _, err := client.OpenFgaApi.WriteAuthorizationModel(request.GetContext()).Body(openfga.WriteAuthorizationModelRequest{
TypeDefinitions: request.GetBody().TypeDefinitions,
SchemaVersion: openfga.PtrString(request.GetBody().SchemaVersion),
SchemaVersion: request.GetBody().SchemaVersion,
}).Execute()
if err != nil {
return nil, err
Expand Down Expand Up @@ -954,8 +954,8 @@ func (client *OpenFgaClient) ReadLatestAuthorizationModelExecute(request SdkClie

var authorizationModel *openfga.AuthorizationModel

if len(*response.AuthorizationModels) > 0 {
authorizationModels := *response.AuthorizationModels
if len(response.AuthorizationModels) > 0 {
authorizationModels := response.AuthorizationModels
authorizationModel = &(authorizationModels)[0]
}

Expand Down
46 changes: 23 additions & 23 deletions client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,12 @@ func TestOpenFgaClient(t *testing.T) {
t.Fatalf("%v", err)
}

if len(*got.Stores) != 1 {
if len(got.Stores) != 1 {
t.Fatalf("%v", err)
}

if *((*got.Stores)[0].Id) != *((*expectedResponse.Stores)[0].Id) {
t.Fatalf("OpenFgaClient.%v() = %v, want %v", test.Name, *((*got.Stores)[0].Id), *((*expectedResponse.Stores)[0].Id))
if got.Stores[0].Id != expectedResponse.Stores[0].Id {
t.Fatalf("OpenFgaClient.%v() = %v, want %v", test.Name, got.Stores[0].Id, expectedResponse.Stores[0].Id)
}
// ListStores without options should work
_, err = fgaClient.ListStores(context.Background()).Execute()
Expand Down Expand Up @@ -177,8 +177,8 @@ func TestOpenFgaClient(t *testing.T) {
if err != nil {
t.Fatalf("%v", err)
}
if *got.Name != *expectedResponse.Name {
t.Fatalf("OpenFgaClient.%v() = %v, want %v", test.Name, *got.Name, *expectedResponse.Name)
if got.Name != expectedResponse.Name {
t.Fatalf("OpenFgaClient.%v() = %v, want %v", test.Name, got.Name, expectedResponse.Name)
}
// CreateStore without options should work
_, err = fgaClient.CreateStore(context.Background()).Body(requestBody).Execute()
Expand Down Expand Up @@ -217,8 +217,8 @@ func TestOpenFgaClient(t *testing.T) {
t.Fatalf("%v", err)
}

if *got.Id != *expectedResponse.Id {
t.Fatalf("OpenFgaClient.%v() = %v, want %v", test.Name, *got.Id, *expectedResponse.Id)
if got.Id != expectedResponse.Id {
t.Fatalf("OpenFgaClient.%v() = %v, want %v", test.Name, got.Id, expectedResponse.Id)
}
// GetStore without options should work
_, err = fgaClient.GetStore(context.Background()).Execute()
Expand Down Expand Up @@ -265,11 +265,11 @@ func TestOpenFgaClient(t *testing.T) {
if err != nil {
t.Fatalf("%v", err)
}
if *got1.Name != *expectedResponse.Name {
t.Fatalf("OpenFgaClient.%v() = %v, want %v", test.Name, *got1.Name, *expectedResponse.Name)
if got1.Name != expectedResponse.Name {
t.Fatalf("OpenFgaClient.%v() = %v, want %v", test.Name, got1.Name, expectedResponse.Name)
}

storeId := *got1.Id
storeId := got1.Id
fgaClient.SetStoreId(storeId)

httpmock.Activate()
Expand All @@ -289,8 +289,8 @@ func TestOpenFgaClient(t *testing.T) {
t.Fatalf("%v", err2)
}

if *got2.Id != storeId {
t.Fatalf("OpenFgaClient.%v() = %v, want %v", test.Name, *got2.Id, storeId)
if got2.Id != storeId {
t.Fatalf("OpenFgaClient.%v() = %v, want %v", test.Name, got2.Id, storeId)
}
})

Expand Down Expand Up @@ -360,12 +360,12 @@ func TestOpenFgaClient(t *testing.T) {
t.Fatalf("%v", err)
}

if len(*got.AuthorizationModels) != 1 {
if len(got.AuthorizationModels) != 1 {
t.Fatalf("%v", err)
}

if *((*got.AuthorizationModels)[0].Id) != *((*expectedResponse.AuthorizationModels)[0].Id) {
t.Fatalf("OpenFgaClient.%v() = %v, want %v", test.Name, *((*got.AuthorizationModels)[0].Id), *((*expectedResponse.AuthorizationModels)[0].Id))
if *(got.AuthorizationModels[0].Id) != *(expectedResponse.AuthorizationModels[0].Id) {
t.Fatalf("OpenFgaClient.%v() = %v, want %v", test.Name, *(got.AuthorizationModels[0].Id), *(expectedResponse.AuthorizationModels[0].Id))
}
// ReadAuthorizationModels without options should work
_, err = fgaClient.ReadAuthorizationModels(context.Background()).Execute()
Expand Down Expand Up @@ -393,7 +393,7 @@ func TestOpenFgaClient(t *testing.T) {
This: &map[string]interface{}{},
},
"viewer": {Union: &openfga.Usersets{
Child: &[]openfga.Userset{
Child: []openfga.Userset{
{This: &map[string]interface{}{}},
{ComputedUserset: &openfga.ObjectRelation{
Object: openfga.PtrString(""),
Expand Down Expand Up @@ -470,7 +470,7 @@ func TestOpenFgaClient(t *testing.T) {
if err := json.Unmarshal([]byte(test.JsonResponse), &expectedResponse); err != nil {
t.Fatalf("%v", err)
}
modelId := *(*expectedResponse.AuthorizationModel).Id
modelId := *(expectedResponse.AuthorizationModel).Id

httpmock.Activate()
defer httpmock.DeactivateAndReset()
Expand All @@ -496,7 +496,7 @@ func TestOpenFgaClient(t *testing.T) {
t.Fatalf("%v", err)
}

if *(*got.AuthorizationModel).Id != modelId {
if *(got.AuthorizationModel).Id != modelId {
t.Fatalf("OpenFgaClient.%v() = %v, want %v", test.Name, string(responseJson), test.JsonResponse)
}
// ReadAuthorizationModel without options should not work
Expand Down Expand Up @@ -528,7 +528,7 @@ func TestOpenFgaClient(t *testing.T) {
if err := json.Unmarshal([]byte(test.JsonResponse), &expectedResponse); err != nil {
t.Fatalf("%v", err)
}
modelId := *((*expectedResponse.AuthorizationModels)[0].Id)
modelId := *(expectedResponse.AuthorizationModels[0].Id)

httpmock.Activate()
defer httpmock.DeactivateAndReset()
Expand All @@ -552,7 +552,7 @@ func TestOpenFgaClient(t *testing.T) {
t.Fatalf("%v", err)
}

if (*got.AuthorizationModel).GetId() != modelId {
if got.AuthorizationModel.GetId() != modelId {
t.Fatalf("OpenFgaClient.%v() = %v, want %v", test.Name, string(responseJson), test.JsonResponse)
}
// ReadLatestAuthorizationModel without options should work
Expand Down Expand Up @@ -602,7 +602,7 @@ func TestOpenFgaClient(t *testing.T) {
t.Fatalf("%v", err)
}

if len(*got.Changes) != len(*expectedResponse.Changes) {
if len(got.Changes) != len(expectedResponse.Changes) {
t.Fatalf("OpenFgaClient.%v() = %v, want %v", test.Name, string(responseJson), test.JsonResponse)
}
// ReadChanges without options should work
Expand Down Expand Up @@ -658,7 +658,7 @@ func TestOpenFgaClient(t *testing.T) {
t.Fatalf("%v", err)
}

if len(*got.Tuples) != len(*expectedResponse.Tuples) {
if len(got.Tuples) != len(expectedResponse.Tuples) {
t.Fatalf("OpenFgaClient.%v() = %v, want %v", test.Name, string(responseJson), test.JsonResponse)
}
// Read without options should work
Expand Down Expand Up @@ -1422,7 +1422,7 @@ func TestOpenFgaClient(t *testing.T) {
t.Fatalf("%v", err)
}

if len(*got.Objects) != len(*expectedResponse.Objects) || (*got.Objects)[0] != (*expectedResponse.Objects)[0] {
if len(got.Objects) != len(expectedResponse.Objects) || (got.Objects)[0] != (expectedResponse.Objects)[0] {
t.Fatalf("OpenFgaClient.%v() = %v, want %v", test.Name, string(responseJson), test.JsonResponse)
}
// ListObjects without options should work
Expand Down
9 changes: 2 additions & 7 deletions docs/AuthorizationModel.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**Id** | Pointer to **string** | | [optional]
**SchemaVersion** | **string** | |
**TypeDefinitions** | Pointer to [**[]TypeDefinition**](TypeDefinition.md) | | [optional]
**TypeDefinitions** | [**[]TypeDefinition**](TypeDefinition.md) | |
**Conditions** | Pointer to [**map[string]Condition**](Condition.md) | | [optional]

## Methods

### NewAuthorizationModel

`func NewAuthorizationModel(schemaVersion string, ) *AuthorizationModel`
`func NewAuthorizationModel(schemaVersion string, typeDefinitions []TypeDefinition, ) *AuthorizationModel`

NewAuthorizationModel instantiates a new AuthorizationModel object
This constructor will assign default values to properties that have it defined,
Expand Down Expand Up @@ -92,11 +92,6 @@ and a boolean to check if the value has been set.

SetTypeDefinitions sets TypeDefinitions field to given value.

### HasTypeDefinitions

`func (o *AuthorizationModel) HasTypeDefinitions() bool`

HasTypeDefinitions returns a boolean if a field has been set.

### GetConditions

Expand Down
9 changes: 2 additions & 7 deletions docs/Computed.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**Userset** | Pointer to **string** | | [optional]
**Userset** | **string** | |

## Methods

### NewComputed

`func NewComputed() *Computed`
`func NewComputed(userset string, ) *Computed`

NewComputed instantiates a new Computed object
This constructor will assign default values to properties that have it defined,
Expand Down Expand Up @@ -44,11 +44,6 @@ and a boolean to check if the value has been set.

SetUserset sets Userset field to given value.

### HasUserset

`func (o *Computed) HasUserset() bool`

HasUserset returns a boolean if a field has been set.


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

0 comments on commit d6dd179

Please sign in to comment.