From be2d1936a0fe4691e6d21fadf06f29c3d4bf5cbd Mon Sep 17 00:00:00 2001 From: Raghd Hamzeh Date: Thu, 29 Sep 2022 17:49:25 -0400 Subject: [PATCH] chore!: rename `TypeDefinitions` interface to `WriteAuthorizationModelRequest` - Add support for metadata in authorization models - Upgrade dependencies Note: The breaking change is only on the SDKs, not the API [BREAKING CHANGE] To call WriteAuthorizationModel with this new change, check: https://github.com/openfga/go-sdk#write-authorization-model --- .openapi-generator/FILES | 10 +- README.md | 32 ++--- api_open_fga.go | 12 +- docs/AuthorizationModel.md | 26 ++++ docs/ErrorCode.md | 4 + docs/Metadata.md | 56 ++++++++ docs/OpenFgaApi.md | 8 +- docs/RelationMetadata.md | 56 ++++++++ docs/RelationReference.md | 77 +++++++++++ docs/TypeDefinition.md | 35 ++++- docs/TypeDefinitions.md | 56 -------- docs/WriteAuthorizationModelRequest.md | 82 +++++++++++ fga_test.go | 36 ++--- model_authorization_model.go | 36 +++++ model_error_code.go | 4 + model_metadata.go | 115 ++++++++++++++++ model_relation_metadata.go | 115 ++++++++++++++++ model_relation_reference.go | 144 ++++++++++++++++++++ model_type_definition.go | 71 ++++++++-- model_type_definitions.go | 115 ---------------- model_write_authorization_model_request.go | 151 +++++++++++++++++++++ 21 files changed, 1007 insertions(+), 234 deletions(-) create mode 100644 docs/Metadata.md create mode 100644 docs/RelationMetadata.md create mode 100644 docs/RelationReference.md delete mode 100644 docs/TypeDefinitions.md create mode 100644 docs/WriteAuthorizationModelRequest.md create mode 100644 model_metadata.go create mode 100644 model_relation_metadata.go create mode 100644 model_relation_reference.go delete mode 100644 model_type_definitions.go create mode 100644 model_write_authorization_model_request.go diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index 1d3a4da..f593417 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -37,6 +37,7 @@ docs/Leaf.md docs/ListObjectsRequest.md docs/ListObjectsResponse.md docs/ListStoresResponse.md +docs/Metadata.md docs/Node.md docs/Nodes.md docs/NotFoundErrorCode.md @@ -49,6 +50,8 @@ docs/ReadAuthorizationModelsResponse.md docs/ReadChangesResponse.md docs/ReadRequest.md docs/ReadResponse.md +docs/RelationMetadata.md +docs/RelationReference.md docs/Status.md docs/Store.md docs/Tuple.md @@ -58,7 +61,6 @@ docs/TupleKeys.md docs/TupleOperation.md docs/TupleToUserset.md docs/TypeDefinition.md -docs/TypeDefinitions.md docs/Users.md docs/Userset.md docs/UsersetTree.md @@ -67,6 +69,7 @@ docs/UsersetTreeTupleToUserset.md docs/Usersets.md docs/ValidationErrorMessageResponse.md docs/WriteAssertionsRequest.md +docs/WriteAuthorizationModelRequest.md docs/WriteAuthorizationModelResponse.md docs/WriteRequest.md fga_test.go @@ -93,6 +96,7 @@ model_leaf.go model_list_objects_request.go model_list_objects_response.go model_list_stores_response.go +model_metadata.go model_node.go model_nodes.go model_not_found_error_code.go @@ -104,6 +108,8 @@ model_read_authorization_models_response.go model_read_changes_response.go model_read_request.go model_read_response.go +model_relation_metadata.go +model_relation_reference.go model_status.go model_store.go model_tuple.go @@ -113,7 +119,6 @@ model_tuple_keys.go model_tuple_operation.go model_tuple_to_userset.go model_type_definition.go -model_type_definitions.go model_users.go model_userset.go model_userset_tree.go @@ -122,6 +127,7 @@ model_userset_tree_tuple_to_userset.go model_usersets.go model_validation_error_message_response.go model_write_assertions_request.go +model_write_authorization_model_request.go model_write_authorization_model_response.go model_write_request.go oauth2/LICENSE diff --git a/README.md b/README.md index 0713901..264e7ed 100644 --- a/README.md +++ b/README.md @@ -45,11 +45,6 @@ This is an autogenerated Go SDK for OpenFGA. It provides a wrapper around the [O OpenFGA is designed to make it easy for application builders to model their permission layer, and to add and integrate fine-grained authorization into their applications. OpenFGA’s design is optimized for reliability and low latency at a high scale. -It allows in-memory data storage for quick development, as well as pluggable database modules - with initial support for PostgreSQL. - -It offers an [HTTP API](https://openfga.dev/api/service) and has SDKs for programming languages including [Node.js/JavaScript](https://github.com/openfga/js-sdk), [GoLang](https://github.com/openfga/go-sdk) and [.NET](https://github.com/openfga/dotnet-sdk). - -More SDKs and integrations such as Rego are planned for the future. ## Resources @@ -237,10 +232,10 @@ if err != nil { > Learn more about [the OpenFGA configuration language](https://openfga.dev/docs/configuration-language). ```golang -body := openfga.TypeDefinitions{TypeDefinitions: &[]openfga.TypeDefinition{ +body := openfga.WriteAuthorizationModelRequest{TypeDefinitions: &[]openfga.TypeDefinition{ { Type: "repo", - Relations: map[string]openfga.Userset{ + Relations: &map[string]openfga.Userset{ "writer": {This: &map[string]interface{}{}}, "reader": {Union: &openfga.Usersets{ Child: &[]openfga.Userset{ @@ -293,7 +288,7 @@ fmt.Printf("%s", (*data.AuthorizationModelIds)[0]) // 1uHxCSuTP0VKPYSnkq1pbb1jeZ ```golang body := openfga.CheckRequest{ TupleKey: &openfga.TupleKey{ - User: openfga.PtrString("81684243-9356-4421-8fbf-a4f8d36aa31b"), + User: openfga.PtrString("user:81684243-9356-4421-8fbf-a4f8d36aa31b"), Relation: openfga.PtrString("admin"), Object: openfga.PtrString("workspace:675bcac4-ad38-4fb1-a19a-94a5648c91d6"), }, @@ -315,7 +310,7 @@ body := openfga.WriteRequest{ Writes: &openfga.TupleKeys{ TupleKeys: []openfga.TupleKey{ { - User: openfga.PtrString("81684243-9356-4421-8fbf-a4f8d36aa31b"), + User: openfga.PtrString("user:81684243-9356-4421-8fbf-a4f8d36aa31b"), Relation: openfga.PtrString("admin"), Object: openfga.PtrString("workspace:675bcac4-ad38-4fb1-a19a-94a5648c91d6"), }, @@ -335,7 +330,7 @@ body := openfga.WriteRequest{ Deletes: &openfga.TupleKeys{ TupleKeys: []openfga.TupleKey{ { - User: openfga.PtrString("81684243-9356-4421-8fbf-a4f8d36aa31b"), + User: openfga.PtrString("user:81684243-9356-4421-8fbf-a4f8d36aa31b"), Relation: openfga.PtrString("admin"), Object: openfga.PtrString("workspace:675bcac4-ad38-4fb1-a19a-94a5648c91d6"), }, @@ -359,7 +354,7 @@ body := openfga.ExpandRequest{ } data, response, err := apiClient.OpenFgaApi.Expand(context.Background()).Body(body).Execute() -// data = {"tree":{"root":{"name":"workspace:675bcac4-ad38-4fb1-a19a-94a5648c91d6#admin","leaf":{"users":{"users":["anne","beth"]}}}}} // JSON +// data = {"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"]}}}}} // JSON ``` #### Read Changes @@ -370,7 +365,7 @@ data, response, err := apiClient.OpenFgaApi.Expand(context.Background()).Body(bo // Find if a relationship tuple stating that a certain user is an admin on a certain workspace body := openfga.ReadRequest{ TupleKey: &openfga.TupleKey{ - User: openfga.PtrString("81684243-9356-4421-8fbf-a4f8d36aa31b"), + User: openfga.PtrString("user:81684243-9356-4421-8fbf-a4f8d36aa31b"), Relation: openfga.PtrString("admin"), Object: openfga.PtrString("workspace:675bcac4-ad38-4fb1-a19a-94a5648c91d6"), }, @@ -379,7 +374,7 @@ body := openfga.ReadRequest{ // Find all relationship tuples where a certain user has a relationship as any relation to a certain workspace body := openfga.ReadRequest{ TupleKey: &openfga.TupleKey{ - User: openfga.PtrString("81684243-9356-4421-8fbf-a4f8d36aa31b"), + User: openfga.PtrString("user:81684243-9356-4421-8fbf-a4f8d36aa31b"), Object: openfga.PtrString("workspace:675bcac4-ad38-4fb1-a19a-94a5648c91d6"), }, } @@ -387,7 +382,7 @@ body := openfga.ReadRequest{ // Find all relationship tuples where a certain user is an admin on any workspace body := openfga.ReadRequest{ TupleKey: &openfga.TupleKey{ - User: openfga.PtrString("81684243-9356-4421-8fbf-a4f8d36aa31b"), + User: openfga.PtrString("user:81684243-9356-4421-8fbf-a4f8d36aa31b"), Relation: openfga.PtrString("admin"), Object: openfga.PtrString("workspace:"), }, @@ -433,12 +428,12 @@ data, response, err := apiClient.OpenFgaApi.ReadChanges(context.Background()). ```golang body := openfga.ListObjectsRequest{ AuthorizationModelId: PtrString("01GAHCE4YVKPQEKZQHT2R89MQV"), - User: PtrString("anne"), + User: PtrString("user:81684243-9356-4421-8fbf-a4f8d36aa31b"), Relation: PtrString("can_read"), Type: PtrString("document"), ContextualTuples: &ContextualTupleKeys{ TupleKeys: []TupleKey{{ - User: PtrString("anne"), + User: PtrString("user:81684243-9356-4421-8fbf-a4f8d36aa31b"), Relation: PtrString("editor"), Object: PtrString("folder:product"), }, { @@ -498,6 +493,7 @@ Class | Method | HTTP request | Description - [ListObjectsRequest](docs/ListObjectsRequest.md) - [ListObjectsResponse](docs/ListObjectsResponse.md) - [ListStoresResponse](docs/ListStoresResponse.md) + - [Metadata](docs/Metadata.md) - [Node](docs/Node.md) - [Nodes](docs/Nodes.md) - [NotFoundErrorCode](docs/NotFoundErrorCode.md) @@ -509,6 +505,8 @@ Class | Method | HTTP request | Description - [ReadChangesResponse](docs/ReadChangesResponse.md) - [ReadRequest](docs/ReadRequest.md) - [ReadResponse](docs/ReadResponse.md) + - [RelationMetadata](docs/RelationMetadata.md) + - [RelationReference](docs/RelationReference.md) - [Status](docs/Status.md) - [Store](docs/Store.md) - [Tuple](docs/Tuple.md) @@ -518,7 +516,6 @@ Class | Method | HTTP request | Description - [TupleOperation](docs/TupleOperation.md) - [TupleToUserset](docs/TupleToUserset.md) - [TypeDefinition](docs/TypeDefinition.md) - - [TypeDefinitions](docs/TypeDefinitions.md) - [Users](docs/Users.md) - [Userset](docs/Userset.md) - [UsersetTree](docs/UsersetTree.md) @@ -527,6 +524,7 @@ Class | Method | HTTP request | Description - [Usersets](docs/Usersets.md) - [ValidationErrorMessageResponse](docs/ValidationErrorMessageResponse.md) - [WriteAssertionsRequest](docs/WriteAssertionsRequest.md) + - [WriteAuthorizationModelRequest](docs/WriteAuthorizationModelRequest.md) - [WriteAuthorizationModelResponse](docs/WriteAuthorizationModelResponse.md) - [WriteRequest](docs/WriteRequest.md) diff --git a/api_open_fga.go b/api_open_fga.go index 4a23680..41a841c 100644 --- a/api_open_fga.go +++ b/api_open_fga.go @@ -4578,11 +4578,11 @@ type ApiWriteAuthorizationModelRequest struct { ctx _context.Context ApiService OpenFgaApi - typeDefinitions *TypeDefinitions + body *WriteAuthorizationModelRequest } -func (r ApiWriteAuthorizationModelRequest) TypeDefinitions(typeDefinitions TypeDefinitions) ApiWriteAuthorizationModelRequest { - r.typeDefinitions = &typeDefinitions +func (r ApiWriteAuthorizationModelRequest) Body(body WriteAuthorizationModelRequest) ApiWriteAuthorizationModelRequest { + r.body = &body return r } @@ -4680,8 +4680,8 @@ func (a *OpenFgaApiService) WriteAuthorizationModelExecute(r ApiWriteAuthorizati localVarHeaderParams := make(map[string]string) localVarQueryParams := _neturl.Values{} localVarFormParams := _neturl.Values{} - if r.typeDefinitions == nil { - return localVarReturnValue, nil, reportError("typeDefinitions is required and must be specified") + if r.body == nil { + return localVarReturnValue, nil, reportError("body is required and must be specified") } // to determine the Content-Type header @@ -4702,7 +4702,7 @@ func (a *OpenFgaApiService) WriteAuthorizationModelExecute(r ApiWriteAuthorizati localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept } // body params - localVarPostBody = r.typeDefinitions + localVarPostBody = r.body req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err diff --git a/docs/AuthorizationModel.md b/docs/AuthorizationModel.md index 4a0bda7..68adb28 100644 --- a/docs/AuthorizationModel.md +++ b/docs/AuthorizationModel.md @@ -5,6 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **Id** | Pointer to **string** | | [optional] +**SchemaVersion** | Pointer to **string** | | [optional] **TypeDefinitions** | Pointer to [**[]TypeDefinition**](TypeDefinition.md) | | [optional] ## Methods @@ -51,6 +52,31 @@ SetId sets Id field to given value. HasId returns a boolean if a field has been set. +### GetSchemaVersion + +`func (o *AuthorizationModel) GetSchemaVersion() string` + +GetSchemaVersion returns the SchemaVersion field if non-nil, zero value otherwise. + +### GetSchemaVersionOk + +`func (o *AuthorizationModel) GetSchemaVersionOk() (*string, bool)` + +GetSchemaVersionOk returns a tuple with the SchemaVersion field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetSchemaVersion + +`func (o *AuthorizationModel) SetSchemaVersion(v string)` + +SetSchemaVersion sets SchemaVersion field to given value. + +### HasSchemaVersion + +`func (o *AuthorizationModel) HasSchemaVersion() bool` + +HasSchemaVersion returns a boolean if a field has been set. + ### GetTypeDefinitions `func (o *AuthorizationModel) GetTypeDefinitions() []TypeDefinition` diff --git a/docs/ErrorCode.md b/docs/ErrorCode.md index 872629c..ae16045 100644 --- a/docs/ErrorCode.md +++ b/docs/ErrorCode.md @@ -95,6 +95,10 @@ * `DUPLICATE_CONTEXTUAL_TUPLE` (value: `"duplicate_contextual_tuple"`) +* `INVALID_AUTHORIZATION_MODEL` (value: `"invalid_authorization_model"`) + +* `UNSUPPORTED_SCHEMA_VERSION` (value: `"unsupported_schema_version"`) + [[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/Metadata.md b/docs/Metadata.md new file mode 100644 index 0000000..4873c9c --- /dev/null +++ b/docs/Metadata.md @@ -0,0 +1,56 @@ +# Metadata + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Relations** | Pointer to [**map[string]RelationMetadata**](RelationMetadata.md) | | [optional] + +## Methods + +### NewMetadata + +`func NewMetadata() *Metadata` + +NewMetadata instantiates a new Metadata 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 + +### NewMetadataWithDefaults + +`func NewMetadataWithDefaults() *Metadata` + +NewMetadataWithDefaults instantiates a new Metadata 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 + +### GetRelations + +`func (o *Metadata) GetRelations() map[string]RelationMetadata` + +GetRelations returns the Relations field if non-nil, zero value otherwise. + +### GetRelationsOk + +`func (o *Metadata) GetRelationsOk() (*map[string]RelationMetadata, bool)` + +GetRelationsOk returns a tuple with the Relations field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetRelations + +`func (o *Metadata) SetRelations(v map[string]RelationMetadata)` + +SetRelations sets Relations field to given value. + +### HasRelations + +`func (o *Metadata) HasRelations() bool` + +HasRelations 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) + + diff --git a/docs/OpenFgaApi.md b/docs/OpenFgaApi.md index cd1a543..61c81d0 100644 --- a/docs/OpenFgaApi.md +++ b/docs/OpenFgaApi.md @@ -1332,7 +1332,7 @@ No authorization required ## WriteAuthorizationModel -> WriteAuthorizationModelResponse WriteAuthorizationModel(ctx).TypeDefinitions(typeDefinitions).Execute() +> WriteAuthorizationModelResponse WriteAuthorizationModel(ctx).Body(body).Execute() Create a new authorization model @@ -1352,7 +1352,7 @@ import ( func main() { - typeDefinitions := *openapiclient.NewTypeDefinitions() // TypeDefinitions | + body := *openapiclient.NewWriteAuthorizationModelRequest() // WriteAuthorizationModelRequest | configuration, err := openfga.NewConfiguration(openfga.Configuration{ ApiScheme: os.Getenv("OPENFGA_API_SCHEME"), // optional, defaults to "https" @@ -1366,7 +1366,7 @@ func main() { apiClient := openfga.NewAPIClient(configuration) - resp, r, err := apiClient.OpenFgaApi.WriteAuthorizationModel(context.Background()).TypeDefinitions(typeDefinitions).Execute() + resp, r, err := apiClient.OpenFgaApi.WriteAuthorizationModel(context.Background()).Body(body).Execute() if err != nil { fmt.Fprintf(os.Stderr, "Error when calling `OpenFgaApi.WriteAuthorizationModel``: %v\n", err) fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) @@ -1404,7 +1404,7 @@ Other parameters are passed through a pointer to a apiWriteAuthorizationModelReq Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**typeDefinitions** | [**TypeDefinitions**](TypeDefinitions.md) | | +**body** | [**WriteAuthorizationModelRequest**](WriteAuthorizationModelRequest.md) | | ### Return type diff --git a/docs/RelationMetadata.md b/docs/RelationMetadata.md new file mode 100644 index 0000000..9e12e32 --- /dev/null +++ b/docs/RelationMetadata.md @@ -0,0 +1,56 @@ +# RelationMetadata + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**DirectlyRelatedUserTypes** | Pointer to [**[]RelationReference**](RelationReference.md) | | [optional] + +## Methods + +### NewRelationMetadata + +`func NewRelationMetadata() *RelationMetadata` + +NewRelationMetadata instantiates a new RelationMetadata 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 + +### NewRelationMetadataWithDefaults + +`func NewRelationMetadataWithDefaults() *RelationMetadata` + +NewRelationMetadataWithDefaults instantiates a new RelationMetadata 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 + +### GetDirectlyRelatedUserTypes + +`func (o *RelationMetadata) GetDirectlyRelatedUserTypes() []RelationReference` + +GetDirectlyRelatedUserTypes returns the DirectlyRelatedUserTypes field if non-nil, zero value otherwise. + +### GetDirectlyRelatedUserTypesOk + +`func (o *RelationMetadata) GetDirectlyRelatedUserTypesOk() (*[]RelationReference, bool)` + +GetDirectlyRelatedUserTypesOk returns a tuple with the DirectlyRelatedUserTypes field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetDirectlyRelatedUserTypes + +`func (o *RelationMetadata) SetDirectlyRelatedUserTypes(v []RelationReference)` + +SetDirectlyRelatedUserTypes sets DirectlyRelatedUserTypes field to given value. + +### HasDirectlyRelatedUserTypes + +`func (o *RelationMetadata) HasDirectlyRelatedUserTypes() bool` + +HasDirectlyRelatedUserTypes 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) + + diff --git a/docs/RelationReference.md b/docs/RelationReference.md new file mode 100644 index 0000000..29cef8e --- /dev/null +++ b/docs/RelationReference.md @@ -0,0 +1,77 @@ +# RelationReference + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Type** | **string** | | +**Relation** | Pointer to **string** | | [optional] + +## Methods + +### NewRelationReference + +`func NewRelationReference(type_ string, ) *RelationReference` + +NewRelationReference instantiates a new RelationReference 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 + +### NewRelationReferenceWithDefaults + +`func NewRelationReferenceWithDefaults() *RelationReference` + +NewRelationReferenceWithDefaults instantiates a new RelationReference 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 + +### GetType + +`func (o *RelationReference) GetType() string` + +GetType returns the Type field if non-nil, zero value otherwise. + +### GetTypeOk + +`func (o *RelationReference) GetTypeOk() (*string, bool)` + +GetTypeOk returns a tuple with the Type field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetType + +`func (o *RelationReference) SetType(v string)` + +SetType sets Type field to given value. + + +### GetRelation + +`func (o *RelationReference) GetRelation() string` + +GetRelation returns the Relation field if non-nil, zero value otherwise. + +### GetRelationOk + +`func (o *RelationReference) 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 *RelationReference) SetRelation(v string)` + +SetRelation sets Relation field to given value. + +### HasRelation + +`func (o *RelationReference) HasRelation() bool` + +HasRelation 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) + + diff --git a/docs/TypeDefinition.md b/docs/TypeDefinition.md index 12f012d..0a8cc5b 100644 --- a/docs/TypeDefinition.md +++ b/docs/TypeDefinition.md @@ -5,13 +5,14 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **Type** | **string** | | -**Relations** | [**map[string]Userset**](Userset.md) | | +**Relations** | Pointer to [**map[string]Userset**](Userset.md) | | [optional] +**Metadata** | Pointer to [**Metadata**](Metadata.md) | | [optional] ## Methods ### NewTypeDefinition -`func NewTypeDefinition(type_ string, relations map[string]Userset, ) *TypeDefinition` +`func NewTypeDefinition(type_ string, ) *TypeDefinition` NewTypeDefinition instantiates a new TypeDefinition object This constructor will assign default values to properties that have it defined, @@ -65,6 +66,36 @@ and a boolean to check if the value has been set. SetRelations sets Relations field to given value. +### HasRelations + +`func (o *TypeDefinition) HasRelations() bool` + +HasRelations returns a boolean if a field has been set. + +### GetMetadata + +`func (o *TypeDefinition) GetMetadata() Metadata` + +GetMetadata returns the Metadata field if non-nil, zero value otherwise. + +### GetMetadataOk + +`func (o *TypeDefinition) GetMetadataOk() (*Metadata, bool)` + +GetMetadataOk returns a tuple with the Metadata field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetMetadata + +`func (o *TypeDefinition) SetMetadata(v Metadata)` + +SetMetadata sets Metadata field to given value. + +### HasMetadata + +`func (o *TypeDefinition) HasMetadata() bool` + +HasMetadata 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) diff --git a/docs/TypeDefinitions.md b/docs/TypeDefinitions.md deleted file mode 100644 index a57be9d..0000000 --- a/docs/TypeDefinitions.md +++ /dev/null @@ -1,56 +0,0 @@ -# TypeDefinitions - -## Properties - -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**TypeDefinitions** | Pointer to [**[]TypeDefinition**](TypeDefinition.md) | | [optional] - -## Methods - -### NewTypeDefinitions - -`func NewTypeDefinitions() *TypeDefinitions` - -NewTypeDefinitions instantiates a new TypeDefinitions 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 - -### NewTypeDefinitionsWithDefaults - -`func NewTypeDefinitionsWithDefaults() *TypeDefinitions` - -NewTypeDefinitionsWithDefaults instantiates a new TypeDefinitions 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 - -### GetTypeDefinitions - -`func (o *TypeDefinitions) GetTypeDefinitions() []TypeDefinition` - -GetTypeDefinitions returns the TypeDefinitions field if non-nil, zero value otherwise. - -### GetTypeDefinitionsOk - -`func (o *TypeDefinitions) GetTypeDefinitionsOk() (*[]TypeDefinition, bool)` - -GetTypeDefinitionsOk returns a tuple with the TypeDefinitions field if it's non-nil, zero value otherwise -and a boolean to check if the value has been set. - -### SetTypeDefinitions - -`func (o *TypeDefinitions) SetTypeDefinitions(v []TypeDefinition)` - -SetTypeDefinitions sets TypeDefinitions field to given value. - -### HasTypeDefinitions - -`func (o *TypeDefinitions) HasTypeDefinitions() bool` - -HasTypeDefinitions 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) - - diff --git a/docs/WriteAuthorizationModelRequest.md b/docs/WriteAuthorizationModelRequest.md new file mode 100644 index 0000000..aff3c05 --- /dev/null +++ b/docs/WriteAuthorizationModelRequest.md @@ -0,0 +1,82 @@ +# WriteAuthorizationModelRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**TypeDefinitions** | Pointer to [**[]TypeDefinition**](TypeDefinition.md) | | [optional] +**SchemaVersion** | Pointer to **string** | | [optional] + +## Methods + +### NewWriteAuthorizationModelRequest + +`func NewWriteAuthorizationModelRequest() *WriteAuthorizationModelRequest` + +NewWriteAuthorizationModelRequest instantiates a new WriteAuthorizationModelRequest 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 + +### NewWriteAuthorizationModelRequestWithDefaults + +`func NewWriteAuthorizationModelRequestWithDefaults() *WriteAuthorizationModelRequest` + +NewWriteAuthorizationModelRequestWithDefaults instantiates a new WriteAuthorizationModelRequest 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 + +### GetTypeDefinitions + +`func (o *WriteAuthorizationModelRequest) GetTypeDefinitions() []TypeDefinition` + +GetTypeDefinitions returns the TypeDefinitions field if non-nil, zero value otherwise. + +### GetTypeDefinitionsOk + +`func (o *WriteAuthorizationModelRequest) GetTypeDefinitionsOk() (*[]TypeDefinition, bool)` + +GetTypeDefinitionsOk returns a tuple with the TypeDefinitions field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetTypeDefinitions + +`func (o *WriteAuthorizationModelRequest) SetTypeDefinitions(v []TypeDefinition)` + +SetTypeDefinitions sets TypeDefinitions field to given value. + +### HasTypeDefinitions + +`func (o *WriteAuthorizationModelRequest) HasTypeDefinitions() bool` + +HasTypeDefinitions returns a boolean if a field has been set. + +### GetSchemaVersion + +`func (o *WriteAuthorizationModelRequest) GetSchemaVersion() string` + +GetSchemaVersion returns the SchemaVersion field if non-nil, zero value otherwise. + +### GetSchemaVersionOk + +`func (o *WriteAuthorizationModelRequest) GetSchemaVersionOk() (*string, bool)` + +GetSchemaVersionOk returns a tuple with the SchemaVersion field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetSchemaVersion + +`func (o *WriteAuthorizationModelRequest) SetSchemaVersion(v string)` + +SetSchemaVersion sets SchemaVersion field to given value. + +### HasSchemaVersion + +`func (o *WriteAuthorizationModelRequest) HasSchemaVersion() bool` + +HasSchemaVersion 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) + + diff --git a/fga_test.go b/fga_test.go index faeee80..cd4f99d 100644 --- a/fga_test.go +++ b/fga_test.go @@ -453,10 +453,10 @@ func TestOpenFgaApi(t *testing.T) { Method: "POST", RequestPath: "authorization-models", } - requestBody := TypeDefinitions{ + requestBody := WriteAuthorizationModelRequest{ TypeDefinitions: &[]TypeDefinition{{ Type: "github-repo", - Relations: map[string]Userset{ + Relations: &map[string]Userset{ "repo_writer": { This: &map[string]interface{}{}, }, @@ -489,7 +489,7 @@ func TestOpenFgaApi(t *testing.T) { return resp, nil }, ) - got, response, err := apiClient.OpenFgaApi.WriteAuthorizationModel(context.Background()).TypeDefinitions(requestBody).Execute() + got, response, err := apiClient.OpenFgaApi.WriteAuthorizationModel(context.Background()).Body(requestBody).Execute() if err != nil { t.Fatalf("%v", err) } @@ -559,7 +559,7 @@ func TestOpenFgaApi(t *testing.T) { } requestBody := CheckRequest{ TupleKey: &TupleKey{ - User: PtrString("anne"), + User: PtrString("user:81684243-9356-4421-8fbf-a4f8d36aa31b"), Relation: PtrString("viewer"), Object: PtrString("document:roadmap"), }, @@ -611,7 +611,7 @@ func TestOpenFgaApi(t *testing.T) { requestBody := WriteRequest{ Writes: &TupleKeys{ TupleKeys: []TupleKey{{ - User: PtrString("anne"), + User: PtrString("user:81684243-9356-4421-8fbf-a4f8d36aa31b"), Relation: PtrString("viewer"), Object: PtrString("document:roadmap"), }}, @@ -656,7 +656,7 @@ func TestOpenFgaApi(t *testing.T) { requestBody := WriteRequest{ Deletes: &TupleKeys{ TupleKeys: []TupleKey{{ - User: PtrString("anne"), + User: PtrString("user:81684243-9356-4421-8fbf-a4f8d36aa31b"), Relation: PtrString("viewer"), Object: PtrString("document:roadmap"), }}, @@ -692,7 +692,7 @@ func TestOpenFgaApi(t *testing.T) { t.Run("Expand", func(t *testing.T) { test := TestDefinition{ Name: "Expand", - JsonResponse: `{"tree":{"root":{"name":"document:roadmap#viewer","union":{"nodes":[{"name": "document:roadmap#viewer","leaf":{"users":{"users":["anne"]}}}]}}}}`, + JsonResponse: `{"tree":{"root":{"name":"document:roadmap#viewer","union":{"nodes":[{"name": "document:roadmap#viewer","leaf":{"users":{"users":["user:81684243-9356-4421-8fbf-a4f8d36aa31b"]}}}]}}}}`, ResponseStatus: 200, Method: "POST", RequestPath: "expand", @@ -739,7 +739,7 @@ func TestOpenFgaApi(t *testing.T) { t.Run("Read", func(t *testing.T) { test := TestDefinition{ Name: "Read", - JsonResponse: `{"tuples":[{"key":{"user":"anne","relation":"viewer","object":"document:roadmap"},"timestamp": "2000-01-01T00:00:00Z"}]}`, + JsonResponse: `{"tuples":[{"key":{"user":"user:81684243-9356-4421-8fbf-a4f8d36aa31b","relation":"viewer","object":"document:roadmap"},"timestamp": "2000-01-01T00:00:00Z"}]}`, ResponseStatus: 200, Method: "POST", RequestPath: "read", @@ -747,7 +747,7 @@ func TestOpenFgaApi(t *testing.T) { requestBody := ReadRequest{ TupleKey: &TupleKey{ - User: PtrString("anne"), + User: PtrString("user:81684243-9356-4421-8fbf-a4f8d36aa31b"), Relation: PtrString("viewer"), Object: PtrString("document:roadmap"), }, @@ -791,7 +791,7 @@ func TestOpenFgaApi(t *testing.T) { t.Run("ReadChanges", func(t *testing.T) { test := TestDefinition{ Name: "ReadChanges", - JsonResponse: `{"changes":[{"tuple_key":{"user":"anne","relation":"viewer","object":"document:roadmap"},"operation":"TUPLE_OPERATION_WRITE","timestamp": "2000-01-01T00:00:00Z"}],"continuation_token":"eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ=="}`, + JsonResponse: `{"changes":[{"tuple_key":{"user":"user:81684243-9356-4421-8fbf-a4f8d36aa31b","relation":"viewer","object":"document:roadmap"},"operation":"TUPLE_OPERATION_WRITE","timestamp": "2000-01-01T00:00:00Z"}],"continuation_token":"eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ=="}`, ResponseStatus: 200, Method: "GET", RequestPath: "changes", @@ -847,12 +847,12 @@ func TestOpenFgaApi(t *testing.T) { requestBody := ListObjectsRequest{ AuthorizationModelId: PtrString("01GAHCE4YVKPQEKZQHT2R89MQV"), - User: PtrString("anne"), + User: PtrString("user:81684243-9356-4421-8fbf-a4f8d36aa31b"), Relation: PtrString("can_read"), Type: PtrString("document"), ContextualTuples: &ContextualTupleKeys{ TupleKeys: []TupleKey{{ - User: PtrString("anne"), + User: PtrString("user:81684243-9356-4421-8fbf-a4f8d36aa31b"), Relation: PtrString("editor"), Object: PtrString("folder:product"), }, { @@ -910,7 +910,7 @@ func TestOpenFgaApi(t *testing.T) { } requestBody := CheckRequest{ TupleKey: &TupleKey{ - User: PtrString("anne"), + User: PtrString("user:81684243-9356-4421-8fbf-a4f8d36aa31b"), Relation: PtrString("viewer"), Object: PtrString("document:roadmap"), }, @@ -973,7 +973,7 @@ func TestOpenFgaApi(t *testing.T) { } requestBody := CheckRequest{ TupleKey: &TupleKey{ - User: PtrString("anne"), + User: PtrString("user:81684243-9356-4421-8fbf-a4f8d36aa31b"), Relation: PtrString("viewer"), Object: PtrString("document:roadmap"), }, @@ -1029,7 +1029,7 @@ func TestOpenFgaApi(t *testing.T) { } requestBody := CheckRequest{ TupleKey: &TupleKey{ - User: PtrString("anne"), + User: PtrString("user:81684243-9356-4421-8fbf-a4f8d36aa31b"), Relation: PtrString("viewer"), Object: PtrString("document:roadmap"), }, @@ -1092,7 +1092,7 @@ func TestOpenFgaApi(t *testing.T) { } requestBody := CheckRequest{ TupleKey: &TupleKey{ - User: PtrString("anne"), + User: PtrString("user:81684243-9356-4421-8fbf-a4f8d36aa31b"), Relation: PtrString("viewer"), Object: PtrString("document:roadmap"), }, @@ -1163,7 +1163,7 @@ func TestOpenFgaApi(t *testing.T) { } requestBody := CheckRequest{ TupleKey: &TupleKey{ - User: PtrString("anne"), + User: PtrString("user:81684243-9356-4421-8fbf-a4f8d36aa31b"), Relation: PtrString("viewer"), Object: PtrString("document:roadmap"), }, @@ -1225,7 +1225,7 @@ func TestOpenFgaApi(t *testing.T) { } requestBody := CheckRequest{ TupleKey: &TupleKey{ - User: PtrString("anne"), + User: PtrString("user:81684243-9356-4421-8fbf-a4f8d36aa31b"), Relation: PtrString("viewer"), Object: PtrString("document:roadmap"), }, diff --git a/model_authorization_model.go b/model_authorization_model.go index a829f23..a7341d1 100644 --- a/model_authorization_model.go +++ b/model_authorization_model.go @@ -19,6 +19,7 @@ import ( // AuthorizationModel struct for AuthorizationModel type AuthorizationModel struct { Id *string `json:"id,omitempty"` + SchemaVersion *string `json:"schema_version,omitempty"` TypeDefinitions *[]TypeDefinition `json:"type_definitions,omitempty"` } @@ -71,6 +72,38 @@ func (o *AuthorizationModel) SetId(v string) { o.Id = &v } +// GetSchemaVersion returns the SchemaVersion field value if set, zero value otherwise. +func (o *AuthorizationModel) GetSchemaVersion() string { + if o == nil || o.SchemaVersion == nil { + var ret string + return ret + } + return *o.SchemaVersion +} + +// GetSchemaVersionOk returns a tuple with the SchemaVersion field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *AuthorizationModel) GetSchemaVersionOk() (*string, bool) { + if o == nil || o.SchemaVersion == nil { + return nil, false + } + return o.SchemaVersion, true +} + +// HasSchemaVersion returns a boolean if a field has been set. +func (o *AuthorizationModel) HasSchemaVersion() bool { + if o != nil && o.SchemaVersion != nil { + return true + } + + return false +} + +// SetSchemaVersion gets a reference to the given string and assigns it to the SchemaVersion field. +func (o *AuthorizationModel) SetSchemaVersion(v string) { + o.SchemaVersion = &v +} + // GetTypeDefinitions returns the TypeDefinitions field value if set, zero value otherwise. func (o *AuthorizationModel) GetTypeDefinitions() []TypeDefinition { if o == nil || o.TypeDefinitions == nil { @@ -108,6 +141,9 @@ func (o AuthorizationModel) MarshalJSON() ([]byte, error) { if o.Id != nil { toSerialize["id"] = o.Id } + if o.SchemaVersion != nil { + toSerialize["schema_version"] = o.SchemaVersion + } if o.TypeDefinitions != nil { toSerialize["type_definitions"] = o.TypeDefinitions } diff --git a/model_error_code.go b/model_error_code.go index 7873952..54f0f62 100644 --- a/model_error_code.go +++ b/model_error_code.go @@ -68,6 +68,8 @@ const ( EXCEEDED_ENTITY_LIMIT ErrorCode = "exceeded_entity_limit" INVALID_CONTEXTUAL_TUPLE ErrorCode = "invalid_contextual_tuple" DUPLICATE_CONTEXTUAL_TUPLE ErrorCode = "duplicate_contextual_tuple" + INVALID_AUTHORIZATION_MODEL ErrorCode = "invalid_authorization_model" + UNSUPPORTED_SCHEMA_VERSION ErrorCode = "unsupported_schema_version" ) var allowedErrorCodeEnumValues = []ErrorCode{ @@ -117,6 +119,8 @@ var allowedErrorCodeEnumValues = []ErrorCode{ "exceeded_entity_limit", "invalid_contextual_tuple", "duplicate_contextual_tuple", + "invalid_authorization_model", + "unsupported_schema_version", } func (v *ErrorCode) UnmarshalJSON(src []byte) error { diff --git a/model_metadata.go b/model_metadata.go new file mode 100644 index 0000000..c2a6d98 --- /dev/null +++ b/model_metadata.go @@ -0,0 +1,115 @@ +/** + * 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" +) + +// Metadata struct for Metadata +type Metadata struct { + Relations *map[string]RelationMetadata `json:"relations,omitempty"` +} + +// NewMetadata instantiates a new Metadata 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 NewMetadata() *Metadata { + this := Metadata{} + return &this +} + +// NewMetadataWithDefaults instantiates a new Metadata 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 NewMetadataWithDefaults() *Metadata { + this := Metadata{} + return &this +} + +// GetRelations returns the Relations field value if set, zero value otherwise. +func (o *Metadata) GetRelations() map[string]RelationMetadata { + if o == nil || o.Relations == nil { + var ret map[string]RelationMetadata + return ret + } + return *o.Relations +} + +// GetRelationsOk returns a tuple with the Relations field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Metadata) GetRelationsOk() (*map[string]RelationMetadata, bool) { + if o == nil || o.Relations == nil { + return nil, false + } + return o.Relations, true +} + +// HasRelations returns a boolean if a field has been set. +func (o *Metadata) HasRelations() bool { + if o != nil && o.Relations != nil { + return true + } + + return false +} + +// SetRelations gets a reference to the given map[string]RelationMetadata and assigns it to the Relations field. +func (o *Metadata) SetRelations(v map[string]RelationMetadata) { + o.Relations = &v +} + +func (o Metadata) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.Relations != nil { + toSerialize["relations"] = o.Relations + } + return json.Marshal(toSerialize) +} + +type NullableMetadata struct { + value *Metadata + isSet bool +} + +func (v NullableMetadata) Get() *Metadata { + return v.value +} + +func (v *NullableMetadata) Set(val *Metadata) { + v.value = val + v.isSet = true +} + +func (v NullableMetadata) IsSet() bool { + return v.isSet +} + +func (v *NullableMetadata) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableMetadata(val *Metadata) *NullableMetadata { + return &NullableMetadata{value: val, isSet: true} +} + +func (v NullableMetadata) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableMetadata) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/model_relation_metadata.go b/model_relation_metadata.go new file mode 100644 index 0000000..7dc578a --- /dev/null +++ b/model_relation_metadata.go @@ -0,0 +1,115 @@ +/** + * 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" +) + +// RelationMetadata struct for RelationMetadata +type RelationMetadata struct { + DirectlyRelatedUserTypes *[]RelationReference `json:"directly_related_user_types,omitempty"` +} + +// NewRelationMetadata instantiates a new RelationMetadata 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 NewRelationMetadata() *RelationMetadata { + this := RelationMetadata{} + return &this +} + +// NewRelationMetadataWithDefaults instantiates a new RelationMetadata 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 NewRelationMetadataWithDefaults() *RelationMetadata { + this := RelationMetadata{} + return &this +} + +// GetDirectlyRelatedUserTypes returns the DirectlyRelatedUserTypes field value if set, zero value otherwise. +func (o *RelationMetadata) GetDirectlyRelatedUserTypes() []RelationReference { + if o == nil || o.DirectlyRelatedUserTypes == nil { + var ret []RelationReference + return ret + } + return *o.DirectlyRelatedUserTypes +} + +// GetDirectlyRelatedUserTypesOk returns a tuple with the DirectlyRelatedUserTypes field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *RelationMetadata) GetDirectlyRelatedUserTypesOk() (*[]RelationReference, bool) { + if o == nil || o.DirectlyRelatedUserTypes == nil { + return nil, false + } + return o.DirectlyRelatedUserTypes, true +} + +// HasDirectlyRelatedUserTypes returns a boolean if a field has been set. +func (o *RelationMetadata) HasDirectlyRelatedUserTypes() bool { + if o != nil && o.DirectlyRelatedUserTypes != nil { + return true + } + + return false +} + +// SetDirectlyRelatedUserTypes gets a reference to the given []RelationReference and assigns it to the DirectlyRelatedUserTypes field. +func (o *RelationMetadata) SetDirectlyRelatedUserTypes(v []RelationReference) { + o.DirectlyRelatedUserTypes = &v +} + +func (o RelationMetadata) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.DirectlyRelatedUserTypes != nil { + toSerialize["directly_related_user_types"] = o.DirectlyRelatedUserTypes + } + return json.Marshal(toSerialize) +} + +type NullableRelationMetadata struct { + value *RelationMetadata + isSet bool +} + +func (v NullableRelationMetadata) Get() *RelationMetadata { + return v.value +} + +func (v *NullableRelationMetadata) Set(val *RelationMetadata) { + v.value = val + v.isSet = true +} + +func (v NullableRelationMetadata) IsSet() bool { + return v.isSet +} + +func (v *NullableRelationMetadata) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableRelationMetadata(val *RelationMetadata) *NullableRelationMetadata { + return &NullableRelationMetadata{value: val, isSet: true} +} + +func (v NullableRelationMetadata) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableRelationMetadata) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/model_relation_reference.go b/model_relation_reference.go new file mode 100644 index 0000000..5c37792 --- /dev/null +++ b/model_relation_reference.go @@ -0,0 +1,144 @@ +/** + * 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" +) + +// RelationReference RelationReference represents a relation of a particular object type (e.g. 'document#viewer'). +type RelationReference struct { + Type string `json:"type"` + Relation *string `json:"relation,omitempty"` +} + +// NewRelationReference instantiates a new RelationReference 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 NewRelationReference(type_ string) *RelationReference { + this := RelationReference{} + this.Type = type_ + return &this +} + +// NewRelationReferenceWithDefaults instantiates a new RelationReference 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 NewRelationReferenceWithDefaults() *RelationReference { + this := RelationReference{} + return &this +} + +// GetType returns the Type field value +func (o *RelationReference) GetType() string { + if o == nil { + var ret string + return ret + } + + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *RelationReference) GetTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value +func (o *RelationReference) SetType(v string) { + o.Type = v +} + +// GetRelation returns the Relation field value if set, zero value otherwise. +func (o *RelationReference) GetRelation() string { + if o == nil || o.Relation == nil { + var ret string + return ret + } + return *o.Relation +} + +// GetRelationOk returns a tuple with the Relation field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *RelationReference) GetRelationOk() (*string, bool) { + if o == nil || o.Relation == nil { + return nil, false + } + return o.Relation, true +} + +// HasRelation returns a boolean if a field has been set. +func (o *RelationReference) HasRelation() bool { + if o != nil && o.Relation != nil { + return true + } + + return false +} + +// SetRelation gets a reference to the given string and assigns it to the Relation field. +func (o *RelationReference) SetRelation(v string) { + o.Relation = &v +} + +func (o RelationReference) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if true { + toSerialize["type"] = o.Type + } + if o.Relation != nil { + toSerialize["relation"] = o.Relation + } + return json.Marshal(toSerialize) +} + +type NullableRelationReference struct { + value *RelationReference + isSet bool +} + +func (v NullableRelationReference) Get() *RelationReference { + return v.value +} + +func (v *NullableRelationReference) Set(val *RelationReference) { + v.value = val + v.isSet = true +} + +func (v NullableRelationReference) IsSet() bool { + return v.isSet +} + +func (v *NullableRelationReference) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableRelationReference(val *RelationReference) *NullableRelationReference { + return &NullableRelationReference{value: val, isSet: true} +} + +func (v NullableRelationReference) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableRelationReference) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/model_type_definition.go b/model_type_definition.go index 850a36f..611e90d 100644 --- a/model_type_definition.go +++ b/model_type_definition.go @@ -18,18 +18,18 @@ import ( // TypeDefinition struct for TypeDefinition type TypeDefinition struct { - Type string `json:"type"` - Relations map[string]Userset `json:"relations"` + Type string `json:"type"` + Relations *map[string]Userset `json:"relations,omitempty"` + Metadata *Metadata `json:"metadata,omitempty"` } // NewTypeDefinition instantiates a new TypeDefinition 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 NewTypeDefinition(type_ string, relations map[string]Userset) *TypeDefinition { +func NewTypeDefinition(type_ string) *TypeDefinition { this := TypeDefinition{} this.Type = type_ - this.Relations = relations return &this } @@ -65,28 +65,68 @@ func (o *TypeDefinition) SetType(v string) { o.Type = v } -// GetRelations returns the Relations field value +// GetRelations returns the Relations field value if set, zero value otherwise. func (o *TypeDefinition) GetRelations() map[string]Userset { - if o == nil { + if o == nil || o.Relations == nil { var ret map[string]Userset return ret } - - return o.Relations + return *o.Relations } -// GetRelationsOk returns a tuple with the Relations field value +// GetRelationsOk returns a tuple with the Relations field value if set, nil otherwise // and a boolean to check if the value has been set. func (o *TypeDefinition) GetRelationsOk() (*map[string]Userset, bool) { - if o == nil { + if o == nil || o.Relations == nil { return nil, false } - return &o.Relations, true + return o.Relations, true +} + +// HasRelations returns a boolean if a field has been set. +func (o *TypeDefinition) HasRelations() bool { + if o != nil && o.Relations != nil { + return true + } + + return false } -// SetRelations sets field value +// SetRelations gets a reference to the given map[string]Userset and assigns it to the Relations field. func (o *TypeDefinition) SetRelations(v map[string]Userset) { - o.Relations = v + o.Relations = &v +} + +// GetMetadata returns the Metadata field value if set, zero value otherwise. +func (o *TypeDefinition) GetMetadata() Metadata { + if o == nil || o.Metadata == nil { + var ret Metadata + return ret + } + return *o.Metadata +} + +// GetMetadataOk returns a tuple with the Metadata field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TypeDefinition) GetMetadataOk() (*Metadata, bool) { + if o == nil || o.Metadata == nil { + return nil, false + } + return o.Metadata, true +} + +// HasMetadata returns a boolean if a field has been set. +func (o *TypeDefinition) HasMetadata() bool { + if o != nil && o.Metadata != nil { + return true + } + + return false +} + +// SetMetadata gets a reference to the given Metadata and assigns it to the Metadata field. +func (o *TypeDefinition) SetMetadata(v Metadata) { + o.Metadata = &v } func (o TypeDefinition) MarshalJSON() ([]byte, error) { @@ -94,9 +134,12 @@ func (o TypeDefinition) MarshalJSON() ([]byte, error) { if true { toSerialize["type"] = o.Type } - if true { + if o.Relations != nil { toSerialize["relations"] = o.Relations } + if o.Metadata != nil { + toSerialize["metadata"] = o.Metadata + } return json.Marshal(toSerialize) } diff --git a/model_type_definitions.go b/model_type_definitions.go deleted file mode 100644 index 8016608..0000000 --- a/model_type_definitions.go +++ /dev/null @@ -1,115 +0,0 @@ -/** - * 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" -) - -// TypeDefinitions struct for TypeDefinitions -type TypeDefinitions struct { - TypeDefinitions *[]TypeDefinition `json:"type_definitions,omitempty"` -} - -// NewTypeDefinitions instantiates a new TypeDefinitions 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 NewTypeDefinitions() *TypeDefinitions { - this := TypeDefinitions{} - return &this -} - -// NewTypeDefinitionsWithDefaults instantiates a new TypeDefinitions 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 NewTypeDefinitionsWithDefaults() *TypeDefinitions { - this := TypeDefinitions{} - return &this -} - -// GetTypeDefinitions returns the TypeDefinitions field value if set, zero value otherwise. -func (o *TypeDefinitions) GetTypeDefinitions() []TypeDefinition { - if o == nil || o.TypeDefinitions == nil { - var ret []TypeDefinition - return ret - } - return *o.TypeDefinitions -} - -// GetTypeDefinitionsOk returns a tuple with the TypeDefinitions field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *TypeDefinitions) GetTypeDefinitionsOk() (*[]TypeDefinition, bool) { - if o == nil || o.TypeDefinitions == nil { - return nil, false - } - return o.TypeDefinitions, true -} - -// HasTypeDefinitions returns a boolean if a field has been set. -func (o *TypeDefinitions) HasTypeDefinitions() bool { - if o != nil && o.TypeDefinitions != nil { - return true - } - - return false -} - -// SetTypeDefinitions gets a reference to the given []TypeDefinition and assigns it to the TypeDefinitions field. -func (o *TypeDefinitions) SetTypeDefinitions(v []TypeDefinition) { - o.TypeDefinitions = &v -} - -func (o TypeDefinitions) MarshalJSON() ([]byte, error) { - toSerialize := map[string]interface{}{} - if o.TypeDefinitions != nil { - toSerialize["type_definitions"] = o.TypeDefinitions - } - return json.Marshal(toSerialize) -} - -type NullableTypeDefinitions struct { - value *TypeDefinitions - isSet bool -} - -func (v NullableTypeDefinitions) Get() *TypeDefinitions { - return v.value -} - -func (v *NullableTypeDefinitions) Set(val *TypeDefinitions) { - v.value = val - v.isSet = true -} - -func (v NullableTypeDefinitions) IsSet() bool { - return v.isSet -} - -func (v *NullableTypeDefinitions) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableTypeDefinitions(val *TypeDefinitions) *NullableTypeDefinitions { - return &NullableTypeDefinitions{value: val, isSet: true} -} - -func (v NullableTypeDefinitions) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableTypeDefinitions) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} diff --git a/model_write_authorization_model_request.go b/model_write_authorization_model_request.go new file mode 100644 index 0000000..0b7cd83 --- /dev/null +++ b/model_write_authorization_model_request.go @@ -0,0 +1,151 @@ +/** + * 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" +) + +// WriteAuthorizationModelRequest struct for WriteAuthorizationModelRequest +type WriteAuthorizationModelRequest struct { + TypeDefinitions *[]TypeDefinition `json:"type_definitions,omitempty"` + SchemaVersion *string `json:"schema_version,omitempty"` +} + +// NewWriteAuthorizationModelRequest instantiates a new WriteAuthorizationModelRequest 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 NewWriteAuthorizationModelRequest() *WriteAuthorizationModelRequest { + this := WriteAuthorizationModelRequest{} + return &this +} + +// NewWriteAuthorizationModelRequestWithDefaults instantiates a new WriteAuthorizationModelRequest 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 NewWriteAuthorizationModelRequestWithDefaults() *WriteAuthorizationModelRequest { + this := WriteAuthorizationModelRequest{} + return &this +} + +// GetTypeDefinitions returns the TypeDefinitions field value if set, zero value otherwise. +func (o *WriteAuthorizationModelRequest) GetTypeDefinitions() []TypeDefinition { + if o == nil || o.TypeDefinitions == nil { + var ret []TypeDefinition + return ret + } + return *o.TypeDefinitions +} + +// GetTypeDefinitionsOk returns a tuple with the TypeDefinitions field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *WriteAuthorizationModelRequest) GetTypeDefinitionsOk() (*[]TypeDefinition, bool) { + if o == nil || o.TypeDefinitions == nil { + return nil, false + } + return o.TypeDefinitions, true +} + +// HasTypeDefinitions returns a boolean if a field has been set. +func (o *WriteAuthorizationModelRequest) HasTypeDefinitions() bool { + if o != nil && o.TypeDefinitions != nil { + return true + } + + return false +} + +// SetTypeDefinitions gets a reference to the given []TypeDefinition and assigns it to the TypeDefinitions field. +func (o *WriteAuthorizationModelRequest) SetTypeDefinitions(v []TypeDefinition) { + o.TypeDefinitions = &v +} + +// GetSchemaVersion returns the SchemaVersion field value if set, zero value otherwise. +func (o *WriteAuthorizationModelRequest) GetSchemaVersion() string { + if o == nil || o.SchemaVersion == nil { + var ret string + return ret + } + return *o.SchemaVersion +} + +// GetSchemaVersionOk returns a tuple with the SchemaVersion field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *WriteAuthorizationModelRequest) GetSchemaVersionOk() (*string, bool) { + if o == nil || o.SchemaVersion == nil { + return nil, false + } + return o.SchemaVersion, true +} + +// HasSchemaVersion returns a boolean if a field has been set. +func (o *WriteAuthorizationModelRequest) HasSchemaVersion() bool { + if o != nil && o.SchemaVersion != nil { + return true + } + + return false +} + +// SetSchemaVersion gets a reference to the given string and assigns it to the SchemaVersion field. +func (o *WriteAuthorizationModelRequest) SetSchemaVersion(v string) { + o.SchemaVersion = &v +} + +func (o WriteAuthorizationModelRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.TypeDefinitions != nil { + toSerialize["type_definitions"] = o.TypeDefinitions + } + if o.SchemaVersion != nil { + toSerialize["schema_version"] = o.SchemaVersion + } + return json.Marshal(toSerialize) +} + +type NullableWriteAuthorizationModelRequest struct { + value *WriteAuthorizationModelRequest + isSet bool +} + +func (v NullableWriteAuthorizationModelRequest) Get() *WriteAuthorizationModelRequest { + return v.value +} + +func (v *NullableWriteAuthorizationModelRequest) Set(val *WriteAuthorizationModelRequest) { + v.value = val + v.isSet = true +} + +func (v NullableWriteAuthorizationModelRequest) IsSet() bool { + return v.isSet +} + +func (v *NullableWriteAuthorizationModelRequest) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableWriteAuthorizationModelRequest(val *WriteAuthorizationModelRequest) *NullableWriteAuthorizationModelRequest { + return &NullableWriteAuthorizationModelRequest{value: val, isSet: true} +} + +func (v NullableWriteAuthorizationModelRequest) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableWriteAuthorizationModelRequest) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +}