From 450b68899ca7c31a72ca18c29505dd104d0d1530 Mon Sep 17 00:00:00 2001 From: Evan Sims Date: Wed, 3 Apr 2024 20:46:53 -0500 Subject: [PATCH] feat: add support for modular models metadata --- .openapi-generator/FILES | 4 + README.md | 2 + docs/Condition.md | 1 + docs/ConditionMetadata.md | 11 ++ docs/Metadata.md | 2 + docs/RelationMetadata.md | 2 + docs/SourceInfo.md | 10 ++ src/OpenFga.Sdk/Model/Condition.cs | 20 ++- src/OpenFga.Sdk/Model/ConditionMetadata.cs | 147 +++++++++++++++++++++ src/OpenFga.Sdk/Model/Metadata.cs | 38 +++++- src/OpenFga.Sdk/Model/RelationMetadata.cs | 38 +++++- src/OpenFga.Sdk/Model/SourceInfo.cs | 129 ++++++++++++++++++ 12 files changed, 401 insertions(+), 3 deletions(-) create mode 100644 docs/ConditionMetadata.md create mode 100644 docs/SourceInfo.md create mode 100644 src/OpenFga.Sdk/Model/ConditionMetadata.cs create mode 100644 src/OpenFga.Sdk/Model/SourceInfo.cs diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index 76d6536..a744b1a 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -26,6 +26,7 @@ docs/CheckRequestTupleKey.md docs/CheckResponse.md docs/Computed.md docs/Condition.md +docs/ConditionMetadata.md docs/ConditionParamTypeRef.md docs/ContextualTupleKeys.md docs/CreateStoreRequest.md @@ -60,6 +61,7 @@ docs/ReadResponse.md docs/RelationMetadata.md docs/RelationReference.md docs/RelationshipCondition.md +docs/SourceInfo.md docs/Status.md docs/Store.md docs/Tuple.md @@ -160,6 +162,7 @@ src/OpenFga.Sdk/Model/CheckRequestTupleKey.cs src/OpenFga.Sdk/Model/CheckResponse.cs src/OpenFga.Sdk/Model/Computed.cs src/OpenFga.Sdk/Model/Condition.cs +src/OpenFga.Sdk/Model/ConditionMetadata.cs src/OpenFga.Sdk/Model/ConditionParamTypeRef.cs src/OpenFga.Sdk/Model/ContextualTupleKeys.cs src/OpenFga.Sdk/Model/CreateStoreRequest.cs @@ -194,6 +197,7 @@ src/OpenFga.Sdk/Model/ReadResponse.cs src/OpenFga.Sdk/Model/RelationMetadata.cs src/OpenFga.Sdk/Model/RelationReference.cs src/OpenFga.Sdk/Model/RelationshipCondition.cs +src/OpenFga.Sdk/Model/SourceInfo.cs src/OpenFga.Sdk/Model/Status.cs src/OpenFga.Sdk/Model/Store.cs src/OpenFga.Sdk/Model/Tuple.cs diff --git a/README.md b/README.md index 9f3b42a..635ee79 100644 --- a/README.md +++ b/README.md @@ -812,6 +812,7 @@ namespace Example { - [Model.CheckResponse](docs/CheckResponse.md) - [Model.Computed](docs/Computed.md) - [Model.Condition](docs/Condition.md) + - [Model.ConditionMetadata](docs/ConditionMetadata.md) - [Model.ConditionParamTypeRef](docs/ConditionParamTypeRef.md) - [Model.ContextualTupleKeys](docs/ContextualTupleKeys.md) - [Model.CreateStoreRequest](docs/CreateStoreRequest.md) @@ -845,6 +846,7 @@ namespace Example { - [Model.RelationMetadata](docs/RelationMetadata.md) - [Model.RelationReference](docs/RelationReference.md) - [Model.RelationshipCondition](docs/RelationshipCondition.md) + - [Model.SourceInfo](docs/SourceInfo.md) - [Model.Status](docs/Status.md) - [Model.Store](docs/Store.md) - [Model.Tuple](docs/Tuple.md) diff --git a/docs/Condition.md b/docs/Condition.md index 7f072d9..697b151 100644 --- a/docs/Condition.md +++ b/docs/Condition.md @@ -7,6 +7,7 @@ Name | Type | Description | Notes **Name** | **string** | | **Expression** | **string** | A Google CEL expression, expressed as a string. | **Parameters** | [**Dictionary<string, ConditionParamTypeRef>**](ConditionParamTypeRef.md) | A map of parameter names to the parameter's defined type reference. | [optional] +**Metadata** | [**ConditionMetadata**](ConditionMetadata.md) | | [optional] [[Back to Model list]](../README.md#models) [[Back to API list]](../README.md#api-endpoints) [[Back to README]](../README.md) diff --git a/docs/ConditionMetadata.md b/docs/ConditionMetadata.md new file mode 100644 index 0000000..0e472f7 --- /dev/null +++ b/docs/ConditionMetadata.md @@ -0,0 +1,11 @@ +# OpenFga.Sdk.Model.ConditionMetadata + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Module** | **string** | | [optional] +**SourceInfo** | [**SourceInfo**](SourceInfo.md) | | [optional] + +[[Back to Model list]](../README.md#models) [[Back to API list]](../README.md#api-endpoints) [[Back to README]](../README.md) + diff --git a/docs/Metadata.md b/docs/Metadata.md index da7330e..56ed408 100644 --- a/docs/Metadata.md +++ b/docs/Metadata.md @@ -5,6 +5,8 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **Relations** | [**Dictionary<string, RelationMetadata>**](RelationMetadata.md) | | [optional] +**Module** | **string** | | [optional] +**SourceInfo** | [**SourceInfo**](SourceInfo.md) | | [optional] [[Back to Model list]](../README.md#models) [[Back to API list]](../README.md#api-endpoints) [[Back to README]](../README.md) diff --git a/docs/RelationMetadata.md b/docs/RelationMetadata.md index 8d1ed86..9da0df5 100644 --- a/docs/RelationMetadata.md +++ b/docs/RelationMetadata.md @@ -5,6 +5,8 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **DirectlyRelatedUserTypes** | [**List<RelationReference>**](RelationReference.md) | | [optional] +**Module** | **string** | | [optional] +**SourceInfo** | [**SourceInfo**](SourceInfo.md) | | [optional] [[Back to Model list]](../README.md#models) [[Back to API list]](../README.md#api-endpoints) [[Back to README]](../README.md) diff --git a/docs/SourceInfo.md b/docs/SourceInfo.md new file mode 100644 index 0000000..9b10d56 --- /dev/null +++ b/docs/SourceInfo.md @@ -0,0 +1,10 @@ +# OpenFga.Sdk.Model.SourceInfo + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**File** | **string** | | [optional] + +[[Back to Model list]](../README.md#models) [[Back to API list]](../README.md#api-endpoints) [[Back to README]](../README.md) + diff --git a/src/OpenFga.Sdk/Model/Condition.cs b/src/OpenFga.Sdk/Model/Condition.cs index b713043..f5ca8fd 100644 --- a/src/OpenFga.Sdk/Model/Condition.cs +++ b/src/OpenFga.Sdk/Model/Condition.cs @@ -36,7 +36,8 @@ public Condition() { /// name (required). /// A Google CEL expression, expressed as a string. (required). /// A map of parameter names to the parameter's defined type reference.. - public Condition(string name = default(string), string expression = default(string), Dictionary parameters = default(Dictionary)) { + /// metadata. + public Condition(string name = default(string), string expression = default(string), Dictionary parameters = default(Dictionary), ConditionMetadata metadata = default(ConditionMetadata)) { // to ensure "name" is required (not null) if (name == null) { throw new ArgumentNullException("name is a required property for Condition and cannot be null"); @@ -48,6 +49,7 @@ public Condition() { } this.Expression = expression; this.Parameters = parameters; + this.Metadata = metadata; this.AdditionalProperties = new Dictionary(); } @@ -77,6 +79,14 @@ public Condition() { [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] public Dictionary? Parameters { get; set; } + /// + /// Gets or Sets Metadata + /// + [DataMember(Name = "metadata", EmitDefaultValue = false)] + [JsonPropertyName("metadata")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public ConditionMetadata? Metadata { get; set; } + /// /// Gets or Sets additional properties /// @@ -134,6 +144,11 @@ public bool Equals(Condition input) { this.Parameters != null && input.Parameters != null && this.Parameters.SequenceEqual(input.Parameters) + ) && + ( + this.Metadata == input.Metadata || + (this.Metadata != null && + this.Metadata.Equals(input.Metadata)) ) && (this.AdditionalProperties.Count == input.AdditionalProperties.Count && !this.AdditionalProperties.Except(input.AdditionalProperties).Any()); } @@ -155,6 +170,9 @@ public override int GetHashCode() { if (this.Parameters != null) { hashCode = (hashCode * 9923) + this.Parameters.GetHashCode(); } + if (this.Metadata != null) { + hashCode = (hashCode * 9923) + this.Metadata.GetHashCode(); + } if (this.AdditionalProperties != null) { hashCode = (hashCode * 9923) + this.AdditionalProperties.GetHashCode(); } diff --git a/src/OpenFga.Sdk/Model/ConditionMetadata.cs b/src/OpenFga.Sdk/Model/ConditionMetadata.cs new file mode 100644 index 0000000..4272d26 --- /dev/null +++ b/src/OpenFga.Sdk/Model/ConditionMetadata.cs @@ -0,0 +1,147 @@ +// +// OpenFGA/.NET SDK for OpenFGA +// +// API version: 0.1 +// Website: https://openfga.dev +// Documentation: https://openfga.dev/docs +// Support: https://openfga.dev/community +// License: [Apache-2.0](https://github.com/openfga/dotnet-sdk/blob/main/LICENSE) +// +// NOTE: This file was auto generated. DO NOT EDIT. +// + + +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace OpenFga.Sdk.Model { + /// + /// ConditionMetadata + /// + [DataContract(Name = "ConditionMetadata")] + public partial class ConditionMetadata : IEquatable, IValidatableObject { + /// + /// Initializes a new instance of the class. + /// + [JsonConstructor] + public ConditionMetadata() { + this.AdditionalProperties = new Dictionary(); + } + + /// + /// Initializes a new instance of the class. + /// + /// module. + /// sourceInfo. + public ConditionMetadata(string module = default(string), SourceInfo sourceInfo = default(SourceInfo)) { + this.Module = module; + this.SourceInfo = sourceInfo; + this.AdditionalProperties = new Dictionary(); + } + + /// + /// Gets or Sets Module + /// + [DataMember(Name = "module", EmitDefaultValue = false)] + [JsonPropertyName("module")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public string? Module { get; set; } + + /// + /// Gets or Sets SourceInfo + /// + [DataMember(Name = "source_info", EmitDefaultValue = false)] + [JsonPropertyName("source_info")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public SourceInfo? SourceInfo { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public IDictionary AdditionalProperties { get; set; } + + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public virtual string ToJson() { + return JsonSerializer.Serialize(this); + } + + /// + /// Builds a ConditionMetadata from the JSON string presentation of the object + /// + /// ConditionMetadata + public static ConditionMetadata FromJson(string jsonString) { + return JsonSerializer.Deserialize(jsonString) ?? throw new InvalidOperationException(); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) { + return this.Equals(input as ConditionMetadata); + } + + /// + /// Returns true if ConditionMetadata instances are equal + /// + /// Instance of ConditionMetadata to be compared + /// Boolean + public bool Equals(ConditionMetadata input) { + if (input == null) { + return false; + } + return + ( + this.Module == input.Module || + (this.Module != null && + this.Module.Equals(input.Module)) + ) && + ( + this.SourceInfo == input.SourceInfo || + (this.SourceInfo != null && + this.SourceInfo.Equals(input.SourceInfo)) + ) + && (this.AdditionalProperties.Count == input.AdditionalProperties.Count && !this.AdditionalProperties.Except(input.AdditionalProperties).Any()); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() { + unchecked // Overflow is fine, just wrap + { + int hashCode = 9661; + if (this.Module != null) { + hashCode = (hashCode * 9923) + this.Module.GetHashCode(); + } + if (this.SourceInfo != null) { + hashCode = (hashCode * 9923) + this.SourceInfo.GetHashCode(); + } + if (this.AdditionalProperties != null) { + hashCode = (hashCode * 9923) + this.AdditionalProperties.GetHashCode(); + } + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + public IEnumerable Validate(ValidationContext validationContext) { + yield break; + } + + } + +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/Metadata.cs b/src/OpenFga.Sdk/Model/Metadata.cs index 3d8b7c5..ee09aa6 100644 --- a/src/OpenFga.Sdk/Model/Metadata.cs +++ b/src/OpenFga.Sdk/Model/Metadata.cs @@ -34,8 +34,12 @@ public Metadata() { /// Initializes a new instance of the class. /// /// relations. - public Metadata(Dictionary relations = default(Dictionary)) { + /// module. + /// sourceInfo. + public Metadata(Dictionary relations = default(Dictionary), string module = default(string), SourceInfo sourceInfo = default(SourceInfo)) { this.Relations = relations; + this.Module = module; + this.SourceInfo = sourceInfo; this.AdditionalProperties = new Dictionary(); } @@ -47,6 +51,22 @@ public Metadata() { [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] public Dictionary? Relations { get; set; } + /// + /// Gets or Sets Module + /// + [DataMember(Name = "module", EmitDefaultValue = false)] + [JsonPropertyName("module")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public string? Module { get; set; } + + /// + /// Gets or Sets SourceInfo + /// + [DataMember(Name = "source_info", EmitDefaultValue = false)] + [JsonPropertyName("source_info")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public SourceInfo? SourceInfo { get; set; } + /// /// Gets or Sets additional properties /// @@ -94,6 +114,16 @@ public bool Equals(Metadata input) { this.Relations != null && input.Relations != null && this.Relations.SequenceEqual(input.Relations) + ) && + ( + this.Module == input.Module || + (this.Module != null && + this.Module.Equals(input.Module)) + ) && + ( + this.SourceInfo == input.SourceInfo || + (this.SourceInfo != null && + this.SourceInfo.Equals(input.SourceInfo)) ) && (this.AdditionalProperties.Count == input.AdditionalProperties.Count && !this.AdditionalProperties.Except(input.AdditionalProperties).Any()); } @@ -109,6 +139,12 @@ public override int GetHashCode() { if (this.Relations != null) { hashCode = (hashCode * 9923) + this.Relations.GetHashCode(); } + if (this.Module != null) { + hashCode = (hashCode * 9923) + this.Module.GetHashCode(); + } + if (this.SourceInfo != null) { + hashCode = (hashCode * 9923) + this.SourceInfo.GetHashCode(); + } if (this.AdditionalProperties != null) { hashCode = (hashCode * 9923) + this.AdditionalProperties.GetHashCode(); } diff --git a/src/OpenFga.Sdk/Model/RelationMetadata.cs b/src/OpenFga.Sdk/Model/RelationMetadata.cs index 2de4540..50562de 100644 --- a/src/OpenFga.Sdk/Model/RelationMetadata.cs +++ b/src/OpenFga.Sdk/Model/RelationMetadata.cs @@ -34,8 +34,12 @@ public RelationMetadata() { /// Initializes a new instance of the class. /// /// directlyRelatedUserTypes. - public RelationMetadata(List directlyRelatedUserTypes = default(List)) { + /// module. + /// sourceInfo. + public RelationMetadata(List directlyRelatedUserTypes = default(List), string module = default(string), SourceInfo sourceInfo = default(SourceInfo)) { this.DirectlyRelatedUserTypes = directlyRelatedUserTypes; + this.Module = module; + this.SourceInfo = sourceInfo; this.AdditionalProperties = new Dictionary(); } @@ -47,6 +51,22 @@ public RelationMetadata() { [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] public List? DirectlyRelatedUserTypes { get; set; } + /// + /// Gets or Sets Module + /// + [DataMember(Name = "module", EmitDefaultValue = false)] + [JsonPropertyName("module")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public string? Module { get; set; } + + /// + /// Gets or Sets SourceInfo + /// + [DataMember(Name = "source_info", EmitDefaultValue = false)] + [JsonPropertyName("source_info")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public SourceInfo? SourceInfo { get; set; } + /// /// Gets or Sets additional properties /// @@ -94,6 +114,16 @@ public bool Equals(RelationMetadata input) { this.DirectlyRelatedUserTypes != null && input.DirectlyRelatedUserTypes != null && this.DirectlyRelatedUserTypes.SequenceEqual(input.DirectlyRelatedUserTypes) + ) && + ( + this.Module == input.Module || + (this.Module != null && + this.Module.Equals(input.Module)) + ) && + ( + this.SourceInfo == input.SourceInfo || + (this.SourceInfo != null && + this.SourceInfo.Equals(input.SourceInfo)) ) && (this.AdditionalProperties.Count == input.AdditionalProperties.Count && !this.AdditionalProperties.Except(input.AdditionalProperties).Any()); } @@ -109,6 +139,12 @@ public override int GetHashCode() { if (this.DirectlyRelatedUserTypes != null) { hashCode = (hashCode * 9923) + this.DirectlyRelatedUserTypes.GetHashCode(); } + if (this.Module != null) { + hashCode = (hashCode * 9923) + this.Module.GetHashCode(); + } + if (this.SourceInfo != null) { + hashCode = (hashCode * 9923) + this.SourceInfo.GetHashCode(); + } if (this.AdditionalProperties != null) { hashCode = (hashCode * 9923) + this.AdditionalProperties.GetHashCode(); } diff --git a/src/OpenFga.Sdk/Model/SourceInfo.cs b/src/OpenFga.Sdk/Model/SourceInfo.cs new file mode 100644 index 0000000..ccbc4bf --- /dev/null +++ b/src/OpenFga.Sdk/Model/SourceInfo.cs @@ -0,0 +1,129 @@ +// +// OpenFGA/.NET SDK for OpenFGA +// +// API version: 0.1 +// Website: https://openfga.dev +// Documentation: https://openfga.dev/docs +// Support: https://openfga.dev/community +// License: [Apache-2.0](https://github.com/openfga/dotnet-sdk/blob/main/LICENSE) +// +// NOTE: This file was auto generated. DO NOT EDIT. +// + + +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace OpenFga.Sdk.Model { + /// + /// SourceInfo + /// + [DataContract(Name = "SourceInfo")] + public partial class SourceInfo : IEquatable, IValidatableObject { + /// + /// Initializes a new instance of the class. + /// + [JsonConstructor] + public SourceInfo() { + this.AdditionalProperties = new Dictionary(); + } + + /// + /// Initializes a new instance of the class. + /// + /// file. + public SourceInfo(string file = default(string)) { + this.File = file; + this.AdditionalProperties = new Dictionary(); + } + + /// + /// Gets or Sets File + /// + [DataMember(Name = "file", EmitDefaultValue = false)] + [JsonPropertyName("file")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public string? File { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public IDictionary AdditionalProperties { get; set; } + + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public virtual string ToJson() { + return JsonSerializer.Serialize(this); + } + + /// + /// Builds a SourceInfo from the JSON string presentation of the object + /// + /// SourceInfo + public static SourceInfo FromJson(string jsonString) { + return JsonSerializer.Deserialize(jsonString) ?? throw new InvalidOperationException(); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) { + return this.Equals(input as SourceInfo); + } + + /// + /// Returns true if SourceInfo instances are equal + /// + /// Instance of SourceInfo to be compared + /// Boolean + public bool Equals(SourceInfo input) { + if (input == null) { + return false; + } + return + ( + this.File == input.File || + (this.File != null && + this.File.Equals(input.File)) + ) + && (this.AdditionalProperties.Count == input.AdditionalProperties.Count && !this.AdditionalProperties.Except(input.AdditionalProperties).Any()); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() { + unchecked // Overflow is fine, just wrap + { + int hashCode = 9661; + if (this.File != null) { + hashCode = (hashCode * 9923) + this.File.GetHashCode(); + } + if (this.AdditionalProperties != null) { + hashCode = (hashCode * 9923) + this.AdditionalProperties.GetHashCode(); + } + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + public IEnumerable Validate(ValidationContext validationContext) { + yield break; + } + + } + +} \ No newline at end of file