Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for modular models metadata #53

Merged
merged 1 commit into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions docs/Condition.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

11 changes: 11 additions & 0 deletions docs/ConditionMetadata.md
Original file line number Diff line number Diff line change
@@ -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)

2 changes: 2 additions & 0 deletions docs/Metadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

2 changes: 2 additions & 0 deletions docs/RelationMetadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

10 changes: 10 additions & 0 deletions docs/SourceInfo.md
Original file line number Diff line number Diff line change
@@ -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)

20 changes: 19 additions & 1 deletion src/OpenFga.Sdk/Model/Condition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ public Condition() {
/// <param name="name">name (required).</param>
/// <param name="expression">A Google CEL expression, expressed as a string. (required).</param>
/// <param name="parameters">A map of parameter names to the parameter&#39;s defined type reference..</param>
public Condition(string name = default(string), string expression = default(string), Dictionary<string, ConditionParamTypeRef> parameters = default(Dictionary<string, ConditionParamTypeRef>)) {
/// <param name="metadata">metadata.</param>
public Condition(string name = default(string), string expression = default(string), Dictionary<string, ConditionParamTypeRef> parameters = default(Dictionary<string, ConditionParamTypeRef>), 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");
Expand All @@ -48,6 +49,7 @@ public Condition() {
}
this.Expression = expression;
this.Parameters = parameters;
this.Metadata = metadata;
this.AdditionalProperties = new Dictionary<string, object>();
}

Expand Down Expand Up @@ -77,6 +79,14 @@ public Condition() {
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public Dictionary<string, ConditionParamTypeRef>? Parameters { get; set; }

/// <summary>
/// Gets or Sets Metadata
/// </summary>
[DataMember(Name = "metadata", EmitDefaultValue = false)]
[JsonPropertyName("metadata")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public ConditionMetadata? Metadata { get; set; }

/// <summary>
/// Gets or Sets additional properties
/// </summary>
Expand Down Expand Up @@ -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());
}
Expand All @@ -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();
}
Expand Down
147 changes: 147 additions & 0 deletions src/OpenFga.Sdk/Model/ConditionMetadata.cs
Original file line number Diff line number Diff line change
@@ -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 {
/// <summary>
/// ConditionMetadata
/// </summary>
[DataContract(Name = "ConditionMetadata")]
public partial class ConditionMetadata : IEquatable<ConditionMetadata>, IValidatableObject {
/// <summary>
/// Initializes a new instance of the <see cref="ConditionMetadata" /> class.
/// </summary>
[JsonConstructor]
public ConditionMetadata() {
this.AdditionalProperties = new Dictionary<string, object>();
}

/// <summary>
/// Initializes a new instance of the <see cref="ConditionMetadata" /> class.
/// </summary>
/// <param name="module">module.</param>
/// <param name="sourceInfo">sourceInfo.</param>
public ConditionMetadata(string module = default(string), SourceInfo sourceInfo = default(SourceInfo)) {
this.Module = module;
this.SourceInfo = sourceInfo;
this.AdditionalProperties = new Dictionary<string, object>();
}

/// <summary>
/// Gets or Sets Module
/// </summary>
[DataMember(Name = "module", EmitDefaultValue = false)]
[JsonPropertyName("module")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public string? Module { get; set; }

/// <summary>
/// Gets or Sets SourceInfo
/// </summary>
[DataMember(Name = "source_info", EmitDefaultValue = false)]
[JsonPropertyName("source_info")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public SourceInfo? SourceInfo { get; set; }

/// <summary>
/// Gets or Sets additional properties
/// </summary>
[JsonExtensionData]
public IDictionary<string, object> AdditionalProperties { get; set; }


/// <summary>
/// Returns the JSON string presentation of the object
/// </summary>
/// <returns>JSON string presentation of the object</returns>
public virtual string ToJson() {
return JsonSerializer.Serialize(this);
}

/// <summary>
/// Builds a ConditionMetadata from the JSON string presentation of the object
/// </summary>
/// <returns>ConditionMetadata</returns>
public static ConditionMetadata FromJson(string jsonString) {
return JsonSerializer.Deserialize<ConditionMetadata>(jsonString) ?? throw new InvalidOperationException();
}

/// <summary>
/// Returns true if objects are equal
/// </summary>
/// <param name="input">Object to be compared</param>
/// <returns>Boolean</returns>
public override bool Equals(object input) {
return this.Equals(input as ConditionMetadata);
}

/// <summary>
/// Returns true if ConditionMetadata instances are equal
/// </summary>
/// <param name="input">Instance of ConditionMetadata to be compared</param>
/// <returns>Boolean</returns>
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());
}

/// <summary>
/// Gets the hash code
/// </summary>
/// <returns>Hash code</returns>
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;
}
}

/// <summary>
/// To validate all properties of the instance
/// </summary>
/// <param name="validationContext">Validation context</param>
/// <returns>Validation Result</returns>
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext) {
yield break;
}

}

}
38 changes: 37 additions & 1 deletion src/OpenFga.Sdk/Model/Metadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,12 @@ public Metadata() {
/// Initializes a new instance of the <see cref="Metadata" /> class.
/// </summary>
/// <param name="relations">relations.</param>
public Metadata(Dictionary<string, RelationMetadata> relations = default(Dictionary<string, RelationMetadata>)) {
/// <param name="module">module.</param>
/// <param name="sourceInfo">sourceInfo.</param>
public Metadata(Dictionary<string, RelationMetadata> relations = default(Dictionary<string, RelationMetadata>), string module = default(string), SourceInfo sourceInfo = default(SourceInfo)) {
this.Relations = relations;
this.Module = module;
this.SourceInfo = sourceInfo;
this.AdditionalProperties = new Dictionary<string, object>();
}

Expand All @@ -47,6 +51,22 @@ public Metadata() {
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public Dictionary<string, RelationMetadata>? Relations { get; set; }

/// <summary>
/// Gets or Sets Module
/// </summary>
[DataMember(Name = "module", EmitDefaultValue = false)]
[JsonPropertyName("module")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public string? Module { get; set; }

/// <summary>
/// Gets or Sets SourceInfo
/// </summary>
[DataMember(Name = "source_info", EmitDefaultValue = false)]
[JsonPropertyName("source_info")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public SourceInfo? SourceInfo { get; set; }

/// <summary>
/// Gets or Sets additional properties
/// </summary>
Expand Down Expand Up @@ -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());
}
Expand All @@ -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();
}
Expand Down
Loading
Loading