From e28d0c8c6c1ab67e21d3c8e46940124377734320 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Padilla?= Date: Wed, 22 Nov 2023 11:14:00 -0500 Subject: [PATCH] refactor(write): normalize deletes field --- README.md | 4 +- api_open_fga.go | 2 + api_open_fga_test.go | 6 +- client/client.go | 47 +++-- client/client_test.go | 6 +- docs/TupleKeyWithoutCondition.md | 93 ++++++++++ docs/WriteRequest.md | 16 +- docs/WriteRequestDeletes.md | 51 ++++++ ...uestTupleKeys.md => WriteRequestWrites.md} | 20 +-- model_null_value.go | 2 +- model_tuple_key_without_condition.go | 160 ++++++++++++++++++ model_write_request.go | 26 +-- model_write_request_deletes.go | 106 ++++++++++++ ...e_keys.go => model_write_request_writes.go | 44 ++--- 14 files changed, 509 insertions(+), 74 deletions(-) create mode 100644 docs/TupleKeyWithoutCondition.md create mode 100644 docs/WriteRequestDeletes.md rename docs/{WriteRequestTupleKeys.md => WriteRequestWrites.md} (62%) create mode 100644 model_tuple_key_without_condition.go create mode 100644 model_write_request_deletes.go rename model_write_request_tuple_keys.go => model_write_request_writes.go (53%) diff --git a/README.md b/README.md index 8870364..b2db29a 100644 --- a/README.md +++ b/README.md @@ -843,6 +843,7 @@ Class | Method | HTTP request | Description - [Tuple](docs/Tuple.md) - [TupleChange](docs/TupleChange.md) - [TupleKey](docs/TupleKey.md) + - [TupleKeyWithoutCondition](docs/TupleKeyWithoutCondition.md) - [TupleOperation](docs/TupleOperation.md) - [TupleToUserset](docs/TupleToUserset.md) - [TypeDefinition](docs/TypeDefinition.md) @@ -858,8 +859,9 @@ Class | Method | HTTP request | Description - [WriteAuthorizationModelRequest](docs/WriteAuthorizationModelRequest.md) - [WriteAuthorizationModelResponse](docs/WriteAuthorizationModelResponse.md) - [WriteRequest](docs/WriteRequest.md) + - [WriteRequestDeletes](docs/WriteRequestDeletes.md) - [WriteRequestTupleKey](docs/WriteRequestTupleKey.md) - - [WriteRequestTupleKeys](docs/WriteRequestTupleKeys.md) + - [WriteRequestWrites](docs/WriteRequestWrites.md) ## Contributing diff --git a/api_open_fga.go b/api_open_fga.go index 40c60e2..c7f71df 100644 --- a/api_open_fga.go +++ b/api_open_fga.go @@ -189,6 +189,7 @@ type OpenFgaApi interface { You may also specify `contextual_tuples` that will be treated as regular tuples. The response will contain the related objects in an array in the "objects" field of the response and they will be strings in the object format `:` (e.g. "document:roadmap"). The number of objects in the response array will be limited by the execution timeout specified in the flag OPENFGA_LIST_OBJECTS_DEADLINE and by the upper bound specified in the flag OPENFGA_LIST_OBJECTS_MAX_RESULTS, whichever is hit first. + The objects given will not be sorted, and therefore two identical calls can give a given different set of objects. * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @return ApiListObjectsRequest */ @@ -1998,6 +1999,7 @@ An `authorization_model_id` may be specified in the body. If it is not specified You may also specify `contextual_tuples` that will be treated as regular tuples. The response will contain the related objects in an array in the "objects" field of the response and they will be strings in the object format `:` (e.g. "document:roadmap"). The number of objects in the response array will be limited by the execution timeout specified in the flag OPENFGA_LIST_OBJECTS_DEADLINE and by the upper bound specified in the flag OPENFGA_LIST_OBJECTS_MAX_RESULTS, whichever is hit first. +The objects given will not be sorted, and therefore two identical calls can give a given different set of objects. - @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @return ApiListObjectsRequest */ diff --git a/api_open_fga_test.go b/api_open_fga_test.go index af76e2f..ffa3b23 100644 --- a/api_open_fga_test.go +++ b/api_open_fga_test.go @@ -621,7 +621,7 @@ func TestOpenFgaApi(t *testing.T) { RequestPath: "write", } requestBody := WriteRequest{ - Writes: &WriteRequestTupleKeys{ + Writes: &WriteRequestWrites{ TupleKeys: []WriteRequestTupleKey{{ User: "user:81684243-9356-4421-8fbf-a4f8d36aa31b", Relation: "viewer", @@ -667,8 +667,8 @@ func TestOpenFgaApi(t *testing.T) { } requestBody := WriteRequest{ - Deletes: &WriteRequestTupleKeys{ - TupleKeys: []WriteRequestTupleKey{{ + Deletes: &WriteRequestDeletes{ + TupleKeys: []TupleKeyWithoutCondition{{ User: "user:81684243-9356-4421-8fbf-a4f8d36aa31b", Relation: "viewer", Object: "document:roadmap", diff --git a/client/client.go b/client/client.go index 40375ec..24c7a8b 100644 --- a/client/client.go +++ b/client/client.go @@ -114,6 +114,7 @@ type ClientRequestOptionsWithAuthZModelId struct { } type ClientTupleKey = fgaSdk.TupleKey +type ClientTupleKeyWithoutCondition = fgaSdk.TupleKeyWithoutCondition type ClientWriteRequestTupleKey = fgaSdk.WriteRequestTupleKey type ClientCheckRequestTupleKey = fgaSdk.CheckRequestTupleKey type ClientReadRequestTupleKey = fgaSdk.ReadRequestTupleKey @@ -1157,7 +1158,7 @@ type SdkClientWriteRequestInterface interface { type ClientWriteRequest struct { Writes []ClientWriteRequestTupleKey - Deletes []ClientWriteRequestTupleKey + Deletes []ClientTupleKeyWithoutCondition } type TransactionOptions struct { @@ -1182,14 +1183,34 @@ const ( FAILURE ClientWriteStatus = "CLIENT_WRITE_STATUS_FAILURE" ) -type ClientWriteSingleResponse struct { +type ClientWriteRequestWriteResponse struct { TupleKey ClientWriteRequestTupleKey `json:"tuple_key,omitempty"` Status ClientWriteStatus `json:"status,omitempty"` HttpResponse *_nethttp.Response `json:"http_response,omitempty"` Error error `json:"error,omitempty"` } -func (o ClientWriteSingleResponse) MarshalJSON() ([]byte, error) { +func (o ClientWriteRequestWriteResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + toSerialize["tuple_key"] = o.TupleKey + toSerialize["status"] = o.Status + if o.HttpResponse != nil { + toSerialize["http_response"] = o.HttpResponse + } + if o.Error != nil { + toSerialize["error"] = o.Error + } + return json.Marshal(toSerialize) +} + +type ClientWriteRequestDeleteResponse struct { + TupleKey ClientTupleKeyWithoutCondition `json:"tuple_key,omitempty"` + Status ClientWriteStatus `json:"status,omitempty"` + HttpResponse *_nethttp.Response `json:"http_response,omitempty"` + Error error `json:"error,omitempty"` +} + +func (o ClientWriteRequestDeleteResponse) MarshalJSON() ([]byte, error) { toSerialize := map[string]interface{}{} toSerialize["tuple_key"] = o.TupleKey toSerialize["status"] = o.Status @@ -1203,8 +1224,8 @@ func (o ClientWriteSingleResponse) MarshalJSON() ([]byte, error) { } type ClientWriteResponse struct { - Writes []ClientWriteSingleResponse `json:"writes,omitempty"` - Deletes []ClientWriteSingleResponse `json:"deletes,omitempty"` + Writes []ClientWriteRequestWriteResponse `json:"writes,omitempty"` + Deletes []ClientWriteRequestDeleteResponse `json:"deletes,omitempty"` } func (o ClientWriteResponse) MarshalJSON() ([]byte, error) { @@ -1269,8 +1290,8 @@ func (client *OpenFgaClient) WriteExecute(request SdkClientWriteRequestInterface } response := ClientWriteResponse{ - Writes: []ClientWriteSingleResponse{}, - Deletes: []ClientWriteSingleResponse{}, + Writes: []ClientWriteRequestWriteResponse{}, + Deletes: []ClientWriteRequestDeleteResponse{}, } authorizationModelId, err := client.getAuthorizationModelId(request.GetAuthorizationModelIdOverride()) @@ -1285,14 +1306,14 @@ func (client *OpenFgaClient) WriteExecute(request SdkClientWriteRequestInterface AuthorizationModelId: authorizationModelId, } if request.GetBody().Writes != nil && len(request.GetBody().Writes) > 0 { - writes := fgaSdk.WriteRequestTupleKeys{} + writes := fgaSdk.WriteRequestWrites{} for index := 0; index < len(request.GetBody().Writes); index++ { writes.TupleKeys = append(writes.TupleKeys, (request.GetBody().Writes)[index]) } writeRequest.Writes = &writes } if request.GetBody().Deletes != nil && len(request.GetBody().Deletes) > 0 { - deletes := fgaSdk.WriteRequestTupleKeys{} + deletes := fgaSdk.WriteRequestDeletes{} for index := 0; index < len(request.GetBody().Deletes); index++ { deletes.TupleKeys = append(deletes.TupleKeys, (request.GetBody().Deletes)[index]) } @@ -1308,7 +1329,7 @@ func (client *OpenFgaClient) WriteExecute(request SdkClientWriteRequestInterface if request.GetBody() != nil && request.GetBody().Writes != nil { writeRequestTupleKeys := request.GetBody().Writes for index := 0; index < len(writeRequestTupleKeys); index++ { - response.Writes = append(response.Writes, ClientWriteSingleResponse{ + response.Writes = append(response.Writes, ClientWriteRequestWriteResponse{ TupleKey: writeRequestTupleKeys[index], HttpResponse: httpResponse, Status: clientWriteStatus, @@ -1320,7 +1341,7 @@ func (client *OpenFgaClient) WriteExecute(request SdkClientWriteRequestInterface if request.GetBody() != nil && request.GetBody().Deletes != nil { deleteRequestTupleKeys := request.GetBody().Deletes for index := 0; index < len(deleteRequestTupleKeys); index++ { - response.Deletes = append(response.Deletes, ClientWriteSingleResponse{ + response.Deletes = append(response.Deletes, ClientWriteRequestDeleteResponse{ TupleKey: deleteRequestTupleKeys[index], HttpResponse: httpResponse, Status: clientWriteStatus, @@ -1377,7 +1398,7 @@ func (client *OpenFgaClient) WriteExecute(request SdkClientWriteRequestInterface _ = writeGroup.Wait() var deleteChunkSize = int(maxPerChunk) - var deleteChunks [][]ClientWriteRequestTupleKey + var deleteChunks [][]ClientTupleKeyWithoutCondition if request.GetBody() != nil { for i := 0; i < len(request.GetBody().Deletes); i += deleteChunkSize { end := int(math.Min(float64(i+writeChunkSize), float64(len(request.GetBody().Deletes)))) @@ -1509,7 +1530,7 @@ type SdkClientDeleteTuplesRequestInterface interface { GetOptions() *ClientWriteOptions } -type ClientDeleteTuplesBody = []ClientWriteRequestTupleKey +type ClientDeleteTuplesBody = []ClientTupleKeyWithoutCondition func (client *OpenFgaClient) DeleteTuples(ctx _context.Context) SdkClientDeleteTuplesRequestInterface { return &SdkClientDeleteTuplesRequest{ diff --git a/client/client_test.go b/client/client_test.go index 8fb326c..b571fb8 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -20,7 +20,7 @@ import ( "testing" "github.com/jarcoal/httpmock" - "github.com/openfga/go-sdk" + openfga "github.com/openfga/go-sdk" . "github.com/openfga/go-sdk/client" ) @@ -800,7 +800,7 @@ func TestOpenFgaClient(t *testing.T) { Relation: "viewer", Object: "document:budget", }}, - Deletes: []ClientWriteRequestTupleKey{{ + Deletes: []ClientTupleKeyWithoutCondition{{ User: "user:81684243-9356-4421-8fbf-a4f8d36aa31b", Relation: "viewer", Object: "document:planning", @@ -972,7 +972,7 @@ func TestOpenFgaClient(t *testing.T) { RequestPath: "write", } - requestBody := []ClientWriteRequestTupleKey{{ + requestBody := []ClientTupleKeyWithoutCondition{{ User: "user:81684243-9356-4421-8fbf-a4f8d36aa31b", Relation: "viewer", Object: "document:roadmap", diff --git a/docs/TupleKeyWithoutCondition.md b/docs/TupleKeyWithoutCondition.md new file mode 100644 index 0000000..91f07a3 --- /dev/null +++ b/docs/TupleKeyWithoutCondition.md @@ -0,0 +1,93 @@ +# TupleKeyWithoutCondition + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**User** | **string** | | +**Relation** | **string** | | +**Object** | **string** | | + +## Methods + +### NewTupleKeyWithoutCondition + +`func NewTupleKeyWithoutCondition(user string, relation string, object string, ) *TupleKeyWithoutCondition` + +NewTupleKeyWithoutCondition instantiates a new TupleKeyWithoutCondition object +This constructor will assign default values to properties that have it defined, +and makes sure properties required by API are set, but the set of arguments +will change when the set of required properties is changed + +### NewTupleKeyWithoutConditionWithDefaults + +`func NewTupleKeyWithoutConditionWithDefaults() *TupleKeyWithoutCondition` + +NewTupleKeyWithoutConditionWithDefaults instantiates a new TupleKeyWithoutCondition object +This constructor will only assign default values to properties that have it defined, +but it doesn't guarantee that properties required by API are set + +### GetUser + +`func (o *TupleKeyWithoutCondition) GetUser() string` + +GetUser returns the User field if non-nil, zero value otherwise. + +### GetUserOk + +`func (o *TupleKeyWithoutCondition) GetUserOk() (*string, bool)` + +GetUserOk returns a tuple with the User field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetUser + +`func (o *TupleKeyWithoutCondition) SetUser(v string)` + +SetUser sets User field to given value. + + +### GetRelation + +`func (o *TupleKeyWithoutCondition) GetRelation() string` + +GetRelation returns the Relation field if non-nil, zero value otherwise. + +### GetRelationOk + +`func (o *TupleKeyWithoutCondition) GetRelationOk() (*string, bool)` + +GetRelationOk returns a tuple with the Relation field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetRelation + +`func (o *TupleKeyWithoutCondition) SetRelation(v string)` + +SetRelation sets Relation field to given value. + + +### GetObject + +`func (o *TupleKeyWithoutCondition) GetObject() string` + +GetObject returns the Object field if non-nil, zero value otherwise. + +### GetObjectOk + +`func (o *TupleKeyWithoutCondition) GetObjectOk() (*string, bool)` + +GetObjectOk returns a tuple with the Object field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetObject + +`func (o *TupleKeyWithoutCondition) SetObject(v string)` + +SetObject sets Object field to given value. + + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/WriteRequest.md b/docs/WriteRequest.md index f090a70..3577332 100644 --- a/docs/WriteRequest.md +++ b/docs/WriteRequest.md @@ -4,8 +4,8 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**Writes** | Pointer to [**WriteRequestTupleKeys**](WriteRequestTupleKeys.md) | | [optional] -**Deletes** | Pointer to [**WriteRequestTupleKeys**](WriteRequestTupleKeys.md) | | [optional] +**Writes** | Pointer to [**WriteRequestWrites**](WriteRequestWrites.md) | | [optional] +**Deletes** | Pointer to [**WriteRequestDeletes**](WriteRequestDeletes.md) | | [optional] **AuthorizationModelId** | Pointer to **string** | | [optional] ## Methods @@ -29,20 +29,20 @@ but it doesn't guarantee that properties required by API are set ### GetWrites -`func (o *WriteRequest) GetWrites() WriteRequestTupleKeys` +`func (o *WriteRequest) GetWrites() WriteRequestWrites` GetWrites returns the Writes field if non-nil, zero value otherwise. ### GetWritesOk -`func (o *WriteRequest) GetWritesOk() (*WriteRequestTupleKeys, bool)` +`func (o *WriteRequest) GetWritesOk() (*WriteRequestWrites, bool)` GetWritesOk returns a tuple with the Writes field if it's non-nil, zero value otherwise and a boolean to check if the value has been set. ### SetWrites -`func (o *WriteRequest) SetWrites(v WriteRequestTupleKeys)` +`func (o *WriteRequest) SetWrites(v WriteRequestWrites)` SetWrites sets Writes field to given value. @@ -54,20 +54,20 @@ HasWrites returns a boolean if a field has been set. ### GetDeletes -`func (o *WriteRequest) GetDeletes() WriteRequestTupleKeys` +`func (o *WriteRequest) GetDeletes() WriteRequestDeletes` GetDeletes returns the Deletes field if non-nil, zero value otherwise. ### GetDeletesOk -`func (o *WriteRequest) GetDeletesOk() (*WriteRequestTupleKeys, bool)` +`func (o *WriteRequest) GetDeletesOk() (*WriteRequestDeletes, bool)` GetDeletesOk returns a tuple with the Deletes field if it's non-nil, zero value otherwise and a boolean to check if the value has been set. ### SetDeletes -`func (o *WriteRequest) SetDeletes(v WriteRequestTupleKeys)` +`func (o *WriteRequest) SetDeletes(v WriteRequestDeletes)` SetDeletes sets Deletes field to given value. diff --git a/docs/WriteRequestDeletes.md b/docs/WriteRequestDeletes.md new file mode 100644 index 0000000..9ef9418 --- /dev/null +++ b/docs/WriteRequestDeletes.md @@ -0,0 +1,51 @@ +# WriteRequestDeletes + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**TupleKeys** | [**[]TupleKeyWithoutCondition**](TupleKeyWithoutCondition.md) | | + +## Methods + +### NewWriteRequestDeletes + +`func NewWriteRequestDeletes(tupleKeys []TupleKeyWithoutCondition, ) *WriteRequestDeletes` + +NewWriteRequestDeletes instantiates a new WriteRequestDeletes object +This constructor will assign default values to properties that have it defined, +and makes sure properties required by API are set, but the set of arguments +will change when the set of required properties is changed + +### NewWriteRequestDeletesWithDefaults + +`func NewWriteRequestDeletesWithDefaults() *WriteRequestDeletes` + +NewWriteRequestDeletesWithDefaults instantiates a new WriteRequestDeletes object +This constructor will only assign default values to properties that have it defined, +but it doesn't guarantee that properties required by API are set + +### GetTupleKeys + +`func (o *WriteRequestDeletes) GetTupleKeys() []TupleKeyWithoutCondition` + +GetTupleKeys returns the TupleKeys field if non-nil, zero value otherwise. + +### GetTupleKeysOk + +`func (o *WriteRequestDeletes) GetTupleKeysOk() (*[]TupleKeyWithoutCondition, bool)` + +GetTupleKeysOk returns a tuple with the TupleKeys field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetTupleKeys + +`func (o *WriteRequestDeletes) SetTupleKeys(v []TupleKeyWithoutCondition)` + +SetTupleKeys sets TupleKeys field to given value. + + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/WriteRequestTupleKeys.md b/docs/WriteRequestWrites.md similarity index 62% rename from docs/WriteRequestTupleKeys.md rename to docs/WriteRequestWrites.md index 68c4b9f..f8df60c 100644 --- a/docs/WriteRequestTupleKeys.md +++ b/docs/WriteRequestWrites.md @@ -1,4 +1,4 @@ -# WriteRequestTupleKeys +# WriteRequestWrites ## Properties @@ -8,39 +8,39 @@ Name | Type | Description | Notes ## Methods -### NewWriteRequestTupleKeys +### NewWriteRequestWrites -`func NewWriteRequestTupleKeys(tupleKeys []WriteRequestTupleKey, ) *WriteRequestTupleKeys` +`func NewWriteRequestWrites(tupleKeys []WriteRequestTupleKey, ) *WriteRequestWrites` -NewWriteRequestTupleKeys instantiates a new WriteRequestTupleKeys object +NewWriteRequestWrites instantiates a new WriteRequestWrites object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed -### NewWriteRequestTupleKeysWithDefaults +### NewWriteRequestWritesWithDefaults -`func NewWriteRequestTupleKeysWithDefaults() *WriteRequestTupleKeys` +`func NewWriteRequestWritesWithDefaults() *WriteRequestWrites` -NewWriteRequestTupleKeysWithDefaults instantiates a new WriteRequestTupleKeys object +NewWriteRequestWritesWithDefaults instantiates a new WriteRequestWrites object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set ### GetTupleKeys -`func (o *WriteRequestTupleKeys) GetTupleKeys() []WriteRequestTupleKey` +`func (o *WriteRequestWrites) GetTupleKeys() []WriteRequestTupleKey` GetTupleKeys returns the TupleKeys field if non-nil, zero value otherwise. ### GetTupleKeysOk -`func (o *WriteRequestTupleKeys) GetTupleKeysOk() (*[]WriteRequestTupleKey, bool)` +`func (o *WriteRequestWrites) GetTupleKeysOk() (*[]WriteRequestTupleKey, bool)` GetTupleKeysOk returns a tuple with the TupleKeys field if it's non-nil, zero value otherwise and a boolean to check if the value has been set. ### SetTupleKeys -`func (o *WriteRequestTupleKeys) SetTupleKeys(v []WriteRequestTupleKey)` +`func (o *WriteRequestWrites) SetTupleKeys(v []WriteRequestTupleKey)` SetTupleKeys sets TupleKeys field to given value. diff --git a/model_null_value.go b/model_null_value.go index e409c1c..a3203d9 100644 --- a/model_null_value.go +++ b/model_null_value.go @@ -17,7 +17,7 @@ import ( "fmt" ) -// NullValue `NullValue` is a singleton enumeration to represent the null value for the `Value` type union. The JSON representation for `NullValue` is JSON `null`. - NULL_VALUE: Null value. +// NullValue `NullValue` is a singleton enumeration to represent the null value for the `Value` type union. The JSON representation for `NullValue` is JSON `null`. - NULL_VALUE: Null value. type NullValue string // List of NullValue diff --git a/model_tuple_key_without_condition.go b/model_tuple_key_without_condition.go new file mode 100644 index 0000000..3e6e0d9 --- /dev/null +++ b/model_tuple_key_without_condition.go @@ -0,0 +1,160 @@ +/** + * Go SDK for OpenFGA + * + * API version: 0.1 + * Website: https://openfga.dev + * Documentation: https://openfga.dev/docs + * Support: https://discord.gg/8naAwJfWN6 + * License: [Apache-2.0](https://github.com/openfga/go-sdk/blob/main/LICENSE) + * + * NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. + */ + +package openfga + +import ( + "encoding/json" +) + +// TupleKeyWithoutCondition struct for TupleKeyWithoutCondition +type TupleKeyWithoutCondition struct { + User string `json:"user"yaml:"user"` + Relation string `json:"relation"yaml:"relation"` + Object string `json:"object"yaml:"object"` +} + +// NewTupleKeyWithoutCondition instantiates a new TupleKeyWithoutCondition object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewTupleKeyWithoutCondition(user string, relation string, object string) *TupleKeyWithoutCondition { + this := TupleKeyWithoutCondition{} + this.User = user + this.Relation = relation + this.Object = object + return &this +} + +// NewTupleKeyWithoutConditionWithDefaults instantiates a new TupleKeyWithoutCondition object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewTupleKeyWithoutConditionWithDefaults() *TupleKeyWithoutCondition { + this := TupleKeyWithoutCondition{} + return &this +} + +// GetUser returns the User field value +func (o *TupleKeyWithoutCondition) GetUser() string { + if o == nil { + var ret string + return ret + } + + return o.User +} + +// GetUserOk returns a tuple with the User field value +// and a boolean to check if the value has been set. +func (o *TupleKeyWithoutCondition) GetUserOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.User, true +} + +// SetUser sets field value +func (o *TupleKeyWithoutCondition) SetUser(v string) { + o.User = v +} + +// GetRelation returns the Relation field value +func (o *TupleKeyWithoutCondition) GetRelation() string { + if o == nil { + var ret string + return ret + } + + return o.Relation +} + +// GetRelationOk returns a tuple with the Relation field value +// and a boolean to check if the value has been set. +func (o *TupleKeyWithoutCondition) GetRelationOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Relation, true +} + +// SetRelation sets field value +func (o *TupleKeyWithoutCondition) SetRelation(v string) { + o.Relation = v +} + +// GetObject returns the Object field value +func (o *TupleKeyWithoutCondition) GetObject() string { + if o == nil { + var ret string + return ret + } + + return o.Object +} + +// GetObjectOk returns a tuple with the Object field value +// and a boolean to check if the value has been set. +func (o *TupleKeyWithoutCondition) GetObjectOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Object, true +} + +// SetObject sets field value +func (o *TupleKeyWithoutCondition) SetObject(v string) { + o.Object = v +} + +func (o TupleKeyWithoutCondition) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + toSerialize["user"] = o.User + toSerialize["relation"] = o.Relation + toSerialize["object"] = o.Object + return json.Marshal(toSerialize) +} + +type NullableTupleKeyWithoutCondition struct { + value *TupleKeyWithoutCondition + isSet bool +} + +func (v NullableTupleKeyWithoutCondition) Get() *TupleKeyWithoutCondition { + return v.value +} + +func (v *NullableTupleKeyWithoutCondition) Set(val *TupleKeyWithoutCondition) { + v.value = val + v.isSet = true +} + +func (v NullableTupleKeyWithoutCondition) IsSet() bool { + return v.isSet +} + +func (v *NullableTupleKeyWithoutCondition) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableTupleKeyWithoutCondition(val *TupleKeyWithoutCondition) *NullableTupleKeyWithoutCondition { + return &NullableTupleKeyWithoutCondition{value: val, isSet: true} +} + +func (v NullableTupleKeyWithoutCondition) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableTupleKeyWithoutCondition) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/model_write_request.go b/model_write_request.go index 7acf8b6..12843b7 100644 --- a/model_write_request.go +++ b/model_write_request.go @@ -18,9 +18,9 @@ import ( // WriteRequest struct for WriteRequest type WriteRequest struct { - Writes *WriteRequestTupleKeys `json:"writes,omitempty"yaml:"writes,omitempty"` - Deletes *WriteRequestTupleKeys `json:"deletes,omitempty"yaml:"deletes,omitempty"` - AuthorizationModelId *string `json:"authorization_model_id,omitempty"yaml:"authorization_model_id,omitempty"` + Writes *WriteRequestWrites `json:"writes,omitempty"yaml:"writes,omitempty"` + Deletes *WriteRequestDeletes `json:"deletes,omitempty"yaml:"deletes,omitempty"` + AuthorizationModelId *string `json:"authorization_model_id,omitempty"yaml:"authorization_model_id,omitempty"` } // NewWriteRequest instantiates a new WriteRequest object @@ -41,9 +41,9 @@ func NewWriteRequestWithDefaults() *WriteRequest { } // GetWrites returns the Writes field value if set, zero value otherwise. -func (o *WriteRequest) GetWrites() WriteRequestTupleKeys { +func (o *WriteRequest) GetWrites() WriteRequestWrites { if o == nil || o.Writes == nil { - var ret WriteRequestTupleKeys + var ret WriteRequestWrites return ret } return *o.Writes @@ -51,7 +51,7 @@ func (o *WriteRequest) GetWrites() WriteRequestTupleKeys { // GetWritesOk returns a tuple with the Writes field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *WriteRequest) GetWritesOk() (*WriteRequestTupleKeys, bool) { +func (o *WriteRequest) GetWritesOk() (*WriteRequestWrites, bool) { if o == nil || o.Writes == nil { return nil, false } @@ -67,15 +67,15 @@ func (o *WriteRequest) HasWrites() bool { return false } -// SetWrites gets a reference to the given WriteRequestTupleKeys and assigns it to the Writes field. -func (o *WriteRequest) SetWrites(v WriteRequestTupleKeys) { +// SetWrites gets a reference to the given WriteRequestWrites and assigns it to the Writes field. +func (o *WriteRequest) SetWrites(v WriteRequestWrites) { o.Writes = &v } // GetDeletes returns the Deletes field value if set, zero value otherwise. -func (o *WriteRequest) GetDeletes() WriteRequestTupleKeys { +func (o *WriteRequest) GetDeletes() WriteRequestDeletes { if o == nil || o.Deletes == nil { - var ret WriteRequestTupleKeys + var ret WriteRequestDeletes return ret } return *o.Deletes @@ -83,7 +83,7 @@ func (o *WriteRequest) GetDeletes() WriteRequestTupleKeys { // GetDeletesOk returns a tuple with the Deletes field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *WriteRequest) GetDeletesOk() (*WriteRequestTupleKeys, bool) { +func (o *WriteRequest) GetDeletesOk() (*WriteRequestDeletes, bool) { if o == nil || o.Deletes == nil { return nil, false } @@ -99,8 +99,8 @@ func (o *WriteRequest) HasDeletes() bool { return false } -// SetDeletes gets a reference to the given WriteRequestTupleKeys and assigns it to the Deletes field. -func (o *WriteRequest) SetDeletes(v WriteRequestTupleKeys) { +// SetDeletes gets a reference to the given WriteRequestDeletes and assigns it to the Deletes field. +func (o *WriteRequest) SetDeletes(v WriteRequestDeletes) { o.Deletes = &v } diff --git a/model_write_request_deletes.go b/model_write_request_deletes.go new file mode 100644 index 0000000..841d7f1 --- /dev/null +++ b/model_write_request_deletes.go @@ -0,0 +1,106 @@ +/** + * Go SDK for OpenFGA + * + * API version: 0.1 + * Website: https://openfga.dev + * Documentation: https://openfga.dev/docs + * Support: https://discord.gg/8naAwJfWN6 + * License: [Apache-2.0](https://github.com/openfga/go-sdk/blob/main/LICENSE) + * + * NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. + */ + +package openfga + +import ( + "encoding/json" +) + +// WriteRequestDeletes struct for WriteRequestDeletes +type WriteRequestDeletes struct { + TupleKeys []TupleKeyWithoutCondition `json:"tuple_keys"yaml:"tuple_keys"` +} + +// NewWriteRequestDeletes instantiates a new WriteRequestDeletes object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewWriteRequestDeletes(tupleKeys []TupleKeyWithoutCondition) *WriteRequestDeletes { + this := WriteRequestDeletes{} + this.TupleKeys = tupleKeys + return &this +} + +// NewWriteRequestDeletesWithDefaults instantiates a new WriteRequestDeletes object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewWriteRequestDeletesWithDefaults() *WriteRequestDeletes { + this := WriteRequestDeletes{} + return &this +} + +// GetTupleKeys returns the TupleKeys field value +func (o *WriteRequestDeletes) GetTupleKeys() []TupleKeyWithoutCondition { + if o == nil { + var ret []TupleKeyWithoutCondition + return ret + } + + return o.TupleKeys +} + +// GetTupleKeysOk returns a tuple with the TupleKeys field value +// and a boolean to check if the value has been set. +func (o *WriteRequestDeletes) GetTupleKeysOk() (*[]TupleKeyWithoutCondition, bool) { + if o == nil { + return nil, false + } + return &o.TupleKeys, true +} + +// SetTupleKeys sets field value +func (o *WriteRequestDeletes) SetTupleKeys(v []TupleKeyWithoutCondition) { + o.TupleKeys = v +} + +func (o WriteRequestDeletes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + toSerialize["tuple_keys"] = o.TupleKeys + return json.Marshal(toSerialize) +} + +type NullableWriteRequestDeletes struct { + value *WriteRequestDeletes + isSet bool +} + +func (v NullableWriteRequestDeletes) Get() *WriteRequestDeletes { + return v.value +} + +func (v *NullableWriteRequestDeletes) Set(val *WriteRequestDeletes) { + v.value = val + v.isSet = true +} + +func (v NullableWriteRequestDeletes) IsSet() bool { + return v.isSet +} + +func (v *NullableWriteRequestDeletes) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableWriteRequestDeletes(val *WriteRequestDeletes) *NullableWriteRequestDeletes { + return &NullableWriteRequestDeletes{value: val, isSet: true} +} + +func (v NullableWriteRequestDeletes) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableWriteRequestDeletes) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/model_write_request_tuple_keys.go b/model_write_request_writes.go similarity index 53% rename from model_write_request_tuple_keys.go rename to model_write_request_writes.go index 0fb3009..37305eb 100644 --- a/model_write_request_tuple_keys.go +++ b/model_write_request_writes.go @@ -16,31 +16,31 @@ import ( "encoding/json" ) -// WriteRequestTupleKeys struct for WriteRequestTupleKeys -type WriteRequestTupleKeys struct { +// WriteRequestWrites struct for WriteRequestWrites +type WriteRequestWrites struct { TupleKeys []WriteRequestTupleKey `json:"tuple_keys"yaml:"tuple_keys"` } -// NewWriteRequestTupleKeys instantiates a new WriteRequestTupleKeys object +// NewWriteRequestWrites instantiates a new WriteRequestWrites object // This constructor will assign default values to properties that have it defined, // and makes sure properties required by API are set, but the set of arguments // will change when the set of required properties is changed -func NewWriteRequestTupleKeys(tupleKeys []WriteRequestTupleKey) *WriteRequestTupleKeys { - this := WriteRequestTupleKeys{} +func NewWriteRequestWrites(tupleKeys []WriteRequestTupleKey) *WriteRequestWrites { + this := WriteRequestWrites{} this.TupleKeys = tupleKeys return &this } -// NewWriteRequestTupleKeysWithDefaults instantiates a new WriteRequestTupleKeys object +// NewWriteRequestWritesWithDefaults instantiates a new WriteRequestWrites object // This constructor will only assign default values to properties that have it defined, // but it doesn't guarantee that properties required by API are set -func NewWriteRequestTupleKeysWithDefaults() *WriteRequestTupleKeys { - this := WriteRequestTupleKeys{} +func NewWriteRequestWritesWithDefaults() *WriteRequestWrites { + this := WriteRequestWrites{} return &this } // GetTupleKeys returns the TupleKeys field value -func (o *WriteRequestTupleKeys) GetTupleKeys() []WriteRequestTupleKey { +func (o *WriteRequestWrites) GetTupleKeys() []WriteRequestTupleKey { if o == nil { var ret []WriteRequestTupleKey return ret @@ -51,7 +51,7 @@ func (o *WriteRequestTupleKeys) GetTupleKeys() []WriteRequestTupleKey { // GetTupleKeysOk returns a tuple with the TupleKeys field value // and a boolean to check if the value has been set. -func (o *WriteRequestTupleKeys) GetTupleKeysOk() (*[]WriteRequestTupleKey, bool) { +func (o *WriteRequestWrites) GetTupleKeysOk() (*[]WriteRequestTupleKey, bool) { if o == nil { return nil, false } @@ -59,48 +59,48 @@ func (o *WriteRequestTupleKeys) GetTupleKeysOk() (*[]WriteRequestTupleKey, bool) } // SetTupleKeys sets field value -func (o *WriteRequestTupleKeys) SetTupleKeys(v []WriteRequestTupleKey) { +func (o *WriteRequestWrites) SetTupleKeys(v []WriteRequestTupleKey) { o.TupleKeys = v } -func (o WriteRequestTupleKeys) MarshalJSON() ([]byte, error) { +func (o WriteRequestWrites) MarshalJSON() ([]byte, error) { toSerialize := map[string]interface{}{} toSerialize["tuple_keys"] = o.TupleKeys return json.Marshal(toSerialize) } -type NullableWriteRequestTupleKeys struct { - value *WriteRequestTupleKeys +type NullableWriteRequestWrites struct { + value *WriteRequestWrites isSet bool } -func (v NullableWriteRequestTupleKeys) Get() *WriteRequestTupleKeys { +func (v NullableWriteRequestWrites) Get() *WriteRequestWrites { return v.value } -func (v *NullableWriteRequestTupleKeys) Set(val *WriteRequestTupleKeys) { +func (v *NullableWriteRequestWrites) Set(val *WriteRequestWrites) { v.value = val v.isSet = true } -func (v NullableWriteRequestTupleKeys) IsSet() bool { +func (v NullableWriteRequestWrites) IsSet() bool { return v.isSet } -func (v *NullableWriteRequestTupleKeys) Unset() { +func (v *NullableWriteRequestWrites) Unset() { v.value = nil v.isSet = false } -func NewNullableWriteRequestTupleKeys(val *WriteRequestTupleKeys) *NullableWriteRequestTupleKeys { - return &NullableWriteRequestTupleKeys{value: val, isSet: true} +func NewNullableWriteRequestWrites(val *WriteRequestWrites) *NullableWriteRequestWrites { + return &NullableWriteRequestWrites{value: val, isSet: true} } -func (v NullableWriteRequestTupleKeys) MarshalJSON() ([]byte, error) { +func (v NullableWriteRequestWrites) MarshalJSON() ([]byte, error) { return json.Marshal(v.value) } -func (v *NullableWriteRequestTupleKeys) UnmarshalJSON(src []byte) error { +func (v *NullableWriteRequestWrites) UnmarshalJSON(src []byte) error { v.isSet = true return json.Unmarshal(src, &v.value) }