From 5edaae992871cb54af53d56919f89d2d22ce18cd Mon Sep 17 00:00:00 2001 From: Anurag Bandyopadhyay Date: Wed, 28 Jan 2026 20:49:03 +0530 Subject: [PATCH 01/23] feat: init raw requests api executor --- .claude/settings.local.json | 9 + CHANGELOG.md | 8 + README.md | 66 +++ .../ApiExecutorRequestBuilderTests.cs | 297 ++++++++++++ .../Client/ApiExecutor/ApiExecutorTests.cs | 427 ++++++++++++++++++ .../Client/ApiExecutor/ApiResponseTests.cs | 169 +++++++ src/OpenFga.Sdk/Api/OpenFgaApi.cs | 5 + src/OpenFga.Sdk/ApiClient/ApiClient.cs | 40 ++ .../Client/ApiExecutor/ApiExecutor.cs | 124 +++++ .../ApiExecutor/ApiExecutorRequestBuilder.cs | 172 +++++++ .../Client/ApiExecutor/ApiResponse.cs | 103 +++++ src/OpenFga.Sdk/Client/Client.cs | 21 +- 12 files changed, 1440 insertions(+), 1 deletion(-) create mode 100644 .claude/settings.local.json create mode 100644 src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorRequestBuilderTests.cs create mode 100644 src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorTests.cs create mode 100644 src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiResponseTests.cs create mode 100644 src/OpenFga.Sdk/Client/ApiExecutor/ApiExecutor.cs create mode 100644 src/OpenFga.Sdk/Client/ApiExecutor/ApiExecutorRequestBuilder.cs create mode 100644 src/OpenFga.Sdk/Client/ApiExecutor/ApiResponse.cs diff --git a/.claude/settings.local.json b/.claude/settings.local.json new file mode 100644 index 00000000..a0010289 --- /dev/null +++ b/.claude/settings.local.json @@ -0,0 +1,9 @@ +{ + "permissions": { + "allow": [ + "Bash(grep:*)", + "Bash(tree:*)", + "Bash(wc:*)" + ] + } +} diff --git a/CHANGELOG.md b/CHANGELOG.md index f6fc9aed..e60e59e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,15 @@ ## [Unreleased](https://github.com/openfga/dotnet-sdk/compare/v0.9.0...HEAD) +### Added - feat: add support for [StreamedListObjects](https://openfga.dev/api/service#/Relationship%20Queries/StreamedListObjects). See [documentation](#streamed-list-objects) +- feat: add API Executor for making custom API requests + - New `ApiExecutor` class accessible via `client.ApiExecutor()` method + - Fluent `ApiExecutorRequestBuilder` for constructing requests + - `ApiResponse` wrapper providing both raw and typed responses + - Automatically leverages SDK authentication, retry logic, and error handling + - Supports custom headers, path parameters, query parameters, and request bodies + - See [Calling Other API Endpoints documentation](README.md#calling-other-api-endpoints) for usage examples ## v0.9.0 diff --git a/README.md b/README.md index 948bbaa1..1588d49f 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,7 @@ This is an autogenerated SDK for OpenFGA. It provides a wrapper around the [Open - [Assertions](#assertions) - [Read Assertions](#read-assertions) - [Write Assertions](#write-assertions) + - [Calling Other API Endpoints](#calling-other-api-endpoints) - [Retries](#retries) - [API Endpoints](#api-endpoints) - [Models](#models) @@ -965,6 +966,71 @@ var body = new List() {new ClientAssertion() { await fgaClient.WriteAssertions(body, options); ``` +#### Calling Other API Endpoints + +The API Executor allows you to call arbitrary OpenFGA API endpoints that may not have direct SDK methods yet, while automatically leveraging the SDK's authentication, retry logic, and error handling. + +##### Example: Custom Check Request + +```csharp +using OpenFga.Sdk.Client.ApiExecutor; +using System.Net.Http; + +// Build the API request +var request = ApiExecutorRequestBuilder + .Of(HttpMethod.Post, "/stores/{store_id}/check") + .PathParam("store_id", fgaClient.StoreId) + .QueryParam("page_size", "20") + .Header("X-Custom-Header", "custom-value") + .Body(new { + tuple_key = new { + user = "user:anne", + relation = "reader", + @object = "document:2021-budget" + }, + contextual_tuples = new { + tuple_keys = new[] { + new { + user = "user:anne", + relation = "member", + @object = "group:engineering" + } + } + } + }) + .Build(); + +// Execute the request with typed response +var response = await fgaClient.ApiExecutor().SendAsync(request); +Console.WriteLine($"Status: {response.StatusCode}"); +Console.WriteLine($"Allowed: {response.Data.Allowed}"); + +// Or get raw JSON response +var rawResponse = await fgaClient.ApiExecutor().SendAsync(request); +Console.WriteLine($"Raw JSON: {rawResponse.RawResponse}"); +``` + +##### Features + +- **Automatic Authentication**: Uses configured credentials (API token or OAuth2) +- **Retry Logic**: Automatically retries on 429 and 5xx errors +- **Error Handling**: Throws appropriate `FgaApiError` exceptions +- **Flexible Response**: Get typed data or raw JSON +- **Custom Headers**: Add request-specific headers for debugging or tracing + +##### Available Methods + +- `ApiExecutor().SendAsync(request)` - Returns typed response with deserialized data +- `ApiExecutor().SendAsync(request)` - Returns raw JSON string as data + +##### Response Properties + +- `StatusCode` - HTTP status code +- `Headers` - Response headers (case-insensitive) +- `RawResponse` - Raw response body as string +- `Data` - Deserialized response data (type varies) +- `IsSuccessful` - True if status is 2xx + ### Retries diff --git a/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorRequestBuilderTests.cs b/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorRequestBuilderTests.cs new file mode 100644 index 00000000..dfb747d6 --- /dev/null +++ b/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorRequestBuilderTests.cs @@ -0,0 +1,297 @@ +using OpenFga.Sdk.Client.ApiExecutor; +using OpenFga.Sdk.Exceptions; +using System; +using System.Net.Http; +using Xunit; + +namespace OpenFga.Sdk.Test.Client.ApiExecutor; + +public class ApiExecutorRequestBuilderTests { + [Fact] + public void Of_ValidMethodAndPath_ReturnsBuilder() { + // Act + var builder = ApiExecutorRequestBuilder.Of(HttpMethod.Get, "/stores"); + + // Assert + Assert.NotNull(builder); + Assert.Equal(HttpMethod.Get, builder.Method); + Assert.Equal("/stores", builder.PathTemplate); + } + + [Fact] + public void Of_NullMethod_ThrowsArgumentNullException() { + // Act & Assert + var exception = Assert.Throws(() => + ApiExecutorRequestBuilder.Of(null, "/stores")); + Assert.Contains("method", exception.Message, StringComparison.OrdinalIgnoreCase); + } + + [Fact] + public void Of_NullPath_ThrowsArgumentNullException() { + // Act & Assert + var exception = Assert.Throws(() => + ApiExecutorRequestBuilder.Of(HttpMethod.Get, null)); + Assert.Contains("path", exception.Message, StringComparison.OrdinalIgnoreCase); + } + + [Fact] + public void Of_EmptyPath_ThrowsArgumentException() { + // Act & Assert + var exception = Assert.Throws(() => + ApiExecutorRequestBuilder.Of(HttpMethod.Get, "")); + Assert.Contains("path", exception.Message, StringComparison.OrdinalIgnoreCase); + } + + [Fact] + public void Of_WhitespacePath_ThrowsArgumentException() { + // Act & Assert + var exception = Assert.Throws(() => + ApiExecutorRequestBuilder.Of(HttpMethod.Get, " ")); + Assert.Contains("path", exception.Message, StringComparison.OrdinalIgnoreCase); + } + + [Fact] + public void Of_PathWithoutLeadingSlash_ThrowsArgumentException() { + // Act & Assert + var exception = Assert.Throws(() => + ApiExecutorRequestBuilder.Of(HttpMethod.Get, "stores")); + Assert.Contains("must start with '/'", exception.Message, StringComparison.OrdinalIgnoreCase); + } + + [Fact] + public void PathParam_ValidKeyValue_StoresParameter() { + // Arrange + var builder = ApiExecutorRequestBuilder.Of(HttpMethod.Post, "/stores/{store_id}/check"); + + // Act + var result = builder.PathParam("store_id", "store123"); + + // Assert + Assert.Same(builder, result); // Verify fluent chaining + } + + [Fact] + public void PathParam_NullKey_ThrowsArgumentException() { + // Arrange + var builder = ApiExecutorRequestBuilder.Of(HttpMethod.Post, "/stores/{store_id}/check"); + + // Act & Assert + var exception = Assert.Throws(() => + builder.PathParam(null, "value")); + Assert.Contains("key", exception.Message, StringComparison.OrdinalIgnoreCase); + } + + [Fact] + public void PathParam_EmptyKey_ThrowsArgumentException() { + // Arrange + var builder = ApiExecutorRequestBuilder.Of(HttpMethod.Post, "/stores/{store_id}/check"); + + // Act & Assert + var exception = Assert.Throws(() => + builder.PathParam("", "value")); + Assert.Contains("key", exception.Message, StringComparison.OrdinalIgnoreCase); + } + + [Fact] + public void PathParam_NullValue_ThrowsArgumentNullException() { + // Arrange + var builder = ApiExecutorRequestBuilder.Of(HttpMethod.Post, "/stores/{store_id}/check"); + + // Act & Assert + var exception = Assert.Throws(() => + builder.PathParam("store_id", null)); + Assert.Contains("value", exception.Message, StringComparison.OrdinalIgnoreCase); + } + + [Fact] + public void QueryParam_ValidKeyValue_StoresParameter() { + // Arrange + var builder = ApiExecutorRequestBuilder.Of(HttpMethod.Get, "/stores"); + + // Act + var result = builder.QueryParam("page_size", "20"); + + // Assert + Assert.Same(builder, result); // Verify fluent chaining + } + + [Fact] + public void QueryParam_NullKey_ThrowsArgumentException() { + // Arrange + var builder = ApiExecutorRequestBuilder.Of(HttpMethod.Get, "/stores"); + + // Act & Assert + var exception = Assert.Throws(() => + builder.QueryParam(null, "value")); + Assert.Contains("key", exception.Message, StringComparison.OrdinalIgnoreCase); + } + + [Fact] + public void QueryParam_NullValue_ThrowsArgumentNullException() { + // Arrange + var builder = ApiExecutorRequestBuilder.Of(HttpMethod.Get, "/stores"); + + // Act & Assert + var exception = Assert.Throws(() => + builder.QueryParam("page_size", null)); + Assert.Contains("value", exception.Message, StringComparison.OrdinalIgnoreCase); + } + + [Fact] + public void Header_ValidKeyValue_StoresHeader() { + // Arrange + var builder = ApiExecutorRequestBuilder.Of(HttpMethod.Post, "/stores"); + + // Act + var result = builder.Header("X-Custom-Header", "custom-value"); + + // Assert + Assert.Same(builder, result); // Verify fluent chaining + } + + [Fact] + public void Header_ReservedHeader_ThrowsArgumentException() { + // Arrange + var builder = ApiExecutorRequestBuilder.Of(HttpMethod.Post, "/stores"); + + // Act & Assert - Authorization is a reserved header + var exception = Assert.Throws(() => + builder.Header("Authorization", "Bearer token")); + Assert.Contains("reserved", exception.Message, StringComparison.OrdinalIgnoreCase); + } + + [Fact] + public void Header_NullKey_ThrowsArgumentException() { + // Arrange + var builder = ApiExecutorRequestBuilder.Of(HttpMethod.Post, "/stores"); + + // Act & Assert + var exception = Assert.Throws(() => + builder.Header(null, "value")); + Assert.Contains("name", exception.Message, StringComparison.OrdinalIgnoreCase); + } + + [Fact] + public void Header_NullValue_ThrowsArgumentException() { + // Arrange + var builder = ApiExecutorRequestBuilder.Of(HttpMethod.Post, "/stores"); + + // Act & Assert + var exception = Assert.Throws(() => + builder.Header("X-Custom-Header", null)); + Assert.Contains("value", exception.Message, StringComparison.OrdinalIgnoreCase); + } + + [Fact] + public void Header_InvalidCharacters_ThrowsArgumentException() { + // Arrange + var builder = ApiExecutorRequestBuilder.Of(HttpMethod.Post, "/stores"); + + // Act & Assert - CR/LF characters are not allowed + var exception = Assert.Throws(() => + builder.Header("X-Custom-Header", "value\r\nwith newline")); + Assert.Contains("invalid characters", exception.Message, StringComparison.OrdinalIgnoreCase); + } + + [Fact] + public void Body_ValidObject_StoresBody() { + // Arrange + var builder = ApiExecutorRequestBuilder.Of(HttpMethod.Post, "/stores"); + var body = new { name = "test-store" }; + + // Act + var result = builder.Body(body); + + // Assert + Assert.Same(builder, result); // Verify fluent chaining + } + + [Fact] + public void Body_NullObject_StoresNull() { + // Arrange + var builder = ApiExecutorRequestBuilder.Of(HttpMethod.Post, "/stores"); + + // Act + var result = builder.Body(null); + + // Assert + Assert.Same(builder, result); + } + + [Fact] + public void Build_WithValidRequest_ReturnsBuilder() { + // Arrange + var builder = ApiExecutorRequestBuilder.Of(HttpMethod.Post, "/stores/{store_id}/check") + .PathParam("store_id", "store123") + .QueryParam("page_size", "20") + .Header("X-Custom-Header", "value") + .Body(new { user = "user:anne" }); + + // Act + var result = builder.Build(); + + // Assert + Assert.Same(builder, result); + } + + [Fact] + public void FluentChaining_AllMethods_ReturnsBuilder() { + // Act + var builder = ApiExecutorRequestBuilder + .Of(HttpMethod.Post, "/stores/{store_id}/check") + .PathParam("store_id", "store123") + .QueryParam("page_size", "20") + .Header("X-Custom-Header", "value") + .Body(new { user = "user:anne" }) + .Build(); + + // Assert + Assert.NotNull(builder); + Assert.Equal(HttpMethod.Post, builder.Method); + Assert.Equal("/stores/{store_id}/check", builder.PathTemplate); + } + + [Fact] + public void ToRequestBuilder_ConvertsCorrectly() { + // Arrange + var builder = ApiExecutorRequestBuilder + .Of(HttpMethod.Post, "/stores/{store_id}/check") + .PathParam("store_id", "store123") + .QueryParam("page_size", "20") + .Body(new { user = "user:anne" }) + .Build(); + + // Act + var requestBuilder = builder.ToRequestBuilder("https://api.fga.example"); + + // Assert + Assert.NotNull(requestBuilder); + Assert.Equal(HttpMethod.Post, requestBuilder.Method); + Assert.Equal("https://api.fga.example", requestBuilder.BasePath); + Assert.Equal("/stores/{store_id}/check", requestBuilder.PathTemplate); + Assert.True(requestBuilder.PathParameters.ContainsKey("store_id")); + Assert.Equal("store123", requestBuilder.PathParameters["store_id"]); + Assert.True(requestBuilder.QueryParameters.ContainsKey("page_size")); + Assert.Equal("20", requestBuilder.QueryParameters["page_size"]); + Assert.NotNull(requestBuilder.Body); + } + + [Fact] + public void GetHeaders_ReturnsCustomHeaders() { + // Arrange + var builder = ApiExecutorRequestBuilder + .Of(HttpMethod.Post, "/stores") + .Header("X-Custom-Header", "value1") + .Header("X-Another-Header", "value2") + .Build(); + + // Act + var headers = builder.GetHeaders(); + + // Assert + Assert.NotNull(headers); + Assert.Equal(2, headers.Count); + Assert.Equal("value1", headers["X-Custom-Header"]); + Assert.Equal("value2", headers["X-Another-Header"]); + } +} diff --git a/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorTests.cs b/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorTests.cs new file mode 100644 index 00000000..cceda89e --- /dev/null +++ b/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorTests.cs @@ -0,0 +1,427 @@ +using Moq; +using Moq.Protected; +using OpenFga.Sdk.Client; +using OpenFga.Sdk.Client.ApiExecutor; +using OpenFga.Sdk.Client.Model; +using OpenFga.Sdk.Exceptions; +using OpenFga.Sdk.Model; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Text; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Xunit; + +namespace OpenFga.Sdk.Test.Client.ApiExecutor; + +public class ApiExecutorTests : IDisposable { + private readonly string _storeId = "01H0H015178Y2V4CX10C2KGHF4"; + private readonly string _apiUrl = "https://api.fga.example"; + + public void Dispose() { + // Cleanup when everything is done. + } + + private (OpenFgaClient client, Mock handler) CreateMockClient( + HttpResponseMessage response, + Func? requestValidator = null) { + var mockHandler = new Mock(MockBehavior.Strict); + mockHandler.Protected() + .Setup>( + "SendAsync", + requestValidator != null + ? ItExpr.Is(req => requestValidator(req)) + : ItExpr.IsAny(), + ItExpr.IsAny() + ) + .ReturnsAsync(response); + + var config = new ClientConfiguration { + ApiUrl = _apiUrl, + StoreId = _storeId + }; + var client = new OpenFgaClient(config, new HttpClient(mockHandler.Object)); + return (client, mockHandler); + } + + [Fact] + public async Task SendAsync_ValidGetRequest_ReturnsSuccessResponse() { + // Arrange + var expectedResponse = new { id = _storeId, name = "test-store" }; + var responseMessage = new HttpResponseMessage { + StatusCode = HttpStatusCode.OK, + Content = new StringContent( + JsonSerializer.Serialize(expectedResponse), + Encoding.UTF8, + "application/json") + }; + responseMessage.Headers.Add("X-Request-Id", "req-123"); + + var (client, mockHandler) = CreateMockClient(responseMessage, req => + req.Method == HttpMethod.Get && + req.RequestUri.ToString().Contains("/stores/" + _storeId)); + + var request = ApiExecutorRequestBuilder + .Of(HttpMethod.Get, "/stores/{store_id}") + .PathParam("store_id", _storeId) + .Build(); + + // Act + var response = await client.ApiExecutor().SendAsync(request); + + // Assert + Assert.NotNull(response); + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.True(response.IsSuccessful); + Assert.NotNull(response.Data); + Assert.Contains("test-store", response.RawResponse); + Assert.True(response.Headers.ContainsKey("X-Request-Id")); + } + + [Fact] + public async Task SendAsync_ValidPostRequest_ReturnsSuccessResponse() { + // Arrange + var requestBody = new { user = "user:anne", relation = "reader", @object = "document:2021-budget" }; + var expectedResponse = new { allowed = true }; + var responseMessage = new HttpResponseMessage { + StatusCode = HttpStatusCode.OK, + Content = new StringContent( + JsonSerializer.Serialize(expectedResponse), + Encoding.UTF8, + "application/json") + }; + + var (client, mockHandler) = CreateMockClient(responseMessage, req => + req.Method == HttpMethod.Post && + req.RequestUri.ToString().Contains("/stores/" + _storeId + "/check")); + + var request = ApiExecutorRequestBuilder + .Of(HttpMethod.Post, "/stores/{store_id}/check") + .PathParam("store_id", _storeId) + .Body(requestBody) + .Build(); + + // Act + var response = await client.ApiExecutor().SendAsync(request); + + // Assert + Assert.NotNull(response); + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.True(response.IsSuccessful); + Assert.NotNull(response.Data); + } + + [Fact] + public async Task SendAsync_WithPathParams_ReplacesInUrl() { + // Arrange + var responseMessage = new HttpResponseMessage { + StatusCode = HttpStatusCode.OK, + Content = new StringContent("{}", Encoding.UTF8, "application/json") + }; + + var (client, mockHandler) = CreateMockClient(responseMessage, req => + req.RequestUri.ToString().Contains("/stores/" + _storeId + "/check")); + + var request = ApiExecutorRequestBuilder + .Of(HttpMethod.Post, "/stores/{store_id}/check") + .PathParam("store_id", _storeId) + .Build(); + + // Act + await client.ApiExecutor().SendAsync(request); + + // Assert + mockHandler.Protected().Verify( + "SendAsync", + Times.Once(), + ItExpr.Is(req => + req.RequestUri.ToString().Contains("/stores/" + _storeId + "/check")), + ItExpr.IsAny() + ); + } + + [Fact] + public async Task SendAsync_WithQueryParams_AppendsToUrl() { + // Arrange + var responseMessage = new HttpResponseMessage { + StatusCode = HttpStatusCode.OK, + Content = new StringContent("[]", Encoding.UTF8, "application/json") + }; + + var (client, mockHandler) = CreateMockClient(responseMessage, req => + req.RequestUri.ToString().Contains("page_size=20") && + req.RequestUri.ToString().Contains("continuation_token=abc123")); + + var request = ApiExecutorRequestBuilder + .Of(HttpMethod.Get, "/stores") + .QueryParam("page_size", "20") + .QueryParam("continuation_token", "abc123") + .Build(); + + // Act + await client.ApiExecutor().SendAsync(request); + + // Assert + mockHandler.Protected().Verify( + "SendAsync", + Times.Once(), + ItExpr.Is(req => + req.RequestUri.ToString().Contains("page_size=20") && + req.RequestUri.ToString().Contains("continuation_token=abc123")), + ItExpr.IsAny() + ); + } + + [Fact] + public async Task SendAsync_WithCustomHeaders_IncludesInRequest() { + // Arrange + var responseMessage = new HttpResponseMessage { + StatusCode = HttpStatusCode.OK, + Content = new StringContent("{}", Encoding.UTF8, "application/json") + }; + + var (client, mockHandler) = CreateMockClient(responseMessage); + + var request = ApiExecutorRequestBuilder + .Of(HttpMethod.Post, "/stores") + .Header("X-Custom-Header", "custom-value") + .Header("X-Another-Header", "another-value") + .Build(); + + // Act + await client.ApiExecutor().SendAsync(request); + + // Assert + mockHandler.Protected().Verify( + "SendAsync", + Times.Once(), + ItExpr.Is(req => + req.Headers.Contains("X-Custom-Header") && + req.Headers.GetValues("X-Custom-Header").First() == "custom-value" && + req.Headers.Contains("X-Another-Header") && + req.Headers.GetValues("X-Another-Header").First() == "another-value"), + ItExpr.IsAny() + ); + } + + [Fact] + public async Task SendAsync_WithBody_SerializesToJson() { + // Arrange + var requestBody = new { name = "test-store" }; + var responseMessage = new HttpResponseMessage { + StatusCode = HttpStatusCode.Created, + Content = new StringContent( + JsonSerializer.Serialize(new { id = "new-store-123" }), + Encoding.UTF8, + "application/json") + }; + + var (client, mockHandler) = CreateMockClient(responseMessage); + + var request = ApiExecutorRequestBuilder + .Of(HttpMethod.Post, "/stores") + .Body(requestBody) + .Build(); + + // Act + await client.ApiExecutor().SendAsync(request); + + // Assert + mockHandler.Protected().Verify( + "SendAsync", + Times.Once(), + ItExpr.Is(req => + req.Content != null && + req.Content.Headers.ContentType.MediaType == "application/json"), + ItExpr.IsAny() + ); + } + + [Fact] + public async Task SendAsync_RawResponse_ReturnsJsonString() { + // Arrange + var expectedJson = "{\"id\":\"123\",\"name\":\"test\"}"; + var responseMessage = new HttpResponseMessage { + StatusCode = HttpStatusCode.OK, + Content = new StringContent(expectedJson, Encoding.UTF8, "application/json") + }; + + var (client, mockHandler) = CreateMockClient(responseMessage); + + var request = ApiExecutorRequestBuilder + .Of(HttpMethod.Get, "/stores/{store_id}") + .PathParam("store_id", _storeId) + .Build(); + + // Act + var response = await client.ApiExecutor().SendAsync(request); + + // Assert + Assert.NotNull(response); + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.Equal(expectedJson, response.Data); + Assert.Equal(expectedJson, response.RawResponse); + } + + [Fact] + public async Task SendAsync_ApiError_ThrowsFgaApiError() { + // Arrange + var errorResponse = new { + code = "invalid_request", + message = "Invalid request parameters" + }; + var responseMessage = new HttpResponseMessage { + StatusCode = HttpStatusCode.BadRequest, + Content = new StringContent( + JsonSerializer.Serialize(errorResponse), + Encoding.UTF8, + "application/json") + }; + + var (client, mockHandler) = CreateMockClient(responseMessage); + + var request = ApiExecutorRequestBuilder + .Of(HttpMethod.Post, "/stores/{store_id}/check") + .PathParam("store_id", _storeId) + .Build(); + + // Act & Assert + await Assert.ThrowsAsync(async () => + await client.ApiExecutor().SendAsync(request)); + } + + [Fact] + public async Task SendAsync_NullRequest_ThrowsArgumentNullException() { + // Arrange + var config = new ClientConfiguration { + ApiUrl = _apiUrl, + StoreId = _storeId + }; + var client = new OpenFgaClient(config); + + // Act & Assert + await Assert.ThrowsAsync(async () => + await client.ApiExecutor().SendAsync(null)); + } + + [Fact] + public void ApiExecutor_CalledMultipleTimes_ReturnsSameInstance() { + // Arrange + var config = new ClientConfiguration { + ApiUrl = _apiUrl, + StoreId = _storeId + }; + var client = new OpenFgaClient(config); + + // Act + var executor1 = client.ApiExecutor(); + var executor2 = client.ApiExecutor(); + + // Assert + Assert.Same(executor1, executor2); + } + + [Fact] + public async Task SendAsync_TypedResponse_DeserializesCorrectly() { + // Arrange + var expectedResponse = new CheckResponse { + Allowed = true + }; + var responseMessage = new HttpResponseMessage { + StatusCode = HttpStatusCode.OK, + Content = new StringContent( + JsonSerializer.Serialize(expectedResponse), + Encoding.UTF8, + "application/json") + }; + + var (client, mockHandler) = CreateMockClient(responseMessage); + + var request = ApiExecutorRequestBuilder + .Of(HttpMethod.Post, "/stores/{store_id}/check") + .PathParam("store_id", _storeId) + .Body(new { user = "user:anne", relation = "reader", @object = "document:test" }) + .Build(); + + // Act + var response = await client.ApiExecutor().SendAsync(request); + + // Assert + Assert.NotNull(response); + Assert.NotNull(response.Data); + Assert.True(response.Data.Allowed); + } + + [Fact] + public async Task SendAsync_CancellationToken_CancelsRequest() { + // Arrange + var cts = new CancellationTokenSource(); + cts.Cancel(); // Cancel immediately + + var config = new ClientConfiguration { + ApiUrl = _apiUrl, + StoreId = _storeId + }; + var client = new OpenFgaClient(config); + + var request = ApiExecutorRequestBuilder + .Of(HttpMethod.Get, "/stores") + .Build(); + + // Act & Assert + await Assert.ThrowsAnyAsync(async () => + await client.ApiExecutor().SendAsync(request, cts.Token)); + } + + [Fact] + public async Task SendAsync_WithCredentials_IncludesAuthorizationHeader() { + // Arrange + var responseMessage = new HttpResponseMessage { + StatusCode = HttpStatusCode.OK, + Content = new StringContent("{}", Encoding.UTF8, "application/json") + }; + + var mockHandler = new Mock(MockBehavior.Strict); + mockHandler.Protected() + .Setup>( + "SendAsync", + ItExpr.IsAny(), + ItExpr.IsAny() + ) + .ReturnsAsync(responseMessage); + + var config = new ClientConfiguration { + ApiUrl = _apiUrl, + StoreId = _storeId, + Credentials = new Credentials.Credentials { + Method = Credentials.CredentialsMethod.ApiToken, + Config = new Credentials.CredentialsConfig { + ApiToken = "test-token-123" + } + } + }; + var client = new OpenFgaClient(config, new HttpClient(mockHandler.Object)); + + var request = ApiExecutorRequestBuilder + .Of(HttpMethod.Get, "/stores") + .Build(); + + // Act + await client.ApiExecutor().SendAsync(request); + + // Assert + mockHandler.Protected().Verify( + "SendAsync", + Times.Once(), + ItExpr.Is(req => + req.Headers.Authorization != null && + req.Headers.Authorization.Scheme == "Bearer" && + req.Headers.Authorization.Parameter == "test-token-123"), + ItExpr.IsAny() + ); + } +} diff --git a/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiResponseTests.cs b/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiResponseTests.cs new file mode 100644 index 00000000..6fe7a34b --- /dev/null +++ b/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiResponseTests.cs @@ -0,0 +1,169 @@ +using OpenFga.Sdk.Client.ApiExecutor; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Text; +using Xunit; + +namespace OpenFga.Sdk.Test.Client.ApiExecutor; + +public class ApiResponseTests { + [Fact] + public void Constructor_ValidData_SetsAllProperties() { + // Arrange + var statusCode = HttpStatusCode.OK; + var headers = new Dictionary> { + { "X-Request-Id", new[] { "req-123" } }, + { "Content-Type", new[] { "application/json" } } + }; + var rawResponse = "{\"id\":\"123\"}"; + var data = new { id = "123" }; + + // Act + var response = new ApiResponse(statusCode, headers, rawResponse, data); + + // Assert + Assert.Equal(statusCode, response.StatusCode); + Assert.Equal(headers, response.Headers); + Assert.Equal(rawResponse, response.RawResponse); + Assert.Equal(data, response.Data); + } + + [Fact] + public void IsSuccessful_2xxStatusCode_ReturnsTrue() { + // Arrange + var headers = new Dictionary>(); + var testCases = new[] { + HttpStatusCode.OK, // 200 + HttpStatusCode.Created, // 201 + HttpStatusCode.Accepted, // 202 + HttpStatusCode.NoContent // 204 + }; + + foreach (var statusCode in testCases) { + // Act + var response = new ApiResponse(statusCode, headers, "", null); + + // Assert + Assert.True(response.IsSuccessful, $"Status code {statusCode} should be successful"); + } + } + + [Fact] + public void IsSuccessful_NonSuccessStatusCode_ReturnsFalse() { + // Arrange + var headers = new Dictionary>(); + var testCases = new[] { + HttpStatusCode.BadRequest, // 400 + HttpStatusCode.Unauthorized, // 401 + HttpStatusCode.Forbidden, // 403 + HttpStatusCode.NotFound, // 404 + HttpStatusCode.InternalServerError, // 500 + HttpStatusCode.ServiceUnavailable // 503 + }; + + foreach (var statusCode in testCases) { + // Act + var response = new ApiResponse(statusCode, headers, "", null); + + // Assert + Assert.False(response.IsSuccessful, $"Status code {statusCode} should not be successful"); + } + } + + [Fact] + public void FromHttpResponse_ContainsAllResponseHeaders() { + // Arrange + var httpResponse = new HttpResponseMessage { + StatusCode = HttpStatusCode.OK, + Content = new StringContent("{\"id\":\"123\"}", Encoding.UTF8, "application/json") + }; + httpResponse.Headers.Add("X-Request-Id", "req-123"); + httpResponse.Headers.Add("X-Trace-Id", "trace-456"); + + var rawResponse = "{\"id\":\"123\"}"; + var data = new { id = "123" }; + + // Act + var response = ApiResponse.FromHttpResponse(httpResponse, rawResponse, data); + + // Assert + Assert.True(response.Headers.ContainsKey("X-Request-Id")); + Assert.Equal("req-123", response.Headers["X-Request-Id"].First()); + Assert.True(response.Headers.ContainsKey("X-Trace-Id")); + Assert.Equal("trace-456", response.Headers["X-Trace-Id"].First()); + } + + [Fact] + public void FromHttpResponse_ContainsContentHeaders() { + // Arrange + var httpResponse = new HttpResponseMessage { + StatusCode = HttpStatusCode.OK, + Content = new StringContent("{\"id\":\"123\"}", Encoding.UTF8, "application/json") + }; + + var rawResponse = "{\"id\":\"123\"}"; + var data = new { id = "123" }; + + // Act + var response = ApiResponse.FromHttpResponse(httpResponse, rawResponse, data); + + // Assert + Assert.True(response.Headers.ContainsKey("Content-Type")); + Assert.Contains("application/json", response.Headers["Content-Type"].First()); + } + + [Fact] + public void Headers_AreCaseInsensitive() { + // Arrange + var httpResponse = new HttpResponseMessage { + StatusCode = HttpStatusCode.OK, + Content = new StringContent("", Encoding.UTF8, "application/json") + }; + httpResponse.Headers.Add("X-Custom-Header", "value"); + + var rawResponse = ""; + var data = (string)null; + + // Act + var response = ApiResponse.FromHttpResponse(httpResponse, rawResponse, data); + + // Assert + Assert.True(response.Headers.ContainsKey("x-custom-header")); + Assert.True(response.Headers.ContainsKey("X-CUSTOM-HEADER")); + Assert.True(response.Headers.ContainsKey("X-Custom-Header")); + } + + [Fact] + public void FromHttpResponse_WithNullData_StoresNull() { + // Arrange + var httpResponse = new HttpResponseMessage { + StatusCode = HttpStatusCode.NoContent + }; + + var rawResponse = ""; + + // Act + var response = ApiResponse.FromHttpResponse(httpResponse, rawResponse, null); + + // Assert + Assert.Null(response.Data); + Assert.Equal("", response.RawResponse); + Assert.Equal(HttpStatusCode.NoContent, response.StatusCode); + } + + [Fact] + public void RawResponse_PreservesOriginalContent() { + // Arrange + var rawJson = "{\"id\":\"123\",\"name\":\"test\",\"nested\":{\"value\":42}}"; + var headers = new Dictionary>(); + var data = new { id = "123" }; + + // Act + var response = new ApiResponse(HttpStatusCode.OK, headers, rawJson, data); + + // Assert + Assert.Equal(rawJson, response.RawResponse); + } +} diff --git a/src/OpenFga.Sdk/Api/OpenFgaApi.cs b/src/OpenFga.Sdk/Api/OpenFgaApi.cs index 91e9d64a..97ab9c88 100644 --- a/src/OpenFga.Sdk/Api/OpenFgaApi.cs +++ b/src/OpenFga.Sdk/Api/OpenFgaApi.cs @@ -27,6 +27,11 @@ public class OpenFgaApi : IDisposable { private readonly ApiClient.ApiClient _apiClient; private readonly Configuration.Configuration _configuration; + /// + /// Exposes the internal ApiClient for use by ApiExecutor. + /// + internal ApiClient.ApiClient ApiClientInternal => _apiClient; + /// /// Initializes a new instance of the class. /// diff --git a/src/OpenFga.Sdk/ApiClient/ApiClient.cs b/src/OpenFga.Sdk/ApiClient/ApiClient.cs index 779cc13b..622adf3f 100644 --- a/src/OpenFga.Sdk/ApiClient/ApiClient.cs +++ b/src/OpenFga.Sdk/ApiClient/ApiClient.cs @@ -112,6 +112,46 @@ await _baseClient.SendRequestAsync(requestBuilder, additionalHeaders return response.responseContent; } + /// + /// Internal method that returns the full ResponseWrapper including raw response. + /// Used by ApiExecutor to provide both raw and typed response data. + /// + /// + /// + /// Additional headers to merge with auth headers + /// + /// Request Type + /// Response Type + /// The full ResponseWrapper with raw response and deserialized content + /// + internal async Task> SendRequestWithWrapperAsync( + RequestBuilder requestBuilder, + string apiName, + IDictionary? additionalHeaders = null, + CancellationToken cancellationToken = default) { + var sw = Stopwatch.StartNew(); + + var authToken = await GetAuthenticationTokenAsync(apiName); + var mergedHeaders = BuildHeaders(_configuration, authToken, null); + + // Merge additional headers (from ApiExecutor) with auth headers + if (additionalHeaders != null) { + foreach (var header in additionalHeaders) { + mergedHeaders[header.Key] = header.Value; + } + } + + var response = await Retry(async () => + await _baseClient.SendRequestAsync(requestBuilder, mergedHeaders, apiName, + cancellationToken)); + + sw.Stop(); + metrics.BuildForResponse(apiName, response.rawResponse, requestBuilder, sw, + response.retryCount); + + return response; + } + /// /// Handles getting the access token, calling the API, and potentially retrying (use for requests that return no /// content) diff --git a/src/OpenFga.Sdk/Client/ApiExecutor/ApiExecutor.cs b/src/OpenFga.Sdk/Client/ApiExecutor/ApiExecutor.cs new file mode 100644 index 00000000..07cac8f0 --- /dev/null +++ b/src/OpenFga.Sdk/Client/ApiExecutor/ApiExecutor.cs @@ -0,0 +1,124 @@ +using OpenFga.Sdk.ApiClient; +using OpenFga.Sdk.Configuration; +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; + +namespace OpenFga.Sdk.Client.ApiExecutor; + +/// +/// Provides the ability to execute arbitrary API requests against the OpenFGA API. +/// Automatically leverages SDK authentication, retry logic, and error handling. +/// +public class ApiExecutor : IDisposable { + private readonly ApiClient.ApiClient _apiClient; + private readonly Configuration.Configuration _configuration; + + /// + /// Initializes a new instance of the ApiExecutor class. + /// + /// The API client for handling requests + /// The SDK configuration + internal ApiExecutor( + ApiClient.ApiClient apiClient, + Configuration.Configuration configuration) { + _apiClient = apiClient ?? throw new ArgumentNullException(nameof(apiClient)); + _configuration = configuration ?? throw new ArgumentNullException(nameof(configuration)); + } + + /// + /// Sends an API request and returns a typed response. + /// + /// The type to deserialize the response to + /// The request builder containing the request details + /// Cancellation token + /// An ApiResponse containing status, headers, raw response, and typed data + /// Thrown when request is null + /// Thrown when the request is invalid + /// Thrown when the API returns an error response + public async Task> SendAsync( + ApiExecutorRequestBuilder request, + CancellationToken cancellationToken = default) { + if (request == null) { + throw new ArgumentNullException(nameof(request)); + } + + // Validate the request + request.Build(); + + // Convert to internal RequestBuilder + var requestBuilder = request.ToRequestBuilder(_configuration.BasePath); + + // Get custom headers from the request + var customHeaders = request.GetHeaders(); + + // Send the request and get the full ResponseWrapper + var responseWrapper = await _apiClient.SendRequestWithWrapperAsync( + requestBuilder, + "ApiExecutor", + customHeaders, + cancellationToken); + + // Read the raw response body + var rawResponse = await responseWrapper.rawResponse.Content.ReadAsStringAsync(); + + // Create and return ApiResponse + return ApiResponse.FromHttpResponse( + responseWrapper.rawResponse, + rawResponse, + responseWrapper.responseContent); + } + + /// + /// Sends an API request and returns a response with raw JSON string as data. + /// Useful when you want to process the JSON response manually. + /// + /// The request builder containing the request details + /// Cancellation token + /// An ApiResponse with the raw JSON response as the Data property + /// Thrown when request is null + /// Thrown when the request is invalid + /// Thrown when the API returns an error response + public async Task> SendAsync( + ApiExecutorRequestBuilder request, + CancellationToken cancellationToken = default) { + if (request == null) { + throw new ArgumentNullException(nameof(request)); + } + + // Validate the request + request.Build(); + + // Convert to internal RequestBuilder + var requestBuilder = request.ToRequestBuilder(_configuration.BasePath); + + // Get custom headers from the request + var customHeaders = request.GetHeaders(); + + // Send the request and get the full ResponseWrapper + // Use JsonElement as intermediate type to avoid double deserialization + var responseWrapper = await _apiClient.SendRequestWithWrapperAsync( + requestBuilder, + "ApiExecutor", + customHeaders, + cancellationToken); + + // Read the raw response body + var rawResponse = await responseWrapper.rawResponse.Content.ReadAsStringAsync(); + + // Create and return ApiResponse with raw JSON as both RawResponse and Data + return ApiResponse.FromHttpResponse( + responseWrapper.rawResponse, + rawResponse, + rawResponse); + } + + /// + /// Disposes of resources used by the ApiExecutor. + /// + public void Dispose() { + // ApiClient is owned by OpenFgaApi, so we don't dispose it here + GC.SuppressFinalize(this); + } +} diff --git a/src/OpenFga.Sdk/Client/ApiExecutor/ApiExecutorRequestBuilder.cs b/src/OpenFga.Sdk/Client/ApiExecutor/ApiExecutorRequestBuilder.cs new file mode 100644 index 00000000..1b5933d0 --- /dev/null +++ b/src/OpenFga.Sdk/Client/ApiExecutor/ApiExecutorRequestBuilder.cs @@ -0,0 +1,172 @@ +using OpenFga.Sdk.ApiClient; +using OpenFga.Sdk.Exceptions; +using System; +using System.Collections.Generic; +using System.Net.Http; + +namespace OpenFga.Sdk.Client.ApiExecutor; + +/// +/// A fluent builder for constructing API requests to be executed via the ApiExecutor. +/// +public class ApiExecutorRequestBuilder { + /// + /// Gets the HTTP method for this request. + /// + public HttpMethod Method { get; private set; } + + /// + /// Gets the path template for this request (e.g., "/stores/{store_id}/check"). + /// + public string PathTemplate { get; private set; } + + private readonly Dictionary _pathParams = new Dictionary(); + private readonly Dictionary _queryParams = new Dictionary(); + private readonly Dictionary _headers = new Dictionary(); + private object? _body; + + /// + /// Private constructor to enforce usage of the Of() factory method. + /// + private ApiExecutorRequestBuilder() { } + + /// + /// Creates a new ApiExecutorRequestBuilder with the specified HTTP method and path. + /// + /// The HTTP method (e.g., GET, POST, PUT, DELETE) + /// The path template (e.g., "/stores/{store_id}/check") + /// A new ApiExecutorRequestBuilder instance + /// Thrown when method or path is null + /// Thrown when path is empty or whitespace + public static ApiExecutorRequestBuilder Of(HttpMethod method, string path) { + if (method == null) { + throw new ArgumentNullException(nameof(method), "HTTP method cannot be null"); + } + + if (path == null) { + throw new ArgumentNullException(nameof(path), "Path cannot be null"); + } + + if (string.IsNullOrWhiteSpace(path)) { + throw new ArgumentException("Path cannot be empty or whitespace", nameof(path)); + } + + if (!path.StartsWith("/")) { + throw new ArgumentException("Path must start with '/'", nameof(path)); + } + + return new ApiExecutorRequestBuilder { + Method = method, + PathTemplate = path + }; + } + + /// + /// Adds a path parameter to the request. The parameter will replace {key} in the path template. + /// + /// The parameter name (without braces) + /// The parameter value + /// This builder instance for method chaining + /// Thrown when key is null, empty, or whitespace + /// Thrown when value is null + public ApiExecutorRequestBuilder PathParam(string key, string value) { + if (string.IsNullOrWhiteSpace(key)) { + throw new ArgumentException("Path parameter key cannot be null, empty, or whitespace", nameof(key)); + } + + if (value == null) { + throw new ArgumentNullException(nameof(value), $"Path parameter value for key '{key}' cannot be null"); + } + + _pathParams[key] = value; + return this; + } + + /// + /// Adds a query parameter to the request. The parameter will be appended to the URL as ?key=value. + /// + /// The query parameter name + /// The query parameter value + /// This builder instance for method chaining + /// Thrown when key is null, empty, or whitespace + /// Thrown when value is null + public ApiExecutorRequestBuilder QueryParam(string key, string value) { + if (string.IsNullOrWhiteSpace(key)) { + throw new ArgumentException("Query parameter key cannot be null, empty, or whitespace", nameof(key)); + } + + if (value == null) { + throw new ArgumentNullException(nameof(value), $"Query parameter value for key '{key}' cannot be null"); + } + + _queryParams[key] = value; + return this; + } + + /// + /// Adds a custom header to the request. + /// + /// The header name + /// The header value + /// This builder instance for method chaining + /// Thrown when the header is reserved or invalid + public ApiExecutorRequestBuilder Header(string key, string value) { + // Validate using the existing Configuration.ValidateHeaders method + var headers = new Dictionary { { key, value } }; + Configuration.Configuration.ValidateHeaders(headers, "header"); + + _headers[key] = value; + return this; + } + + /// + /// Sets the request body. The body will be JSON-serialized when sent. + /// + /// The request body object (will be serialized to JSON) + /// This builder instance for method chaining + public ApiExecutorRequestBuilder Body(object? body) { + _body = body; + return this; + } + + /// + /// Validates and finalizes the builder. Call this method before passing to ApiExecutor. + /// + /// This builder instance + /// Thrown when the builder state is invalid + public ApiExecutorRequestBuilder Build() { + if (Method == null) { + throw new FgaValidationError("HTTP method must be specified. Use ApiExecutorRequestBuilder.Of() to create a builder."); + } + + if (string.IsNullOrWhiteSpace(PathTemplate)) { + throw new FgaValidationError("Path template must be specified. Use ApiExecutorRequestBuilder.Of() to create a builder."); + } + + return this; + } + + /// + /// Converts this ApiExecutorRequestBuilder to an internal RequestBuilder for API execution. + /// + /// The base path/URL for the API + /// A RequestBuilder configured for the API client + internal RequestBuilder ToRequestBuilder(string basePath) { + return new RequestBuilder { + Method = this.Method, + BasePath = basePath, + PathTemplate = this.PathTemplate, + PathParameters = new Dictionary(_pathParams), + QueryParameters = new Dictionary(_queryParams), + Body = _body + }; + } + + /// + /// Gets the custom headers for this request. + /// + /// A dictionary of custom headers + internal IDictionary GetHeaders() { + return new Dictionary(_headers); + } +} diff --git a/src/OpenFga.Sdk/Client/ApiExecutor/ApiResponse.cs b/src/OpenFga.Sdk/Client/ApiExecutor/ApiResponse.cs new file mode 100644 index 00000000..eb94ecff --- /dev/null +++ b/src/OpenFga.Sdk/Client/ApiExecutor/ApiResponse.cs @@ -0,0 +1,103 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; + +namespace OpenFga.Sdk.Client.ApiExecutor; + +/// +/// Represents the response from an API Executor request, containing both raw and typed response data. +/// +/// The type of the deserialized response data +public class ApiResponse { + /// + /// Gets the HTTP status code of the response. + /// + public HttpStatusCode StatusCode { get; } + + /// + /// Gets the response headers as a read-only dictionary. + /// Keys are case-insensitive. Includes both response and content headers. + /// + public IReadOnlyDictionary> Headers { get; } + + /// + /// Gets the raw response body as a string. + /// + public string RawResponse { get; } + + /// + /// Gets the deserialized response data. + /// Will be null if deserialization fails or if the response has no content. + /// + public T? Data { get; } + + /// + /// Gets whether the response indicates success (2xx status code). + /// + public bool IsSuccessful => (int)StatusCode >= 200 && (int)StatusCode < 300; + + /// + /// Initializes a new instance of the ApiResponse class. + /// + /// The HTTP status code + /// The response headers + /// The raw response body + /// The deserialized response data + internal ApiResponse( + HttpStatusCode statusCode, + IReadOnlyDictionary> headers, + string rawResponse, + T? data) { + StatusCode = statusCode; + Headers = headers; + RawResponse = rawResponse; + Data = data; + } + + /// + /// Creates an ApiResponse from an HttpResponseMessage. + /// + /// The HTTP response message + /// The raw response body as a string + /// The deserialized response data + /// A new ApiResponse instance + internal static ApiResponse FromHttpResponse( + HttpResponseMessage response, + string rawResponse, + T? data) { + var headers = ConvertHeaders(response); + return new ApiResponse( + response.StatusCode, + headers, + rawResponse, + data); + } + + /// + /// Converts HttpResponseMessage headers to a case-insensitive dictionary. + /// Includes both response headers and content headers. + /// + /// The HTTP response message + /// A read-only dictionary of headers + private static IReadOnlyDictionary> ConvertHeaders( + HttpResponseMessage response) { + var headers = new Dictionary>( + StringComparer.OrdinalIgnoreCase); + + // Add response headers + foreach (var header in response.Headers) { + headers[header.Key] = header.Value; + } + + // Add content headers if present + if (response.Content?.Headers != null) { + foreach (var header in response.Content.Headers) { + headers[header.Key] = header.Value; + } + } + + return headers; + } +} diff --git a/src/OpenFga.Sdk/Client/Client.cs b/src/OpenFga.Sdk/Client/Client.cs index 6cec8df8..1b65a906 100644 --- a/src/OpenFga.Sdk/Client/Client.cs +++ b/src/OpenFga.Sdk/Client/Client.cs @@ -22,6 +22,7 @@ namespace OpenFga.Sdk.Client; public class OpenFgaClient : IOpenFgaClient, IDisposable { private readonly ClientConfiguration _configuration; protected OpenFgaApi api; + private ApiExecutor.ApiExecutor? _apiExecutor; public OpenFgaClient( ClientConfiguration configuration, @@ -44,7 +45,25 @@ public string? AuthorizationModelId { set => _configuration.AuthorizationModelId = value; } - public void Dispose() => api.Dispose(); + /// + /// Gets the ApiExecutor for making custom API requests. + /// The ApiExecutor allows you to call arbitrary OpenFGA API endpoints while + /// automatically leveraging the SDK's authentication, retry logic, and error handling. + /// + /// An ApiExecutor instance + public ApiExecutor.ApiExecutor ApiExecutor() { + if (_apiExecutor == null) { + _apiExecutor = new ApiExecutor.ApiExecutor( + api.ApiClientInternal, + _configuration); + } + return _apiExecutor; + } + + public void Dispose() { + _apiExecutor?.Dispose(); + api.Dispose(); + } #if NET6_0_OR_GREATER private async Task ProcessWriteChunksAsync( From f4bb328506ecc0501047bc416b6bfb30e512317f Mon Sep 17 00:00:00 2001 From: Anurag Bandyopadhyay Date: Wed, 28 Jan 2026 20:51:26 +0530 Subject: [PATCH 02/23] fix: ignore local Claude settings --- .claude/settings.local.json | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 .claude/settings.local.json diff --git a/.claude/settings.local.json b/.claude/settings.local.json deleted file mode 100644 index a0010289..00000000 --- a/.claude/settings.local.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "permissions": { - "allow": [ - "Bash(grep:*)", - "Bash(tree:*)", - "Bash(wc:*)" - ] - } -} From f23510c3114ab34340aabebf2d660812dac84e0b Mon Sep 17 00:00:00 2001 From: SoulPancake Date: Wed, 28 Jan 2026 22:57:50 +0530 Subject: [PATCH 03/23] fix: api executor test --- .../Client/ApiExecutor/ApiExecutorTests.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorTests.cs b/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorTests.cs index cceda89e..edcd2c16 100644 --- a/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorTests.cs +++ b/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorTests.cs @@ -3,6 +3,7 @@ using OpenFga.Sdk.Client; using OpenFga.Sdk.Client.ApiExecutor; using OpenFga.Sdk.Client.Model; +using OpenFga.Sdk.Configuration; using OpenFga.Sdk.Exceptions; using OpenFga.Sdk.Model; using System; @@ -397,9 +398,9 @@ public async Task SendAsync_WithCredentials_IncludesAuthorizationHeader() { var config = new ClientConfiguration { ApiUrl = _apiUrl, StoreId = _storeId, - Credentials = new Credentials.Credentials { - Method = Credentials.CredentialsMethod.ApiToken, - Config = new Credentials.CredentialsConfig { + Credentials = new Credentials { + Method = CredentialsMethod.ApiToken, + Config = new CredentialsConfig { ApiToken = "test-token-123" } } From 170007e3829c203d9667f7a28e3db6e71c3fb602 Mon Sep 17 00:00:00 2001 From: SoulPancake Date: Thu, 29 Jan 2026 01:09:07 +0530 Subject: [PATCH 04/23] feat: refactor changelog --- CHANGELOG.md | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e60e59e3..5c94eb41 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,14 +3,8 @@ ## [Unreleased](https://github.com/openfga/dotnet-sdk/compare/v0.9.0...HEAD) ### Added -- feat: add support for [StreamedListObjects](https://openfga.dev/api/service#/Relationship%20Queries/StreamedListObjects). See [documentation](#streamed-list-objects) -- feat: add API Executor for making custom API requests - - New `ApiExecutor` class accessible via `client.ApiExecutor()` method - - Fluent `ApiExecutorRequestBuilder` for constructing requests - - `ApiResponse` wrapper providing both raw and typed responses - - Automatically leverages SDK authentication, retry logic, and error handling - - Supports custom headers, path parameters, query parameters, and request bodies - - See [Calling Other API Endpoints documentation](README.md#calling-other-api-endpoints) for usage examples +- feat: add StreamedListObjects API support +- feat: add ApiExecutor for custom API requests with fluent builder pattern ## v0.9.0 From 94bd5f9e4746a7f264e085a3d62cfb44973cffdf Mon Sep 17 00:00:00 2001 From: SoulPancake Date: Thu, 29 Jan 2026 01:20:11 +0530 Subject: [PATCH 05/23] feat: testcontainers for raw req integration tests --- .../ApiExecutorIntegrationTests.cs | 640 ++++++++++++++++++ src/OpenFga.Sdk.Test/OpenFga.Sdk.Test.csproj | 1 + 2 files changed, 641 insertions(+) create mode 100644 src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorIntegrationTests.cs diff --git a/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorIntegrationTests.cs b/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorIntegrationTests.cs new file mode 100644 index 00000000..39895c1e --- /dev/null +++ b/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorIntegrationTests.cs @@ -0,0 +1,640 @@ +using DotNet.Testcontainers.Builders; +using DotNet.Testcontainers.Containers; +using OpenFga.Sdk.Client; +using OpenFga.Sdk.Client.ApiExecutor; +using OpenFga.Sdk.Configuration; +using OpenFga.Sdk.Exceptions; +using OpenFga.Sdk.Model; +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Threading.Tasks; +using Xunit; + +namespace OpenFga.Sdk.Test.Client.ApiExecutor; + +/// +/// Integration tests for ApiExecutor functionality. +/// These tests demonstrate how to use API Executor to call OpenFGA endpoints +/// without using the SDK's typed methods. +/// Runs against an actual OpenFGA server using Testcontainers. +/// +public class ApiExecutorIntegrationTests : IAsyncLifetime { + private IContainer? _openFgaContainer; + private OpenFgaClient? _fga; + private const string OpenFgaImage = "openfga/openfga:v1.10.2"; + private const int OpenFgaPort = 8080; + + public async Task InitializeAsync() { + // Create and start OpenFGA container + _openFgaContainer = new ContainerBuilder() + .WithImage(OpenFgaImage) + .WithPortBinding(OpenFgaPort, true) + .WithWaitStrategy(Wait.ForUnixContainer().UntilHttpRequestIsSucceeded(r => r + .ForPort(OpenFgaPort) + .ForPath("/healthz") + )) + .Build(); + + await _openFgaContainer.StartAsync(); + + // Initialize OpenFGA client + var apiUrl = $"http://{_openFgaContainer.Hostname}:{_openFgaContainer.GetMappedPublicPort(OpenFgaPort)}"; + var config = new ClientConfiguration { + ApiUrl = apiUrl + }; + _fga = new OpenFgaClient(config); + } + + public async Task DisposeAsync() { + _fga?.Dispose(); + if (_openFgaContainer != null) { + await _openFgaContainer.DisposeAsync(); + } + } + + /// + /// Test listing stores using ApiExecutor instead of fga.ListStores(). + /// + [Fact] + public async Task RawRequest_ListStores() { + // Create a store first so we have something to list + var storeName = "test-store-" + DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); + await CreateStoreUsingRawRequest(storeName); + + // Use ApiExecutor to list stores (equivalent to GET /stores) + var request = ApiExecutorRequestBuilder + .Of(HttpMethod.Get, "/stores") + .Build(); + + var response = await _fga!.ApiExecutor().SendAsync(request); + + // Verify response + Assert.NotNull(response); + Assert.Equal(System.Net.HttpStatusCode.OK, response.StatusCode); + Assert.True(response.IsSuccessful); + Assert.NotNull(response.Data); + Assert.NotNull(response.Data.Stores); + Assert.NotEmpty(response.Data.Stores); + + // Verify we can find our store + var foundStore = false; + foreach (var store in response.Data.Stores) { + if (store.Name == storeName) { + foundStore = true; + break; + } + } + Assert.True(foundStore, "Should find the store we created"); + } + + /// + /// Test creating a store using ApiExecutor with typed response. + /// + [Fact] + public async Task RawRequest_CreateStore_TypedResponse() { + var storeName = "raw-test-store-" + DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); + + // Build request body + var requestBody = new Dictionary { + { "name", storeName } + }; + + // Use ApiExecutor to create store (equivalent to POST /stores) + var request = ApiExecutorRequestBuilder + .Of(HttpMethod.Post, "/stores") + .Body(requestBody) + .Build(); + + var response = await _fga!.ApiExecutor().SendAsync(request); + + // Verify response + Assert.NotNull(response); + Assert.Equal(System.Net.HttpStatusCode.Created, response.StatusCode); + Assert.True(response.IsSuccessful); + Assert.NotNull(response.Data); + Assert.NotNull(response.Data.Id); + Assert.Equal(storeName, response.Data.Name); + } + + /// + /// Test creating a store using ApiExecutor with raw JSON string response. + /// + [Fact] + public async Task RawRequest_CreateStore_RawJsonResponse() { + var storeName = "raw-json-test-" + DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); + + // Build request body + var requestBody = new Dictionary { + { "name", storeName } + }; + + // Use ApiExecutor to create store and get raw JSON response + var request = ApiExecutorRequestBuilder + .Of(HttpMethod.Post, "/stores") + .Body(requestBody) + .Build(); + + var response = await _fga!.ApiExecutor().SendAsync(request); + + // Verify response + Assert.NotNull(response); + Assert.Equal(System.Net.HttpStatusCode.Created, response.StatusCode); + Assert.True(response.IsSuccessful); + Assert.NotNull(response.Data); + Assert.NotNull(response.RawResponse); + + // Parse the JSON manually + var rawJson = response.Data; + Assert.Contains("\"id\"", rawJson); + Assert.Contains("\"name\"", rawJson); + Assert.Contains(storeName, rawJson); + } + + /// + /// Test getting a specific store using ApiExecutor with path parameters. + /// + [Fact] + public async Task RawRequest_GetStore_WithPathParams() { + // Create a store first + var storeName = "get-test-store-" + DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); + var storeId = await CreateStoreUsingRawRequest(storeName); + + // Use ApiExecutor to get store details (equivalent to GET /stores/{store_id}) + var request = ApiExecutorRequestBuilder + .Of(HttpMethod.Get, "/stores/{store_id}") + .PathParam("store_id", storeId) + .Build(); + + var response = await _fga!.ApiExecutor().SendAsync(request); + + // Verify response + Assert.NotNull(response); + Assert.Equal(System.Net.HttpStatusCode.OK, response.StatusCode); + Assert.True(response.IsSuccessful); + Assert.NotNull(response.Data); + Assert.Equal(storeId, response.Data.Id); + Assert.Equal(storeName, response.Data.Name); + } + + /// + /// Test automatic {store_id} replacement when store ID is configured. + /// + [Fact] + public async Task RawRequest_AutomaticStoreIdReplacement() { + // Create a store and configure it + var storeName = "auto-store-" + DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); + var storeId = await CreateStoreUsingRawRequest(storeName); + _fga!.StoreId = storeId; + + // Use ApiExecutor WITHOUT providing store_id path param - it should be auto-replaced + var request = ApiExecutorRequestBuilder + .Of(HttpMethod.Get, "/stores/{store_id}") + .Build(); + + var response = await _fga.ApiExecutor().SendAsync(request); + + // Verify response + Assert.NotNull(response); + Assert.Equal(System.Net.HttpStatusCode.OK, response.StatusCode); + Assert.True(response.IsSuccessful); + Assert.Equal(storeId, response.Data.Id); + + // Clean up - reset store ID + _fga.StoreId = null; + } + + /// + /// Test writing authorization model using ApiExecutor. + /// + [Fact] + public async Task RawRequest_WriteAuthorizationModel() { + // Create a store first + var storeName = "auth-model-test-" + DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); + var storeId = await CreateStoreUsingRawRequest(storeName); + _fga!.StoreId = storeId; + + // Build authorization model with proper metadata + var requestBody = new Dictionary { + { "schema_version", "1.1" }, + { + "type_definitions", new List> { + new Dictionary { + { "type", "user" }, + { "relations", new Dictionary() } + }, + new Dictionary { + { "type", "document" }, + { + "relations", new Dictionary { + { + "reader", new Dictionary { + { "this", new Dictionary() } + } + } + } + }, + { + "metadata", new Dictionary { + { + "relations", new Dictionary { + { + "reader", new Dictionary { + { + "directly_related_user_types", new List> { + new Dictionary { { "type", "user" } } + } + } + } + } + } + } + } + } + } + } + } + }; + + // Use ApiExecutor to write authorization model + var request = ApiExecutorRequestBuilder + .Of(HttpMethod.Post, "/stores/{store_id}/authorization-models") + .Body(requestBody) + .Build(); + + var response = await _fga.ApiExecutor().SendAsync(request); + + // Verify response + Assert.NotNull(response); + Assert.Equal(System.Net.HttpStatusCode.Created, response.StatusCode); + Assert.True(response.IsSuccessful); + Assert.NotNull(response.Data); + Assert.NotNull(response.Data.AuthorizationModelId); + + // Clean up + _fga.StoreId = null; + } + + /// + /// Test reading authorization models with query parameters. + /// + [Fact] + public async Task RawRequest_ReadAuthorizationModels_WithQueryParams() { + // Create a store and write a model + var storeName = "read-models-test-" + DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); + var storeId = await CreateStoreUsingRawRequest(storeName); + _fga!.StoreId = storeId; + + // Create an authorization model first + await WriteSimpleAuthorizationModel(storeId); + + // Use ApiExecutor to read authorization models with query parameters + var request = ApiExecutorRequestBuilder + .Of(HttpMethod.Get, "/stores/{store_id}/authorization-models") + .QueryParam("page_size", "10") + .Build(); + + var response = await _fga.ApiExecutor().SendAsync(request); + + // Verify response + Assert.NotNull(response); + Assert.Equal(System.Net.HttpStatusCode.OK, response.StatusCode); + Assert.True(response.IsSuccessful); + Assert.NotNull(response.Data); + Assert.NotNull(response.Data.AuthorizationModels); + Assert.NotEmpty(response.Data.AuthorizationModels); + + // Clean up + _fga.StoreId = null; + } + + /// + /// Test Check API using raw request. + /// + [Fact] + public async Task RawRequest_Check() { + // Setup: Create store and authorization model + var storeName = "check-test-" + DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); + var storeId = await CreateStoreUsingRawRequest(storeName); + _fga!.StoreId = storeId; + var modelId = await WriteSimpleAuthorizationModel(storeId); + + // Write a tuple + await WriteTupleUsingRawRequest(storeId, "user:alice", "reader", "document:budget"); + + // Use ApiExecutor to perform check + var checkBody = new Dictionary { + { "authorization_model_id", modelId }, + { + "tuple_key", new Dictionary { + { "user", "user:alice" }, + { "relation", "reader" }, + { "object", "document:budget" } + } + } + }; + + var request = ApiExecutorRequestBuilder + .Of(HttpMethod.Post, "/stores/{store_id}/check") + .Body(checkBody) + .Build(); + + var response = await _fga.ApiExecutor().SendAsync(request); + + // Verify response + Assert.NotNull(response); + Assert.Equal(System.Net.HttpStatusCode.OK, response.StatusCode); + Assert.True(response.IsSuccessful); + Assert.NotNull(response.Data); + Assert.True(response.Data.Allowed, "Alice should be allowed to read the document"); + + // Clean up + _fga.StoreId = null; + } + + /// + /// Test custom headers with raw request. + /// + [Fact] + public async Task RawRequest_WithCustomHeaders() { + var storeName = "headers-test-" + DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); + + var requestBody = new Dictionary { + { "name", storeName } + }; + + // Use ApiExecutor with custom headers + var request = ApiExecutorRequestBuilder + .Of(HttpMethod.Post, "/stores") + .Body(requestBody) + .Header("X-Custom-Header", "custom-value") + .Header("X-Request-ID", "test-123") + .Build(); + + var response = await _fga!.ApiExecutor().SendAsync(request); + + // Verify response + Assert.NotNull(response); + Assert.Equal(System.Net.HttpStatusCode.Created, response.StatusCode); + Assert.True(response.IsSuccessful); + } + + /// + /// Test error handling with raw request. + /// + [Fact] + public async Task RawRequest_ErrorHandling_NotFound() { + // Try to get a non-existent store + var request = ApiExecutorRequestBuilder + .Of(HttpMethod.Get, "/stores/{store_id}") + .PathParam("store_id", "non-existent-store-id") + .Build(); + + // Should throw an exception + await Assert.ThrowsAnyAsync(async () => + await _fga!.ApiExecutor().SendAsync(request)); + } + + /// + /// Test list stores with pagination using query parameters. + /// + [Fact] + public async Task RawRequest_ListStores_WithPagination() { + // Create multiple stores + for (int i = 0; i < 3; i++) { + await CreateStoreUsingRawRequest("pagination-test-" + i + "-" + DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()); + // Small delay to ensure unique timestamps + await Task.Delay(10); + } + + // Use ApiExecutor to list stores with pagination + var request = ApiExecutorRequestBuilder + .Of(HttpMethod.Get, "/stores") + .QueryParam("page_size", "2") + .Build(); + + var response = await _fga!.ApiExecutor().SendAsync(request); + + // Verify response + Assert.NotNull(response); + Assert.Equal(System.Net.HttpStatusCode.OK, response.StatusCode); + Assert.True(response.IsSuccessful); + Assert.NotNull(response.Data); + Assert.NotNull(response.Data.Stores); + } + + /// + /// Test Write API using raw request. + /// + [Fact] + public async Task RawRequest_Write_WriteTuples() { + // Setup: Create store and authorization model + var storeName = "write-test-" + DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); + var storeId = await CreateStoreUsingRawRequest(storeName); + _fga!.StoreId = storeId; + await WriteSimpleAuthorizationModel(storeId); + + // Use ApiExecutor to write tuples + var writeBody = new Dictionary { + { + "writes", new Dictionary { + { + "tuple_keys", new List> { + new Dictionary { + { "user", "user:bob" }, + { "relation", "reader" }, + { "object", "document:report" } + } + } + } + } + } + }; + + var request = ApiExecutorRequestBuilder + .Of(HttpMethod.Post, "/stores/{store_id}/write") + .Body(writeBody) + .Build(); + + var response = await _fga.ApiExecutor().SendAsync(request); + + // Verify response + Assert.NotNull(response); + Assert.Equal(System.Net.HttpStatusCode.OK, response.StatusCode); + Assert.True(response.IsSuccessful); + + // Clean up + _fga.StoreId = null; + } + + /// + /// Test Read API using raw request. + /// + [Fact] + public async Task RawRequest_Read_ReadTuples() { + // Setup: Create store, authorization model, and write a tuple + var storeName = "read-test-" + DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); + var storeId = await CreateStoreUsingRawRequest(storeName); + _fga!.StoreId = storeId; + await WriteSimpleAuthorizationModel(storeId); + await WriteTupleUsingRawRequest(storeId, "user:charlie", "reader", "document:plan"); + + // Use ApiExecutor to read tuples + var readBody = new Dictionary { + { + "tuple_key", new Dictionary { + { "user", "user:charlie" }, + { "relation", "reader" }, + { "object", "document:plan" } + } + } + }; + + var request = ApiExecutorRequestBuilder + .Of(HttpMethod.Post, "/stores/{store_id}/read") + .Body(readBody) + .Build(); + + var response = await _fga.ApiExecutor().SendAsync(request); + + // Verify response + Assert.NotNull(response); + Assert.Equal(System.Net.HttpStatusCode.OK, response.StatusCode); + Assert.True(response.IsSuccessful); + Assert.NotNull(response.Data); + Assert.NotNull(response.Data.Tuples); + Assert.NotEmpty(response.Data.Tuples); + + // Verify the tuple we wrote is present + var foundTuple = false; + foreach (var tuple in response.Data.Tuples) { + if (tuple.Key.User == "user:charlie" && + tuple.Key.Relation == "reader" && + tuple.Key.Object == "document:plan") { + foundTuple = true; + break; + } + } + Assert.True(foundTuple, "Should find the tuple we wrote"); + + // Clean up + _fga.StoreId = null; + } + + /// + /// Test Delete Store using raw request. + /// + [Fact] + public async Task RawRequest_DeleteStore() { + // Create a store first + var storeName = "delete-test-" + DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); + var storeId = await CreateStoreUsingRawRequest(storeName); + + // Use ApiExecutor to delete the store + var request = ApiExecutorRequestBuilder + .Of(HttpMethod.Delete, "/stores/{store_id}") + .PathParam("store_id", storeId) + .Build(); + + var response = await _fga!.ApiExecutor().SendAsync(request); + + // Verify response + Assert.NotNull(response); + Assert.Equal(System.Net.HttpStatusCode.NoContent, response.StatusCode); + Assert.True(response.IsSuccessful); + } + + // Helper methods + + private async Task CreateStoreUsingRawRequest(string storeName) { + var requestBody = new Dictionary { + { "name", storeName } + }; + + var request = ApiExecutorRequestBuilder + .Of(HttpMethod.Post, "/stores") + .Body(requestBody) + .Build(); + + var response = await _fga!.ApiExecutor().SendAsync(request); + return response.Data.Id; + } + + private async Task WriteSimpleAuthorizationModel(string storeId) { + var requestBody = new Dictionary { + { "schema_version", "1.1" }, + { + "type_definitions", new List> { + new Dictionary { + { "type", "user" }, + { "relations", new Dictionary() } + }, + new Dictionary { + { "type", "document" }, + { + "relations", new Dictionary { + { + "reader", new Dictionary { + { "this", new Dictionary() } + } + } + } + }, + { + "metadata", new Dictionary { + { + "relations", new Dictionary { + { + "reader", new Dictionary { + { + "directly_related_user_types", new List> { + new Dictionary { { "type", "user" } } + } + } + } + } + } + } + } + } + } + } + } + }; + + var request = ApiExecutorRequestBuilder + .Of(HttpMethod.Post, "/stores/{store_id}/authorization-models") + .PathParam("store_id", storeId) + .Body(requestBody) + .Build(); + + var response = await _fga!.ApiExecutor().SendAsync(request); + return response.Data.AuthorizationModelId; + } + + private async Task WriteTupleUsingRawRequest(string storeId, string user, string relation, string obj) { + var requestBody = new Dictionary { + { + "writes", new Dictionary { + { + "tuple_keys", new List> { + new Dictionary { + { "user", user }, + { "relation", relation }, + { "object", obj } + } + } + } + } + } + }; + + var request = ApiExecutorRequestBuilder + .Of(HttpMethod.Post, "/stores/{store_id}/write") + .PathParam("store_id", storeId) + .Body(requestBody) + .Build(); + + await _fga!.ApiExecutor().SendAsync(request); + } +} diff --git a/src/OpenFga.Sdk.Test/OpenFga.Sdk.Test.csproj b/src/OpenFga.Sdk.Test/OpenFga.Sdk.Test.csproj index 0e191bab..913384a1 100644 --- a/src/OpenFga.Sdk.Test/OpenFga.Sdk.Test.csproj +++ b/src/OpenFga.Sdk.Test/OpenFga.Sdk.Test.csproj @@ -61,6 +61,7 @@ all runtime; build; native; contentfiles; analyzers + all From 1f7a04e47b427a8066809adf43e4a3de20babf3a Mon Sep 17 00:00:00 2001 From: SoulPancake Date: Thu, 29 Jan 2026 18:59:43 +0530 Subject: [PATCH 06/23] feat: address comments --- CHANGELOG.md | 2 +- .../ApiExecutor/ApiExecutorIntegrationTests.cs | 14 +++++--------- .../ApiExecutorRequestBuilderTests.cs | 8 ++++---- .../Client/ApiExecutor/ApiExecutorTests.cs | 2 +- .../Client/ApiExecutor/ApiResponseTests.cs | 2 +- .../Client/ApiExecutor/ApiExecutor.cs | 4 ++-- src/OpenFga.Sdk/Client/Client.cs | 16 ++++++++-------- 7 files changed, 22 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c94eb41..b3a64466 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ ### Added - feat: add StreamedListObjects API support -- feat: add ApiExecutor for custom API requests with fluent builder pattern +- feat: add ApiExecutor for raw requests ## v0.9.0 diff --git a/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorIntegrationTests.cs b/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorIntegrationTests.cs index 39895c1e..d45609a2 100644 --- a/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorIntegrationTests.cs +++ b/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorIntegrationTests.cs @@ -7,6 +7,7 @@ using OpenFga.Sdk.Model; using System; using System.Collections.Generic; +using System.Linq; using System.Net.Http; using System.Threading.Tasks; using Xunit; @@ -506,15 +507,10 @@ public async Task RawRequest_Read_ReadTuples() { Assert.NotEmpty(response.Data.Tuples); // Verify the tuple we wrote is present - var foundTuple = false; - foreach (var tuple in response.Data.Tuples) { - if (tuple.Key.User == "user:charlie" && - tuple.Key.Relation == "reader" && - tuple.Key.Object == "document:plan") { - foundTuple = true; - break; - } - } + var foundTuple = response.Data.Tuples.Any(tuple => + tuple.Key.User == "user:charlie" && + tuple.Key.Relation == "reader" && + tuple.Key.Object == "document:plan"); Assert.True(foundTuple, "Should find the tuple we wrote"); // Clean up diff --git a/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorRequestBuilderTests.cs b/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorRequestBuilderTests.cs index dfb747d6..25b81fb6 100644 --- a/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorRequestBuilderTests.cs +++ b/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorRequestBuilderTests.cs @@ -269,10 +269,10 @@ public void ToRequestBuilder_ConvertsCorrectly() { Assert.Equal(HttpMethod.Post, requestBuilder.Method); Assert.Equal("https://api.fga.example", requestBuilder.BasePath); Assert.Equal("/stores/{store_id}/check", requestBuilder.PathTemplate); - Assert.True(requestBuilder.PathParameters.ContainsKey("store_id")); - Assert.Equal("store123", requestBuilder.PathParameters["store_id"]); - Assert.True(requestBuilder.QueryParameters.ContainsKey("page_size")); - Assert.Equal("20", requestBuilder.QueryParameters["page_size"]); + Assert.True(requestBuilder.PathParameters.TryGetValue("store_id", out var storeIdValue)); + Assert.Equal("store123", storeIdValue); + Assert.True(requestBuilder.QueryParameters.TryGetValue("page_size", out var pageSizeValue)); + Assert.Equal("20", pageSizeValue); Assert.NotNull(requestBuilder.Body); } diff --git a/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorTests.cs b/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorTests.cs index edcd2c16..ae43b0eb 100644 --- a/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorTests.cs +++ b/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorTests.cs @@ -381,7 +381,7 @@ await Assert.ThrowsAnyAsync(async () => [Fact] public async Task SendAsync_WithCredentials_IncludesAuthorizationHeader() { // Arrange - var responseMessage = new HttpResponseMessage { + using var responseMessage = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent("{}", Encoding.UTF8, "application/json") }; diff --git a/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiResponseTests.cs b/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiResponseTests.cs index 6fe7a34b..9c894a6e 100644 --- a/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiResponseTests.cs +++ b/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiResponseTests.cs @@ -138,7 +138,7 @@ public void Headers_AreCaseInsensitive() { [Fact] public void FromHttpResponse_WithNullData_StoresNull() { // Arrange - var httpResponse = new HttpResponseMessage { + using var httpResponse = new HttpResponseMessage { StatusCode = HttpStatusCode.NoContent }; diff --git a/src/OpenFga.Sdk/Client/ApiExecutor/ApiExecutor.cs b/src/OpenFga.Sdk/Client/ApiExecutor/ApiExecutor.cs index 07cac8f0..d62db9bf 100644 --- a/src/OpenFga.Sdk/Client/ApiExecutor/ApiExecutor.cs +++ b/src/OpenFga.Sdk/Client/ApiExecutor/ApiExecutor.cs @@ -102,10 +102,10 @@ public async Task> SendAsync( requestBuilder, "ApiExecutor", customHeaders, - cancellationToken); + cancellationToken).ConfigureAwait(false); // Read the raw response body - var rawResponse = await responseWrapper.rawResponse.Content.ReadAsStringAsync(); + var rawResponse = await responseWrapper.rawResponse.Content.ReadAsStringAsync().ConfigureAwait(false); // Create and return ApiResponse with raw JSON as both RawResponse and Data return ApiResponse.FromHttpResponse( diff --git a/src/OpenFga.Sdk/Client/Client.cs b/src/OpenFga.Sdk/Client/Client.cs index 1b65a906..ab7ce696 100644 --- a/src/OpenFga.Sdk/Client/Client.cs +++ b/src/OpenFga.Sdk/Client/Client.cs @@ -22,7 +22,7 @@ namespace OpenFga.Sdk.Client; public class OpenFgaClient : IOpenFgaClient, IDisposable { private readonly ClientConfiguration _configuration; protected OpenFgaApi api; - private ApiExecutor.ApiExecutor? _apiExecutor; + private readonly Lazy _apiExecutor; public OpenFgaClient( ClientConfiguration configuration, @@ -31,6 +31,9 @@ public OpenFgaClient( configuration.EnsureValid(); _configuration = configuration; api = new OpenFgaApi(_configuration, httpClient); + _apiExecutor = new Lazy(() => new ApiExecutor.ApiExecutor( + api.ApiClientInternal, + _configuration)); } /// @@ -52,16 +55,13 @@ public string? AuthorizationModelId { /// /// An ApiExecutor instance public ApiExecutor.ApiExecutor ApiExecutor() { - if (_apiExecutor == null) { - _apiExecutor = new ApiExecutor.ApiExecutor( - api.ApiClientInternal, - _configuration); - } - return _apiExecutor; + return _apiExecutor.Value; } public void Dispose() { - _apiExecutor?.Dispose(); + if (_apiExecutor.IsValueCreated) { + _apiExecutor.Value?.Dispose(); + } api.Dispose(); } From a92010643cdaecf6c3d6c6eded45df0f99d57ef8 Mon Sep 17 00:00:00 2001 From: Anurag Bandyopadhyay Date: Wed, 28 Jan 2026 21:28:58 +0530 Subject: [PATCH 07/23] feat: test --- README.md | 70 +------------- src/OpenFga.Sdk/Api/OpenFgaApi.cs | 12 +-- src/OpenFga.Sdk/Constants/FgaConstants.cs | 2 +- .../Model/AbortedMessageResponse.cs | 51 ++++++---- src/OpenFga.Sdk/Model/Any.cs | 46 ++++++---- src/OpenFga.Sdk/Model/Assertion.cs | 61 +++++++----- src/OpenFga.Sdk/Model/AssertionTupleKey.cs | 80 ++++++++++------ src/OpenFga.Sdk/Model/AuthErrorCode.cs | 14 ++- src/OpenFga.Sdk/Model/AuthorizationModel.cs | 70 +++++++++----- src/OpenFga.Sdk/Model/BatchCheckItem.cs | 67 +++++++++----- src/OpenFga.Sdk/Model/BatchCheckRequest.cs | 56 +++++++---- src/OpenFga.Sdk/Model/BatchCheckResponse.cs | 46 ++++++---- .../Model/BatchCheckSingleResult.cs | 48 ++++++---- src/OpenFga.Sdk/Model/CheckError.cs | 50 ++++++---- src/OpenFga.Sdk/Model/CheckRequest.cs | 71 ++++++++------ src/OpenFga.Sdk/Model/CheckRequestTupleKey.cs | 80 ++++++++++------ src/OpenFga.Sdk/Model/CheckResponse.cs | 48 ++++++---- src/OpenFga.Sdk/Model/Computed.cs | 49 ++++++---- src/OpenFga.Sdk/Model/Condition.cs | 67 +++++++++----- src/OpenFga.Sdk/Model/ConditionMetadata.cs | 51 ++++++---- .../Model/ConditionParamTypeRef.cs | 48 ++++++---- .../Model/ConsistencyPreference.cs | 14 ++- src/OpenFga.Sdk/Model/ContextualTupleKeys.cs | 49 ++++++---- src/OpenFga.Sdk/Model/CreateStoreRequest.cs | 49 ++++++---- src/OpenFga.Sdk/Model/CreateStoreResponse.cs | 67 +++++++++----- src/OpenFga.Sdk/Model/Difference.cs | 57 ++++++++---- src/OpenFga.Sdk/Model/ErrorCode.cs | 14 ++- src/OpenFga.Sdk/Model/ExpandRequest.cs | 61 +++++++----- .../Model/ExpandRequestTupleKey.cs | 67 +++++++++----- src/OpenFga.Sdk/Model/ExpandResponse.cs | 46 ++++++---- src/OpenFga.Sdk/Model/FgaObject.cs | 57 ++++++++---- src/OpenFga.Sdk/Model/ForbiddenResponse.cs | 48 ++++++---- src/OpenFga.Sdk/Model/GetStoreResponse.cs | 72 +++++++++------ src/OpenFga.Sdk/Model/InternalErrorCode.cs | 14 ++- .../Model/InternalErrorMessageResponse.cs | 48 ++++++---- src/OpenFga.Sdk/Model/Leaf.cs | 56 +++++++---- src/OpenFga.Sdk/Model/ListObjectsRequest.cs | 92 ++++++++++++------- src/OpenFga.Sdk/Model/ListObjectsResponse.cs | 49 ++++++---- src/OpenFga.Sdk/Model/ListStoresResponse.cs | 57 ++++++++---- src/OpenFga.Sdk/Model/ListUsersRequest.cs | 82 +++++++++++------ src/OpenFga.Sdk/Model/ListUsersResponse.cs | 49 ++++++---- src/OpenFga.Sdk/Model/Metadata.cs | 56 +++++++---- src/OpenFga.Sdk/Model/Node.cs | 69 +++++++++----- src/OpenFga.Sdk/Model/Nodes.cs | 49 ++++++---- src/OpenFga.Sdk/Model/NotFoundErrorCode.cs | 14 ++- src/OpenFga.Sdk/Model/NullValue.cs | 14 ++- src/OpenFga.Sdk/Model/ObjectRelation.cs | 51 ++++++---- .../Model/PathUnknownErrorMessageResponse.cs | 48 ++++++---- .../Model/ReadAssertionsResponse.cs | 54 +++++++---- .../Model/ReadAuthorizationModelResponse.cs | 46 ++++++---- .../Model/ReadAuthorizationModelsResponse.cs | 54 +++++++---- src/OpenFga.Sdk/Model/ReadChangesResponse.cs | 54 +++++++---- src/OpenFga.Sdk/Model/ReadRequest.cs | 65 ++++++++----- src/OpenFga.Sdk/Model/ReadRequestTupleKey.cs | 71 ++++++++------ src/OpenFga.Sdk/Model/ReadResponse.cs | 57 ++++++++---- src/OpenFga.Sdk/Model/RelationMetadata.cs | 56 +++++++---- src/OpenFga.Sdk/Model/RelationReference.cs | 64 ++++++++----- .../Model/RelationshipCondition.cs | 59 +++++++----- src/OpenFga.Sdk/Model/SourceInfo.cs | 46 ++++++---- src/OpenFga.Sdk/Model/Status.cs | 53 +++++++---- src/OpenFga.Sdk/Model/Store.cs | 72 +++++++++------ ...reamResultOfStreamedListObjectsResponse.cs | 51 ++++++---- .../Model/StreamedListObjectsResponse.cs | 49 ++++++---- src/OpenFga.Sdk/Model/Tuple.cs | 54 +++++++---- src/OpenFga.Sdk/Model/TupleChange.cs | 55 ++++++----- src/OpenFga.Sdk/Model/TupleKey.cs | 85 ++++++++++------- .../Model/TupleKeyWithoutCondition.cs | 80 ++++++++++------ src/OpenFga.Sdk/Model/TupleOperation.cs | 14 ++- src/OpenFga.Sdk/Model/TupleToUserset.cs | 57 ++++++++---- src/OpenFga.Sdk/Model/TypeDefinition.cs | 59 +++++++----- src/OpenFga.Sdk/Model/TypeName.cs | 14 ++- src/OpenFga.Sdk/Model/TypedWildcard.cs | 49 ++++++---- .../Model/UnauthenticatedResponse.cs | 48 ++++++---- .../Model/UnprocessableContentErrorCode.cs | 14 ++- .../UnprocessableContentMessageResponse.cs | 48 ++++++---- src/OpenFga.Sdk/Model/User.cs | 56 +++++++---- src/OpenFga.Sdk/Model/UserTypeFilter.cs | 54 +++++++---- src/OpenFga.Sdk/Model/Users.cs | 49 ++++++---- src/OpenFga.Sdk/Model/Userset.cs | 71 ++++++++------ src/OpenFga.Sdk/Model/UsersetTree.cs | 46 ++++++---- .../Model/UsersetTreeDifference.cs | 57 ++++++++---- .../Model/UsersetTreeTupleToUserset.cs | 57 ++++++++---- src/OpenFga.Sdk/Model/UsersetUser.cs | 65 ++++++++----- src/OpenFga.Sdk/Model/Usersets.cs | 49 ++++++---- .../Model/ValidationErrorMessageResponse.cs | 48 ++++++---- .../Model/WriteAssertionsRequest.cs | 49 ++++++---- .../Model/WriteAuthorizationModelRequest.cs | 62 ++++++++----- .../Model/WriteAuthorizationModelResponse.cs | 49 ++++++---- src/OpenFga.Sdk/Model/WriteRequest.cs | 56 +++++++---- src/OpenFga.Sdk/Model/WriteRequestDeletes.cs | 54 +++++++---- src/OpenFga.Sdk/Model/WriteRequestWrites.cs | 54 +++++++---- 91 files changed, 3009 insertions(+), 1731 deletions(-) diff --git a/README.md b/README.md index 1588d49f..a758b24c 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,6 @@ This is an autogenerated SDK for OpenFGA. It provides a wrapper around the [Open - [Assertions](#assertions) - [Read Assertions](#read-assertions) - [Write Assertions](#write-assertions) - - [Calling Other API Endpoints](#calling-other-api-endpoints) - [Retries](#retries) - [API Endpoints](#api-endpoints) - [Models](#models) @@ -192,6 +191,10 @@ namespace Example { Credentials = new Credentials() { Method = CredentialsMethod.ClientCredentials, Config = new CredentialsConfig() { + // API Token Issuer can contain: + // - a scheme, defaults to https + // - a path, defaults to /oauth/token + // - a port ApiTokenIssuer = Environment.GetEnvironmentVariable("FGA_API_TOKEN_ISSUER"), ApiAudience = Environment.GetEnvironmentVariable("FGA_API_AUDIENCE"), ClientId = Environment.GetEnvironmentVariable("FGA_CLIENT_ID"), @@ -966,71 +969,6 @@ var body = new List() {new ClientAssertion() { await fgaClient.WriteAssertions(body, options); ``` -#### Calling Other API Endpoints - -The API Executor allows you to call arbitrary OpenFGA API endpoints that may not have direct SDK methods yet, while automatically leveraging the SDK's authentication, retry logic, and error handling. - -##### Example: Custom Check Request - -```csharp -using OpenFga.Sdk.Client.ApiExecutor; -using System.Net.Http; - -// Build the API request -var request = ApiExecutorRequestBuilder - .Of(HttpMethod.Post, "/stores/{store_id}/check") - .PathParam("store_id", fgaClient.StoreId) - .QueryParam("page_size", "20") - .Header("X-Custom-Header", "custom-value") - .Body(new { - tuple_key = new { - user = "user:anne", - relation = "reader", - @object = "document:2021-budget" - }, - contextual_tuples = new { - tuple_keys = new[] { - new { - user = "user:anne", - relation = "member", - @object = "group:engineering" - } - } - } - }) - .Build(); - -// Execute the request with typed response -var response = await fgaClient.ApiExecutor().SendAsync(request); -Console.WriteLine($"Status: {response.StatusCode}"); -Console.WriteLine($"Allowed: {response.Data.Allowed}"); - -// Or get raw JSON response -var rawResponse = await fgaClient.ApiExecutor().SendAsync(request); -Console.WriteLine($"Raw JSON: {rawResponse.RawResponse}"); -``` - -##### Features - -- **Automatic Authentication**: Uses configured credentials (API token or OAuth2) -- **Retry Logic**: Automatically retries on 429 and 5xx errors -- **Error Handling**: Throws appropriate `FgaApiError` exceptions -- **Flexible Response**: Get typed data or raw JSON -- **Custom Headers**: Add request-specific headers for debugging or tracing - -##### Available Methods - -- `ApiExecutor().SendAsync(request)` - Returns typed response with deserialized data -- `ApiExecutor().SendAsync(request)` - Returns raw JSON string as data - -##### Response Properties - -- `StatusCode` - HTTP status code -- `Headers` - Response headers (case-insensitive) -- `RawResponse` - Raw response body as string -- `Data` - Deserialized response data (type varies) -- `IsSuccessful` - True if status is 2xx - ### Retries diff --git a/src/OpenFga.Sdk/Api/OpenFgaApi.cs b/src/OpenFga.Sdk/Api/OpenFgaApi.cs index 97ab9c88..cabe57dd 100644 --- a/src/OpenFga.Sdk/Api/OpenFgaApi.cs +++ b/src/OpenFga.Sdk/Api/OpenFgaApi.cs @@ -27,11 +27,6 @@ public class OpenFgaApi : IDisposable { private readonly ApiClient.ApiClient _apiClient; private readonly Configuration.Configuration _configuration; - /// - /// Exposes the internal ApiClient for use by ApiExecutor. - /// - internal ApiClient.ApiClient ApiClientInternal => _apiClient; - /// /// Initializes a new instance of the class. /// @@ -46,6 +41,11 @@ public OpenFgaApi( _apiClient = new ApiClient.ApiClient(_configuration, httpClient); } + /// + /// Gets the internal ApiClient instance for making custom API requests. + /// + internal ApiClient.ApiClient ApiClientInternal => _apiClient; + /// /// Send a list of `check` operations in a single request The `BatchCheck` API functions nearly identically to `Check`, but instead of checking a single user-object relationship BatchCheck accepts a list of relationships to check and returns a map containing `BatchCheckItem` response for each check it received. An associated `correlation_id` is required for each check in the batch. This ID is used to correlate a check to the appropriate response. It is a string consisting of only alphanumeric characters or hyphens with a maximum length of 36 characters. This `correlation_id` is used to map the result of each check to the item which was checked, so it must be unique for each item in the batch. We recommend using a UUID or ULID as the `correlation_id`, but you can use whatever unique identifier you need as long as it matches this regex pattern: `^[\\w\\d-]{1,36}$` NOTE: The maximum number of checks that can be passed in the `BatchCheck` API is configurable via the [OPENFGA_MAX_CHECKS_PER_BATCH_CHECK](https://openfga.dev/docs/getting-started/setup-openfga/configuration#OPENFGA_MAX_CHECKS_PER_BATCH_CHECK) environment variable. If `BatchCheck` is called using the SDK, the SDK can split the batch check requests for you. For more details on how `Check` functions, see the docs for `/check`. ### Examples #### A BatchCheckRequest ```json { \"checks\": [ { \"tuple_key\": { \"object\": \"document:2021-budget\" \"relation\": \"reader\", \"user\": \"user:anne\", }, \"contextual_tuples\": {...} \"context\": {} \"correlation_id\": \"01JA8PM3QM7VBPGB8KMPK8SBD5\" }, { \"tuple_key\": { \"object\": \"document:2021-budget\" \"relation\": \"reader\", \"user\": \"user:bob\", }, \"contextual_tuples\": {...} \"context\": {} \"correlation_id\": \"01JA8PMM6A90NV5ET0F28CYSZQ\" } ] } ``` Below is a possible response to the above request. Note that the result map's keys are the `correlation_id` values from the checked items in the request: ```json { \"result\": { \"01JA8PMM6A90NV5ET0F28CYSZQ\": { \"allowed\": false, \"error\": {\"message\": \"\"} }, \"01JA8PM3QM7VBPGB8KMPK8SBD5\": { \"allowed\": true, \"error\": {\"message\": \"\"} } } ``` /// @@ -667,4 +667,4 @@ public async Task WriteAuthorizationModel(strin public void Dispose() { _apiClient.Dispose(); } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Constants/FgaConstants.cs b/src/OpenFga.Sdk/Constants/FgaConstants.cs index c8a9a108..4b22a5cf 100644 --- a/src/OpenFga.Sdk/Constants/FgaConstants.cs +++ b/src/OpenFga.Sdk/Constants/FgaConstants.cs @@ -153,4 +153,4 @@ public static class FgaConstants { /// Prime number used as a multiplier in hash code calculations. /// public const int HashCodeMultiplierPrimeNumber = 9923; -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/AbortedMessageResponse.cs b/src/OpenFga.Sdk/Model/AbortedMessageResponse.cs index 3d5a62e7..3ab5d026 100644 --- a/src/OpenFga.Sdk/Model/AbortedMessageResponse.cs +++ b/src/OpenFga.Sdk/Model/AbortedMessageResponse.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// AbortedMessageResponse /// [DataContract(Name = "AbortedMessageResponse")] - public partial class AbortedMessageResponse : IEquatable, IValidatableObject { + public partial class AbortedMessageResponse : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public AbortedMessageResponse() { + public AbortedMessageResponse() + { this.AdditionalProperties = new Dictionary(); } @@ -39,7 +44,8 @@ public AbortedMessageResponse() { /// /// code. /// message. - public AbortedMessageResponse(string code = default, string message = default) { + public AbortedMessageResponse(string code = default, string message = default) + { this.Code = code; this.Message = message; this.AdditionalProperties = new Dictionary(); @@ -72,7 +78,8 @@ public AbortedMessageResponse(string code = default, string message = default) { /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -89,7 +96,8 @@ public static AbortedMessageResponse FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((AbortedMessageResponse)input); } @@ -99,16 +107,18 @@ public override bool Equals(object input) { /// /// Instance of AbortedMessageResponse to be compared /// Boolean - public bool Equals(AbortedMessageResponse input) { - if (input == null) { + public bool Equals(AbortedMessageResponse input) + { + if (input == null) + { return false; } - return + return ( this.Code == input.Code || (this.Code != null && this.Code.Equals(input.Code)) - ) && + ) && ( this.Message == input.Message || (this.Message != null && @@ -121,17 +131,21 @@ public bool Equals(AbortedMessageResponse input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Code != null) { + if (this.Code != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Code.GetHashCode(); } - if (this.Message != null) { + if (this.Message != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Message.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -143,10 +157,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/Any.cs b/src/OpenFga.Sdk/Model/Any.cs index d3000f78..26252275 100644 --- a/src/OpenFga.Sdk/Model/Any.cs +++ b/src/OpenFga.Sdk/Model/Any.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// Any /// [DataContract(Name = "Any")] - public partial class Any : IEquatable, IValidatableObject { + public partial class Any : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public Any() { + public Any() + { this.AdditionalProperties = new Dictionary(); } @@ -38,7 +43,8 @@ public Any() { /// Initializes a new instance of the class. /// /// type. - public Any(string type = default) { + public Any(string type = default) + { this.Type = type; this.AdditionalProperties = new Dictionary(); } @@ -62,7 +68,8 @@ public Any(string type = default) { /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -79,7 +86,8 @@ public static Any FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((Any)input); } @@ -89,11 +97,13 @@ public override bool Equals(object input) { /// /// Instance of Any to be compared /// Boolean - public bool Equals(Any input) { - if (input == null) { + public bool Equals(Any input) + { + if (input == null) + { return false; } - return + return ( this.Type == input.Type || (this.Type != null && @@ -106,14 +116,17 @@ public bool Equals(Any input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Type != null) { + if (this.Type != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Type.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -125,10 +138,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/Assertion.cs b/src/OpenFga.Sdk/Model/Assertion.cs index cf2fd1d3..3ddf2325 100644 --- a/src/OpenFga.Sdk/Model/Assertion.cs +++ b/src/OpenFga.Sdk/Model/Assertion.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// Assertion /// [DataContract(Name = "Assertion")] - public partial class Assertion : IEquatable, IValidatableObject { + public partial class Assertion : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public Assertion() { + public Assertion() + { this.AdditionalProperties = new Dictionary(); } @@ -41,9 +46,11 @@ public Assertion() { /// expectation (required). /// contextualTuples. /// Additional request context that will be used to evaluate any ABAC conditions encountered in the query evaluation.. - public Assertion(AssertionTupleKey tupleKey = default, bool expectation = default, List contextualTuples = default, Object context = default) { + public Assertion(AssertionTupleKey tupleKey = default, bool expectation = default, List contextualTuples = default, Object context = default) + { // to ensure "tupleKey" is required (not null) - if (tupleKey == null) { + if (tupleKey == null) + { throw new ArgumentNullException("tupleKey is a required property for Assertion and cannot be null"); } this.TupleKey = tupleKey; @@ -97,7 +104,8 @@ public Assertion(AssertionTupleKey tupleKey = default, bool expectation = defaul /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -114,7 +122,8 @@ public static Assertion FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((Assertion)input); } @@ -124,26 +133,28 @@ public override bool Equals(object input) { /// /// Instance of Assertion to be compared /// Boolean - public bool Equals(Assertion input) { - if (input == null) { + public bool Equals(Assertion input) + { + if (input == null) + { return false; } - return + return ( this.TupleKey == input.TupleKey || (this.TupleKey != null && this.TupleKey.Equals(input.TupleKey)) - ) && + ) && ( this.Expectation == input.Expectation || this.Expectation.Equals(input.Expectation) - ) && + ) && ( this.ContextualTuples == input.ContextualTuples || this.ContextualTuples != null && input.ContextualTuples != null && this.ContextualTuples.SequenceEqual(input.ContextualTuples) - ) && + ) && ( this.Context == input.Context || (this.Context != null && @@ -156,21 +167,26 @@ public bool Equals(Assertion input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.TupleKey != null) { + if (this.TupleKey != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.TupleKey.GetHashCode(); } hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Expectation.GetHashCode(); - if (this.ContextualTuples != null) { + if (this.ContextualTuples != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.ContextualTuples.GetHashCode(); } - if (this.Context != null) { + if (this.Context != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Context.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -182,10 +198,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/AssertionTupleKey.cs b/src/OpenFga.Sdk/Model/AssertionTupleKey.cs index 1277083d..02ab2072 100644 --- a/src/OpenFga.Sdk/Model/AssertionTupleKey.cs +++ b/src/OpenFga.Sdk/Model/AssertionTupleKey.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// AssertionTupleKey /// [DataContract(Name = "AssertionTupleKey")] - public partial class AssertionTupleKey : IEquatable, IValidatableObject { + public partial class AssertionTupleKey : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public AssertionTupleKey() { + public AssertionTupleKey() + { this.AdditionalProperties = new Dictionary(); } @@ -40,19 +45,23 @@ public AssertionTupleKey() { /// varObject (required). /// relation (required). /// user (required). - public AssertionTupleKey(string varObject = default, string relation = default, string user = default) { + public AssertionTupleKey(string varObject = default, string relation = default, string user = default) + { // to ensure "varObject" is required (not null) - if (varObject == null) { + if (varObject == null) + { throw new ArgumentNullException("varObject is a required property for AssertionTupleKey and cannot be null"); } this.Object = varObject; // to ensure "relation" is required (not null) - if (relation == null) { + if (relation == null) + { throw new ArgumentNullException("relation is a required property for AssertionTupleKey and cannot be null"); } this.Relation = relation; // to ensure "user" is required (not null) - if (user == null) { + if (user == null) + { throw new ArgumentNullException("user is a required property for AssertionTupleKey and cannot be null"); } this.User = user; @@ -94,7 +103,8 @@ public AssertionTupleKey(string varObject = default, string relation = default, /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -111,7 +121,8 @@ public static AssertionTupleKey FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((AssertionTupleKey)input); } @@ -121,21 +132,23 @@ public override bool Equals(object input) { /// /// Instance of AssertionTupleKey to be compared /// Boolean - public bool Equals(AssertionTupleKey input) { - if (input == null) { + public bool Equals(AssertionTupleKey input) + { + if (input == null) + { return false; } - return + return ( this.Object == input.Object || (this.Object != null && this.Object.Equals(input.Object)) - ) && + ) && ( this.Relation == input.Relation || (this.Relation != null && this.Relation.Equals(input.Relation)) - ) && + ) && ( this.User == input.User || (this.User != null && @@ -148,20 +161,25 @@ public bool Equals(AssertionTupleKey input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Object != null) { + if (this.Object != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Object.GetHashCode(); } - if (this.Relation != null) { + if (this.Relation != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Relation.GetHashCode(); } - if (this.User != null) { + if (this.User != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.User.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -173,20 +191,24 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { // Object (string) maxLength - if (this.Object != null && this.Object.Length > 256) { - yield return new ValidationResult("Invalid value for Object, length must be less than 256.", new[] { "Object" }); + if (this.Object != null && this.Object.Length > 256) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Object, length must be less than 256.", new [] { "Object" }); } // Relation (string) maxLength - if (this.Relation != null && this.Relation.Length > 50) { - yield return new ValidationResult("Invalid value for Relation, length must be less than 50.", new[] { "Relation" }); + if (this.Relation != null && this.Relation.Length > 50) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Relation, length must be less than 50.", new [] { "Relation" }); } // User (string) maxLength - if (this.User != null && this.User.Length > 512) { - yield return new ValidationResult("Invalid value for User, length must be less than 512.", new[] { "User" }); + if (this.User != null && this.User.Length > 512) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for User, length must be less than 512.", new [] { "User" }); } yield break; @@ -194,4 +216,4 @@ public IEnumerable Validate(ValidationContext validationContex } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/AuthErrorCode.cs b/src/OpenFga.Sdk/Model/AuthErrorCode.cs index f9dd1753..8ac3a64a 100644 --- a/src/OpenFga.Sdk/Model/AuthErrorCode.cs +++ b/src/OpenFga.Sdk/Model/AuthErrorCode.cs @@ -11,21 +11,25 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// Defines AuthErrorCode /// [JsonConverter(typeof(JsonStringEnumMemberConverter))] - public enum AuthErrorCode { + public enum AuthErrorCode + { /// /// Enum NoAuthError for value: no_auth_error /// @@ -82,4 +86,4 @@ public enum AuthErrorCode { } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/AuthorizationModel.cs b/src/OpenFga.Sdk/Model/AuthorizationModel.cs index ca78cdec..f0e0a4da 100644 --- a/src/OpenFga.Sdk/Model/AuthorizationModel.cs +++ b/src/OpenFga.Sdk/Model/AuthorizationModel.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// AuthorizationModel /// [DataContract(Name = "AuthorizationModel")] - public partial class AuthorizationModel : IEquatable, IValidatableObject { + public partial class AuthorizationModel : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public AuthorizationModel() { + public AuthorizationModel() + { this.AdditionalProperties = new Dictionary(); } @@ -41,19 +46,23 @@ public AuthorizationModel() { /// schemaVersion (required). /// typeDefinitions (required). /// conditions. - public AuthorizationModel(string id = default, string schemaVersion = default, List typeDefinitions = default, Dictionary conditions = default) { + public AuthorizationModel(string id = default, string schemaVersion = default, List typeDefinitions = default, Dictionary conditions = default) + { // to ensure "id" is required (not null) - if (id == null) { + if (id == null) + { throw new ArgumentNullException("id is a required property for AuthorizationModel and cannot be null"); } this.Id = id; // to ensure "schemaVersion" is required (not null) - if (schemaVersion == null) { + if (schemaVersion == null) + { throw new ArgumentNullException("schemaVersion is a required property for AuthorizationModel and cannot be null"); } this.SchemaVersion = schemaVersion; // to ensure "typeDefinitions" is required (not null) - if (typeDefinitions == null) { + if (typeDefinitions == null) + { throw new ArgumentNullException("typeDefinitions is a required property for AuthorizationModel and cannot be null"); } this.TypeDefinitions = typeDefinitions; @@ -104,7 +113,8 @@ public AuthorizationModel(string id = default, string schemaVersion = default, L /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -121,7 +131,8 @@ public static AuthorizationModel FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((AuthorizationModel)input); } @@ -131,27 +142,29 @@ public override bool Equals(object input) { /// /// Instance of AuthorizationModel to be compared /// Boolean - public bool Equals(AuthorizationModel input) { - if (input == null) { + public bool Equals(AuthorizationModel input) + { + if (input == null) + { return false; } - return + return ( this.Id == input.Id || (this.Id != null && this.Id.Equals(input.Id)) - ) && + ) && ( this.SchemaVersion == input.SchemaVersion || (this.SchemaVersion != null && this.SchemaVersion.Equals(input.SchemaVersion)) - ) && + ) && ( this.TypeDefinitions == input.TypeDefinitions || this.TypeDefinitions != null && input.TypeDefinitions != null && this.TypeDefinitions.SequenceEqual(input.TypeDefinitions) - ) && + ) && ( this.Conditions == input.Conditions || this.Conditions != null && @@ -165,23 +178,29 @@ public bool Equals(AuthorizationModel input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Id != null) { + if (this.Id != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Id.GetHashCode(); } - if (this.SchemaVersion != null) { + if (this.SchemaVersion != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.SchemaVersion.GetHashCode(); } - if (this.TypeDefinitions != null) { + if (this.TypeDefinitions != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.TypeDefinitions.GetHashCode(); } - if (this.Conditions != null) { + if (this.Conditions != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Conditions.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -193,10 +212,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/BatchCheckItem.cs b/src/OpenFga.Sdk/Model/BatchCheckItem.cs index b8697524..2a08a95d 100644 --- a/src/OpenFga.Sdk/Model/BatchCheckItem.cs +++ b/src/OpenFga.Sdk/Model/BatchCheckItem.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// BatchCheckItem /// [DataContract(Name = "BatchCheckItem")] - public partial class BatchCheckItem : IEquatable, IValidatableObject { + public partial class BatchCheckItem : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public BatchCheckItem() { + public BatchCheckItem() + { this.AdditionalProperties = new Dictionary(); } @@ -41,14 +46,17 @@ public BatchCheckItem() { /// contextualTuples. /// context. /// correlation_id must be a string containing only letters, numbers, or hyphens, with length ≤ 36 characters. (required). - public BatchCheckItem(CheckRequestTupleKey tupleKey = default, ContextualTupleKeys contextualTuples = default, Object context = default, string correlationId = default) { + public BatchCheckItem(CheckRequestTupleKey tupleKey = default, ContextualTupleKeys contextualTuples = default, Object context = default, string correlationId = default) + { // to ensure "tupleKey" is required (not null) - if (tupleKey == null) { + if (tupleKey == null) + { throw new ArgumentNullException("tupleKey is a required property for BatchCheckItem and cannot be null"); } this.TupleKey = tupleKey; // to ensure "correlationId" is required (not null) - if (correlationId == null) { + if (correlationId == null) + { throw new ArgumentNullException("correlationId is a required property for BatchCheckItem and cannot be null"); } this.CorrelationId = correlationId; @@ -101,7 +109,8 @@ public BatchCheckItem(CheckRequestTupleKey tupleKey = default, ContextualTupleKe /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -118,7 +127,8 @@ public static BatchCheckItem FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((BatchCheckItem)input); } @@ -128,26 +138,28 @@ public override bool Equals(object input) { /// /// Instance of BatchCheckItem to be compared /// Boolean - public bool Equals(BatchCheckItem input) { - if (input == null) { + public bool Equals(BatchCheckItem input) + { + if (input == null) + { return false; } - return + return ( this.TupleKey == input.TupleKey || (this.TupleKey != null && this.TupleKey.Equals(input.TupleKey)) - ) && + ) && ( this.ContextualTuples == input.ContextualTuples || (this.ContextualTuples != null && this.ContextualTuples.Equals(input.ContextualTuples)) - ) && + ) && ( this.Context == input.Context || (this.Context != null && this.Context.Equals(input.Context)) - ) && + ) && ( this.CorrelationId == input.CorrelationId || (this.CorrelationId != null && @@ -160,23 +172,29 @@ public bool Equals(BatchCheckItem input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.TupleKey != null) { + if (this.TupleKey != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.TupleKey.GetHashCode(); } - if (this.ContextualTuples != null) { + if (this.ContextualTuples != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.ContextualTuples.GetHashCode(); } - if (this.Context != null) { + if (this.Context != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Context.GetHashCode(); } - if (this.CorrelationId != null) { + if (this.CorrelationId != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.CorrelationId.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -188,10 +206,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/BatchCheckRequest.cs b/src/OpenFga.Sdk/Model/BatchCheckRequest.cs index bc86ccd2..37281356 100644 --- a/src/OpenFga.Sdk/Model/BatchCheckRequest.cs +++ b/src/OpenFga.Sdk/Model/BatchCheckRequest.cs @@ -11,21 +11,25 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// BatchCheckRequest /// [DataContract(Name = "BatchCheck_request")] - public partial class BatchCheckRequest : IEquatable, IValidatableObject { + public partial class BatchCheckRequest : IEquatable, IValidatableObject + { /// /// Gets or Sets Consistency @@ -37,7 +41,8 @@ public partial class BatchCheckRequest : IEquatable, IValidat /// Initializes a new instance of the class. /// [JsonConstructor] - public BatchCheckRequest() { + public BatchCheckRequest() + { this.AdditionalProperties = new Dictionary(); } @@ -47,9 +52,11 @@ public BatchCheckRequest() { /// checks (required). /// authorizationModelId. /// consistency. - public BatchCheckRequest(List checks = default, string authorizationModelId = default, ConsistencyPreference? consistency = default) { + public BatchCheckRequest(List checks = default, string authorizationModelId = default, ConsistencyPreference? consistency = default) + { // to ensure "checks" is required (not null) - if (checks == null) { + if (checks == null) + { throw new ArgumentNullException("checks is a required property for BatchCheckRequest and cannot be null"); } this.Checks = checks; @@ -85,7 +92,8 @@ public BatchCheckRequest(List checks = default, string authoriza /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -102,7 +110,8 @@ public static BatchCheckRequest FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((BatchCheckRequest)input); } @@ -112,22 +121,24 @@ public override bool Equals(object input) { /// /// Instance of BatchCheckRequest to be compared /// Boolean - public bool Equals(BatchCheckRequest input) { - if (input == null) { + public bool Equals(BatchCheckRequest input) + { + if (input == null) + { return false; } - return + return ( this.Checks == input.Checks || this.Checks != null && input.Checks != null && this.Checks.SequenceEqual(input.Checks) - ) && + ) && ( this.AuthorizationModelId == input.AuthorizationModelId || (this.AuthorizationModelId != null && this.AuthorizationModelId.Equals(input.AuthorizationModelId)) - ) && + ) && ( this.Consistency == input.Consistency || this.Consistency.Equals(input.Consistency) @@ -139,18 +150,22 @@ public bool Equals(BatchCheckRequest input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Checks != null) { + if (this.Checks != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Checks.GetHashCode(); } - if (this.AuthorizationModelId != null) { + if (this.AuthorizationModelId != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AuthorizationModelId.GetHashCode(); } hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Consistency.GetHashCode(); - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -162,10 +177,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/BatchCheckResponse.cs b/src/OpenFga.Sdk/Model/BatchCheckResponse.cs index 760e2551..91835f08 100644 --- a/src/OpenFga.Sdk/Model/BatchCheckResponse.cs +++ b/src/OpenFga.Sdk/Model/BatchCheckResponse.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// BatchCheckResponse /// [DataContract(Name = "BatchCheckResponse")] - public partial class BatchCheckResponse : IEquatable, IValidatableObject { + public partial class BatchCheckResponse : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public BatchCheckResponse() { + public BatchCheckResponse() + { this.AdditionalProperties = new Dictionary(); } @@ -38,7 +43,8 @@ public BatchCheckResponse() { /// Initializes a new instance of the class. /// /// map keys are the correlation_id values from the BatchCheckItems in the request. - public BatchCheckResponse(Dictionary result = default) { + public BatchCheckResponse(Dictionary result = default) + { this.Result = result; this.AdditionalProperties = new Dictionary(); } @@ -63,7 +69,8 @@ public BatchCheckResponse(Dictionary result = de /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -80,7 +87,8 @@ public static BatchCheckResponse FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((BatchCheckResponse)input); } @@ -90,11 +98,13 @@ public override bool Equals(object input) { /// /// Instance of BatchCheckResponse to be compared /// Boolean - public bool Equals(BatchCheckResponse input) { - if (input == null) { + public bool Equals(BatchCheckResponse input) + { + if (input == null) + { return false; } - return + return ( this.Result == input.Result || this.Result != null && @@ -108,14 +118,17 @@ public bool Equals(BatchCheckResponse input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Result != null) { + if (this.Result != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Result.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -127,10 +140,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/BatchCheckSingleResult.cs b/src/OpenFga.Sdk/Model/BatchCheckSingleResult.cs index ae2da0d9..1747af6d 100644 --- a/src/OpenFga.Sdk/Model/BatchCheckSingleResult.cs +++ b/src/OpenFga.Sdk/Model/BatchCheckSingleResult.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// BatchCheckSingleResult /// [DataContract(Name = "BatchCheckSingleResult")] - public partial class BatchCheckSingleResult : IEquatable, IValidatableObject { + public partial class BatchCheckSingleResult : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public BatchCheckSingleResult() { + public BatchCheckSingleResult() + { this.AdditionalProperties = new Dictionary(); } @@ -39,7 +44,8 @@ public BatchCheckSingleResult() { /// /// allowed. /// error. - public BatchCheckSingleResult(bool allowed = default, CheckError error = default) { + public BatchCheckSingleResult(bool allowed = default, CheckError error = default) + { this.Allowed = allowed; this.Error = error; this.AdditionalProperties = new Dictionary(); @@ -72,7 +78,8 @@ public BatchCheckSingleResult(bool allowed = default, CheckError error = default /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -89,7 +96,8 @@ public static BatchCheckSingleResult FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((BatchCheckSingleResult)input); } @@ -99,15 +107,17 @@ public override bool Equals(object input) { /// /// Instance of BatchCheckSingleResult to be compared /// Boolean - public bool Equals(BatchCheckSingleResult input) { - if (input == null) { + public bool Equals(BatchCheckSingleResult input) + { + if (input == null) + { return false; } - return + return ( this.Allowed == input.Allowed || this.Allowed.Equals(input.Allowed) - ) && + ) && ( this.Error == input.Error || (this.Error != null && @@ -120,15 +130,18 @@ public bool Equals(BatchCheckSingleResult input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Allowed.GetHashCode(); - if (this.Error != null) { + if (this.Error != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Error.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -140,10 +153,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/CheckError.cs b/src/OpenFga.Sdk/Model/CheckError.cs index ad35e8ae..d76efe03 100644 --- a/src/OpenFga.Sdk/Model/CheckError.cs +++ b/src/OpenFga.Sdk/Model/CheckError.cs @@ -11,21 +11,25 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// CheckError /// [DataContract(Name = "CheckError")] - public partial class CheckError : IEquatable, IValidatableObject { + public partial class CheckError : IEquatable, IValidatableObject + { /// /// Gets or Sets InputError @@ -44,7 +48,8 @@ public partial class CheckError : IEquatable, IValidatableObject { /// Initializes a new instance of the class. /// [JsonConstructor] - public CheckError() { + public CheckError() + { this.AdditionalProperties = new Dictionary(); } @@ -54,7 +59,8 @@ public CheckError() { /// inputError. /// internalError. /// message. - public CheckError(ErrorCode? inputError = default, InternalErrorCode? internalError = default, string message = default) { + public CheckError(ErrorCode? inputError = default, InternalErrorCode? internalError = default, string message = default) + { this.InputError = inputError; this.InternalError = internalError; this.Message = message; @@ -80,7 +86,8 @@ public CheckError(ErrorCode? inputError = default, InternalErrorCode? internalEr /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -97,7 +104,8 @@ public static CheckError FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((CheckError)input); } @@ -107,19 +115,21 @@ public override bool Equals(object input) { /// /// Instance of CheckError to be compared /// Boolean - public bool Equals(CheckError input) { - if (input == null) { + public bool Equals(CheckError input) + { + if (input == null) + { return false; } - return + return ( this.InputError == input.InputError || this.InputError.Equals(input.InputError) - ) && + ) && ( this.InternalError == input.InternalError || this.InternalError.Equals(input.InternalError) - ) && + ) && ( this.Message == input.Message || (this.Message != null && @@ -132,16 +142,19 @@ public bool Equals(CheckError input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.InputError.GetHashCode(); hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.InternalError.GetHashCode(); - if (this.Message != null) { + if (this.Message != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Message.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -153,10 +166,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/CheckRequest.cs b/src/OpenFga.Sdk/Model/CheckRequest.cs index 16f0ccb5..182b0c27 100644 --- a/src/OpenFga.Sdk/Model/CheckRequest.cs +++ b/src/OpenFga.Sdk/Model/CheckRequest.cs @@ -11,21 +11,25 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// CheckRequest /// [DataContract(Name = "Check_request")] - public partial class CheckRequest : IEquatable, IValidatableObject { + public partial class CheckRequest : IEquatable, IValidatableObject + { /// /// Gets or Sets Consistency @@ -37,7 +41,8 @@ public partial class CheckRequest : IEquatable, IValidatableObject /// Initializes a new instance of the class. /// [JsonConstructor] - public CheckRequest() { + public CheckRequest() + { this.AdditionalProperties = new Dictionary(); } @@ -49,9 +54,11 @@ public CheckRequest() { /// authorizationModelId. /// Additional request context that will be used to evaluate any ABAC conditions encountered in the query evaluation.. /// consistency. - public CheckRequest(CheckRequestTupleKey tupleKey = default, ContextualTupleKeys contextualTuples = default, string authorizationModelId = default, Object context = default, ConsistencyPreference? consistency = default) { + public CheckRequest(CheckRequestTupleKey tupleKey = default, ContextualTupleKeys contextualTuples = default, string authorizationModelId = default, Object context = default, ConsistencyPreference? consistency = default) + { // to ensure "tupleKey" is required (not null) - if (tupleKey == null) { + if (tupleKey == null) + { throw new ArgumentNullException("tupleKey is a required property for CheckRequest and cannot be null"); } this.TupleKey = tupleKey; @@ -99,7 +106,8 @@ public CheckRequest(CheckRequestTupleKey tupleKey = default, ContextualTupleKeys /// Returns false as Trace should not be serialized given that it's read-only. /// /// false (boolean) - public bool ShouldSerializeTrace() { + public bool ShouldSerializeTrace() + { return false; } /// @@ -122,7 +130,8 @@ public bool ShouldSerializeTrace() { /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -139,7 +148,8 @@ public static CheckRequest FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((CheckRequest)input); } @@ -149,35 +159,37 @@ public override bool Equals(object input) { /// /// Instance of CheckRequest to be compared /// Boolean - public bool Equals(CheckRequest input) { - if (input == null) { + public bool Equals(CheckRequest input) + { + if (input == null) + { return false; } - return + return ( this.TupleKey == input.TupleKey || (this.TupleKey != null && this.TupleKey.Equals(input.TupleKey)) - ) && + ) && ( this.ContextualTuples == input.ContextualTuples || (this.ContextualTuples != null && this.ContextualTuples.Equals(input.ContextualTuples)) - ) && + ) && ( this.AuthorizationModelId == input.AuthorizationModelId || (this.AuthorizationModelId != null && this.AuthorizationModelId.Equals(input.AuthorizationModelId)) - ) && + ) && ( this.Trace == input.Trace || this.Trace.Equals(input.Trace) - ) && + ) && ( this.Context == input.Context || (this.Context != null && this.Context.Equals(input.Context)) - ) && + ) && ( this.Consistency == input.Consistency || this.Consistency.Equals(input.Consistency) @@ -189,25 +201,31 @@ public bool Equals(CheckRequest input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.TupleKey != null) { + if (this.TupleKey != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.TupleKey.GetHashCode(); } - if (this.ContextualTuples != null) { + if (this.ContextualTuples != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.ContextualTuples.GetHashCode(); } - if (this.AuthorizationModelId != null) { + if (this.AuthorizationModelId != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AuthorizationModelId.GetHashCode(); } hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Trace.GetHashCode(); - if (this.Context != null) { + if (this.Context != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Context.GetHashCode(); } hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Consistency.GetHashCode(); - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -219,10 +237,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/CheckRequestTupleKey.cs b/src/OpenFga.Sdk/Model/CheckRequestTupleKey.cs index 5fa08e22..6d3a3960 100644 --- a/src/OpenFga.Sdk/Model/CheckRequestTupleKey.cs +++ b/src/OpenFga.Sdk/Model/CheckRequestTupleKey.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// CheckRequestTupleKey /// [DataContract(Name = "CheckRequestTupleKey")] - public partial class CheckRequestTupleKey : IEquatable, IValidatableObject { + public partial class CheckRequestTupleKey : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public CheckRequestTupleKey() { + public CheckRequestTupleKey() + { this.AdditionalProperties = new Dictionary(); } @@ -40,19 +45,23 @@ public CheckRequestTupleKey() { /// user (required). /// relation (required). /// varObject (required). - public CheckRequestTupleKey(string user = default, string relation = default, string varObject = default) { + public CheckRequestTupleKey(string user = default, string relation = default, string varObject = default) + { // to ensure "user" is required (not null) - if (user == null) { + if (user == null) + { throw new ArgumentNullException("user is a required property for CheckRequestTupleKey and cannot be null"); } this.User = user; // to ensure "relation" is required (not null) - if (relation == null) { + if (relation == null) + { throw new ArgumentNullException("relation is a required property for CheckRequestTupleKey and cannot be null"); } this.Relation = relation; // to ensure "varObject" is required (not null) - if (varObject == null) { + if (varObject == null) + { throw new ArgumentNullException("varObject is a required property for CheckRequestTupleKey and cannot be null"); } this.Object = varObject; @@ -94,7 +103,8 @@ public CheckRequestTupleKey(string user = default, string relation = default, st /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -111,7 +121,8 @@ public static CheckRequestTupleKey FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((CheckRequestTupleKey)input); } @@ -121,21 +132,23 @@ public override bool Equals(object input) { /// /// Instance of CheckRequestTupleKey to be compared /// Boolean - public bool Equals(CheckRequestTupleKey input) { - if (input == null) { + public bool Equals(CheckRequestTupleKey input) + { + if (input == null) + { return false; } - return + return ( this.User == input.User || (this.User != null && this.User.Equals(input.User)) - ) && + ) && ( this.Relation == input.Relation || (this.Relation != null && this.Relation.Equals(input.Relation)) - ) && + ) && ( this.Object == input.Object || (this.Object != null && @@ -148,20 +161,25 @@ public bool Equals(CheckRequestTupleKey input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.User != null) { + if (this.User != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.User.GetHashCode(); } - if (this.Relation != null) { + if (this.Relation != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Relation.GetHashCode(); } - if (this.Object != null) { + if (this.Object != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Object.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -173,20 +191,24 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { // User (string) maxLength - if (this.User != null && this.User.Length > 512) { - yield return new ValidationResult("Invalid value for User, length must be less than 512.", new[] { "User" }); + if (this.User != null && this.User.Length > 512) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for User, length must be less than 512.", new [] { "User" }); } // Relation (string) maxLength - if (this.Relation != null && this.Relation.Length > 50) { - yield return new ValidationResult("Invalid value for Relation, length must be less than 50.", new[] { "Relation" }); + if (this.Relation != null && this.Relation.Length > 50) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Relation, length must be less than 50.", new [] { "Relation" }); } // Object (string) maxLength - if (this.Object != null && this.Object.Length > 256) { - yield return new ValidationResult("Invalid value for Object, length must be less than 256.", new[] { "Object" }); + if (this.Object != null && this.Object.Length > 256) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Object, length must be less than 256.", new [] { "Object" }); } yield break; @@ -194,4 +216,4 @@ public IEnumerable Validate(ValidationContext validationContex } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/CheckResponse.cs b/src/OpenFga.Sdk/Model/CheckResponse.cs index a89d4e68..09d34ade 100644 --- a/src/OpenFga.Sdk/Model/CheckResponse.cs +++ b/src/OpenFga.Sdk/Model/CheckResponse.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// CheckResponse /// [DataContract(Name = "CheckResponse")] - public partial class CheckResponse : IEquatable, IValidatableObject { + public partial class CheckResponse : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public CheckResponse() { + public CheckResponse() + { this.AdditionalProperties = new Dictionary(); } @@ -39,7 +44,8 @@ public CheckResponse() { /// /// allowed. /// For internal use only.. - public CheckResponse(bool allowed = default, string resolution = default) { + public CheckResponse(bool allowed = default, string resolution = default) + { this.Allowed = allowed; this.Resolution = resolution; this.AdditionalProperties = new Dictionary(); @@ -73,7 +79,8 @@ public CheckResponse(bool allowed = default, string resolution = default) { /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -90,7 +97,8 @@ public static CheckResponse FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((CheckResponse)input); } @@ -100,15 +108,17 @@ public override bool Equals(object input) { /// /// Instance of CheckResponse to be compared /// Boolean - public bool Equals(CheckResponse input) { - if (input == null) { + public bool Equals(CheckResponse input) + { + if (input == null) + { return false; } - return + return ( this.Allowed == input.Allowed || this.Allowed.Equals(input.Allowed) - ) && + ) && ( this.Resolution == input.Resolution || (this.Resolution != null && @@ -121,15 +131,18 @@ public bool Equals(CheckResponse input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Allowed.GetHashCode(); - if (this.Resolution != null) { + if (this.Resolution != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Resolution.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -141,10 +154,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/Computed.cs b/src/OpenFga.Sdk/Model/Computed.cs index 08e311ec..5745d4fa 100644 --- a/src/OpenFga.Sdk/Model/Computed.cs +++ b/src/OpenFga.Sdk/Model/Computed.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// Computed /// [DataContract(Name = "Computed")] - public partial class Computed : IEquatable, IValidatableObject { + public partial class Computed : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public Computed() { + public Computed() + { this.AdditionalProperties = new Dictionary(); } @@ -38,9 +43,11 @@ public Computed() { /// Initializes a new instance of the class. /// /// userset (required). - public Computed(string userset = default) { + public Computed(string userset = default) + { // to ensure "userset" is required (not null) - if (userset == null) { + if (userset == null) + { throw new ArgumentNullException("userset is a required property for Computed and cannot be null"); } this.Userset = userset; @@ -66,7 +73,8 @@ public Computed(string userset = default) { /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -83,7 +91,8 @@ public static Computed FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((Computed)input); } @@ -93,11 +102,13 @@ public override bool Equals(object input) { /// /// Instance of Computed to be compared /// Boolean - public bool Equals(Computed input) { - if (input == null) { + public bool Equals(Computed input) + { + if (input == null) + { return false; } - return + return ( this.Userset == input.Userset || (this.Userset != null && @@ -110,14 +121,17 @@ public bool Equals(Computed input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Userset != null) { + if (this.Userset != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Userset.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -129,10 +143,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/Condition.cs b/src/OpenFga.Sdk/Model/Condition.cs index 6c8c6140..d6e26e93 100644 --- a/src/OpenFga.Sdk/Model/Condition.cs +++ b/src/OpenFga.Sdk/Model/Condition.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// Condition /// [DataContract(Name = "Condition")] - public partial class Condition : IEquatable, IValidatableObject { + public partial class Condition : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public Condition() { + public Condition() + { this.AdditionalProperties = new Dictionary(); } @@ -41,14 +46,17 @@ public Condition() { /// A Google CEL expression, expressed as a string. (required). /// A map of parameter names to the parameter's defined type reference.. /// metadata. - public Condition(string name = default, string expression = default, Dictionary parameters = default, ConditionMetadata metadata = default) { + public Condition(string name = default, string expression = default, Dictionary parameters = default, ConditionMetadata metadata = default) + { // to ensure "name" is required (not null) - if (name == null) { + if (name == null) + { throw new ArgumentNullException("name is a required property for Condition and cannot be null"); } this.Name = name; // to ensure "expression" is required (not null) - if (expression == null) { + if (expression == null) + { throw new ArgumentNullException("expression is a required property for Condition and cannot be null"); } this.Expression = expression; @@ -102,7 +110,8 @@ public Condition(string name = default, string expression = default, Dictionary< /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -119,7 +128,8 @@ public static Condition FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((Condition)input); } @@ -129,27 +139,29 @@ public override bool Equals(object input) { /// /// Instance of Condition to be compared /// Boolean - public bool Equals(Condition input) { - if (input == null) { + public bool Equals(Condition input) + { + if (input == null) + { return false; } - return + return ( this.Name == input.Name || (this.Name != null && this.Name.Equals(input.Name)) - ) && + ) && ( this.Expression == input.Expression || (this.Expression != null && this.Expression.Equals(input.Expression)) - ) && + ) && ( this.Parameters == input.Parameters || this.Parameters != null && input.Parameters != null && this.Parameters.SequenceEqual(input.Parameters) - ) && + ) && ( this.Metadata == input.Metadata || (this.Metadata != null && @@ -162,23 +174,29 @@ public bool Equals(Condition input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Name != null) { + if (this.Name != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Name.GetHashCode(); } - if (this.Expression != null) { + if (this.Expression != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Expression.GetHashCode(); } - if (this.Parameters != null) { + if (this.Parameters != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Parameters.GetHashCode(); } - if (this.Metadata != null) { + if (this.Metadata != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Metadata.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -190,10 +208,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/ConditionMetadata.cs b/src/OpenFga.Sdk/Model/ConditionMetadata.cs index 4222a7a3..2f90f7af 100644 --- a/src/OpenFga.Sdk/Model/ConditionMetadata.cs +++ b/src/OpenFga.Sdk/Model/ConditionMetadata.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// ConditionMetadata /// [DataContract(Name = "ConditionMetadata")] - public partial class ConditionMetadata : IEquatable, IValidatableObject { + public partial class ConditionMetadata : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public ConditionMetadata() { + public ConditionMetadata() + { this.AdditionalProperties = new Dictionary(); } @@ -39,7 +44,8 @@ public ConditionMetadata() { /// /// module. /// sourceInfo. - public ConditionMetadata(string module = default, SourceInfo sourceInfo = default) { + public ConditionMetadata(string module = default, SourceInfo sourceInfo = default) + { this.Module = module; this.SourceInfo = sourceInfo; this.AdditionalProperties = new Dictionary(); @@ -72,7 +78,8 @@ public ConditionMetadata(string module = default, SourceInfo sourceInfo = defaul /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -89,7 +96,8 @@ public static ConditionMetadata FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((ConditionMetadata)input); } @@ -99,16 +107,18 @@ public override bool Equals(object input) { /// /// Instance of ConditionMetadata to be compared /// Boolean - public bool Equals(ConditionMetadata input) { - if (input == null) { + public bool Equals(ConditionMetadata input) + { + if (input == null) + { return false; } - return + return ( this.Module == input.Module || (this.Module != null && this.Module.Equals(input.Module)) - ) && + ) && ( this.SourceInfo == input.SourceInfo || (this.SourceInfo != null && @@ -121,17 +131,21 @@ public bool Equals(ConditionMetadata input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Module != null) { + if (this.Module != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Module.GetHashCode(); } - if (this.SourceInfo != null) { + if (this.SourceInfo != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.SourceInfo.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -143,10 +157,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/ConditionParamTypeRef.cs b/src/OpenFga.Sdk/Model/ConditionParamTypeRef.cs index 2e3fcfab..7b532db4 100644 --- a/src/OpenFga.Sdk/Model/ConditionParamTypeRef.cs +++ b/src/OpenFga.Sdk/Model/ConditionParamTypeRef.cs @@ -11,21 +11,25 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// ConditionParamTypeRef /// [DataContract(Name = "ConditionParamTypeRef")] - public partial class ConditionParamTypeRef : IEquatable, IValidatableObject { + public partial class ConditionParamTypeRef : IEquatable, IValidatableObject + { /// /// Gets or Sets TypeName @@ -37,7 +41,8 @@ public partial class ConditionParamTypeRef : IEquatable, /// Initializes a new instance of the class. /// [JsonConstructor] - public ConditionParamTypeRef() { + public ConditionParamTypeRef() + { this.AdditionalProperties = new Dictionary(); } @@ -46,7 +51,8 @@ public ConditionParamTypeRef() { /// /// typeName (required). /// genericTypes. - public ConditionParamTypeRef(TypeName typeName = default, List genericTypes = default) { + public ConditionParamTypeRef(TypeName typeName = default, List genericTypes = default) + { this.TypeName = typeName; this.GenericTypes = genericTypes; this.AdditionalProperties = new Dictionary(); @@ -71,7 +77,8 @@ public ConditionParamTypeRef(TypeName typeName = default, List /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -88,7 +95,8 @@ public static ConditionParamTypeRef FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((ConditionParamTypeRef)input); } @@ -98,15 +106,17 @@ public override bool Equals(object input) { /// /// Instance of ConditionParamTypeRef to be compared /// Boolean - public bool Equals(ConditionParamTypeRef input) { - if (input == null) { + public bool Equals(ConditionParamTypeRef input) + { + if (input == null) + { return false; } - return + return ( this.TypeName == input.TypeName || this.TypeName.Equals(input.TypeName) - ) && + ) && ( this.GenericTypes == input.GenericTypes || this.GenericTypes != null && @@ -120,15 +130,18 @@ public bool Equals(ConditionParamTypeRef input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.TypeName.GetHashCode(); - if (this.GenericTypes != null) { + if (this.GenericTypes != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.GenericTypes.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -140,10 +153,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/ConsistencyPreference.cs b/src/OpenFga.Sdk/Model/ConsistencyPreference.cs index 559e218d..80285867 100644 --- a/src/OpenFga.Sdk/Model/ConsistencyPreference.cs +++ b/src/OpenFga.Sdk/Model/ConsistencyPreference.cs @@ -11,22 +11,26 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// Controls the consistency preferences when calling the query APIs. - UNSPECIFIED: Default if not set. Behavior will be the same as MINIMIZE_LATENCY. - MINIMIZE_LATENCY: Minimize latency at the potential expense of lower consistency. - HIGHER_CONSISTENCY: Prefer higher consistency, at the potential expense of increased latency. /// /// Controls the consistency preferences when calling the query APIs. - UNSPECIFIED: Default if not set. Behavior will be the same as MINIMIZE_LATENCY. - MINIMIZE_LATENCY: Minimize latency at the potential expense of lower consistency. - HIGHER_CONSISTENCY: Prefer higher consistency, at the potential expense of increased latency. [JsonConverter(typeof(JsonStringEnumMemberConverter))] - public enum ConsistencyPreference { + public enum ConsistencyPreference + { /// /// Enum UNSPECIFIED for value: UNSPECIFIED /// @@ -47,4 +51,4 @@ public enum ConsistencyPreference { } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/ContextualTupleKeys.cs b/src/OpenFga.Sdk/Model/ContextualTupleKeys.cs index 73b88a78..81e55d8c 100644 --- a/src/OpenFga.Sdk/Model/ContextualTupleKeys.cs +++ b/src/OpenFga.Sdk/Model/ContextualTupleKeys.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// ContextualTupleKeys /// [DataContract(Name = "ContextualTupleKeys")] - public partial class ContextualTupleKeys : IEquatable, IValidatableObject { + public partial class ContextualTupleKeys : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public ContextualTupleKeys() { + public ContextualTupleKeys() + { this.AdditionalProperties = new Dictionary(); } @@ -38,9 +43,11 @@ public ContextualTupleKeys() { /// Initializes a new instance of the class. /// /// tupleKeys (required). - public ContextualTupleKeys(List tupleKeys = default) { + public ContextualTupleKeys(List tupleKeys = default) + { // to ensure "tupleKeys" is required (not null) - if (tupleKeys == null) { + if (tupleKeys == null) + { throw new ArgumentNullException("tupleKeys is a required property for ContextualTupleKeys and cannot be null"); } this.TupleKeys = tupleKeys; @@ -66,7 +73,8 @@ public ContextualTupleKeys(List tupleKeys = default) { /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -83,7 +91,8 @@ public static ContextualTupleKeys FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((ContextualTupleKeys)input); } @@ -93,11 +102,13 @@ public override bool Equals(object input) { /// /// Instance of ContextualTupleKeys to be compared /// Boolean - public bool Equals(ContextualTupleKeys input) { - if (input == null) { + public bool Equals(ContextualTupleKeys input) + { + if (input == null) + { return false; } - return + return ( this.TupleKeys == input.TupleKeys || this.TupleKeys != null && @@ -111,14 +122,17 @@ public bool Equals(ContextualTupleKeys input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.TupleKeys != null) { + if (this.TupleKeys != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.TupleKeys.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -130,10 +144,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/CreateStoreRequest.cs b/src/OpenFga.Sdk/Model/CreateStoreRequest.cs index 340cdae9..5753ad19 100644 --- a/src/OpenFga.Sdk/Model/CreateStoreRequest.cs +++ b/src/OpenFga.Sdk/Model/CreateStoreRequest.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// CreateStoreRequest /// [DataContract(Name = "CreateStoreRequest")] - public partial class CreateStoreRequest : IEquatable, IValidatableObject { + public partial class CreateStoreRequest : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public CreateStoreRequest() { + public CreateStoreRequest() + { this.AdditionalProperties = new Dictionary(); } @@ -38,9 +43,11 @@ public CreateStoreRequest() { /// Initializes a new instance of the class. /// /// name (required). - public CreateStoreRequest(string name = default) { + public CreateStoreRequest(string name = default) + { // to ensure "name" is required (not null) - if (name == null) { + if (name == null) + { throw new ArgumentNullException("name is a required property for CreateStoreRequest and cannot be null"); } this.Name = name; @@ -66,7 +73,8 @@ public CreateStoreRequest(string name = default) { /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -83,7 +91,8 @@ public static CreateStoreRequest FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((CreateStoreRequest)input); } @@ -93,11 +102,13 @@ public override bool Equals(object input) { /// /// Instance of CreateStoreRequest to be compared /// Boolean - public bool Equals(CreateStoreRequest input) { - if (input == null) { + public bool Equals(CreateStoreRequest input) + { + if (input == null) + { return false; } - return + return ( this.Name == input.Name || (this.Name != null && @@ -110,14 +121,17 @@ public bool Equals(CreateStoreRequest input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Name != null) { + if (this.Name != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Name.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -129,10 +143,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/CreateStoreResponse.cs b/src/OpenFga.Sdk/Model/CreateStoreResponse.cs index f516ca98..da47e24e 100644 --- a/src/OpenFga.Sdk/Model/CreateStoreResponse.cs +++ b/src/OpenFga.Sdk/Model/CreateStoreResponse.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// CreateStoreResponse /// [DataContract(Name = "CreateStoreResponse")] - public partial class CreateStoreResponse : IEquatable, IValidatableObject { + public partial class CreateStoreResponse : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public CreateStoreResponse() { + public CreateStoreResponse() + { this.AdditionalProperties = new Dictionary(); } @@ -41,14 +46,17 @@ public CreateStoreResponse() { /// name (required). /// createdAt (required). /// updatedAt (required). - public CreateStoreResponse(string id = default, string name = default, DateTime createdAt = default, DateTime updatedAt = default) { + public CreateStoreResponse(string id = default, string name = default, DateTime createdAt = default, DateTime updatedAt = default) + { // to ensure "id" is required (not null) - if (id == null) { + if (id == null) + { throw new ArgumentNullException("id is a required property for CreateStoreResponse and cannot be null"); } this.Id = id; // to ensure "name" is required (not null) - if (name == null) { + if (name == null) + { throw new ArgumentNullException("name is a required property for CreateStoreResponse and cannot be null"); } this.Name = name; @@ -100,7 +108,8 @@ public CreateStoreResponse(string id = default, string name = default, DateTime /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -117,7 +126,8 @@ public static CreateStoreResponse FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((CreateStoreResponse)input); } @@ -127,26 +137,28 @@ public override bool Equals(object input) { /// /// Instance of CreateStoreResponse to be compared /// Boolean - public bool Equals(CreateStoreResponse input) { - if (input == null) { + public bool Equals(CreateStoreResponse input) + { + if (input == null) + { return false; } - return + return ( this.Id == input.Id || (this.Id != null && this.Id.Equals(input.Id)) - ) && + ) && ( this.Name == input.Name || (this.Name != null && this.Name.Equals(input.Name)) - ) && + ) && ( this.CreatedAt == input.CreatedAt || (this.CreatedAt != null && this.CreatedAt.Equals(input.CreatedAt)) - ) && + ) && ( this.UpdatedAt == input.UpdatedAt || (this.UpdatedAt != null && @@ -159,23 +171,29 @@ public bool Equals(CreateStoreResponse input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Id != null) { + if (this.Id != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Id.GetHashCode(); } - if (this.Name != null) { + if (this.Name != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Name.GetHashCode(); } - if (this.CreatedAt != null) { + if (this.CreatedAt != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.CreatedAt.GetHashCode(); } - if (this.UpdatedAt != null) { + if (this.UpdatedAt != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.UpdatedAt.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -187,10 +205,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/Difference.cs b/src/OpenFga.Sdk/Model/Difference.cs index 03946d44..69c4b487 100644 --- a/src/OpenFga.Sdk/Model/Difference.cs +++ b/src/OpenFga.Sdk/Model/Difference.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// Difference /// [DataContract(Name = "Difference")] - public partial class Difference : IEquatable, IValidatableObject { + public partial class Difference : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public Difference() { + public Difference() + { this.AdditionalProperties = new Dictionary(); } @@ -39,14 +44,17 @@ public Difference() { /// /// varBase (required). /// subtract (required). - public Difference(Userset varBase = default, Userset subtract = default) { + public Difference(Userset varBase = default, Userset subtract = default) + { // to ensure "varBase" is required (not null) - if (varBase == null) { + if (varBase == null) + { throw new ArgumentNullException("varBase is a required property for Difference and cannot be null"); } this.Base = varBase; // to ensure "subtract" is required (not null) - if (subtract == null) { + if (subtract == null) + { throw new ArgumentNullException("subtract is a required property for Difference and cannot be null"); } this.Subtract = subtract; @@ -80,7 +88,8 @@ public Difference(Userset varBase = default, Userset subtract = default) { /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -97,7 +106,8 @@ public static Difference FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((Difference)input); } @@ -107,16 +117,18 @@ public override bool Equals(object input) { /// /// Instance of Difference to be compared /// Boolean - public bool Equals(Difference input) { - if (input == null) { + public bool Equals(Difference input) + { + if (input == null) + { return false; } - return + return ( this.Base == input.Base || (this.Base != null && this.Base.Equals(input.Base)) - ) && + ) && ( this.Subtract == input.Subtract || (this.Subtract != null && @@ -129,17 +141,21 @@ public bool Equals(Difference input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Base != null) { + if (this.Base != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Base.GetHashCode(); } - if (this.Subtract != null) { + if (this.Subtract != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Subtract.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -151,10 +167,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/ErrorCode.cs b/src/OpenFga.Sdk/Model/ErrorCode.cs index 558dc3d0..4b39b109 100644 --- a/src/OpenFga.Sdk/Model/ErrorCode.cs +++ b/src/OpenFga.Sdk/Model/ErrorCode.cs @@ -11,21 +11,25 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// Defines ErrorCode /// [JsonConverter(typeof(JsonStringEnumMemberConverter))] - public enum ErrorCode { + public enum ErrorCode + { /// /// Enum NoError for value: no_error /// @@ -328,4 +332,4 @@ public enum ErrorCode { } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/ExpandRequest.cs b/src/OpenFga.Sdk/Model/ExpandRequest.cs index 0f9f62fd..51b2cf26 100644 --- a/src/OpenFga.Sdk/Model/ExpandRequest.cs +++ b/src/OpenFga.Sdk/Model/ExpandRequest.cs @@ -11,21 +11,25 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// ExpandRequest /// [DataContract(Name = "Expand_request")] - public partial class ExpandRequest : IEquatable, IValidatableObject { + public partial class ExpandRequest : IEquatable, IValidatableObject + { /// /// Gets or Sets Consistency @@ -37,7 +41,8 @@ public partial class ExpandRequest : IEquatable, IValidatableObje /// Initializes a new instance of the class. /// [JsonConstructor] - public ExpandRequest() { + public ExpandRequest() + { this.AdditionalProperties = new Dictionary(); } @@ -48,9 +53,11 @@ public ExpandRequest() { /// authorizationModelId. /// consistency. /// contextualTuples. - public ExpandRequest(ExpandRequestTupleKey tupleKey = default, string authorizationModelId = default, ConsistencyPreference? consistency = default, ContextualTupleKeys contextualTuples = default) { + public ExpandRequest(ExpandRequestTupleKey tupleKey = default, string authorizationModelId = default, ConsistencyPreference? consistency = default, ContextualTupleKeys contextualTuples = default) + { // to ensure "tupleKey" is required (not null) - if (tupleKey == null) { + if (tupleKey == null) + { throw new ArgumentNullException("tupleKey is a required property for ExpandRequest and cannot be null"); } this.TupleKey = tupleKey; @@ -95,7 +102,8 @@ public ExpandRequest(ExpandRequestTupleKey tupleKey = default, string authorizat /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -112,7 +120,8 @@ public static ExpandRequest FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((ExpandRequest)input); } @@ -122,25 +131,27 @@ public override bool Equals(object input) { /// /// Instance of ExpandRequest to be compared /// Boolean - public bool Equals(ExpandRequest input) { - if (input == null) { + public bool Equals(ExpandRequest input) + { + if (input == null) + { return false; } - return + return ( this.TupleKey == input.TupleKey || (this.TupleKey != null && this.TupleKey.Equals(input.TupleKey)) - ) && + ) && ( this.AuthorizationModelId == input.AuthorizationModelId || (this.AuthorizationModelId != null && this.AuthorizationModelId.Equals(input.AuthorizationModelId)) - ) && + ) && ( this.Consistency == input.Consistency || this.Consistency.Equals(input.Consistency) - ) && + ) && ( this.ContextualTuples == input.ContextualTuples || (this.ContextualTuples != null && @@ -153,21 +164,26 @@ public bool Equals(ExpandRequest input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.TupleKey != null) { + if (this.TupleKey != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.TupleKey.GetHashCode(); } - if (this.AuthorizationModelId != null) { + if (this.AuthorizationModelId != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AuthorizationModelId.GetHashCode(); } hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Consistency.GetHashCode(); - if (this.ContextualTuples != null) { + if (this.ContextualTuples != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.ContextualTuples.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -179,10 +195,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/ExpandRequestTupleKey.cs b/src/OpenFga.Sdk/Model/ExpandRequestTupleKey.cs index 00f51b06..456cab21 100644 --- a/src/OpenFga.Sdk/Model/ExpandRequestTupleKey.cs +++ b/src/OpenFga.Sdk/Model/ExpandRequestTupleKey.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// ExpandRequestTupleKey /// [DataContract(Name = "ExpandRequestTupleKey")] - public partial class ExpandRequestTupleKey : IEquatable, IValidatableObject { + public partial class ExpandRequestTupleKey : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public ExpandRequestTupleKey() { + public ExpandRequestTupleKey() + { this.AdditionalProperties = new Dictionary(); } @@ -39,14 +44,17 @@ public ExpandRequestTupleKey() { /// /// relation (required). /// varObject (required). - public ExpandRequestTupleKey(string relation = default, string varObject = default) { + public ExpandRequestTupleKey(string relation = default, string varObject = default) + { // to ensure "relation" is required (not null) - if (relation == null) { + if (relation == null) + { throw new ArgumentNullException("relation is a required property for ExpandRequestTupleKey and cannot be null"); } this.Relation = relation; // to ensure "varObject" is required (not null) - if (varObject == null) { + if (varObject == null) + { throw new ArgumentNullException("varObject is a required property for ExpandRequestTupleKey and cannot be null"); } this.Object = varObject; @@ -80,7 +88,8 @@ public ExpandRequestTupleKey(string relation = default, string varObject = defau /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -97,7 +106,8 @@ public static ExpandRequestTupleKey FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((ExpandRequestTupleKey)input); } @@ -107,16 +117,18 @@ public override bool Equals(object input) { /// /// Instance of ExpandRequestTupleKey to be compared /// Boolean - public bool Equals(ExpandRequestTupleKey input) { - if (input == null) { + public bool Equals(ExpandRequestTupleKey input) + { + if (input == null) + { return false; } - return + return ( this.Relation == input.Relation || (this.Relation != null && this.Relation.Equals(input.Relation)) - ) && + ) && ( this.Object == input.Object || (this.Object != null && @@ -129,17 +141,21 @@ public bool Equals(ExpandRequestTupleKey input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Relation != null) { + if (this.Relation != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Relation.GetHashCode(); } - if (this.Object != null) { + if (this.Object != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Object.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -151,15 +167,18 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { // Relation (string) maxLength - if (this.Relation != null && this.Relation.Length > 50) { - yield return new ValidationResult("Invalid value for Relation, length must be less than 50.", new[] { "Relation" }); + if (this.Relation != null && this.Relation.Length > 50) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Relation, length must be less than 50.", new [] { "Relation" }); } // Object (string) maxLength - if (this.Object != null && this.Object.Length > 256) { - yield return new ValidationResult("Invalid value for Object, length must be less than 256.", new[] { "Object" }); + if (this.Object != null && this.Object.Length > 256) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Object, length must be less than 256.", new [] { "Object" }); } yield break; @@ -167,4 +186,4 @@ public IEnumerable Validate(ValidationContext validationContex } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/ExpandResponse.cs b/src/OpenFga.Sdk/Model/ExpandResponse.cs index bbb0bdca..47cc8ba5 100644 --- a/src/OpenFga.Sdk/Model/ExpandResponse.cs +++ b/src/OpenFga.Sdk/Model/ExpandResponse.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// ExpandResponse /// [DataContract(Name = "ExpandResponse")] - public partial class ExpandResponse : IEquatable, IValidatableObject { + public partial class ExpandResponse : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public ExpandResponse() { + public ExpandResponse() + { this.AdditionalProperties = new Dictionary(); } @@ -38,7 +43,8 @@ public ExpandResponse() { /// Initializes a new instance of the class. /// /// tree. - public ExpandResponse(UsersetTree tree = default) { + public ExpandResponse(UsersetTree tree = default) + { this.Tree = tree; this.AdditionalProperties = new Dictionary(); } @@ -62,7 +68,8 @@ public ExpandResponse(UsersetTree tree = default) { /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -79,7 +86,8 @@ public static ExpandResponse FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((ExpandResponse)input); } @@ -89,11 +97,13 @@ public override bool Equals(object input) { /// /// Instance of ExpandResponse to be compared /// Boolean - public bool Equals(ExpandResponse input) { - if (input == null) { + public bool Equals(ExpandResponse input) + { + if (input == null) + { return false; } - return + return ( this.Tree == input.Tree || (this.Tree != null && @@ -106,14 +116,17 @@ public bool Equals(ExpandResponse input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Tree != null) { + if (this.Tree != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Tree.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -125,10 +138,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/FgaObject.cs b/src/OpenFga.Sdk/Model/FgaObject.cs index 3709185e..93b99b50 100644 --- a/src/OpenFga.Sdk/Model/FgaObject.cs +++ b/src/OpenFga.Sdk/Model/FgaObject.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// Object represents an OpenFGA Object. An Object is composed of a type and identifier (e.g. 'document:1') See https://openfga.dev/docs/concepts#what-is-an-object /// [DataContract(Name = "FgaObject")] - public partial class FgaObject : IEquatable, IValidatableObject { + public partial class FgaObject : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public FgaObject() { + public FgaObject() + { this.AdditionalProperties = new Dictionary(); } @@ -39,14 +44,17 @@ public FgaObject() { /// /// type (required). /// id (required). - public FgaObject(string type = default, string id = default) { + public FgaObject(string type = default, string id = default) + { // to ensure "type" is required (not null) - if (type == null) { + if (type == null) + { throw new ArgumentNullException("type is a required property for FgaObject and cannot be null"); } this.Type = type; // to ensure "id" is required (not null) - if (id == null) { + if (id == null) + { throw new ArgumentNullException("id is a required property for FgaObject and cannot be null"); } this.Id = id; @@ -80,7 +88,8 @@ public FgaObject(string type = default, string id = default) { /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -97,7 +106,8 @@ public static FgaObject FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((FgaObject)input); } @@ -107,16 +117,18 @@ public override bool Equals(object input) { /// /// Instance of FgaObject to be compared /// Boolean - public bool Equals(FgaObject input) { - if (input == null) { + public bool Equals(FgaObject input) + { + if (input == null) + { return false; } - return + return ( this.Type == input.Type || (this.Type != null && this.Type.Equals(input.Type)) - ) && + ) && ( this.Id == input.Id || (this.Id != null && @@ -129,17 +141,21 @@ public bool Equals(FgaObject input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Type != null) { + if (this.Type != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Type.GetHashCode(); } - if (this.Id != null) { + if (this.Id != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Id.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -151,10 +167,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/ForbiddenResponse.cs b/src/OpenFga.Sdk/Model/ForbiddenResponse.cs index 0776fb14..b019278f 100644 --- a/src/OpenFga.Sdk/Model/ForbiddenResponse.cs +++ b/src/OpenFga.Sdk/Model/ForbiddenResponse.cs @@ -11,21 +11,25 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// ForbiddenResponse /// [DataContract(Name = "ForbiddenResponse")] - public partial class ForbiddenResponse : IEquatable, IValidatableObject { + public partial class ForbiddenResponse : IEquatable, IValidatableObject + { /// /// Gets or Sets Code @@ -37,7 +41,8 @@ public partial class ForbiddenResponse : IEquatable, IValidat /// Initializes a new instance of the class. /// [JsonConstructor] - public ForbiddenResponse() { + public ForbiddenResponse() + { this.AdditionalProperties = new Dictionary(); } @@ -46,7 +51,8 @@ public ForbiddenResponse() { /// /// code. /// message. - public ForbiddenResponse(AuthErrorCode? code = default, string message = default) { + public ForbiddenResponse(AuthErrorCode? code = default, string message = default) + { this.Code = code; this.Message = message; this.AdditionalProperties = new Dictionary(); @@ -71,7 +77,8 @@ public ForbiddenResponse(AuthErrorCode? code = default, string message = default /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -88,7 +95,8 @@ public static ForbiddenResponse FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((ForbiddenResponse)input); } @@ -98,15 +106,17 @@ public override bool Equals(object input) { /// /// Instance of ForbiddenResponse to be compared /// Boolean - public bool Equals(ForbiddenResponse input) { - if (input == null) { + public bool Equals(ForbiddenResponse input) + { + if (input == null) + { return false; } - return + return ( this.Code == input.Code || this.Code.Equals(input.Code) - ) && + ) && ( this.Message == input.Message || (this.Message != null && @@ -119,15 +129,18 @@ public bool Equals(ForbiddenResponse input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Code.GetHashCode(); - if (this.Message != null) { + if (this.Message != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Message.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -139,10 +152,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/GetStoreResponse.cs b/src/OpenFga.Sdk/Model/GetStoreResponse.cs index bde98f23..0fe8ef58 100644 --- a/src/OpenFga.Sdk/Model/GetStoreResponse.cs +++ b/src/OpenFga.Sdk/Model/GetStoreResponse.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// GetStoreResponse /// [DataContract(Name = "GetStoreResponse")] - public partial class GetStoreResponse : IEquatable, IValidatableObject { + public partial class GetStoreResponse : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public GetStoreResponse() { + public GetStoreResponse() + { this.AdditionalProperties = new Dictionary(); } @@ -42,14 +47,17 @@ public GetStoreResponse() { /// createdAt (required). /// updatedAt (required). /// deletedAt. - public GetStoreResponse(string id = default, string name = default, DateTime createdAt = default, DateTime updatedAt = default, DateTime deletedAt = default) { + public GetStoreResponse(string id = default, string name = default, DateTime createdAt = default, DateTime updatedAt = default, DateTime deletedAt = default) + { // to ensure "id" is required (not null) - if (id == null) { + if (id == null) + { throw new ArgumentNullException("id is a required property for GetStoreResponse and cannot be null"); } this.Id = id; // to ensure "name" is required (not null) - if (name == null) { + if (name == null) + { throw new ArgumentNullException("name is a required property for GetStoreResponse and cannot be null"); } this.Name = name; @@ -110,7 +118,8 @@ public GetStoreResponse(string id = default, string name = default, DateTime cre /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -127,7 +136,8 @@ public static GetStoreResponse FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((GetStoreResponse)input); } @@ -137,31 +147,33 @@ public override bool Equals(object input) { /// /// Instance of GetStoreResponse to be compared /// Boolean - public bool Equals(GetStoreResponse input) { - if (input == null) { + public bool Equals(GetStoreResponse input) + { + if (input == null) + { return false; } - return + return ( this.Id == input.Id || (this.Id != null && this.Id.Equals(input.Id)) - ) && + ) && ( this.Name == input.Name || (this.Name != null && this.Name.Equals(input.Name)) - ) && + ) && ( this.CreatedAt == input.CreatedAt || (this.CreatedAt != null && this.CreatedAt.Equals(input.CreatedAt)) - ) && + ) && ( this.UpdatedAt == input.UpdatedAt || (this.UpdatedAt != null && this.UpdatedAt.Equals(input.UpdatedAt)) - ) && + ) && ( this.DeletedAt == input.DeletedAt || (this.DeletedAt != null && @@ -174,26 +186,33 @@ public bool Equals(GetStoreResponse input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Id != null) { + if (this.Id != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Id.GetHashCode(); } - if (this.Name != null) { + if (this.Name != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Name.GetHashCode(); } - if (this.CreatedAt != null) { + if (this.CreatedAt != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.CreatedAt.GetHashCode(); } - if (this.UpdatedAt != null) { + if (this.UpdatedAt != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.UpdatedAt.GetHashCode(); } - if (this.DeletedAt != null) { + if (this.DeletedAt != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.DeletedAt.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -205,10 +224,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/InternalErrorCode.cs b/src/OpenFga.Sdk/Model/InternalErrorCode.cs index 6b9275c0..b5257463 100644 --- a/src/OpenFga.Sdk/Model/InternalErrorCode.cs +++ b/src/OpenFga.Sdk/Model/InternalErrorCode.cs @@ -11,21 +11,25 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// Defines InternalErrorCode /// [JsonConverter(typeof(JsonStringEnumMemberConverter))] - public enum InternalErrorCode { + public enum InternalErrorCode + { /// /// Enum NoInternalError for value: no_internal_error /// @@ -88,4 +92,4 @@ public enum InternalErrorCode { } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/InternalErrorMessageResponse.cs b/src/OpenFga.Sdk/Model/InternalErrorMessageResponse.cs index 87101e28..0ee49199 100644 --- a/src/OpenFga.Sdk/Model/InternalErrorMessageResponse.cs +++ b/src/OpenFga.Sdk/Model/InternalErrorMessageResponse.cs @@ -11,21 +11,25 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// InternalErrorMessageResponse /// [DataContract(Name = "InternalErrorMessageResponse")] - public partial class InternalErrorMessageResponse : IEquatable, IValidatableObject { + public partial class InternalErrorMessageResponse : IEquatable, IValidatableObject + { /// /// Gets or Sets Code @@ -37,7 +41,8 @@ public partial class InternalErrorMessageResponse : IEquatable class. /// [JsonConstructor] - public InternalErrorMessageResponse() { + public InternalErrorMessageResponse() + { this.AdditionalProperties = new Dictionary(); } @@ -46,7 +51,8 @@ public InternalErrorMessageResponse() { /// /// code. /// message. - public InternalErrorMessageResponse(InternalErrorCode? code = default, string message = default) { + public InternalErrorMessageResponse(InternalErrorCode? code = default, string message = default) + { this.Code = code; this.Message = message; this.AdditionalProperties = new Dictionary(); @@ -71,7 +77,8 @@ public InternalErrorMessageResponse(InternalErrorCode? code = default, string me /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -88,7 +95,8 @@ public static InternalErrorMessageResponse FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((InternalErrorMessageResponse)input); } @@ -98,15 +106,17 @@ public override bool Equals(object input) { /// /// Instance of InternalErrorMessageResponse to be compared /// Boolean - public bool Equals(InternalErrorMessageResponse input) { - if (input == null) { + public bool Equals(InternalErrorMessageResponse input) + { + if (input == null) + { return false; } - return + return ( this.Code == input.Code || this.Code.Equals(input.Code) - ) && + ) && ( this.Message == input.Message || (this.Message != null && @@ -119,15 +129,18 @@ public bool Equals(InternalErrorMessageResponse input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Code.GetHashCode(); - if (this.Message != null) { + if (this.Message != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Message.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -139,10 +152,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/Leaf.cs b/src/OpenFga.Sdk/Model/Leaf.cs index a8aea60f..7dba1840 100644 --- a/src/OpenFga.Sdk/Model/Leaf.cs +++ b/src/OpenFga.Sdk/Model/Leaf.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// A leaf node contains either - a set of users (which may be individual users, or usersets referencing other relations) - a computed node, which is the result of a computed userset value in the authorization model - a tupleToUserset nodes, containing the result of expanding a tupleToUserset value in a authorization model. /// [DataContract(Name = "Leaf")] - public partial class Leaf : IEquatable, IValidatableObject { + public partial class Leaf : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public Leaf() { + public Leaf() + { this.AdditionalProperties = new Dictionary(); } @@ -40,7 +45,8 @@ public Leaf() { /// users. /// computed. /// tupleToUserset. - public Leaf(Users users = default, Computed computed = default, UsersetTreeTupleToUserset tupleToUserset = default) { + public Leaf(Users users = default, Computed computed = default, UsersetTreeTupleToUserset tupleToUserset = default) + { this.Users = users; this.Computed = computed; this.TupleToUserset = tupleToUserset; @@ -82,7 +88,8 @@ public Leaf(Users users = default, Computed computed = default, UsersetTreeTuple /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -99,7 +106,8 @@ public static Leaf FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((Leaf)input); } @@ -109,21 +117,23 @@ public override bool Equals(object input) { /// /// Instance of Leaf to be compared /// Boolean - public bool Equals(Leaf input) { - if (input == null) { + public bool Equals(Leaf input) + { + if (input == null) + { return false; } - return + return ( this.Users == input.Users || (this.Users != null && this.Users.Equals(input.Users)) - ) && + ) && ( this.Computed == input.Computed || (this.Computed != null && this.Computed.Equals(input.Computed)) - ) && + ) && ( this.TupleToUserset == input.TupleToUserset || (this.TupleToUserset != null && @@ -136,20 +146,25 @@ public bool Equals(Leaf input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Users != null) { + if (this.Users != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Users.GetHashCode(); } - if (this.Computed != null) { + if (this.Computed != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Computed.GetHashCode(); } - if (this.TupleToUserset != null) { + if (this.TupleToUserset != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.TupleToUserset.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -161,10 +176,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/ListObjectsRequest.cs b/src/OpenFga.Sdk/Model/ListObjectsRequest.cs index 76b64658..61ae22ac 100644 --- a/src/OpenFga.Sdk/Model/ListObjectsRequest.cs +++ b/src/OpenFga.Sdk/Model/ListObjectsRequest.cs @@ -11,21 +11,25 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// ListObjectsRequest /// [DataContract(Name = "ListObjects_request")] - public partial class ListObjectsRequest : IEquatable, IValidatableObject { + public partial class ListObjectsRequest : IEquatable, IValidatableObject + { /// /// Gets or Sets Consistency @@ -37,7 +41,8 @@ public partial class ListObjectsRequest : IEquatable, IValid /// Initializes a new instance of the class. /// [JsonConstructor] - public ListObjectsRequest() { + public ListObjectsRequest() + { this.AdditionalProperties = new Dictionary(); } @@ -51,19 +56,23 @@ public ListObjectsRequest() { /// contextualTuples. /// Additional request context that will be used to evaluate any ABAC conditions encountered in the query evaluation.. /// consistency. - public ListObjectsRequest(string authorizationModelId = default, string type = default, string relation = default, string user = default, ContextualTupleKeys contextualTuples = default, Object context = default, ConsistencyPreference? consistency = default) { + public ListObjectsRequest(string authorizationModelId = default, string type = default, string relation = default, string user = default, ContextualTupleKeys contextualTuples = default, Object context = default, ConsistencyPreference? consistency = default) + { // to ensure "type" is required (not null) - if (type == null) { + if (type == null) + { throw new ArgumentNullException("type is a required property for ListObjectsRequest and cannot be null"); } this.Type = type; // to ensure "relation" is required (not null) - if (relation == null) { + if (relation == null) + { throw new ArgumentNullException("relation is a required property for ListObjectsRequest and cannot be null"); } this.Relation = relation; // to ensure "user" is required (not null) - if (user == null) { + if (user == null) + { throw new ArgumentNullException("user is a required property for ListObjectsRequest and cannot be null"); } this.User = user; @@ -134,7 +143,8 @@ public ListObjectsRequest(string authorizationModelId = default, string type = d /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -151,7 +161,8 @@ public static ListObjectsRequest FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((ListObjectsRequest)input); } @@ -161,41 +172,43 @@ public override bool Equals(object input) { /// /// Instance of ListObjectsRequest to be compared /// Boolean - public bool Equals(ListObjectsRequest input) { - if (input == null) { + public bool Equals(ListObjectsRequest input) + { + if (input == null) + { return false; } - return + return ( this.AuthorizationModelId == input.AuthorizationModelId || (this.AuthorizationModelId != null && this.AuthorizationModelId.Equals(input.AuthorizationModelId)) - ) && + ) && ( this.Type == input.Type || (this.Type != null && this.Type.Equals(input.Type)) - ) && + ) && ( this.Relation == input.Relation || (this.Relation != null && this.Relation.Equals(input.Relation)) - ) && + ) && ( this.User == input.User || (this.User != null && this.User.Equals(input.User)) - ) && + ) && ( this.ContextualTuples == input.ContextualTuples || (this.ContextualTuples != null && this.ContextualTuples.Equals(input.ContextualTuples)) - ) && + ) && ( this.Context == input.Context || (this.Context != null && this.Context.Equals(input.Context)) - ) && + ) && ( this.Consistency == input.Consistency || this.Consistency.Equals(input.Consistency) @@ -207,30 +220,38 @@ public bool Equals(ListObjectsRequest input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.AuthorizationModelId != null) { + if (this.AuthorizationModelId != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AuthorizationModelId.GetHashCode(); } - if (this.Type != null) { + if (this.Type != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Type.GetHashCode(); } - if (this.Relation != null) { + if (this.Relation != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Relation.GetHashCode(); } - if (this.User != null) { + if (this.User != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.User.GetHashCode(); } - if (this.ContextualTuples != null) { + if (this.ContextualTuples != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.ContextualTuples.GetHashCode(); } - if (this.Context != null) { + if (this.Context != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Context.GetHashCode(); } hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Consistency.GetHashCode(); - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -242,15 +263,18 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { // User (string) maxLength - if (this.User != null && this.User.Length > 512) { - yield return new ValidationResult("Invalid value for User, length must be less than 512.", new[] { "User" }); + if (this.User != null && this.User.Length > 512) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for User, length must be less than 512.", new [] { "User" }); } // User (string) minLength - if (this.User != null && this.User.Length < 1) { - yield return new ValidationResult("Invalid value for User, length must be greater than 1.", new[] { "User" }); + if (this.User != null && this.User.Length < 1) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for User, length must be greater than 1.", new [] { "User" }); } yield break; @@ -258,4 +282,4 @@ public IEnumerable Validate(ValidationContext validationContex } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/ListObjectsResponse.cs b/src/OpenFga.Sdk/Model/ListObjectsResponse.cs index 57b9e4b0..6c8bc2f5 100644 --- a/src/OpenFga.Sdk/Model/ListObjectsResponse.cs +++ b/src/OpenFga.Sdk/Model/ListObjectsResponse.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// ListObjectsResponse /// [DataContract(Name = "ListObjectsResponse")] - public partial class ListObjectsResponse : IEquatable, IValidatableObject { + public partial class ListObjectsResponse : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public ListObjectsResponse() { + public ListObjectsResponse() + { this.AdditionalProperties = new Dictionary(); } @@ -38,9 +43,11 @@ public ListObjectsResponse() { /// Initializes a new instance of the class. /// /// objects (required). - public ListObjectsResponse(List objects = default) { + public ListObjectsResponse(List objects = default) + { // to ensure "objects" is required (not null) - if (objects == null) { + if (objects == null) + { throw new ArgumentNullException("objects is a required property for ListObjectsResponse and cannot be null"); } this.Objects = objects; @@ -66,7 +73,8 @@ public ListObjectsResponse(List objects = default) { /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -83,7 +91,8 @@ public static ListObjectsResponse FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((ListObjectsResponse)input); } @@ -93,11 +102,13 @@ public override bool Equals(object input) { /// /// Instance of ListObjectsResponse to be compared /// Boolean - public bool Equals(ListObjectsResponse input) { - if (input == null) { + public bool Equals(ListObjectsResponse input) + { + if (input == null) + { return false; } - return + return ( this.Objects == input.Objects || this.Objects != null && @@ -111,14 +122,17 @@ public bool Equals(ListObjectsResponse input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Objects != null) { + if (this.Objects != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Objects.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -130,10 +144,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/ListStoresResponse.cs b/src/OpenFga.Sdk/Model/ListStoresResponse.cs index a14611e9..990fd5bd 100644 --- a/src/OpenFga.Sdk/Model/ListStoresResponse.cs +++ b/src/OpenFga.Sdk/Model/ListStoresResponse.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// ListStoresResponse /// [DataContract(Name = "ListStoresResponse")] - public partial class ListStoresResponse : IEquatable, IValidatableObject { + public partial class ListStoresResponse : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public ListStoresResponse() { + public ListStoresResponse() + { this.AdditionalProperties = new Dictionary(); } @@ -39,14 +44,17 @@ public ListStoresResponse() { /// /// stores (required). /// The continuation token will be empty if there are no more stores. (required). - public ListStoresResponse(List stores = default, string continuationToken = default) { + public ListStoresResponse(List stores = default, string continuationToken = default) + { // to ensure "stores" is required (not null) - if (stores == null) { + if (stores == null) + { throw new ArgumentNullException("stores is a required property for ListStoresResponse and cannot be null"); } this.Stores = stores; // to ensure "continuationToken" is required (not null) - if (continuationToken == null) { + if (continuationToken == null) + { throw new ArgumentNullException("continuationToken is a required property for ListStoresResponse and cannot be null"); } this.ContinuationToken = continuationToken; @@ -81,7 +89,8 @@ public ListStoresResponse(List stores = default, string continuationToken /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -98,7 +107,8 @@ public static ListStoresResponse FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((ListStoresResponse)input); } @@ -108,17 +118,19 @@ public override bool Equals(object input) { /// /// Instance of ListStoresResponse to be compared /// Boolean - public bool Equals(ListStoresResponse input) { - if (input == null) { + public bool Equals(ListStoresResponse input) + { + if (input == null) + { return false; } - return + return ( this.Stores == input.Stores || this.Stores != null && input.Stores != null && this.Stores.SequenceEqual(input.Stores) - ) && + ) && ( this.ContinuationToken == input.ContinuationToken || (this.ContinuationToken != null && @@ -131,17 +143,21 @@ public bool Equals(ListStoresResponse input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Stores != null) { + if (this.Stores != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Stores.GetHashCode(); } - if (this.ContinuationToken != null) { + if (this.ContinuationToken != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.ContinuationToken.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -153,10 +169,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/ListUsersRequest.cs b/src/OpenFga.Sdk/Model/ListUsersRequest.cs index 53c56d0e..2438083c 100644 --- a/src/OpenFga.Sdk/Model/ListUsersRequest.cs +++ b/src/OpenFga.Sdk/Model/ListUsersRequest.cs @@ -11,21 +11,25 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// ListUsersRequest /// [DataContract(Name = "ListUsers_request")] - public partial class ListUsersRequest : IEquatable, IValidatableObject { + public partial class ListUsersRequest : IEquatable, IValidatableObject + { /// /// Gets or Sets Consistency @@ -37,7 +41,8 @@ public partial class ListUsersRequest : IEquatable, IValidatab /// Initializes a new instance of the class. /// [JsonConstructor] - public ListUsersRequest() { + public ListUsersRequest() + { this.AdditionalProperties = new Dictionary(); } @@ -51,19 +56,23 @@ public ListUsersRequest() { /// contextualTuples. /// Additional request context that will be used to evaluate any ABAC conditions encountered in the query evaluation.. /// consistency. - public ListUsersRequest(string authorizationModelId = default, FgaObject varObject = default, string relation = default, List userFilters = default, List contextualTuples = default, Object context = default, ConsistencyPreference? consistency = default) { + public ListUsersRequest(string authorizationModelId = default, FgaObject varObject = default, string relation = default, List userFilters = default, List contextualTuples = default, Object context = default, ConsistencyPreference? consistency = default) + { // to ensure "varObject" is required (not null) - if (varObject == null) { + if (varObject == null) + { throw new ArgumentNullException("varObject is a required property for ListUsersRequest and cannot be null"); } this.Object = varObject; // to ensure "relation" is required (not null) - if (relation == null) { + if (relation == null) + { throw new ArgumentNullException("relation is a required property for ListUsersRequest and cannot be null"); } this.Relation = relation; // to ensure "userFilters" is required (not null) - if (userFilters == null) { + if (userFilters == null) + { throw new ArgumentNullException("userFilters is a required property for ListUsersRequest and cannot be null"); } this.UserFilters = userFilters; @@ -135,7 +144,8 @@ public ListUsersRequest(string authorizationModelId = default, FgaObject varObje /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -152,7 +162,8 @@ public static ListUsersRequest FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((ListUsersRequest)input); } @@ -162,43 +173,45 @@ public override bool Equals(object input) { /// /// Instance of ListUsersRequest to be compared /// Boolean - public bool Equals(ListUsersRequest input) { - if (input == null) { + public bool Equals(ListUsersRequest input) + { + if (input == null) + { return false; } - return + return ( this.AuthorizationModelId == input.AuthorizationModelId || (this.AuthorizationModelId != null && this.AuthorizationModelId.Equals(input.AuthorizationModelId)) - ) && + ) && ( this.Object == input.Object || (this.Object != null && this.Object.Equals(input.Object)) - ) && + ) && ( this.Relation == input.Relation || (this.Relation != null && this.Relation.Equals(input.Relation)) - ) && + ) && ( this.UserFilters == input.UserFilters || this.UserFilters != null && input.UserFilters != null && this.UserFilters.SequenceEqual(input.UserFilters) - ) && + ) && ( this.ContextualTuples == input.ContextualTuples || this.ContextualTuples != null && input.ContextualTuples != null && this.ContextualTuples.SequenceEqual(input.ContextualTuples) - ) && + ) && ( this.Context == input.Context || (this.Context != null && this.Context.Equals(input.Context)) - ) && + ) && ( this.Consistency == input.Consistency || this.Consistency.Equals(input.Consistency) @@ -210,30 +223,38 @@ public bool Equals(ListUsersRequest input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.AuthorizationModelId != null) { + if (this.AuthorizationModelId != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AuthorizationModelId.GetHashCode(); } - if (this.Object != null) { + if (this.Object != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Object.GetHashCode(); } - if (this.Relation != null) { + if (this.Relation != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Relation.GetHashCode(); } - if (this.UserFilters != null) { + if (this.UserFilters != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.UserFilters.GetHashCode(); } - if (this.ContextualTuples != null) { + if (this.ContextualTuples != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.ContextualTuples.GetHashCode(); } - if (this.Context != null) { + if (this.Context != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Context.GetHashCode(); } hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Consistency.GetHashCode(); - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -245,10 +266,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/ListUsersResponse.cs b/src/OpenFga.Sdk/Model/ListUsersResponse.cs index e3a2ca28..ea8d850d 100644 --- a/src/OpenFga.Sdk/Model/ListUsersResponse.cs +++ b/src/OpenFga.Sdk/Model/ListUsersResponse.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// ListUsersResponse /// [DataContract(Name = "ListUsersResponse")] - public partial class ListUsersResponse : IEquatable, IValidatableObject { + public partial class ListUsersResponse : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public ListUsersResponse() { + public ListUsersResponse() + { this.AdditionalProperties = new Dictionary(); } @@ -38,9 +43,11 @@ public ListUsersResponse() { /// Initializes a new instance of the class. /// /// users (required). - public ListUsersResponse(List users = default) { + public ListUsersResponse(List users = default) + { // to ensure "users" is required (not null) - if (users == null) { + if (users == null) + { throw new ArgumentNullException("users is a required property for ListUsersResponse and cannot be null"); } this.Users = users; @@ -66,7 +73,8 @@ public ListUsersResponse(List users = default) { /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -83,7 +91,8 @@ public static ListUsersResponse FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((ListUsersResponse)input); } @@ -93,11 +102,13 @@ public override bool Equals(object input) { /// /// Instance of ListUsersResponse to be compared /// Boolean - public bool Equals(ListUsersResponse input) { - if (input == null) { + public bool Equals(ListUsersResponse input) + { + if (input == null) + { return false; } - return + return ( this.Users == input.Users || this.Users != null && @@ -111,14 +122,17 @@ public bool Equals(ListUsersResponse input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Users != null) { + if (this.Users != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Users.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -130,10 +144,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + 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 ed14b16f..200c2ab1 100644 --- a/src/OpenFga.Sdk/Model/Metadata.cs +++ b/src/OpenFga.Sdk/Model/Metadata.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// Metadata /// [DataContract(Name = "Metadata")] - public partial class Metadata : IEquatable, IValidatableObject { + public partial class Metadata : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public Metadata() { + public Metadata() + { this.AdditionalProperties = new Dictionary(); } @@ -40,7 +45,8 @@ public Metadata() { /// relations. /// module. /// sourceInfo. - public Metadata(Dictionary relations = default, string module = default, SourceInfo sourceInfo = default) { + public Metadata(Dictionary relations = default, string module = default, SourceInfo sourceInfo = default) + { this.Relations = relations; this.Module = module; this.SourceInfo = sourceInfo; @@ -82,7 +88,8 @@ public Metadata(Dictionary relations = default, string /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -99,7 +106,8 @@ public static Metadata FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((Metadata)input); } @@ -109,22 +117,24 @@ public override bool Equals(object input) { /// /// Instance of Metadata to be compared /// Boolean - public bool Equals(Metadata input) { - if (input == null) { + public bool Equals(Metadata input) + { + if (input == null) + { return false; } - return + return ( this.Relations == input.Relations || 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 && @@ -137,20 +147,25 @@ public bool Equals(Metadata input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Relations != null) { + if (this.Relations != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Relations.GetHashCode(); } - if (this.Module != null) { + if (this.Module != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Module.GetHashCode(); } - if (this.SourceInfo != null) { + if (this.SourceInfo != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.SourceInfo.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -162,10 +177,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/Node.cs b/src/OpenFga.Sdk/Model/Node.cs index de47f4bb..615c0f68 100644 --- a/src/OpenFga.Sdk/Model/Node.cs +++ b/src/OpenFga.Sdk/Model/Node.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// Node /// [DataContract(Name = "Node")] - public partial class Node : IEquatable, IValidatableObject { + public partial class Node : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public Node() { + public Node() + { this.AdditionalProperties = new Dictionary(); } @@ -42,9 +47,11 @@ public Node() { /// difference. /// union. /// intersection. - public Node(string name = default, Leaf leaf = default, UsersetTreeDifference difference = default, Nodes union = default, Nodes intersection = default) { + public Node(string name = default, Leaf leaf = default, UsersetTreeDifference difference = default, Nodes union = default, Nodes intersection = default) + { // to ensure "name" is required (not null) - if (name == null) { + if (name == null) + { throw new ArgumentNullException("name is a required property for Node and cannot be null"); } this.Name = name; @@ -106,7 +113,8 @@ public Node(string name = default, Leaf leaf = default, UsersetTreeDifference di /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -123,7 +131,8 @@ public static Node FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((Node)input); } @@ -133,31 +142,33 @@ public override bool Equals(object input) { /// /// Instance of Node to be compared /// Boolean - public bool Equals(Node input) { - if (input == null) { + public bool Equals(Node input) + { + if (input == null) + { return false; } - return + return ( this.Name == input.Name || (this.Name != null && this.Name.Equals(input.Name)) - ) && + ) && ( this.Leaf == input.Leaf || (this.Leaf != null && this.Leaf.Equals(input.Leaf)) - ) && + ) && ( this.Difference == input.Difference || (this.Difference != null && this.Difference.Equals(input.Difference)) - ) && + ) && ( this.Union == input.Union || (this.Union != null && this.Union.Equals(input.Union)) - ) && + ) && ( this.Intersection == input.Intersection || (this.Intersection != null && @@ -170,26 +181,33 @@ public bool Equals(Node input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Name != null) { + if (this.Name != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Name.GetHashCode(); } - if (this.Leaf != null) { + if (this.Leaf != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Leaf.GetHashCode(); } - if (this.Difference != null) { + if (this.Difference != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Difference.GetHashCode(); } - if (this.Union != null) { + if (this.Union != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Union.GetHashCode(); } - if (this.Intersection != null) { + if (this.Intersection != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Intersection.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -201,10 +219,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/Nodes.cs b/src/OpenFga.Sdk/Model/Nodes.cs index 75b8e132..67c92fe3 100644 --- a/src/OpenFga.Sdk/Model/Nodes.cs +++ b/src/OpenFga.Sdk/Model/Nodes.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// Nodes /// [DataContract(Name = "Nodes")] - public partial class Nodes : IEquatable, IValidatableObject { + public partial class Nodes : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public Nodes() { + public Nodes() + { this.AdditionalProperties = new Dictionary(); } @@ -38,9 +43,11 @@ public Nodes() { /// Initializes a new instance of the class. /// /// varNodes (required). - public Nodes(List varNodes = default) { + public Nodes(List varNodes = default) + { // to ensure "varNodes" is required (not null) - if (varNodes == null) { + if (varNodes == null) + { throw new ArgumentNullException("varNodes is a required property for Nodes and cannot be null"); } this.VarNodes = varNodes; @@ -66,7 +73,8 @@ public Nodes(List varNodes = default) { /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -83,7 +91,8 @@ public static Nodes FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((Nodes)input); } @@ -93,11 +102,13 @@ public override bool Equals(object input) { /// /// Instance of Nodes to be compared /// Boolean - public bool Equals(Nodes input) { - if (input == null) { + public bool Equals(Nodes input) + { + if (input == null) + { return false; } - return + return ( this.VarNodes == input.VarNodes || this.VarNodes != null && @@ -111,14 +122,17 @@ public bool Equals(Nodes input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.VarNodes != null) { + if (this.VarNodes != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.VarNodes.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -130,10 +144,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/NotFoundErrorCode.cs b/src/OpenFga.Sdk/Model/NotFoundErrorCode.cs index e5c81a37..f4b7f167 100644 --- a/src/OpenFga.Sdk/Model/NotFoundErrorCode.cs +++ b/src/OpenFga.Sdk/Model/NotFoundErrorCode.cs @@ -11,21 +11,25 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// Defines NotFoundErrorCode /// [JsonConverter(typeof(JsonStringEnumMemberConverter))] - public enum NotFoundErrorCode { + public enum NotFoundErrorCode + { /// /// Enum NoNotFoundError for value: no_not_found_error /// @@ -52,4 +56,4 @@ public enum NotFoundErrorCode { } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/NullValue.cs b/src/OpenFga.Sdk/Model/NullValue.cs index 5bc14416..a5186be6 100644 --- a/src/OpenFga.Sdk/Model/NullValue.cs +++ b/src/OpenFga.Sdk/Model/NullValue.cs @@ -11,22 +11,26 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// `NullValue` is a singleton enumeration to represent the null value for the `Value` type union. The JSON representation for `NullValue` is JSON `null`. - NULL_VALUE: Null value. /// /// `NullValue` is a singleton enumeration to represent the null value for the `Value` type union. The JSON representation for `NullValue` is JSON `null`. - NULL_VALUE: Null value. [JsonConverter(typeof(JsonStringEnumMemberConverter))] - public enum NullValue { + public enum NullValue + { /// /// Enum NULLVALUE for value: NULL_VALUE /// @@ -35,4 +39,4 @@ public enum NullValue { } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/ObjectRelation.cs b/src/OpenFga.Sdk/Model/ObjectRelation.cs index 9acabdda..0936c143 100644 --- a/src/OpenFga.Sdk/Model/ObjectRelation.cs +++ b/src/OpenFga.Sdk/Model/ObjectRelation.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// ObjectRelation /// [DataContract(Name = "ObjectRelation")] - public partial class ObjectRelation : IEquatable, IValidatableObject { + public partial class ObjectRelation : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public ObjectRelation() { + public ObjectRelation() + { this.AdditionalProperties = new Dictionary(); } @@ -39,7 +44,8 @@ public ObjectRelation() { /// /// varObject. /// relation. - public ObjectRelation(string varObject = default, string relation = default) { + public ObjectRelation(string varObject = default, string relation = default) + { this.Object = varObject; this.Relation = relation; this.AdditionalProperties = new Dictionary(); @@ -72,7 +78,8 @@ public ObjectRelation(string varObject = default, string relation = default) { /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -89,7 +96,8 @@ public static ObjectRelation FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((ObjectRelation)input); } @@ -99,16 +107,18 @@ public override bool Equals(object input) { /// /// Instance of ObjectRelation to be compared /// Boolean - public bool Equals(ObjectRelation input) { - if (input == null) { + public bool Equals(ObjectRelation input) + { + if (input == null) + { return false; } - return + return ( this.Object == input.Object || (this.Object != null && this.Object.Equals(input.Object)) - ) && + ) && ( this.Relation == input.Relation || (this.Relation != null && @@ -121,17 +131,21 @@ public bool Equals(ObjectRelation input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Object != null) { + if (this.Object != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Object.GetHashCode(); } - if (this.Relation != null) { + if (this.Relation != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Relation.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -143,10 +157,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/PathUnknownErrorMessageResponse.cs b/src/OpenFga.Sdk/Model/PathUnknownErrorMessageResponse.cs index 84373143..fa457f89 100644 --- a/src/OpenFga.Sdk/Model/PathUnknownErrorMessageResponse.cs +++ b/src/OpenFga.Sdk/Model/PathUnknownErrorMessageResponse.cs @@ -11,21 +11,25 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// PathUnknownErrorMessageResponse /// [DataContract(Name = "PathUnknownErrorMessageResponse")] - public partial class PathUnknownErrorMessageResponse : IEquatable, IValidatableObject { + public partial class PathUnknownErrorMessageResponse : IEquatable, IValidatableObject + { /// /// Gets or Sets Code @@ -37,7 +41,8 @@ public partial class PathUnknownErrorMessageResponse : IEquatable class. /// [JsonConstructor] - public PathUnknownErrorMessageResponse() { + public PathUnknownErrorMessageResponse() + { this.AdditionalProperties = new Dictionary(); } @@ -46,7 +51,8 @@ public PathUnknownErrorMessageResponse() { /// /// code. /// message. - public PathUnknownErrorMessageResponse(NotFoundErrorCode? code = default, string message = default) { + public PathUnknownErrorMessageResponse(NotFoundErrorCode? code = default, string message = default) + { this.Code = code; this.Message = message; this.AdditionalProperties = new Dictionary(); @@ -71,7 +77,8 @@ public PathUnknownErrorMessageResponse(NotFoundErrorCode? code = default, string /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -88,7 +95,8 @@ public static PathUnknownErrorMessageResponse FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((PathUnknownErrorMessageResponse)input); } @@ -98,15 +106,17 @@ public override bool Equals(object input) { /// /// Instance of PathUnknownErrorMessageResponse to be compared /// Boolean - public bool Equals(PathUnknownErrorMessageResponse input) { - if (input == null) { + public bool Equals(PathUnknownErrorMessageResponse input) + { + if (input == null) + { return false; } - return + return ( this.Code == input.Code || this.Code.Equals(input.Code) - ) && + ) && ( this.Message == input.Message || (this.Message != null && @@ -119,15 +129,18 @@ public bool Equals(PathUnknownErrorMessageResponse input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Code.GetHashCode(); - if (this.Message != null) { + if (this.Message != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Message.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -139,10 +152,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/ReadAssertionsResponse.cs b/src/OpenFga.Sdk/Model/ReadAssertionsResponse.cs index 422ba901..bf9f2bd6 100644 --- a/src/OpenFga.Sdk/Model/ReadAssertionsResponse.cs +++ b/src/OpenFga.Sdk/Model/ReadAssertionsResponse.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// ReadAssertionsResponse /// [DataContract(Name = "ReadAssertionsResponse")] - public partial class ReadAssertionsResponse : IEquatable, IValidatableObject { + public partial class ReadAssertionsResponse : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public ReadAssertionsResponse() { + public ReadAssertionsResponse() + { this.AdditionalProperties = new Dictionary(); } @@ -39,9 +44,11 @@ public ReadAssertionsResponse() { /// /// authorizationModelId (required). /// assertions. - public ReadAssertionsResponse(string authorizationModelId = default, List assertions = default) { + public ReadAssertionsResponse(string authorizationModelId = default, List assertions = default) + { // to ensure "authorizationModelId" is required (not null) - if (authorizationModelId == null) { + if (authorizationModelId == null) + { throw new ArgumentNullException("authorizationModelId is a required property for ReadAssertionsResponse and cannot be null"); } this.AuthorizationModelId = authorizationModelId; @@ -76,7 +83,8 @@ public ReadAssertionsResponse(string authorizationModelId = default, List /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -93,7 +101,8 @@ public static ReadAssertionsResponse FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((ReadAssertionsResponse)input); } @@ -103,16 +112,18 @@ public override bool Equals(object input) { /// /// Instance of ReadAssertionsResponse to be compared /// Boolean - public bool Equals(ReadAssertionsResponse input) { - if (input == null) { + public bool Equals(ReadAssertionsResponse input) + { + if (input == null) + { return false; } - return + return ( this.AuthorizationModelId == input.AuthorizationModelId || (this.AuthorizationModelId != null && this.AuthorizationModelId.Equals(input.AuthorizationModelId)) - ) && + ) && ( this.Assertions == input.Assertions || this.Assertions != null && @@ -126,17 +137,21 @@ public bool Equals(ReadAssertionsResponse input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.AuthorizationModelId != null) { + if (this.AuthorizationModelId != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AuthorizationModelId.GetHashCode(); } - if (this.Assertions != null) { + if (this.Assertions != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Assertions.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -148,10 +163,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/ReadAuthorizationModelResponse.cs b/src/OpenFga.Sdk/Model/ReadAuthorizationModelResponse.cs index f138e3c4..a4f56c1f 100644 --- a/src/OpenFga.Sdk/Model/ReadAuthorizationModelResponse.cs +++ b/src/OpenFga.Sdk/Model/ReadAuthorizationModelResponse.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// ReadAuthorizationModelResponse /// [DataContract(Name = "ReadAuthorizationModelResponse")] - public partial class ReadAuthorizationModelResponse : IEquatable, IValidatableObject { + public partial class ReadAuthorizationModelResponse : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public ReadAuthorizationModelResponse() { + public ReadAuthorizationModelResponse() + { this.AdditionalProperties = new Dictionary(); } @@ -38,7 +43,8 @@ public ReadAuthorizationModelResponse() { /// Initializes a new instance of the class. /// /// authorizationModel. - public ReadAuthorizationModelResponse(AuthorizationModel authorizationModel = default) { + public ReadAuthorizationModelResponse(AuthorizationModel authorizationModel = default) + { this.AuthorizationModel = authorizationModel; this.AdditionalProperties = new Dictionary(); } @@ -62,7 +68,8 @@ public ReadAuthorizationModelResponse(AuthorizationModel authorizationModel = de /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -79,7 +86,8 @@ public static ReadAuthorizationModelResponse FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((ReadAuthorizationModelResponse)input); } @@ -89,11 +97,13 @@ public override bool Equals(object input) { /// /// Instance of ReadAuthorizationModelResponse to be compared /// Boolean - public bool Equals(ReadAuthorizationModelResponse input) { - if (input == null) { + public bool Equals(ReadAuthorizationModelResponse input) + { + if (input == null) + { return false; } - return + return ( this.AuthorizationModel == input.AuthorizationModel || (this.AuthorizationModel != null && @@ -106,14 +116,17 @@ public bool Equals(ReadAuthorizationModelResponse input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.AuthorizationModel != null) { + if (this.AuthorizationModel != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AuthorizationModel.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -125,10 +138,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/ReadAuthorizationModelsResponse.cs b/src/OpenFga.Sdk/Model/ReadAuthorizationModelsResponse.cs index 83d57a47..0e91eb44 100644 --- a/src/OpenFga.Sdk/Model/ReadAuthorizationModelsResponse.cs +++ b/src/OpenFga.Sdk/Model/ReadAuthorizationModelsResponse.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// ReadAuthorizationModelsResponse /// [DataContract(Name = "ReadAuthorizationModelsResponse")] - public partial class ReadAuthorizationModelsResponse : IEquatable, IValidatableObject { + public partial class ReadAuthorizationModelsResponse : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public ReadAuthorizationModelsResponse() { + public ReadAuthorizationModelsResponse() + { this.AdditionalProperties = new Dictionary(); } @@ -39,9 +44,11 @@ public ReadAuthorizationModelsResponse() { /// /// authorizationModels (required). /// The continuation token will be empty if there are no more models.. - public ReadAuthorizationModelsResponse(List authorizationModels = default, string continuationToken = default) { + public ReadAuthorizationModelsResponse(List authorizationModels = default, string continuationToken = default) + { // to ensure "authorizationModels" is required (not null) - if (authorizationModels == null) { + if (authorizationModels == null) + { throw new ArgumentNullException("authorizationModels is a required property for ReadAuthorizationModelsResponse and cannot be null"); } this.AuthorizationModels = authorizationModels; @@ -77,7 +84,8 @@ public ReadAuthorizationModelsResponse(List authorizationMod /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -94,7 +102,8 @@ public static ReadAuthorizationModelsResponse FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((ReadAuthorizationModelsResponse)input); } @@ -104,17 +113,19 @@ public override bool Equals(object input) { /// /// Instance of ReadAuthorizationModelsResponse to be compared /// Boolean - public bool Equals(ReadAuthorizationModelsResponse input) { - if (input == null) { + public bool Equals(ReadAuthorizationModelsResponse input) + { + if (input == null) + { return false; } - return + return ( this.AuthorizationModels == input.AuthorizationModels || this.AuthorizationModels != null && input.AuthorizationModels != null && this.AuthorizationModels.SequenceEqual(input.AuthorizationModels) - ) && + ) && ( this.ContinuationToken == input.ContinuationToken || (this.ContinuationToken != null && @@ -127,17 +138,21 @@ public bool Equals(ReadAuthorizationModelsResponse input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.AuthorizationModels != null) { + if (this.AuthorizationModels != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AuthorizationModels.GetHashCode(); } - if (this.ContinuationToken != null) { + if (this.ContinuationToken != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.ContinuationToken.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -149,10 +164,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/ReadChangesResponse.cs b/src/OpenFga.Sdk/Model/ReadChangesResponse.cs index 71394fad..af5fb846 100644 --- a/src/OpenFga.Sdk/Model/ReadChangesResponse.cs +++ b/src/OpenFga.Sdk/Model/ReadChangesResponse.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// ReadChangesResponse /// [DataContract(Name = "ReadChangesResponse")] - public partial class ReadChangesResponse : IEquatable, IValidatableObject { + public partial class ReadChangesResponse : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public ReadChangesResponse() { + public ReadChangesResponse() + { this.AdditionalProperties = new Dictionary(); } @@ -39,9 +44,11 @@ public ReadChangesResponse() { /// /// changes (required). /// The continuation token will be identical if there are no new changes.. - public ReadChangesResponse(List changes = default, string continuationToken = default) { + public ReadChangesResponse(List changes = default, string continuationToken = default) + { // to ensure "changes" is required (not null) - if (changes == null) { + if (changes == null) + { throw new ArgumentNullException("changes is a required property for ReadChangesResponse and cannot be null"); } this.Changes = changes; @@ -77,7 +84,8 @@ public ReadChangesResponse(List changes = default, string continuat /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -94,7 +102,8 @@ public static ReadChangesResponse FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((ReadChangesResponse)input); } @@ -104,17 +113,19 @@ public override bool Equals(object input) { /// /// Instance of ReadChangesResponse to be compared /// Boolean - public bool Equals(ReadChangesResponse input) { - if (input == null) { + public bool Equals(ReadChangesResponse input) + { + if (input == null) + { return false; } - return + return ( this.Changes == input.Changes || this.Changes != null && input.Changes != null && this.Changes.SequenceEqual(input.Changes) - ) && + ) && ( this.ContinuationToken == input.ContinuationToken || (this.ContinuationToken != null && @@ -127,17 +138,21 @@ public bool Equals(ReadChangesResponse input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Changes != null) { + if (this.Changes != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Changes.GetHashCode(); } - if (this.ContinuationToken != null) { + if (this.ContinuationToken != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.ContinuationToken.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -149,10 +164,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/ReadRequest.cs b/src/OpenFga.Sdk/Model/ReadRequest.cs index 530351e9..036c51e9 100644 --- a/src/OpenFga.Sdk/Model/ReadRequest.cs +++ b/src/OpenFga.Sdk/Model/ReadRequest.cs @@ -11,21 +11,25 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// ReadRequest /// [DataContract(Name = "Read_request")] - public partial class ReadRequest : IEquatable, IValidatableObject { + public partial class ReadRequest : IEquatable, IValidatableObject + { /// /// Gets or Sets Consistency @@ -37,7 +41,8 @@ public partial class ReadRequest : IEquatable, IValidatableObject { /// Initializes a new instance of the class. /// [JsonConstructor] - public ReadRequest() { + public ReadRequest() + { this.AdditionalProperties = new Dictionary(); } @@ -48,7 +53,8 @@ public ReadRequest() { /// pageSize. /// continuationToken. /// consistency. - public ReadRequest(ReadRequestTupleKey tupleKey = default, int pageSize = default, string continuationToken = default, ConsistencyPreference? consistency = default) { + public ReadRequest(ReadRequestTupleKey tupleKey = default, int pageSize = default, string continuationToken = default, ConsistencyPreference? consistency = default) + { this.TupleKey = tupleKey; this.PageSize = pageSize; this.ContinuationToken = continuationToken; @@ -91,7 +97,8 @@ public ReadRequest(ReadRequestTupleKey tupleKey = default, int pageSize = defaul /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -108,7 +115,8 @@ public static ReadRequest FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((ReadRequest)input); } @@ -118,25 +126,27 @@ public override bool Equals(object input) { /// /// Instance of ReadRequest to be compared /// Boolean - public bool Equals(ReadRequest input) { - if (input == null) { + public bool Equals(ReadRequest input) + { + if (input == null) + { return false; } - return + return ( this.TupleKey == input.TupleKey || (this.TupleKey != null && this.TupleKey.Equals(input.TupleKey)) - ) && + ) && ( this.PageSize == input.PageSize || this.PageSize.Equals(input.PageSize) - ) && + ) && ( this.ContinuationToken == input.ContinuationToken || (this.ContinuationToken != null && this.ContinuationToken.Equals(input.ContinuationToken)) - ) && + ) && ( this.Consistency == input.Consistency || this.Consistency.Equals(input.Consistency) @@ -148,19 +158,23 @@ public bool Equals(ReadRequest input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.TupleKey != null) { + if (this.TupleKey != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.TupleKey.GetHashCode(); } hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.PageSize.GetHashCode(); - if (this.ContinuationToken != null) { + if (this.ContinuationToken != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.ContinuationToken.GetHashCode(); } hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Consistency.GetHashCode(); - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -172,15 +186,18 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { // PageSize (int) maximum - if (this.PageSize > 100) { - yield return new ValidationResult("Invalid value for PageSize, must be a value less than or equal to 100.", new[] { "PageSize" }); + if (this.PageSize > (int)100) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for PageSize, must be a value less than or equal to 100.", new [] { "PageSize" }); } // PageSize (int) minimum - if (this.PageSize < 1) { - yield return new ValidationResult("Invalid value for PageSize, must be a value greater than or equal to 1.", new[] { "PageSize" }); + if (this.PageSize < (int)1) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for PageSize, must be a value greater than or equal to 1.", new [] { "PageSize" }); } yield break; @@ -188,4 +205,4 @@ public IEnumerable Validate(ValidationContext validationContex } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/ReadRequestTupleKey.cs b/src/OpenFga.Sdk/Model/ReadRequestTupleKey.cs index cc14f320..7078fade 100644 --- a/src/OpenFga.Sdk/Model/ReadRequestTupleKey.cs +++ b/src/OpenFga.Sdk/Model/ReadRequestTupleKey.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// ReadRequestTupleKey /// [DataContract(Name = "ReadRequestTupleKey")] - public partial class ReadRequestTupleKey : IEquatable, IValidatableObject { + public partial class ReadRequestTupleKey : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public ReadRequestTupleKey() { + public ReadRequestTupleKey() + { this.AdditionalProperties = new Dictionary(); } @@ -40,7 +45,8 @@ public ReadRequestTupleKey() { /// user. /// relation. /// varObject. - public ReadRequestTupleKey(string user = default, string relation = default, string varObject = default) { + public ReadRequestTupleKey(string user = default, string relation = default, string varObject = default) + { this.User = user; this.Relation = relation; this.Object = varObject; @@ -82,7 +88,8 @@ public ReadRequestTupleKey(string user = default, string relation = default, str /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -99,7 +106,8 @@ public static ReadRequestTupleKey FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((ReadRequestTupleKey)input); } @@ -109,21 +117,23 @@ public override bool Equals(object input) { /// /// Instance of ReadRequestTupleKey to be compared /// Boolean - public bool Equals(ReadRequestTupleKey input) { - if (input == null) { + public bool Equals(ReadRequestTupleKey input) + { + if (input == null) + { return false; } - return + return ( this.User == input.User || (this.User != null && this.User.Equals(input.User)) - ) && + ) && ( this.Relation == input.Relation || (this.Relation != null && this.Relation.Equals(input.Relation)) - ) && + ) && ( this.Object == input.Object || (this.Object != null && @@ -136,20 +146,25 @@ public bool Equals(ReadRequestTupleKey input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.User != null) { + if (this.User != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.User.GetHashCode(); } - if (this.Relation != null) { + if (this.Relation != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Relation.GetHashCode(); } - if (this.Object != null) { + if (this.Object != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Object.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -161,20 +176,24 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { // User (string) maxLength - if (this.User != null && this.User.Length > 512) { - yield return new ValidationResult("Invalid value for User, length must be less than 512.", new[] { "User" }); + if (this.User != null && this.User.Length > 512) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for User, length must be less than 512.", new [] { "User" }); } // Relation (string) maxLength - if (this.Relation != null && this.Relation.Length > 50) { - yield return new ValidationResult("Invalid value for Relation, length must be less than 50.", new[] { "Relation" }); + if (this.Relation != null && this.Relation.Length > 50) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Relation, length must be less than 50.", new [] { "Relation" }); } // Object (string) maxLength - if (this.Object != null && this.Object.Length > 256) { - yield return new ValidationResult("Invalid value for Object, length must be less than 256.", new[] { "Object" }); + if (this.Object != null && this.Object.Length > 256) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Object, length must be less than 256.", new [] { "Object" }); } yield break; @@ -182,4 +201,4 @@ public IEnumerable Validate(ValidationContext validationContex } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/ReadResponse.cs b/src/OpenFga.Sdk/Model/ReadResponse.cs index c6893269..135dfe37 100644 --- a/src/OpenFga.Sdk/Model/ReadResponse.cs +++ b/src/OpenFga.Sdk/Model/ReadResponse.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// ReadResponse /// [DataContract(Name = "ReadResponse")] - public partial class ReadResponse : IEquatable, IValidatableObject { + public partial class ReadResponse : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public ReadResponse() { + public ReadResponse() + { this.AdditionalProperties = new Dictionary(); } @@ -39,14 +44,17 @@ public ReadResponse() { /// /// tuples (required). /// The continuation token will be empty if there are no more tuples. (required). - public ReadResponse(List tuples = default, string continuationToken = default) { + public ReadResponse(List tuples = default, string continuationToken = default) + { // to ensure "tuples" is required (not null) - if (tuples == null) { + if (tuples == null) + { throw new ArgumentNullException("tuples is a required property for ReadResponse and cannot be null"); } this.Tuples = tuples; // to ensure "continuationToken" is required (not null) - if (continuationToken == null) { + if (continuationToken == null) + { throw new ArgumentNullException("continuationToken is a required property for ReadResponse and cannot be null"); } this.ContinuationToken = continuationToken; @@ -81,7 +89,8 @@ public ReadResponse(List tuples = default, string continuationToken = def /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -98,7 +107,8 @@ public static ReadResponse FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((ReadResponse)input); } @@ -108,17 +118,19 @@ public override bool Equals(object input) { /// /// Instance of ReadResponse to be compared /// Boolean - public bool Equals(ReadResponse input) { - if (input == null) { + public bool Equals(ReadResponse input) + { + if (input == null) + { return false; } - return + return ( this.Tuples == input.Tuples || this.Tuples != null && input.Tuples != null && this.Tuples.SequenceEqual(input.Tuples) - ) && + ) && ( this.ContinuationToken == input.ContinuationToken || (this.ContinuationToken != null && @@ -131,17 +143,21 @@ public bool Equals(ReadResponse input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Tuples != null) { + if (this.Tuples != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Tuples.GetHashCode(); } - if (this.ContinuationToken != null) { + if (this.ContinuationToken != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.ContinuationToken.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -153,10 +169,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/RelationMetadata.cs b/src/OpenFga.Sdk/Model/RelationMetadata.cs index d405362e..7f592510 100644 --- a/src/OpenFga.Sdk/Model/RelationMetadata.cs +++ b/src/OpenFga.Sdk/Model/RelationMetadata.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// RelationMetadata /// [DataContract(Name = "RelationMetadata")] - public partial class RelationMetadata : IEquatable, IValidatableObject { + public partial class RelationMetadata : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public RelationMetadata() { + public RelationMetadata() + { this.AdditionalProperties = new Dictionary(); } @@ -40,7 +45,8 @@ public RelationMetadata() { /// directlyRelatedUserTypes. /// module. /// sourceInfo. - public RelationMetadata(List directlyRelatedUserTypes = default, string module = default, SourceInfo sourceInfo = default) { + public RelationMetadata(List directlyRelatedUserTypes = default, string module = default, SourceInfo sourceInfo = default) + { this.DirectlyRelatedUserTypes = directlyRelatedUserTypes; this.Module = module; this.SourceInfo = sourceInfo; @@ -82,7 +88,8 @@ public RelationMetadata(List directlyRelatedUserTypes = defau /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -99,7 +106,8 @@ public static RelationMetadata FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((RelationMetadata)input); } @@ -109,22 +117,24 @@ public override bool Equals(object input) { /// /// Instance of RelationMetadata to be compared /// Boolean - public bool Equals(RelationMetadata input) { - if (input == null) { + public bool Equals(RelationMetadata input) + { + if (input == null) + { return false; } - return + return ( this.DirectlyRelatedUserTypes == input.DirectlyRelatedUserTypes || 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 && @@ -137,20 +147,25 @@ public bool Equals(RelationMetadata input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.DirectlyRelatedUserTypes != null) { + if (this.DirectlyRelatedUserTypes != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.DirectlyRelatedUserTypes.GetHashCode(); } - if (this.Module != null) { + if (this.Module != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Module.GetHashCode(); } - if (this.SourceInfo != null) { + if (this.SourceInfo != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.SourceInfo.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -162,10 +177,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/RelationReference.cs b/src/OpenFga.Sdk/Model/RelationReference.cs index 2391da3c..a9e2631d 100644 --- a/src/OpenFga.Sdk/Model/RelationReference.cs +++ b/src/OpenFga.Sdk/Model/RelationReference.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// RelationReference represents a relation of a particular object type (e.g. 'document#viewer'). /// [DataContract(Name = "RelationReference")] - public partial class RelationReference : IEquatable, IValidatableObject { + public partial class RelationReference : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public RelationReference() { + public RelationReference() + { this.AdditionalProperties = new Dictionary(); } @@ -41,9 +46,11 @@ public RelationReference() { /// relation. /// wildcard. /// The name of a condition that is enforced over the allowed relation.. - public RelationReference(string type = default, string relation = default, Object wildcard = default, string condition = default) { + public RelationReference(string type = default, string relation = default, Object wildcard = default, string condition = default) + { // to ensure "type" is required (not null) - if (type == null) { + if (type == null) + { throw new ArgumentNullException("type is a required property for RelationReference and cannot be null"); } this.Type = type; @@ -97,7 +104,8 @@ public RelationReference(string type = default, string relation = default, Objec /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -114,7 +122,8 @@ public static RelationReference FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((RelationReference)input); } @@ -124,26 +133,28 @@ public override bool Equals(object input) { /// /// Instance of RelationReference to be compared /// Boolean - public bool Equals(RelationReference input) { - if (input == null) { + public bool Equals(RelationReference input) + { + if (input == null) + { return false; } - return + return ( this.Type == input.Type || (this.Type != null && this.Type.Equals(input.Type)) - ) && + ) && ( this.Relation == input.Relation || (this.Relation != null && this.Relation.Equals(input.Relation)) - ) && + ) && ( this.Wildcard == input.Wildcard || (this.Wildcard != null && this.Wildcard.Equals(input.Wildcard)) - ) && + ) && ( this.Condition == input.Condition || (this.Condition != null && @@ -156,23 +167,29 @@ public bool Equals(RelationReference input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Type != null) { + if (this.Type != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Type.GetHashCode(); } - if (this.Relation != null) { + if (this.Relation != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Relation.GetHashCode(); } - if (this.Wildcard != null) { + if (this.Wildcard != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Wildcard.GetHashCode(); } - if (this.Condition != null) { + if (this.Condition != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Condition.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -184,10 +201,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/RelationshipCondition.cs b/src/OpenFga.Sdk/Model/RelationshipCondition.cs index 851ebb50..4ce10fc5 100644 --- a/src/OpenFga.Sdk/Model/RelationshipCondition.cs +++ b/src/OpenFga.Sdk/Model/RelationshipCondition.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// RelationshipCondition /// [DataContract(Name = "RelationshipCondition")] - public partial class RelationshipCondition : IEquatable, IValidatableObject { + public partial class RelationshipCondition : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public RelationshipCondition() { + public RelationshipCondition() + { this.AdditionalProperties = new Dictionary(); } @@ -39,9 +44,11 @@ public RelationshipCondition() { /// /// A reference (by name) of the relationship condition defined in the authorization model. (required). /// Additional context/data to persist along with the condition. The keys must match the parameters defined by the condition, and the value types must match the parameter type definitions.. - public RelationshipCondition(string name = default, Object context = default) { + public RelationshipCondition(string name = default, Object context = default) + { // to ensure "name" is required (not null) - if (name == null) { + if (name == null) + { throw new ArgumentNullException("name is a required property for RelationshipCondition and cannot be null"); } this.Name = name; @@ -78,7 +85,8 @@ public RelationshipCondition(string name = default, Object context = default) { /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -95,7 +103,8 @@ public static RelationshipCondition FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((RelationshipCondition)input); } @@ -105,16 +114,18 @@ public override bool Equals(object input) { /// /// Instance of RelationshipCondition to be compared /// Boolean - public bool Equals(RelationshipCondition input) { - if (input == null) { + public bool Equals(RelationshipCondition input) + { + if (input == null) + { return false; } - return + return ( this.Name == input.Name || (this.Name != null && this.Name.Equals(input.Name)) - ) && + ) && ( this.Context == input.Context || (this.Context != null && @@ -127,17 +138,21 @@ public bool Equals(RelationshipCondition input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Name != null) { + if (this.Name != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Name.GetHashCode(); } - if (this.Context != null) { + if (this.Context != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Context.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -149,10 +164,12 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { // Name (string) maxLength - if (this.Name != null && this.Name.Length > 256) { - yield return new ValidationResult("Invalid value for Name, length must be less than 256.", new[] { "Name" }); + if (this.Name != null && this.Name.Length > 256) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Name, length must be less than 256.", new [] { "Name" }); } yield break; @@ -160,4 +177,4 @@ public IEnumerable Validate(ValidationContext validationContex } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/SourceInfo.cs b/src/OpenFga.Sdk/Model/SourceInfo.cs index 0b8e5c41..081f3f27 100644 --- a/src/OpenFga.Sdk/Model/SourceInfo.cs +++ b/src/OpenFga.Sdk/Model/SourceInfo.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// SourceInfo /// [DataContract(Name = "SourceInfo")] - public partial class SourceInfo : IEquatable, IValidatableObject { + public partial class SourceInfo : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public SourceInfo() { + public SourceInfo() + { this.AdditionalProperties = new Dictionary(); } @@ -38,7 +43,8 @@ public SourceInfo() { /// Initializes a new instance of the class. /// /// file. - public SourceInfo(string file = default) { + public SourceInfo(string file = default) + { this.File = file; this.AdditionalProperties = new Dictionary(); } @@ -62,7 +68,8 @@ public SourceInfo(string file = default) { /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -79,7 +86,8 @@ public static SourceInfo FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((SourceInfo)input); } @@ -89,11 +97,13 @@ public override bool Equals(object input) { /// /// Instance of SourceInfo to be compared /// Boolean - public bool Equals(SourceInfo input) { - if (input == null) { + public bool Equals(SourceInfo input) + { + if (input == null) + { return false; } - return + return ( this.File == input.File || (this.File != null && @@ -106,14 +116,17 @@ public bool Equals(SourceInfo input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.File != null) { + if (this.File != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.File.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -125,10 +138,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/Status.cs b/src/OpenFga.Sdk/Model/Status.cs index ac4230d0..8939193c 100644 --- a/src/OpenFga.Sdk/Model/Status.cs +++ b/src/OpenFga.Sdk/Model/Status.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// Status /// [DataContract(Name = "Status")] - public partial class Status : IEquatable, IValidatableObject { + public partial class Status : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public Status() { + public Status() + { this.AdditionalProperties = new Dictionary(); } @@ -40,7 +45,8 @@ public Status() { /// code. /// message. /// details. - public Status(int code = default, string message = default, List details = default) { + public Status(int code = default, string message = default, List details = default) + { this.Code = code; this.Message = message; this.Details = details; @@ -82,7 +88,8 @@ public Status(int code = default, string message = default, List details = /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -99,7 +106,8 @@ public static Status FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((Status)input); } @@ -109,20 +117,22 @@ public override bool Equals(object input) { /// /// Instance of Status to be compared /// Boolean - public bool Equals(Status input) { - if (input == null) { + public bool Equals(Status input) + { + if (input == null) + { return false; } - return + return ( this.Code == input.Code || this.Code.Equals(input.Code) - ) && + ) && ( this.Message == input.Message || (this.Message != null && this.Message.Equals(input.Message)) - ) && + ) && ( this.Details == input.Details || this.Details != null && @@ -136,18 +146,22 @@ public bool Equals(Status input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Code.GetHashCode(); - if (this.Message != null) { + if (this.Message != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Message.GetHashCode(); } - if (this.Details != null) { + if (this.Details != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Details.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -159,10 +173,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/Store.cs b/src/OpenFga.Sdk/Model/Store.cs index 6c39279b..3e81ea70 100644 --- a/src/OpenFga.Sdk/Model/Store.cs +++ b/src/OpenFga.Sdk/Model/Store.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// Store /// [DataContract(Name = "Store")] - public partial class Store : IEquatable, IValidatableObject { + public partial class Store : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public Store() { + public Store() + { this.AdditionalProperties = new Dictionary(); } @@ -42,14 +47,17 @@ public Store() { /// createdAt (required). /// updatedAt (required). /// deletedAt. - public Store(string id = default, string name = default, DateTime createdAt = default, DateTime updatedAt = default, DateTime deletedAt = default) { + public Store(string id = default, string name = default, DateTime createdAt = default, DateTime updatedAt = default, DateTime deletedAt = default) + { // to ensure "id" is required (not null) - if (id == null) { + if (id == null) + { throw new ArgumentNullException("id is a required property for Store and cannot be null"); } this.Id = id; // to ensure "name" is required (not null) - if (name == null) { + if (name == null) + { throw new ArgumentNullException("name is a required property for Store and cannot be null"); } this.Name = name; @@ -110,7 +118,8 @@ public Store(string id = default, string name = default, DateTime createdAt = de /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -127,7 +136,8 @@ public static Store FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((Store)input); } @@ -137,31 +147,33 @@ public override bool Equals(object input) { /// /// Instance of Store to be compared /// Boolean - public bool Equals(Store input) { - if (input == null) { + public bool Equals(Store input) + { + if (input == null) + { return false; } - return + return ( this.Id == input.Id || (this.Id != null && this.Id.Equals(input.Id)) - ) && + ) && ( this.Name == input.Name || (this.Name != null && this.Name.Equals(input.Name)) - ) && + ) && ( this.CreatedAt == input.CreatedAt || (this.CreatedAt != null && this.CreatedAt.Equals(input.CreatedAt)) - ) && + ) && ( this.UpdatedAt == input.UpdatedAt || (this.UpdatedAt != null && this.UpdatedAt.Equals(input.UpdatedAt)) - ) && + ) && ( this.DeletedAt == input.DeletedAt || (this.DeletedAt != null && @@ -174,26 +186,33 @@ public bool Equals(Store input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Id != null) { + if (this.Id != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Id.GetHashCode(); } - if (this.Name != null) { + if (this.Name != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Name.GetHashCode(); } - if (this.CreatedAt != null) { + if (this.CreatedAt != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.CreatedAt.GetHashCode(); } - if (this.UpdatedAt != null) { + if (this.UpdatedAt != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.UpdatedAt.GetHashCode(); } - if (this.DeletedAt != null) { + if (this.DeletedAt != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.DeletedAt.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -205,10 +224,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/StreamResultOfStreamedListObjectsResponse.cs b/src/OpenFga.Sdk/Model/StreamResultOfStreamedListObjectsResponse.cs index 0b8fbef7..255f055d 100644 --- a/src/OpenFga.Sdk/Model/StreamResultOfStreamedListObjectsResponse.cs +++ b/src/OpenFga.Sdk/Model/StreamResultOfStreamedListObjectsResponse.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// StreamResultOfStreamedListObjectsResponse /// [DataContract(Name = "Stream_result_of_StreamedListObjectsResponse")] - public partial class StreamResultOfStreamedListObjectsResponse : IEquatable, IValidatableObject { + public partial class StreamResultOfStreamedListObjectsResponse : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public StreamResultOfStreamedListObjectsResponse() { + public StreamResultOfStreamedListObjectsResponse() + { this.AdditionalProperties = new Dictionary(); } @@ -39,7 +44,8 @@ public StreamResultOfStreamedListObjectsResponse() { /// /// result. /// error. - public StreamResultOfStreamedListObjectsResponse(StreamedListObjectsResponse result = default, Status error = default) { + public StreamResultOfStreamedListObjectsResponse(StreamedListObjectsResponse result = default, Status error = default) + { this.Result = result; this.Error = error; this.AdditionalProperties = new Dictionary(); @@ -72,7 +78,8 @@ public StreamResultOfStreamedListObjectsResponse(StreamedListObjectsResponse res /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -89,7 +96,8 @@ public static StreamResultOfStreamedListObjectsResponse FromJson(string jsonStri /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((StreamResultOfStreamedListObjectsResponse)input); } @@ -99,16 +107,18 @@ public override bool Equals(object input) { /// /// Instance of StreamResultOfStreamedListObjectsResponse to be compared /// Boolean - public bool Equals(StreamResultOfStreamedListObjectsResponse input) { - if (input == null) { + public bool Equals(StreamResultOfStreamedListObjectsResponse input) + { + if (input == null) + { return false; } - return + return ( this.Result == input.Result || (this.Result != null && this.Result.Equals(input.Result)) - ) && + ) && ( this.Error == input.Error || (this.Error != null && @@ -121,17 +131,21 @@ public bool Equals(StreamResultOfStreamedListObjectsResponse input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Result != null) { + if (this.Result != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Result.GetHashCode(); } - if (this.Error != null) { + if (this.Error != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Error.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -143,10 +157,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/StreamedListObjectsResponse.cs b/src/OpenFga.Sdk/Model/StreamedListObjectsResponse.cs index 8681f9db..80a00e8d 100644 --- a/src/OpenFga.Sdk/Model/StreamedListObjectsResponse.cs +++ b/src/OpenFga.Sdk/Model/StreamedListObjectsResponse.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// The response for a StreamedListObjects RPC. /// [DataContract(Name = "StreamedListObjectsResponse")] - public partial class StreamedListObjectsResponse : IEquatable, IValidatableObject { + public partial class StreamedListObjectsResponse : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public StreamedListObjectsResponse() { + public StreamedListObjectsResponse() + { this.AdditionalProperties = new Dictionary(); } @@ -38,9 +43,11 @@ public StreamedListObjectsResponse() { /// Initializes a new instance of the class. /// /// varObject (required). - public StreamedListObjectsResponse(string varObject = default) { + public StreamedListObjectsResponse(string varObject = default) + { // to ensure "varObject" is required (not null) - if (varObject == null) { + if (varObject == null) + { throw new ArgumentNullException("varObject is a required property for StreamedListObjectsResponse and cannot be null"); } this.Object = varObject; @@ -66,7 +73,8 @@ public StreamedListObjectsResponse(string varObject = default) { /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -83,7 +91,8 @@ public static StreamedListObjectsResponse FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((StreamedListObjectsResponse)input); } @@ -93,11 +102,13 @@ public override bool Equals(object input) { /// /// Instance of StreamedListObjectsResponse to be compared /// Boolean - public bool Equals(StreamedListObjectsResponse input) { - if (input == null) { + public bool Equals(StreamedListObjectsResponse input) + { + if (input == null) + { return false; } - return + return ( this.Object == input.Object || (this.Object != null && @@ -110,14 +121,17 @@ public bool Equals(StreamedListObjectsResponse input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Object != null) { + if (this.Object != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Object.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -129,10 +143,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/Tuple.cs b/src/OpenFga.Sdk/Model/Tuple.cs index dbe7190e..155e1ab8 100644 --- a/src/OpenFga.Sdk/Model/Tuple.cs +++ b/src/OpenFga.Sdk/Model/Tuple.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// Tuple /// [DataContract(Name = "Tuple")] - public partial class Tuple : IEquatable, IValidatableObject { + public partial class Tuple : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public Tuple() { + public Tuple() + { this.AdditionalProperties = new Dictionary(); } @@ -39,9 +44,11 @@ public Tuple() { /// /// key (required). /// timestamp (required). - public Tuple(TupleKey key = default, DateTime timestamp = default) { + public Tuple(TupleKey key = default, DateTime timestamp = default) + { // to ensure "key" is required (not null) - if (key == null) { + if (key == null) + { throw new ArgumentNullException("key is a required property for Tuple and cannot be null"); } this.Key = key; @@ -76,7 +83,8 @@ public Tuple(TupleKey key = default, DateTime timestamp = default) { /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -93,7 +101,8 @@ public static Tuple FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((Tuple)input); } @@ -103,16 +112,18 @@ public override bool Equals(object input) { /// /// Instance of Tuple to be compared /// Boolean - public bool Equals(Tuple input) { - if (input == null) { + public bool Equals(Tuple input) + { + if (input == null) + { return false; } - return + return ( this.Key == input.Key || (this.Key != null && this.Key.Equals(input.Key)) - ) && + ) && ( this.Timestamp == input.Timestamp || (this.Timestamp != null && @@ -125,17 +136,21 @@ public bool Equals(Tuple input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Key != null) { + if (this.Key != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Key.GetHashCode(); } - if (this.Timestamp != null) { + if (this.Timestamp != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Timestamp.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -147,10 +162,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/TupleChange.cs b/src/OpenFga.Sdk/Model/TupleChange.cs index 8a96ef4c..bcbf0efd 100644 --- a/src/OpenFga.Sdk/Model/TupleChange.cs +++ b/src/OpenFga.Sdk/Model/TupleChange.cs @@ -11,21 +11,25 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// TupleChange /// [DataContract(Name = "TupleChange")] - public partial class TupleChange : IEquatable, IValidatableObject { + public partial class TupleChange : IEquatable, IValidatableObject + { /// /// Gets or Sets Operation @@ -37,7 +41,8 @@ public partial class TupleChange : IEquatable, IValidatableObject { /// Initializes a new instance of the class. /// [JsonConstructor] - public TupleChange() { + public TupleChange() + { this.AdditionalProperties = new Dictionary(); } @@ -47,9 +52,11 @@ public TupleChange() { /// tupleKey (required). /// operation (required). /// timestamp (required). - public TupleChange(TupleKey tupleKey = default, TupleOperation operation = default, DateTime timestamp = default) { + public TupleChange(TupleKey tupleKey = default, TupleOperation operation = default, DateTime timestamp = default) + { // to ensure "tupleKey" is required (not null) - if (tupleKey == null) { + if (tupleKey == null) + { throw new ArgumentNullException("tupleKey is a required property for TupleChange and cannot be null"); } this.TupleKey = tupleKey; @@ -85,7 +92,8 @@ public TupleChange(TupleKey tupleKey = default, TupleOperation operation = defau /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -102,7 +110,8 @@ public static TupleChange FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((TupleChange)input); } @@ -112,8 +121,10 @@ public override bool Equals(object input) { /// /// Instance of TupleChange to be compared /// Boolean - public bool Equals(TupleChange input) { - if (input == null) { + public bool Equals(TupleChange input) + { + if (input == null) + { return false; } return @@ -127,9 +138,7 @@ public bool Equals(TupleChange input) { this.Operation.Equals(input.Operation) ) && ( - this.Timestamp == input.Timestamp || - (this.Timestamp != null && - this.Timestamp.Equals(input.Timestamp)) + this.Timestamp.Equals(input.Timestamp) ) && (this.AdditionalProperties.Count == input.AdditionalProperties.Count && this.AdditionalProperties.All(kv => input.AdditionalProperties.TryGetValue(kv.Key, out var inputValue) && Equals(kv.Value, inputValue))); } @@ -138,18 +147,19 @@ public bool Equals(TupleChange input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.TupleKey != null) { + if (this.TupleKey != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.TupleKey.GetHashCode(); } hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Operation.GetHashCode(); - if (this.Timestamp != null) { - hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Timestamp.GetHashCode(); - } - if (this.AdditionalProperties != null) { + hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Timestamp.GetHashCode(); + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -161,10 +171,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/TupleKey.cs b/src/OpenFga.Sdk/Model/TupleKey.cs index b429ad2d..9ac525ad 100644 --- a/src/OpenFga.Sdk/Model/TupleKey.cs +++ b/src/OpenFga.Sdk/Model/TupleKey.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// TupleKey /// [DataContract(Name = "TupleKey")] - public partial class TupleKey : IEquatable, IValidatableObject { + public partial class TupleKey : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public TupleKey() { + public TupleKey() + { this.AdditionalProperties = new Dictionary(); } @@ -41,19 +46,23 @@ public TupleKey() { /// relation (required). /// varObject (required). /// condition. - public TupleKey(string user = default, string relation = default, string varObject = default, RelationshipCondition condition = default) { + public TupleKey(string user = default, string relation = default, string varObject = default, RelationshipCondition condition = default) + { // to ensure "user" is required (not null) - if (user == null) { + if (user == null) + { throw new ArgumentNullException("user is a required property for TupleKey and cannot be null"); } this.User = user; // to ensure "relation" is required (not null) - if (relation == null) { + if (relation == null) + { throw new ArgumentNullException("relation is a required property for TupleKey and cannot be null"); } this.Relation = relation; // to ensure "varObject" is required (not null) - if (varObject == null) { + if (varObject == null) + { throw new ArgumentNullException("varObject is a required property for TupleKey and cannot be null"); } this.Object = varObject; @@ -104,7 +113,8 @@ public TupleKey(string user = default, string relation = default, string varObje /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -121,7 +131,8 @@ public static TupleKey FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((TupleKey)input); } @@ -131,26 +142,28 @@ public override bool Equals(object input) { /// /// Instance of TupleKey to be compared /// Boolean - public bool Equals(TupleKey input) { - if (input == null) { + public bool Equals(TupleKey input) + { + if (input == null) + { return false; } - return + return ( this.User == input.User || (this.User != null && this.User.Equals(input.User)) - ) && + ) && ( this.Relation == input.Relation || (this.Relation != null && this.Relation.Equals(input.Relation)) - ) && + ) && ( this.Object == input.Object || (this.Object != null && this.Object.Equals(input.Object)) - ) && + ) && ( this.Condition == input.Condition || (this.Condition != null && @@ -163,23 +176,29 @@ public bool Equals(TupleKey input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.User != null) { + if (this.User != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.User.GetHashCode(); } - if (this.Relation != null) { + if (this.Relation != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Relation.GetHashCode(); } - if (this.Object != null) { + if (this.Object != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Object.GetHashCode(); } - if (this.Condition != null) { + if (this.Condition != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Condition.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -191,20 +210,24 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { // User (string) maxLength - if (this.User != null && this.User.Length > 512) { - yield return new ValidationResult("Invalid value for User, length must be less than 512.", new[] { "User" }); + if (this.User != null && this.User.Length > 512) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for User, length must be less than 512.", new [] { "User" }); } // Relation (string) maxLength - if (this.Relation != null && this.Relation.Length > 50) { - yield return new ValidationResult("Invalid value for Relation, length must be less than 50.", new[] { "Relation" }); + if (this.Relation != null && this.Relation.Length > 50) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Relation, length must be less than 50.", new [] { "Relation" }); } // Object (string) maxLength - if (this.Object != null && this.Object.Length > 256) { - yield return new ValidationResult("Invalid value for Object, length must be less than 256.", new[] { "Object" }); + if (this.Object != null && this.Object.Length > 256) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Object, length must be less than 256.", new [] { "Object" }); } yield break; @@ -212,4 +235,4 @@ public IEnumerable Validate(ValidationContext validationContex } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/TupleKeyWithoutCondition.cs b/src/OpenFga.Sdk/Model/TupleKeyWithoutCondition.cs index 6555b75c..a3c948ae 100644 --- a/src/OpenFga.Sdk/Model/TupleKeyWithoutCondition.cs +++ b/src/OpenFga.Sdk/Model/TupleKeyWithoutCondition.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// TupleKeyWithoutCondition /// [DataContract(Name = "TupleKeyWithoutCondition")] - public partial class TupleKeyWithoutCondition : IEquatable, IValidatableObject { + public partial class TupleKeyWithoutCondition : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public TupleKeyWithoutCondition() { + public TupleKeyWithoutCondition() + { this.AdditionalProperties = new Dictionary(); } @@ -40,19 +45,23 @@ public TupleKeyWithoutCondition() { /// user (required). /// relation (required). /// varObject (required). - public TupleKeyWithoutCondition(string user = default, string relation = default, string varObject = default) { + public TupleKeyWithoutCondition(string user = default, string relation = default, string varObject = default) + { // to ensure "user" is required (not null) - if (user == null) { + if (user == null) + { throw new ArgumentNullException("user is a required property for TupleKeyWithoutCondition and cannot be null"); } this.User = user; // to ensure "relation" is required (not null) - if (relation == null) { + if (relation == null) + { throw new ArgumentNullException("relation is a required property for TupleKeyWithoutCondition and cannot be null"); } this.Relation = relation; // to ensure "varObject" is required (not null) - if (varObject == null) { + if (varObject == null) + { throw new ArgumentNullException("varObject is a required property for TupleKeyWithoutCondition and cannot be null"); } this.Object = varObject; @@ -94,7 +103,8 @@ public TupleKeyWithoutCondition(string user = default, string relation = default /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -111,7 +121,8 @@ public static TupleKeyWithoutCondition FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((TupleKeyWithoutCondition)input); } @@ -121,21 +132,23 @@ public override bool Equals(object input) { /// /// Instance of TupleKeyWithoutCondition to be compared /// Boolean - public bool Equals(TupleKeyWithoutCondition input) { - if (input == null) { + public bool Equals(TupleKeyWithoutCondition input) + { + if (input == null) + { return false; } - return + return ( this.User == input.User || (this.User != null && this.User.Equals(input.User)) - ) && + ) && ( this.Relation == input.Relation || (this.Relation != null && this.Relation.Equals(input.Relation)) - ) && + ) && ( this.Object == input.Object || (this.Object != null && @@ -148,20 +161,25 @@ public bool Equals(TupleKeyWithoutCondition input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.User != null) { + if (this.User != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.User.GetHashCode(); } - if (this.Relation != null) { + if (this.Relation != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Relation.GetHashCode(); } - if (this.Object != null) { + if (this.Object != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Object.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -173,20 +191,24 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { // User (string) maxLength - if (this.User != null && this.User.Length > 512) { - yield return new ValidationResult("Invalid value for User, length must be less than 512.", new[] { "User" }); + if (this.User != null && this.User.Length > 512) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for User, length must be less than 512.", new [] { "User" }); } // Relation (string) maxLength - if (this.Relation != null && this.Relation.Length > 50) { - yield return new ValidationResult("Invalid value for Relation, length must be less than 50.", new[] { "Relation" }); + if (this.Relation != null && this.Relation.Length > 50) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Relation, length must be less than 50.", new [] { "Relation" }); } // Object (string) maxLength - if (this.Object != null && this.Object.Length > 256) { - yield return new ValidationResult("Invalid value for Object, length must be less than 256.", new[] { "Object" }); + if (this.Object != null && this.Object.Length > 256) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Object, length must be less than 256.", new [] { "Object" }); } yield break; @@ -194,4 +216,4 @@ public IEnumerable Validate(ValidationContext validationContex } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/TupleOperation.cs b/src/OpenFga.Sdk/Model/TupleOperation.cs index 66b2794f..49cedad2 100644 --- a/src/OpenFga.Sdk/Model/TupleOperation.cs +++ b/src/OpenFga.Sdk/Model/TupleOperation.cs @@ -11,21 +11,25 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// Defines TupleOperation /// [JsonConverter(typeof(JsonStringEnumMemberConverter))] - public enum TupleOperation { + public enum TupleOperation + { /// /// Enum TUPLEOPERATIONWRITE for value: TUPLE_OPERATION_WRITE /// @@ -40,4 +44,4 @@ public enum TupleOperation { } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/TupleToUserset.cs b/src/OpenFga.Sdk/Model/TupleToUserset.cs index 51b38fbf..f9881e41 100644 --- a/src/OpenFga.Sdk/Model/TupleToUserset.cs +++ b/src/OpenFga.Sdk/Model/TupleToUserset.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// TupleToUserset /// [DataContract(Name = "TupleToUserset")] - public partial class TupleToUserset : IEquatable, IValidatableObject { + public partial class TupleToUserset : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public TupleToUserset() { + public TupleToUserset() + { this.AdditionalProperties = new Dictionary(); } @@ -39,14 +44,17 @@ public TupleToUserset() { /// /// tupleset (required). /// computedUserset (required). - public TupleToUserset(ObjectRelation tupleset = default, ObjectRelation computedUserset = default) { + public TupleToUserset(ObjectRelation tupleset = default, ObjectRelation computedUserset = default) + { // to ensure "tupleset" is required (not null) - if (tupleset == null) { + if (tupleset == null) + { throw new ArgumentNullException("tupleset is a required property for TupleToUserset and cannot be null"); } this.Tupleset = tupleset; // to ensure "computedUserset" is required (not null) - if (computedUserset == null) { + if (computedUserset == null) + { throw new ArgumentNullException("computedUserset is a required property for TupleToUserset and cannot be null"); } this.ComputedUserset = computedUserset; @@ -80,7 +88,8 @@ public TupleToUserset(ObjectRelation tupleset = default, ObjectRelation computed /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -97,7 +106,8 @@ public static TupleToUserset FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((TupleToUserset)input); } @@ -107,16 +117,18 @@ public override bool Equals(object input) { /// /// Instance of TupleToUserset to be compared /// Boolean - public bool Equals(TupleToUserset input) { - if (input == null) { + public bool Equals(TupleToUserset input) + { + if (input == null) + { return false; } - return + return ( this.Tupleset == input.Tupleset || (this.Tupleset != null && this.Tupleset.Equals(input.Tupleset)) - ) && + ) && ( this.ComputedUserset == input.ComputedUserset || (this.ComputedUserset != null && @@ -129,17 +141,21 @@ public bool Equals(TupleToUserset input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Tupleset != null) { + if (this.Tupleset != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Tupleset.GetHashCode(); } - if (this.ComputedUserset != null) { + if (this.ComputedUserset != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.ComputedUserset.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -151,10 +167,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/TypeDefinition.cs b/src/OpenFga.Sdk/Model/TypeDefinition.cs index bcbc9c71..f3573538 100644 --- a/src/OpenFga.Sdk/Model/TypeDefinition.cs +++ b/src/OpenFga.Sdk/Model/TypeDefinition.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// TypeDefinition /// [DataContract(Name = "TypeDefinition")] - public partial class TypeDefinition : IEquatable, IValidatableObject { + public partial class TypeDefinition : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public TypeDefinition() { + public TypeDefinition() + { this.AdditionalProperties = new Dictionary(); } @@ -40,9 +45,11 @@ public TypeDefinition() { /// type (required). /// relations. /// metadata. - public TypeDefinition(string type = default, Dictionary relations = default, Metadata metadata = default) { + public TypeDefinition(string type = default, Dictionary relations = default, Metadata metadata = default) + { // to ensure "type" is required (not null) - if (type == null) { + if (type == null) + { throw new ArgumentNullException("type is a required property for TypeDefinition and cannot be null"); } this.Type = type; @@ -86,7 +93,8 @@ public TypeDefinition(string type = default, Dictionary relatio /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -103,7 +111,8 @@ public static TypeDefinition FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((TypeDefinition)input); } @@ -113,22 +122,24 @@ public override bool Equals(object input) { /// /// Instance of TypeDefinition to be compared /// Boolean - public bool Equals(TypeDefinition input) { - if (input == null) { + public bool Equals(TypeDefinition input) + { + if (input == null) + { return false; } - return + return ( this.Type == input.Type || (this.Type != null && this.Type.Equals(input.Type)) - ) && + ) && ( this.Relations == input.Relations || this.Relations != null && input.Relations != null && this.Relations.SequenceEqual(input.Relations) - ) && + ) && ( this.Metadata == input.Metadata || (this.Metadata != null && @@ -141,20 +152,25 @@ public bool Equals(TypeDefinition input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Type != null) { + if (this.Type != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Type.GetHashCode(); } - if (this.Relations != null) { + if (this.Relations != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Relations.GetHashCode(); } - if (this.Metadata != null) { + if (this.Metadata != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Metadata.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -166,10 +182,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/TypeName.cs b/src/OpenFga.Sdk/Model/TypeName.cs index be58945b..3d7b1d4f 100644 --- a/src/OpenFga.Sdk/Model/TypeName.cs +++ b/src/OpenFga.Sdk/Model/TypeName.cs @@ -11,21 +11,25 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// Defines TypeName /// [JsonConverter(typeof(JsonStringEnumMemberConverter))] - public enum TypeName { + public enum TypeName + { /// /// Enum TYPENAMEUNSPECIFIED for value: TYPE_NAME_UNSPECIFIED /// @@ -100,4 +104,4 @@ public enum TypeName { } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/TypedWildcard.cs b/src/OpenFga.Sdk/Model/TypedWildcard.cs index 8acffdb4..188c8aa2 100644 --- a/src/OpenFga.Sdk/Model/TypedWildcard.cs +++ b/src/OpenFga.Sdk/Model/TypedWildcard.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// Type bound public access. Normally represented using the `<type>:*` syntax `employee:*` represents every object of type `employee`, including those not currently present in the system See https://openfga.dev/docs/concepts#what-is-type-bound-public-access /// [DataContract(Name = "TypedWildcard")] - public partial class TypedWildcard : IEquatable, IValidatableObject { + public partial class TypedWildcard : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public TypedWildcard() { + public TypedWildcard() + { this.AdditionalProperties = new Dictionary(); } @@ -38,9 +43,11 @@ public TypedWildcard() { /// Initializes a new instance of the class. /// /// type (required). - public TypedWildcard(string type = default) { + public TypedWildcard(string type = default) + { // to ensure "type" is required (not null) - if (type == null) { + if (type == null) + { throw new ArgumentNullException("type is a required property for TypedWildcard and cannot be null"); } this.Type = type; @@ -66,7 +73,8 @@ public TypedWildcard(string type = default) { /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -83,7 +91,8 @@ public static TypedWildcard FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((TypedWildcard)input); } @@ -93,11 +102,13 @@ public override bool Equals(object input) { /// /// Instance of TypedWildcard to be compared /// Boolean - public bool Equals(TypedWildcard input) { - if (input == null) { + public bool Equals(TypedWildcard input) + { + if (input == null) + { return false; } - return + return ( this.Type == input.Type || (this.Type != null && @@ -110,14 +121,17 @@ public bool Equals(TypedWildcard input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Type != null) { + if (this.Type != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Type.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -129,10 +143,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/UnauthenticatedResponse.cs b/src/OpenFga.Sdk/Model/UnauthenticatedResponse.cs index f5cdf742..1be5689d 100644 --- a/src/OpenFga.Sdk/Model/UnauthenticatedResponse.cs +++ b/src/OpenFga.Sdk/Model/UnauthenticatedResponse.cs @@ -11,21 +11,25 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// UnauthenticatedResponse /// [DataContract(Name = "UnauthenticatedResponse")] - public partial class UnauthenticatedResponse : IEquatable, IValidatableObject { + public partial class UnauthenticatedResponse : IEquatable, IValidatableObject + { /// /// Gets or Sets Code @@ -37,7 +41,8 @@ public partial class UnauthenticatedResponse : IEquatable class. /// [JsonConstructor] - public UnauthenticatedResponse() { + public UnauthenticatedResponse() + { this.AdditionalProperties = new Dictionary(); } @@ -46,7 +51,8 @@ public UnauthenticatedResponse() { /// /// code. /// message. - public UnauthenticatedResponse(ErrorCode? code = default, string message = default) { + public UnauthenticatedResponse(ErrorCode? code = default, string message = default) + { this.Code = code; this.Message = message; this.AdditionalProperties = new Dictionary(); @@ -71,7 +77,8 @@ public UnauthenticatedResponse(ErrorCode? code = default, string message = defau /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -88,7 +95,8 @@ public static UnauthenticatedResponse FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((UnauthenticatedResponse)input); } @@ -98,15 +106,17 @@ public override bool Equals(object input) { /// /// Instance of UnauthenticatedResponse to be compared /// Boolean - public bool Equals(UnauthenticatedResponse input) { - if (input == null) { + public bool Equals(UnauthenticatedResponse input) + { + if (input == null) + { return false; } - return + return ( this.Code == input.Code || this.Code.Equals(input.Code) - ) && + ) && ( this.Message == input.Message || (this.Message != null && @@ -119,15 +129,18 @@ public bool Equals(UnauthenticatedResponse input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Code.GetHashCode(); - if (this.Message != null) { + if (this.Message != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Message.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -139,10 +152,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/UnprocessableContentErrorCode.cs b/src/OpenFga.Sdk/Model/UnprocessableContentErrorCode.cs index 2dc572aa..af05fbf2 100644 --- a/src/OpenFga.Sdk/Model/UnprocessableContentErrorCode.cs +++ b/src/OpenFga.Sdk/Model/UnprocessableContentErrorCode.cs @@ -11,21 +11,25 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// Defines UnprocessableContentErrorCode /// [JsonConverter(typeof(JsonStringEnumMemberConverter))] - public enum UnprocessableContentErrorCode { + public enum UnprocessableContentErrorCode + { /// /// Enum NoThrottledErrorCode for value: no_throttled_error_code /// @@ -40,4 +44,4 @@ public enum UnprocessableContentErrorCode { } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/UnprocessableContentMessageResponse.cs b/src/OpenFga.Sdk/Model/UnprocessableContentMessageResponse.cs index 04995916..5f72af88 100644 --- a/src/OpenFga.Sdk/Model/UnprocessableContentMessageResponse.cs +++ b/src/OpenFga.Sdk/Model/UnprocessableContentMessageResponse.cs @@ -11,21 +11,25 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// UnprocessableContentMessageResponse /// [DataContract(Name = "UnprocessableContentMessageResponse")] - public partial class UnprocessableContentMessageResponse : IEquatable, IValidatableObject { + public partial class UnprocessableContentMessageResponse : IEquatable, IValidatableObject + { /// /// Gets or Sets Code @@ -37,7 +41,8 @@ public partial class UnprocessableContentMessageResponse : IEquatable class. /// [JsonConstructor] - public UnprocessableContentMessageResponse() { + public UnprocessableContentMessageResponse() + { this.AdditionalProperties = new Dictionary(); } @@ -46,7 +51,8 @@ public UnprocessableContentMessageResponse() { /// /// code. /// message. - public UnprocessableContentMessageResponse(UnprocessableContentErrorCode? code = default, string message = default) { + public UnprocessableContentMessageResponse(UnprocessableContentErrorCode? code = default, string message = default) + { this.Code = code; this.Message = message; this.AdditionalProperties = new Dictionary(); @@ -71,7 +77,8 @@ public UnprocessableContentMessageResponse(UnprocessableContentErrorCode? code = /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -88,7 +95,8 @@ public static UnprocessableContentMessageResponse FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((UnprocessableContentMessageResponse)input); } @@ -98,15 +106,17 @@ public override bool Equals(object input) { /// /// Instance of UnprocessableContentMessageResponse to be compared /// Boolean - public bool Equals(UnprocessableContentMessageResponse input) { - if (input == null) { + public bool Equals(UnprocessableContentMessageResponse input) + { + if (input == null) + { return false; } - return + return ( this.Code == input.Code || this.Code.Equals(input.Code) - ) && + ) && ( this.Message == input.Message || (this.Message != null && @@ -119,15 +129,18 @@ public bool Equals(UnprocessableContentMessageResponse input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Code.GetHashCode(); - if (this.Message != null) { + if (this.Message != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Message.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -139,10 +152,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/User.cs b/src/OpenFga.Sdk/Model/User.cs index 2e079111..919224c7 100644 --- a/src/OpenFga.Sdk/Model/User.cs +++ b/src/OpenFga.Sdk/Model/User.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// User. Represents any possible value for a user (subject or principal). Can be a: - Specific user object e.g.: 'user:will', 'folder:marketing', 'org:contoso', ...) - Specific userset (e.g. 'group:engineering#member') - Public-typed wildcard (e.g. 'user:*') See https://openfga.dev/docs/concepts#what-is-a-user /// [DataContract(Name = "User")] - public partial class User : IEquatable, IValidatableObject { + public partial class User : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public User() { + public User() + { this.AdditionalProperties = new Dictionary(); } @@ -40,7 +45,8 @@ public User() { /// varObject. /// userset. /// wildcard. - public User(FgaObject varObject = default, UsersetUser userset = default, TypedWildcard wildcard = default) { + public User(FgaObject varObject = default, UsersetUser userset = default, TypedWildcard wildcard = default) + { this.Object = varObject; this.Userset = userset; this.Wildcard = wildcard; @@ -82,7 +88,8 @@ public User(FgaObject varObject = default, UsersetUser userset = default, TypedW /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -99,7 +106,8 @@ public static User FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((User)input); } @@ -109,21 +117,23 @@ public override bool Equals(object input) { /// /// Instance of User to be compared /// Boolean - public bool Equals(User input) { - if (input == null) { + public bool Equals(User input) + { + if (input == null) + { return false; } - return + return ( this.Object == input.Object || (this.Object != null && this.Object.Equals(input.Object)) - ) && + ) && ( this.Userset == input.Userset || (this.Userset != null && this.Userset.Equals(input.Userset)) - ) && + ) && ( this.Wildcard == input.Wildcard || (this.Wildcard != null && @@ -136,20 +146,25 @@ public bool Equals(User input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Object != null) { + if (this.Object != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Object.GetHashCode(); } - if (this.Userset != null) { + if (this.Userset != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Userset.GetHashCode(); } - if (this.Wildcard != null) { + if (this.Wildcard != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Wildcard.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -161,10 +176,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/UserTypeFilter.cs b/src/OpenFga.Sdk/Model/UserTypeFilter.cs index 4e7981a2..7298f03b 100644 --- a/src/OpenFga.Sdk/Model/UserTypeFilter.cs +++ b/src/OpenFga.Sdk/Model/UserTypeFilter.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// UserTypeFilter /// [DataContract(Name = "UserTypeFilter")] - public partial class UserTypeFilter : IEquatable, IValidatableObject { + public partial class UserTypeFilter : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public UserTypeFilter() { + public UserTypeFilter() + { this.AdditionalProperties = new Dictionary(); } @@ -39,9 +44,11 @@ public UserTypeFilter() { /// /// type (required). /// relation. - public UserTypeFilter(string type = default, string relation = default) { + public UserTypeFilter(string type = default, string relation = default) + { // to ensure "type" is required (not null) - if (type == null) { + if (type == null) + { throw new ArgumentNullException("type is a required property for UserTypeFilter and cannot be null"); } this.Type = type; @@ -76,7 +83,8 @@ public UserTypeFilter(string type = default, string relation = default) { /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -93,7 +101,8 @@ public static UserTypeFilter FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((UserTypeFilter)input); } @@ -103,16 +112,18 @@ public override bool Equals(object input) { /// /// Instance of UserTypeFilter to be compared /// Boolean - public bool Equals(UserTypeFilter input) { - if (input == null) { + public bool Equals(UserTypeFilter input) + { + if (input == null) + { return false; } - return + return ( this.Type == input.Type || (this.Type != null && this.Type.Equals(input.Type)) - ) && + ) && ( this.Relation == input.Relation || (this.Relation != null && @@ -125,17 +136,21 @@ public bool Equals(UserTypeFilter input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Type != null) { + if (this.Type != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Type.GetHashCode(); } - if (this.Relation != null) { + if (this.Relation != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Relation.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -147,10 +162,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/Users.cs b/src/OpenFga.Sdk/Model/Users.cs index 4d67b00b..6fd8b1dd 100644 --- a/src/OpenFga.Sdk/Model/Users.cs +++ b/src/OpenFga.Sdk/Model/Users.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// Users /// [DataContract(Name = "Users")] - public partial class Users : IEquatable, IValidatableObject { + public partial class Users : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public Users() { + public Users() + { this.AdditionalProperties = new Dictionary(); } @@ -38,9 +43,11 @@ public Users() { /// Initializes a new instance of the class. /// /// varUsers (required). - public Users(List varUsers = default) { + public Users(List varUsers = default) + { // to ensure "varUsers" is required (not null) - if (varUsers == null) { + if (varUsers == null) + { throw new ArgumentNullException("varUsers is a required property for Users and cannot be null"); } this.VarUsers = varUsers; @@ -66,7 +73,8 @@ public Users(List varUsers = default) { /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -83,7 +91,8 @@ public static Users FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((Users)input); } @@ -93,11 +102,13 @@ public override bool Equals(object input) { /// /// Instance of Users to be compared /// Boolean - public bool Equals(Users input) { - if (input == null) { + public bool Equals(Users input) + { + if (input == null) + { return false; } - return + return ( this.VarUsers == input.VarUsers || this.VarUsers != null && @@ -111,14 +122,17 @@ public bool Equals(Users input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.VarUsers != null) { + if (this.VarUsers != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.VarUsers.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -130,10 +144,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/Userset.cs b/src/OpenFga.Sdk/Model/Userset.cs index cd7e8098..32bbfb69 100644 --- a/src/OpenFga.Sdk/Model/Userset.cs +++ b/src/OpenFga.Sdk/Model/Userset.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// Userset /// [DataContract(Name = "Userset")] - public partial class Userset : IEquatable, IValidatableObject { + public partial class Userset : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public Userset() { + public Userset() + { this.AdditionalProperties = new Dictionary(); } @@ -43,7 +48,8 @@ public Userset() { /// union. /// intersection. /// difference. - public Userset(Object varThis = default, ObjectRelation computedUserset = default, TupleToUserset tupleToUserset = default, Usersets union = default, Usersets intersection = default, Difference difference = default) { + public Userset(Object varThis = default, ObjectRelation computedUserset = default, TupleToUserset tupleToUserset = default, Usersets union = default, Usersets intersection = default, Difference difference = default) + { this.This = varThis; this.ComputedUserset = computedUserset; this.TupleToUserset = tupleToUserset; @@ -113,7 +119,8 @@ public Userset(Object varThis = default, ObjectRelation computedUserset = defaul /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -130,7 +137,8 @@ public static Userset FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((Userset)input); } @@ -140,36 +148,38 @@ public override bool Equals(object input) { /// /// Instance of Userset to be compared /// Boolean - public bool Equals(Userset input) { - if (input == null) { + public bool Equals(Userset input) + { + if (input == null) + { return false; } - return + return ( this.This == input.This || (this.This != null && this.This.Equals(input.This)) - ) && + ) && ( this.ComputedUserset == input.ComputedUserset || (this.ComputedUserset != null && this.ComputedUserset.Equals(input.ComputedUserset)) - ) && + ) && ( this.TupleToUserset == input.TupleToUserset || (this.TupleToUserset != null && this.TupleToUserset.Equals(input.TupleToUserset)) - ) && + ) && ( this.Union == input.Union || (this.Union != null && this.Union.Equals(input.Union)) - ) && + ) && ( this.Intersection == input.Intersection || (this.Intersection != null && this.Intersection.Equals(input.Intersection)) - ) && + ) && ( this.Difference == input.Difference || (this.Difference != null && @@ -182,29 +192,37 @@ public bool Equals(Userset input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.This != null) { + if (this.This != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.This.GetHashCode(); } - if (this.ComputedUserset != null) { + if (this.ComputedUserset != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.ComputedUserset.GetHashCode(); } - if (this.TupleToUserset != null) { + if (this.TupleToUserset != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.TupleToUserset.GetHashCode(); } - if (this.Union != null) { + if (this.Union != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Union.GetHashCode(); } - if (this.Intersection != null) { + if (this.Intersection != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Intersection.GetHashCode(); } - if (this.Difference != null) { + if (this.Difference != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Difference.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -216,10 +234,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/UsersetTree.cs b/src/OpenFga.Sdk/Model/UsersetTree.cs index 9b0d2680..89ba8116 100644 --- a/src/OpenFga.Sdk/Model/UsersetTree.cs +++ b/src/OpenFga.Sdk/Model/UsersetTree.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// A UsersetTree contains the result of an Expansion. /// [DataContract(Name = "UsersetTree")] - public partial class UsersetTree : IEquatable, IValidatableObject { + public partial class UsersetTree : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public UsersetTree() { + public UsersetTree() + { this.AdditionalProperties = new Dictionary(); } @@ -38,7 +43,8 @@ public UsersetTree() { /// Initializes a new instance of the class. /// /// root. - public UsersetTree(Node root = default) { + public UsersetTree(Node root = default) + { this.Root = root; this.AdditionalProperties = new Dictionary(); } @@ -62,7 +68,8 @@ public UsersetTree(Node root = default) { /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -79,7 +86,8 @@ public static UsersetTree FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((UsersetTree)input); } @@ -89,11 +97,13 @@ public override bool Equals(object input) { /// /// Instance of UsersetTree to be compared /// Boolean - public bool Equals(UsersetTree input) { - if (input == null) { + public bool Equals(UsersetTree input) + { + if (input == null) + { return false; } - return + return ( this.Root == input.Root || (this.Root != null && @@ -106,14 +116,17 @@ public bool Equals(UsersetTree input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Root != null) { + if (this.Root != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Root.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -125,10 +138,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/UsersetTreeDifference.cs b/src/OpenFga.Sdk/Model/UsersetTreeDifference.cs index 7513c29d..3151aeb2 100644 --- a/src/OpenFga.Sdk/Model/UsersetTreeDifference.cs +++ b/src/OpenFga.Sdk/Model/UsersetTreeDifference.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// UsersetTreeDifference /// [DataContract(Name = "UsersetTree.Difference")] - public partial class UsersetTreeDifference : IEquatable, IValidatableObject { + public partial class UsersetTreeDifference : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public UsersetTreeDifference() { + public UsersetTreeDifference() + { this.AdditionalProperties = new Dictionary(); } @@ -39,14 +44,17 @@ public UsersetTreeDifference() { /// /// varBase (required). /// subtract (required). - public UsersetTreeDifference(Node varBase = default, Node subtract = default) { + public UsersetTreeDifference(Node varBase = default, Node subtract = default) + { // to ensure "varBase" is required (not null) - if (varBase == null) { + if (varBase == null) + { throw new ArgumentNullException("varBase is a required property for UsersetTreeDifference and cannot be null"); } this.Base = varBase; // to ensure "subtract" is required (not null) - if (subtract == null) { + if (subtract == null) + { throw new ArgumentNullException("subtract is a required property for UsersetTreeDifference and cannot be null"); } this.Subtract = subtract; @@ -80,7 +88,8 @@ public UsersetTreeDifference(Node varBase = default, Node subtract = default) { /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -97,7 +106,8 @@ public static UsersetTreeDifference FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((UsersetTreeDifference)input); } @@ -107,16 +117,18 @@ public override bool Equals(object input) { /// /// Instance of UsersetTreeDifference to be compared /// Boolean - public bool Equals(UsersetTreeDifference input) { - if (input == null) { + public bool Equals(UsersetTreeDifference input) + { + if (input == null) + { return false; } - return + return ( this.Base == input.Base || (this.Base != null && this.Base.Equals(input.Base)) - ) && + ) && ( this.Subtract == input.Subtract || (this.Subtract != null && @@ -129,17 +141,21 @@ public bool Equals(UsersetTreeDifference input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Base != null) { + if (this.Base != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Base.GetHashCode(); } - if (this.Subtract != null) { + if (this.Subtract != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Subtract.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -151,10 +167,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/UsersetTreeTupleToUserset.cs b/src/OpenFga.Sdk/Model/UsersetTreeTupleToUserset.cs index bbbcef1d..ff0b486c 100644 --- a/src/OpenFga.Sdk/Model/UsersetTreeTupleToUserset.cs +++ b/src/OpenFga.Sdk/Model/UsersetTreeTupleToUserset.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// UsersetTreeTupleToUserset /// [DataContract(Name = "UsersetTree.TupleToUserset")] - public partial class UsersetTreeTupleToUserset : IEquatable, IValidatableObject { + public partial class UsersetTreeTupleToUserset : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public UsersetTreeTupleToUserset() { + public UsersetTreeTupleToUserset() + { this.AdditionalProperties = new Dictionary(); } @@ -39,14 +44,17 @@ public UsersetTreeTupleToUserset() { /// /// tupleset (required). /// computed (required). - public UsersetTreeTupleToUserset(string tupleset = default, List computed = default) { + public UsersetTreeTupleToUserset(string tupleset = default, List computed = default) + { // to ensure "tupleset" is required (not null) - if (tupleset == null) { + if (tupleset == null) + { throw new ArgumentNullException("tupleset is a required property for UsersetTreeTupleToUserset and cannot be null"); } this.Tupleset = tupleset; // to ensure "computed" is required (not null) - if (computed == null) { + if (computed == null) + { throw new ArgumentNullException("computed is a required property for UsersetTreeTupleToUserset and cannot be null"); } this.Computed = computed; @@ -80,7 +88,8 @@ public UsersetTreeTupleToUserset(string tupleset = default, List compu /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -97,7 +106,8 @@ public static UsersetTreeTupleToUserset FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((UsersetTreeTupleToUserset)input); } @@ -107,16 +117,18 @@ public override bool Equals(object input) { /// /// Instance of UsersetTreeTupleToUserset to be compared /// Boolean - public bool Equals(UsersetTreeTupleToUserset input) { - if (input == null) { + public bool Equals(UsersetTreeTupleToUserset input) + { + if (input == null) + { return false; } - return + return ( this.Tupleset == input.Tupleset || (this.Tupleset != null && this.Tupleset.Equals(input.Tupleset)) - ) && + ) && ( this.Computed == input.Computed || this.Computed != null && @@ -130,17 +142,21 @@ public bool Equals(UsersetTreeTupleToUserset input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Tupleset != null) { + if (this.Tupleset != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Tupleset.GetHashCode(); } - if (this.Computed != null) { + if (this.Computed != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Computed.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -152,10 +168,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/UsersetUser.cs b/src/OpenFga.Sdk/Model/UsersetUser.cs index f1c262b6..2d584e98 100644 --- a/src/OpenFga.Sdk/Model/UsersetUser.cs +++ b/src/OpenFga.Sdk/Model/UsersetUser.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// Userset. A set or group of users, represented in the `<type>:<id>#<relation>` format `group:fga#member` represents all members of group FGA, not to be confused by `group:fga` which represents the group itself as a specific object. See: https://openfga.dev/docs/modeling/building-blocks/usersets#what-is-a-userset /// [DataContract(Name = "UsersetUser")] - public partial class UsersetUser : IEquatable, IValidatableObject { + public partial class UsersetUser : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public UsersetUser() { + public UsersetUser() + { this.AdditionalProperties = new Dictionary(); } @@ -40,19 +45,23 @@ public UsersetUser() { /// type (required). /// id (required). /// relation (required). - public UsersetUser(string type = default, string id = default, string relation = default) { + public UsersetUser(string type = default, string id = default, string relation = default) + { // to ensure "type" is required (not null) - if (type == null) { + if (type == null) + { throw new ArgumentNullException("type is a required property for UsersetUser and cannot be null"); } this.Type = type; // to ensure "id" is required (not null) - if (id == null) { + if (id == null) + { throw new ArgumentNullException("id is a required property for UsersetUser and cannot be null"); } this.Id = id; // to ensure "relation" is required (not null) - if (relation == null) { + if (relation == null) + { throw new ArgumentNullException("relation is a required property for UsersetUser and cannot be null"); } this.Relation = relation; @@ -94,7 +103,8 @@ public UsersetUser(string type = default, string id = default, string relation = /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -111,7 +121,8 @@ public static UsersetUser FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((UsersetUser)input); } @@ -121,21 +132,23 @@ public override bool Equals(object input) { /// /// Instance of UsersetUser to be compared /// Boolean - public bool Equals(UsersetUser input) { - if (input == null) { + public bool Equals(UsersetUser input) + { + if (input == null) + { return false; } - return + return ( this.Type == input.Type || (this.Type != null && this.Type.Equals(input.Type)) - ) && + ) && ( this.Id == input.Id || (this.Id != null && this.Id.Equals(input.Id)) - ) && + ) && ( this.Relation == input.Relation || (this.Relation != null && @@ -148,20 +161,25 @@ public bool Equals(UsersetUser input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Type != null) { + if (this.Type != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Type.GetHashCode(); } - if (this.Id != null) { + if (this.Id != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Id.GetHashCode(); } - if (this.Relation != null) { + if (this.Relation != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Relation.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -173,10 +191,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/Usersets.cs b/src/OpenFga.Sdk/Model/Usersets.cs index 0321098f..6d6d02be 100644 --- a/src/OpenFga.Sdk/Model/Usersets.cs +++ b/src/OpenFga.Sdk/Model/Usersets.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// Usersets /// [DataContract(Name = "Usersets")] - public partial class Usersets : IEquatable, IValidatableObject { + public partial class Usersets : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public Usersets() { + public Usersets() + { this.AdditionalProperties = new Dictionary(); } @@ -38,9 +43,11 @@ public Usersets() { /// Initializes a new instance of the class. /// /// child (required). - public Usersets(List child = default) { + public Usersets(List child = default) + { // to ensure "child" is required (not null) - if (child == null) { + if (child == null) + { throw new ArgumentNullException("child is a required property for Usersets and cannot be null"); } this.Child = child; @@ -66,7 +73,8 @@ public Usersets(List child = default) { /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -83,7 +91,8 @@ public static Usersets FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((Usersets)input); } @@ -93,11 +102,13 @@ public override bool Equals(object input) { /// /// Instance of Usersets to be compared /// Boolean - public bool Equals(Usersets input) { - if (input == null) { + public bool Equals(Usersets input) + { + if (input == null) + { return false; } - return + return ( this.Child == input.Child || this.Child != null && @@ -111,14 +122,17 @@ public bool Equals(Usersets input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Child != null) { + if (this.Child != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Child.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -130,10 +144,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/ValidationErrorMessageResponse.cs b/src/OpenFga.Sdk/Model/ValidationErrorMessageResponse.cs index 4f6e0add..a59e2d94 100644 --- a/src/OpenFga.Sdk/Model/ValidationErrorMessageResponse.cs +++ b/src/OpenFga.Sdk/Model/ValidationErrorMessageResponse.cs @@ -11,21 +11,25 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// ValidationErrorMessageResponse /// [DataContract(Name = "ValidationErrorMessageResponse")] - public partial class ValidationErrorMessageResponse : IEquatable, IValidatableObject { + public partial class ValidationErrorMessageResponse : IEquatable, IValidatableObject + { /// /// Gets or Sets Code @@ -37,7 +41,8 @@ public partial class ValidationErrorMessageResponse : IEquatable class. /// [JsonConstructor] - public ValidationErrorMessageResponse() { + public ValidationErrorMessageResponse() + { this.AdditionalProperties = new Dictionary(); } @@ -46,7 +51,8 @@ public ValidationErrorMessageResponse() { /// /// code. /// message. - public ValidationErrorMessageResponse(ErrorCode? code = default, string message = default) { + public ValidationErrorMessageResponse(ErrorCode? code = default, string message = default) + { this.Code = code; this.Message = message; this.AdditionalProperties = new Dictionary(); @@ -71,7 +77,8 @@ public ValidationErrorMessageResponse(ErrorCode? code = default, string message /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -88,7 +95,8 @@ public static ValidationErrorMessageResponse FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((ValidationErrorMessageResponse)input); } @@ -98,15 +106,17 @@ public override bool Equals(object input) { /// /// Instance of ValidationErrorMessageResponse to be compared /// Boolean - public bool Equals(ValidationErrorMessageResponse input) { - if (input == null) { + public bool Equals(ValidationErrorMessageResponse input) + { + if (input == null) + { return false; } - return + return ( this.Code == input.Code || this.Code.Equals(input.Code) - ) && + ) && ( this.Message == input.Message || (this.Message != null && @@ -119,15 +129,18 @@ public bool Equals(ValidationErrorMessageResponse input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Code.GetHashCode(); - if (this.Message != null) { + if (this.Message != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Message.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -139,10 +152,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/WriteAssertionsRequest.cs b/src/OpenFga.Sdk/Model/WriteAssertionsRequest.cs index 07aac532..96d1f7fc 100644 --- a/src/OpenFga.Sdk/Model/WriteAssertionsRequest.cs +++ b/src/OpenFga.Sdk/Model/WriteAssertionsRequest.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// WriteAssertionsRequest /// [DataContract(Name = "WriteAssertions_request")] - public partial class WriteAssertionsRequest : IEquatable, IValidatableObject { + public partial class WriteAssertionsRequest : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public WriteAssertionsRequest() { + public WriteAssertionsRequest() + { this.AdditionalProperties = new Dictionary(); } @@ -38,9 +43,11 @@ public WriteAssertionsRequest() { /// Initializes a new instance of the class. /// /// assertions (required). - public WriteAssertionsRequest(List assertions = default) { + public WriteAssertionsRequest(List assertions = default) + { // to ensure "assertions" is required (not null) - if (assertions == null) { + if (assertions == null) + { throw new ArgumentNullException("assertions is a required property for WriteAssertionsRequest and cannot be null"); } this.Assertions = assertions; @@ -66,7 +73,8 @@ public WriteAssertionsRequest(List assertions = default) { /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -83,7 +91,8 @@ public static WriteAssertionsRequest FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((WriteAssertionsRequest)input); } @@ -93,11 +102,13 @@ public override bool Equals(object input) { /// /// Instance of WriteAssertionsRequest to be compared /// Boolean - public bool Equals(WriteAssertionsRequest input) { - if (input == null) { + public bool Equals(WriteAssertionsRequest input) + { + if (input == null) + { return false; } - return + return ( this.Assertions == input.Assertions || this.Assertions != null && @@ -111,14 +122,17 @@ public bool Equals(WriteAssertionsRequest input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Assertions != null) { + if (this.Assertions != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Assertions.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -130,10 +144,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/WriteAuthorizationModelRequest.cs b/src/OpenFga.Sdk/Model/WriteAuthorizationModelRequest.cs index 242ecd4a..5f31d60e 100644 --- a/src/OpenFga.Sdk/Model/WriteAuthorizationModelRequest.cs +++ b/src/OpenFga.Sdk/Model/WriteAuthorizationModelRequest.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// WriteAuthorizationModelRequest /// [DataContract(Name = "WriteAuthorizationModel_request")] - public partial class WriteAuthorizationModelRequest : IEquatable, IValidatableObject { + public partial class WriteAuthorizationModelRequest : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public WriteAuthorizationModelRequest() { + public WriteAuthorizationModelRequest() + { this.AdditionalProperties = new Dictionary(); } @@ -40,14 +45,17 @@ public WriteAuthorizationModelRequest() { /// typeDefinitions (required). /// schemaVersion (required). /// conditions. - public WriteAuthorizationModelRequest(List typeDefinitions = default, string schemaVersion = default, Dictionary conditions = default) { + public WriteAuthorizationModelRequest(List typeDefinitions = default, string schemaVersion = default, Dictionary conditions = default) + { // to ensure "typeDefinitions" is required (not null) - if (typeDefinitions == null) { + if (typeDefinitions == null) + { throw new ArgumentNullException("typeDefinitions is a required property for WriteAuthorizationModelRequest and cannot be null"); } this.TypeDefinitions = typeDefinitions; // to ensure "schemaVersion" is required (not null) - if (schemaVersion == null) { + if (schemaVersion == null) + { throw new ArgumentNullException("schemaVersion is a required property for WriteAuthorizationModelRequest and cannot be null"); } this.SchemaVersion = schemaVersion; @@ -90,7 +98,8 @@ public WriteAuthorizationModelRequest(List typeDefinitions = def /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -107,7 +116,8 @@ public static WriteAuthorizationModelRequest FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((WriteAuthorizationModelRequest)input); } @@ -117,22 +127,24 @@ public override bool Equals(object input) { /// /// Instance of WriteAuthorizationModelRequest to be compared /// Boolean - public bool Equals(WriteAuthorizationModelRequest input) { - if (input == null) { + public bool Equals(WriteAuthorizationModelRequest input) + { + if (input == null) + { return false; } - return + return ( this.TypeDefinitions == input.TypeDefinitions || this.TypeDefinitions != null && input.TypeDefinitions != null && this.TypeDefinitions.SequenceEqual(input.TypeDefinitions) - ) && + ) && ( this.SchemaVersion == input.SchemaVersion || (this.SchemaVersion != null && this.SchemaVersion.Equals(input.SchemaVersion)) - ) && + ) && ( this.Conditions == input.Conditions || this.Conditions != null && @@ -146,20 +158,25 @@ public bool Equals(WriteAuthorizationModelRequest input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.TypeDefinitions != null) { + if (this.TypeDefinitions != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.TypeDefinitions.GetHashCode(); } - if (this.SchemaVersion != null) { + if (this.SchemaVersion != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.SchemaVersion.GetHashCode(); } - if (this.Conditions != null) { + if (this.Conditions != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Conditions.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -171,10 +188,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/WriteAuthorizationModelResponse.cs b/src/OpenFga.Sdk/Model/WriteAuthorizationModelResponse.cs index fee43cda..cfb595e8 100644 --- a/src/OpenFga.Sdk/Model/WriteAuthorizationModelResponse.cs +++ b/src/OpenFga.Sdk/Model/WriteAuthorizationModelResponse.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// WriteAuthorizationModelResponse /// [DataContract(Name = "WriteAuthorizationModelResponse")] - public partial class WriteAuthorizationModelResponse : IEquatable, IValidatableObject { + public partial class WriteAuthorizationModelResponse : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public WriteAuthorizationModelResponse() { + public WriteAuthorizationModelResponse() + { this.AdditionalProperties = new Dictionary(); } @@ -38,9 +43,11 @@ public WriteAuthorizationModelResponse() { /// Initializes a new instance of the class. /// /// authorizationModelId (required). - public WriteAuthorizationModelResponse(string authorizationModelId = default) { + public WriteAuthorizationModelResponse(string authorizationModelId = default) + { // to ensure "authorizationModelId" is required (not null) - if (authorizationModelId == null) { + if (authorizationModelId == null) + { throw new ArgumentNullException("authorizationModelId is a required property for WriteAuthorizationModelResponse and cannot be null"); } this.AuthorizationModelId = authorizationModelId; @@ -66,7 +73,8 @@ public WriteAuthorizationModelResponse(string authorizationModelId = default) { /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -83,7 +91,8 @@ public static WriteAuthorizationModelResponse FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((WriteAuthorizationModelResponse)input); } @@ -93,11 +102,13 @@ public override bool Equals(object input) { /// /// Instance of WriteAuthorizationModelResponse to be compared /// Boolean - public bool Equals(WriteAuthorizationModelResponse input) { - if (input == null) { + public bool Equals(WriteAuthorizationModelResponse input) + { + if (input == null) + { return false; } - return + return ( this.AuthorizationModelId == input.AuthorizationModelId || (this.AuthorizationModelId != null && @@ -110,14 +121,17 @@ public bool Equals(WriteAuthorizationModelResponse input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.AuthorizationModelId != null) { + if (this.AuthorizationModelId != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AuthorizationModelId.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -129,10 +143,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/WriteRequest.cs b/src/OpenFga.Sdk/Model/WriteRequest.cs index 20ed9c70..5d3d7563 100644 --- a/src/OpenFga.Sdk/Model/WriteRequest.cs +++ b/src/OpenFga.Sdk/Model/WriteRequest.cs @@ -11,26 +11,31 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// WriteRequest /// [DataContract(Name = "Write_request")] - public partial class WriteRequest : IEquatable, IValidatableObject { + public partial class WriteRequest : IEquatable, IValidatableObject + { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public WriteRequest() { + public WriteRequest() + { this.AdditionalProperties = new Dictionary(); } @@ -40,7 +45,8 @@ public WriteRequest() { /// writes. /// deletes. /// authorizationModelId. - public WriteRequest(WriteRequestWrites writes = default, WriteRequestDeletes deletes = default, string authorizationModelId = default) { + public WriteRequest(WriteRequestWrites writes = default, WriteRequestDeletes deletes = default, string authorizationModelId = default) + { this.Writes = writes; this.Deletes = deletes; this.AuthorizationModelId = authorizationModelId; @@ -82,7 +88,8 @@ public WriteRequest(WriteRequestWrites writes = default, WriteRequestDeletes del /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -99,7 +106,8 @@ public static WriteRequest FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((WriteRequest)input); } @@ -109,21 +117,23 @@ public override bool Equals(object input) { /// /// Instance of WriteRequest to be compared /// Boolean - public bool Equals(WriteRequest input) { - if (input == null) { + public bool Equals(WriteRequest input) + { + if (input == null) + { return false; } - return + return ( this.Writes == input.Writes || (this.Writes != null && this.Writes.Equals(input.Writes)) - ) && + ) && ( this.Deletes == input.Deletes || (this.Deletes != null && this.Deletes.Equals(input.Deletes)) - ) && + ) && ( this.AuthorizationModelId == input.AuthorizationModelId || (this.AuthorizationModelId != null && @@ -136,20 +146,25 @@ public bool Equals(WriteRequest input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Writes != null) { + if (this.Writes != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Writes.GetHashCode(); } - if (this.Deletes != null) { + if (this.Deletes != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Deletes.GetHashCode(); } - if (this.AuthorizationModelId != null) { + if (this.AuthorizationModelId != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AuthorizationModelId.GetHashCode(); } - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -161,10 +176,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/WriteRequestDeletes.cs b/src/OpenFga.Sdk/Model/WriteRequestDeletes.cs index ff707ce6..c0caa43a 100644 --- a/src/OpenFga.Sdk/Model/WriteRequestDeletes.cs +++ b/src/OpenFga.Sdk/Model/WriteRequestDeletes.cs @@ -11,27 +11,32 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// WriteRequestDeletes /// [DataContract(Name = "WriteRequestDeletes")] - public partial class WriteRequestDeletes : IEquatable, IValidatableObject { + public partial class WriteRequestDeletes : IEquatable, IValidatableObject + { /// /// On 'error', the API returns an error when deleting a tuple that does not exist. On 'ignore', deletes of non-existent tuples are treated as no-ops. /// /// On 'error', the API returns an error when deleting a tuple that does not exist. On 'ignore', deletes of non-existent tuples are treated as no-ops. [JsonConverter(typeof(JsonStringEnumMemberConverter))] - public enum OnMissingEnum { + public enum OnMissingEnum + { /// /// Enum Error for value: error /// @@ -58,7 +63,8 @@ public enum OnMissingEnum { /// Initializes a new instance of the class. /// [JsonConstructor] - public WriteRequestDeletes() { + public WriteRequestDeletes() + { this.AdditionalProperties = new Dictionary(); } @@ -67,9 +73,11 @@ public WriteRequestDeletes() { /// /// tupleKeys (required). /// On 'error', the API returns an error when deleting a tuple that does not exist. On 'ignore', deletes of non-existent tuples are treated as no-ops. (default to OnMissingEnum.Error). - public WriteRequestDeletes(List tupleKeys = default, OnMissingEnum? onMissing = OnMissingEnum.Error) { + public WriteRequestDeletes(List tupleKeys = default, OnMissingEnum? onMissing = OnMissingEnum.Error) + { // to ensure "tupleKeys" is required (not null) - if (tupleKeys == null) { + if (tupleKeys == null) + { throw new ArgumentNullException("tupleKeys is a required property for WriteRequestDeletes and cannot be null"); } this.TupleKeys = tupleKeys; @@ -96,7 +104,8 @@ public WriteRequestDeletes(List tupleKeys = default, O /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -113,7 +122,8 @@ public static WriteRequestDeletes FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((WriteRequestDeletes)input); } @@ -123,17 +133,19 @@ public override bool Equals(object input) { /// /// Instance of WriteRequestDeletes to be compared /// Boolean - public bool Equals(WriteRequestDeletes input) { - if (input == null) { + public bool Equals(WriteRequestDeletes input) + { + if (input == null) + { return false; } - return + return ( this.TupleKeys == input.TupleKeys || this.TupleKeys != null && input.TupleKeys != null && this.TupleKeys.SequenceEqual(input.TupleKeys) - ) && + ) && ( this.OnMissing == input.OnMissing || this.OnMissing.Equals(input.OnMissing) @@ -145,15 +157,18 @@ public bool Equals(WriteRequestDeletes input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.TupleKeys != null) { + if (this.TupleKeys != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.TupleKeys.GetHashCode(); } hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.OnMissing.GetHashCode(); - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -165,10 +180,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} diff --git a/src/OpenFga.Sdk/Model/WriteRequestWrites.cs b/src/OpenFga.Sdk/Model/WriteRequestWrites.cs index 69c59045..8b798d36 100644 --- a/src/OpenFga.Sdk/Model/WriteRequestWrites.cs +++ b/src/OpenFga.Sdk/Model/WriteRequestWrites.cs @@ -11,27 +11,32 @@ // -using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; -namespace OpenFga.Sdk.Model { + +using OpenFga.Sdk.Constants; + +namespace OpenFga.Sdk.Model +{ /// /// WriteRequestWrites /// [DataContract(Name = "WriteRequestWrites")] - public partial class WriteRequestWrites : IEquatable, IValidatableObject { + public partial class WriteRequestWrites : IEquatable, IValidatableObject + { /// /// On 'error' ( or unspecified ), the API returns an error if an identical tuple already exists. On 'ignore', identical writes are treated as no-ops (matching on user, relation, object, and RelationshipCondition). /// /// On 'error' ( or unspecified ), the API returns an error if an identical tuple already exists. On 'ignore', identical writes are treated as no-ops (matching on user, relation, object, and RelationshipCondition). [JsonConverter(typeof(JsonStringEnumMemberConverter))] - public enum OnDuplicateEnum { + public enum OnDuplicateEnum + { /// /// Enum Error for value: error /// @@ -58,7 +63,8 @@ public enum OnDuplicateEnum { /// Initializes a new instance of the class. /// [JsonConstructor] - public WriteRequestWrites() { + public WriteRequestWrites() + { this.AdditionalProperties = new Dictionary(); } @@ -67,9 +73,11 @@ public WriteRequestWrites() { /// /// tupleKeys (required). /// On 'error' ( or unspecified ), the API returns an error if an identical tuple already exists. On 'ignore', identical writes are treated as no-ops (matching on user, relation, object, and RelationshipCondition). (default to OnDuplicateEnum.Error). - public WriteRequestWrites(List tupleKeys = default, OnDuplicateEnum? onDuplicate = OnDuplicateEnum.Error) { + public WriteRequestWrites(List tupleKeys = default, OnDuplicateEnum? onDuplicate = OnDuplicateEnum.Error) + { // to ensure "tupleKeys" is required (not null) - if (tupleKeys == null) { + if (tupleKeys == null) + { throw new ArgumentNullException("tupleKeys is a required property for WriteRequestWrites and cannot be null"); } this.TupleKeys = tupleKeys; @@ -96,7 +104,8 @@ public WriteRequestWrites(List tupleKeys = default, OnDuplicateEnum? o /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() { + public virtual string ToJson() + { return JsonSerializer.Serialize(this); } @@ -113,7 +122,8 @@ public static WriteRequestWrites FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) { + public override bool Equals(object input) + { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((WriteRequestWrites)input); } @@ -123,17 +133,19 @@ public override bool Equals(object input) { /// /// Instance of WriteRequestWrites to be compared /// Boolean - public bool Equals(WriteRequestWrites input) { - if (input == null) { + public bool Equals(WriteRequestWrites input) + { + if (input == null) + { return false; } - return + return ( this.TupleKeys == input.TupleKeys || this.TupleKeys != null && input.TupleKeys != null && this.TupleKeys.SequenceEqual(input.TupleKeys) - ) && + ) && ( this.OnDuplicate == input.OnDuplicate || this.OnDuplicate.Equals(input.OnDuplicate) @@ -145,15 +157,18 @@ public bool Equals(WriteRequestWrites input) { /// Gets the hash code /// /// Hash code - public override int GetHashCode() { + public override int GetHashCode() + { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.TupleKeys != null) { + if (this.TupleKeys != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.TupleKeys.GetHashCode(); } hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.OnDuplicate.GetHashCode(); - if (this.AdditionalProperties != null) { + if (this.AdditionalProperties != null) + { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -165,10 +180,11 @@ public override int GetHashCode() { /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) { + public IEnumerable Validate(ValidationContext validationContext) + { yield break; } } -} \ No newline at end of file +} From 1bb2f0a8036af0d18ded180c18380760e2ea6903 Mon Sep 17 00:00:00 2001 From: Anurag Bandyopadhyay Date: Wed, 4 Feb 2026 01:14:45 +0530 Subject: [PATCH 08/23] fix: config await --- src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorTests.cs | 2 +- src/OpenFga.Sdk/Client/ApiExecutor/ApiExecutor.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorTests.cs b/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorTests.cs index ae43b0eb..edcd2c16 100644 --- a/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorTests.cs +++ b/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorTests.cs @@ -381,7 +381,7 @@ await Assert.ThrowsAnyAsync(async () => [Fact] public async Task SendAsync_WithCredentials_IncludesAuthorizationHeader() { // Arrange - using var responseMessage = new HttpResponseMessage { + var responseMessage = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent("{}", Encoding.UTF8, "application/json") }; diff --git a/src/OpenFga.Sdk/Client/ApiExecutor/ApiExecutor.cs b/src/OpenFga.Sdk/Client/ApiExecutor/ApiExecutor.cs index d62db9bf..5c81a9d8 100644 --- a/src/OpenFga.Sdk/Client/ApiExecutor/ApiExecutor.cs +++ b/src/OpenFga.Sdk/Client/ApiExecutor/ApiExecutor.cs @@ -58,10 +58,10 @@ public async Task> SendAsync( requestBuilder, "ApiExecutor", customHeaders, - cancellationToken); + cancellationToken).ConfigureAwait(false); // Read the raw response body - var rawResponse = await responseWrapper.rawResponse.Content.ReadAsStringAsync(); + var rawResponse = await responseWrapper.rawResponse.Content.ReadAsStringAsync().ConfigureAwait(false); // Create and return ApiResponse return ApiResponse.FromHttpResponse( From 455d3252c4b4f62e17ec3d216de35a04f50b75a3 Mon Sep 17 00:00:00 2001 From: SoulPancake Date: Wed, 4 Feb 2026 13:42:04 +0530 Subject: [PATCH 09/23] fix: address comments, tests fix --- .../ApiExecutorIntegrationTests.cs | 42 +++++++-------- .../ApiExecutorRequestBuilderTests.cs | 4 +- .../Client/ApiExecutor/ApiExecutorTests.cs | 52 +++++++++---------- .../Client/ApiExecutor/ApiResponseTests.cs | 6 +-- src/OpenFga.Sdk/Client/Client.cs | 2 +- 5 files changed, 50 insertions(+), 56 deletions(-) diff --git a/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorIntegrationTests.cs b/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorIntegrationTests.cs index d45609a2..fc023ea8 100644 --- a/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorIntegrationTests.cs +++ b/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorIntegrationTests.cs @@ -68,7 +68,7 @@ public async Task RawRequest_ListStores() { .Of(HttpMethod.Get, "/stores") .Build(); - var response = await _fga!.ApiExecutor().SendAsync(request); + var response = await _fga!.GetApiExecutor().SendAsync(request); // Verify response Assert.NotNull(response); @@ -79,13 +79,7 @@ public async Task RawRequest_ListStores() { Assert.NotEmpty(response.Data.Stores); // Verify we can find our store - var foundStore = false; - foreach (var store in response.Data.Stores) { - if (store.Name == storeName) { - foundStore = true; - break; - } - } + var foundStore = response.Data.Stores.Any(store => store.Name == storeName); Assert.True(foundStore, "Should find the store we created"); } @@ -107,7 +101,7 @@ public async Task RawRequest_CreateStore_TypedResponse() { .Body(requestBody) .Build(); - var response = await _fga!.ApiExecutor().SendAsync(request); + var response = await _fga!.GetApiExecutor().SendAsync(request); // Verify response Assert.NotNull(response); @@ -136,7 +130,7 @@ public async Task RawRequest_CreateStore_RawJsonResponse() { .Body(requestBody) .Build(); - var response = await _fga!.ApiExecutor().SendAsync(request); + var response = await _fga!.GetApiExecutor().SendAsync(request); // Verify response Assert.NotNull(response); @@ -167,7 +161,7 @@ public async Task RawRequest_GetStore_WithPathParams() { .PathParam("store_id", storeId) .Build(); - var response = await _fga!.ApiExecutor().SendAsync(request); + var response = await _fga!.GetApiExecutor().SendAsync(request); // Verify response Assert.NotNull(response); @@ -193,7 +187,7 @@ public async Task RawRequest_AutomaticStoreIdReplacement() { .Of(HttpMethod.Get, "/stores/{store_id}") .Build(); - var response = await _fga.ApiExecutor().SendAsync(request); + var response = await _fga.GetApiExecutor().SendAsync(request); // Verify response Assert.NotNull(response); @@ -263,7 +257,7 @@ public async Task RawRequest_WriteAuthorizationModel() { .Body(requestBody) .Build(); - var response = await _fga.ApiExecutor().SendAsync(request); + var response = await _fga.GetApiExecutor().SendAsync(request); // Verify response Assert.NotNull(response); @@ -295,7 +289,7 @@ public async Task RawRequest_ReadAuthorizationModels_WithQueryParams() { .QueryParam("page_size", "10") .Build(); - var response = await _fga.ApiExecutor().SendAsync(request); + var response = await _fga.GetApiExecutor().SendAsync(request); // Verify response Assert.NotNull(response); @@ -340,7 +334,7 @@ public async Task RawRequest_Check() { .Body(checkBody) .Build(); - var response = await _fga.ApiExecutor().SendAsync(request); + var response = await _fga.GetApiExecutor().SendAsync(request); // Verify response Assert.NotNull(response); @@ -372,7 +366,7 @@ public async Task RawRequest_WithCustomHeaders() { .Header("X-Request-ID", "test-123") .Build(); - var response = await _fga!.ApiExecutor().SendAsync(request); + var response = await _fga!.GetApiExecutor().SendAsync(request); // Verify response Assert.NotNull(response); @@ -393,7 +387,7 @@ public async Task RawRequest_ErrorHandling_NotFound() { // Should throw an exception await Assert.ThrowsAnyAsync(async () => - await _fga!.ApiExecutor().SendAsync(request)); + await _fga!.GetApiExecutor().SendAsync(request)); } /// @@ -414,7 +408,7 @@ public async Task RawRequest_ListStores_WithPagination() { .QueryParam("page_size", "2") .Build(); - var response = await _fga!.ApiExecutor().SendAsync(request); + var response = await _fga!.GetApiExecutor().SendAsync(request); // Verify response Assert.NotNull(response); @@ -457,7 +451,7 @@ public async Task RawRequest_Write_WriteTuples() { .Body(writeBody) .Build(); - var response = await _fga.ApiExecutor().SendAsync(request); + var response = await _fga.GetApiExecutor().SendAsync(request); // Verify response Assert.NotNull(response); @@ -496,7 +490,7 @@ public async Task RawRequest_Read_ReadTuples() { .Body(readBody) .Build(); - var response = await _fga.ApiExecutor().SendAsync(request); + var response = await _fga.GetApiExecutor().SendAsync(request); // Verify response Assert.NotNull(response); @@ -532,7 +526,7 @@ public async Task RawRequest_DeleteStore() { .PathParam("store_id", storeId) .Build(); - var response = await _fga!.ApiExecutor().SendAsync(request); + var response = await _fga!.GetApiExecutor().SendAsync(request); // Verify response Assert.NotNull(response); @@ -552,7 +546,7 @@ private async Task CreateStoreUsingRawRequest(string storeName) { .Body(requestBody) .Build(); - var response = await _fga!.ApiExecutor().SendAsync(request); + var response = await _fga!.GetApiExecutor().SendAsync(request); return response.Data.Id; } @@ -604,7 +598,7 @@ private async Task WriteSimpleAuthorizationModel(string storeId) { .Body(requestBody) .Build(); - var response = await _fga!.ApiExecutor().SendAsync(request); + var response = await _fga!.GetApiExecutor().SendAsync(request); return response.Data.AuthorizationModelId; } @@ -631,6 +625,6 @@ private async Task WriteTupleUsingRawRequest(string storeId, string user, string .Body(requestBody) .Build(); - await _fga!.ApiExecutor().SendAsync(request); + await _fga!.GetApiExecutor().SendAsync(request); } } diff --git a/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorRequestBuilderTests.cs b/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorRequestBuilderTests.cs index 25b81fb6..9c80dfe8 100644 --- a/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorRequestBuilderTests.cs +++ b/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorRequestBuilderTests.cs @@ -166,9 +166,9 @@ public void Header_NullKey_ThrowsArgumentException() { var builder = ApiExecutorRequestBuilder.Of(HttpMethod.Post, "/stores"); // Act & Assert - var exception = Assert.Throws(() => + var exception = Assert.Throws(() => builder.Header(null, "value")); - Assert.Contains("name", exception.Message, StringComparison.OrdinalIgnoreCase); + Assert.Contains("key", exception.Message, StringComparison.OrdinalIgnoreCase); } [Fact] diff --git a/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorTests.cs b/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorTests.cs index edcd2c16..8a999242 100644 --- a/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorTests.cs +++ b/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorTests.cs @@ -53,7 +53,7 @@ public void Dispose() { public async Task SendAsync_ValidGetRequest_ReturnsSuccessResponse() { // Arrange var expectedResponse = new { id = _storeId, name = "test-store" }; - var responseMessage = new HttpResponseMessage { + using var responseMessage = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent( JsonSerializer.Serialize(expectedResponse), @@ -72,7 +72,7 @@ public async Task SendAsync_ValidGetRequest_ReturnsSuccessResponse() { .Build(); // Act - var response = await client.ApiExecutor().SendAsync(request); + var response = await client.GetApiExecutor().SendAsync(request); // Assert Assert.NotNull(response); @@ -88,7 +88,7 @@ public async Task SendAsync_ValidPostRequest_ReturnsSuccessResponse() { // Arrange var requestBody = new { user = "user:anne", relation = "reader", @object = "document:2021-budget" }; var expectedResponse = new { allowed = true }; - var responseMessage = new HttpResponseMessage { + using var responseMessage = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent( JsonSerializer.Serialize(expectedResponse), @@ -96,7 +96,7 @@ public async Task SendAsync_ValidPostRequest_ReturnsSuccessResponse() { "application/json") }; - var (client, mockHandler) = CreateMockClient(responseMessage, req => + var (client, _) = CreateMockClient(responseMessage, req => req.Method == HttpMethod.Post && req.RequestUri.ToString().Contains("/stores/" + _storeId + "/check")); @@ -107,7 +107,7 @@ public async Task SendAsync_ValidPostRequest_ReturnsSuccessResponse() { .Build(); // Act - var response = await client.ApiExecutor().SendAsync(request); + var response = await client.GetApiExecutor().SendAsync(request); // Assert Assert.NotNull(response); @@ -119,7 +119,7 @@ public async Task SendAsync_ValidPostRequest_ReturnsSuccessResponse() { [Fact] public async Task SendAsync_WithPathParams_ReplacesInUrl() { // Arrange - var responseMessage = new HttpResponseMessage { + using var responseMessage = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent("{}", Encoding.UTF8, "application/json") }; @@ -133,7 +133,7 @@ public async Task SendAsync_WithPathParams_ReplacesInUrl() { .Build(); // Act - await client.ApiExecutor().SendAsync(request); + await client.GetApiExecutor().SendAsync(request); // Assert mockHandler.Protected().Verify( @@ -148,7 +148,7 @@ public async Task SendAsync_WithPathParams_ReplacesInUrl() { [Fact] public async Task SendAsync_WithQueryParams_AppendsToUrl() { // Arrange - var responseMessage = new HttpResponseMessage { + using var responseMessage = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent("[]", Encoding.UTF8, "application/json") }; @@ -164,7 +164,7 @@ public async Task SendAsync_WithQueryParams_AppendsToUrl() { .Build(); // Act - await client.ApiExecutor().SendAsync(request); + await client.GetApiExecutor().SendAsync(request); // Assert mockHandler.Protected().Verify( @@ -180,7 +180,7 @@ public async Task SendAsync_WithQueryParams_AppendsToUrl() { [Fact] public async Task SendAsync_WithCustomHeaders_IncludesInRequest() { // Arrange - var responseMessage = new HttpResponseMessage { + using var responseMessage = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent("{}", Encoding.UTF8, "application/json") }; @@ -194,7 +194,7 @@ public async Task SendAsync_WithCustomHeaders_IncludesInRequest() { .Build(); // Act - await client.ApiExecutor().SendAsync(request); + await client.GetApiExecutor().SendAsync(request); // Assert mockHandler.Protected().Verify( @@ -213,7 +213,7 @@ public async Task SendAsync_WithCustomHeaders_IncludesInRequest() { public async Task SendAsync_WithBody_SerializesToJson() { // Arrange var requestBody = new { name = "test-store" }; - var responseMessage = new HttpResponseMessage { + using var responseMessage = new HttpResponseMessage { StatusCode = HttpStatusCode.Created, Content = new StringContent( JsonSerializer.Serialize(new { id = "new-store-123" }), @@ -229,7 +229,7 @@ public async Task SendAsync_WithBody_SerializesToJson() { .Build(); // Act - await client.ApiExecutor().SendAsync(request); + await client.GetApiExecutor().SendAsync(request); // Assert mockHandler.Protected().Verify( @@ -246,7 +246,7 @@ public async Task SendAsync_WithBody_SerializesToJson() { public async Task SendAsync_RawResponse_ReturnsJsonString() { // Arrange var expectedJson = "{\"id\":\"123\",\"name\":\"test\"}"; - var responseMessage = new HttpResponseMessage { + using var responseMessage = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(expectedJson, Encoding.UTF8, "application/json") }; @@ -259,7 +259,7 @@ public async Task SendAsync_RawResponse_ReturnsJsonString() { .Build(); // Act - var response = await client.ApiExecutor().SendAsync(request); + var response = await client.GetApiExecutor().SendAsync(request); // Assert Assert.NotNull(response); @@ -275,7 +275,7 @@ public async Task SendAsync_ApiError_ThrowsFgaApiError() { code = "invalid_request", message = "Invalid request parameters" }; - var responseMessage = new HttpResponseMessage { + using var responseMessage = new HttpResponseMessage { StatusCode = HttpStatusCode.BadRequest, Content = new StringContent( JsonSerializer.Serialize(errorResponse), @@ -292,7 +292,7 @@ public async Task SendAsync_ApiError_ThrowsFgaApiError() { // Act & Assert await Assert.ThrowsAsync(async () => - await client.ApiExecutor().SendAsync(request)); + await client.GetApiExecutor().SendAsync(request)); } [Fact] @@ -306,7 +306,7 @@ public async Task SendAsync_NullRequest_ThrowsArgumentNullException() { // Act & Assert await Assert.ThrowsAsync(async () => - await client.ApiExecutor().SendAsync(null)); + await client.GetApiExecutor().SendAsync(null)); } [Fact] @@ -319,8 +319,8 @@ public void ApiExecutor_CalledMultipleTimes_ReturnsSameInstance() { var client = new OpenFgaClient(config); // Act - var executor1 = client.ApiExecutor(); - var executor2 = client.ApiExecutor(); + var executor1 = client.GetApiExecutor(); + var executor2 = client.GetApiExecutor(); // Assert Assert.Same(executor1, executor2); @@ -332,7 +332,7 @@ public async Task SendAsync_TypedResponse_DeserializesCorrectly() { var expectedResponse = new CheckResponse { Allowed = true }; - var responseMessage = new HttpResponseMessage { + using var responseMessage = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent( JsonSerializer.Serialize(expectedResponse), @@ -349,7 +349,7 @@ public async Task SendAsync_TypedResponse_DeserializesCorrectly() { .Build(); // Act - var response = await client.ApiExecutor().SendAsync(request); + var response = await client.GetApiExecutor().SendAsync(request); // Assert Assert.NotNull(response); @@ -360,7 +360,7 @@ public async Task SendAsync_TypedResponse_DeserializesCorrectly() { [Fact] public async Task SendAsync_CancellationToken_CancelsRequest() { // Arrange - var cts = new CancellationTokenSource(); + using var cts = new CancellationTokenSource(); cts.Cancel(); // Cancel immediately var config = new ClientConfiguration { @@ -375,13 +375,13 @@ public async Task SendAsync_CancellationToken_CancelsRequest() { // Act & Assert await Assert.ThrowsAnyAsync(async () => - await client.ApiExecutor().SendAsync(request, cts.Token)); + await client.GetApiExecutor().SendAsync(request, cts.Token)); } [Fact] public async Task SendAsync_WithCredentials_IncludesAuthorizationHeader() { // Arrange - var responseMessage = new HttpResponseMessage { + using var responseMessage = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent("{}", Encoding.UTF8, "application/json") }; @@ -412,7 +412,7 @@ public async Task SendAsync_WithCredentials_IncludesAuthorizationHeader() { .Build(); // Act - await client.ApiExecutor().SendAsync(request); + await client.GetApiExecutor().SendAsync(request); // Assert mockHandler.Protected().Verify( diff --git a/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiResponseTests.cs b/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiResponseTests.cs index 9c894a6e..e4b6f9f4 100644 --- a/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiResponseTests.cs +++ b/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiResponseTests.cs @@ -75,7 +75,7 @@ public void IsSuccessful_NonSuccessStatusCode_ReturnsFalse() { [Fact] public void FromHttpResponse_ContainsAllResponseHeaders() { // Arrange - var httpResponse = new HttpResponseMessage { + using var httpResponse = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent("{\"id\":\"123\"}", Encoding.UTF8, "application/json") }; @@ -98,7 +98,7 @@ public void FromHttpResponse_ContainsAllResponseHeaders() { [Fact] public void FromHttpResponse_ContainsContentHeaders() { // Arrange - var httpResponse = new HttpResponseMessage { + using var httpResponse = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent("{\"id\":\"123\"}", Encoding.UTF8, "application/json") }; @@ -117,7 +117,7 @@ public void FromHttpResponse_ContainsContentHeaders() { [Fact] public void Headers_AreCaseInsensitive() { // Arrange - var httpResponse = new HttpResponseMessage { + using var httpResponse = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent("", Encoding.UTF8, "application/json") }; diff --git a/src/OpenFga.Sdk/Client/Client.cs b/src/OpenFga.Sdk/Client/Client.cs index ab7ce696..28161dc5 100644 --- a/src/OpenFga.Sdk/Client/Client.cs +++ b/src/OpenFga.Sdk/Client/Client.cs @@ -54,7 +54,7 @@ public string? AuthorizationModelId { /// automatically leveraging the SDK's authentication, retry logic, and error handling. /// /// An ApiExecutor instance - public ApiExecutor.ApiExecutor ApiExecutor() { + public ApiExecutor.ApiExecutor GetApiExecutor() { return _apiExecutor.Value; } From 0e2a8530ff5652434c09cf9845d868aedd096467 Mon Sep 17 00:00:00 2001 From: SoulPancake Date: Wed, 4 Feb 2026 17:33:37 +0530 Subject: [PATCH 10/23] feat: add examples code --- example/ApiExecutorExample/.gitignore | 5 + .../ApiExecutorExample.csproj | 16 + example/ApiExecutorExample/Makefile | 46 ++ example/ApiExecutorExample/Program.cs | 342 ++++++++++ example/ApiExecutorExample/README.md | 196 ++++++ example/README.md | 12 +- .../ApiExecutorIntegrationTests.cs | 630 ------------------ 7 files changed, 616 insertions(+), 631 deletions(-) create mode 100644 example/ApiExecutorExample/.gitignore create mode 100644 example/ApiExecutorExample/ApiExecutorExample.csproj create mode 100644 example/ApiExecutorExample/Makefile create mode 100644 example/ApiExecutorExample/Program.cs create mode 100644 example/ApiExecutorExample/README.md delete mode 100644 src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorIntegrationTests.cs diff --git a/example/ApiExecutorExample/.gitignore b/example/ApiExecutorExample/.gitignore new file mode 100644 index 00000000..2789d716 --- /dev/null +++ b/example/ApiExecutorExample/.gitignore @@ -0,0 +1,5 @@ +bin/ +obj/ +*.user +*.suo +.vs/ diff --git a/example/ApiExecutorExample/ApiExecutorExample.csproj b/example/ApiExecutorExample/ApiExecutorExample.csproj new file mode 100644 index 00000000..8cc38eca --- /dev/null +++ b/example/ApiExecutorExample/ApiExecutorExample.csproj @@ -0,0 +1,16 @@ + + + + Exe + net8.0 + enable + enable + Linux + + + + + + + + diff --git a/example/ApiExecutorExample/Makefile b/example/ApiExecutorExample/Makefile new file mode 100644 index 00000000..0e5c58c1 --- /dev/null +++ b/example/ApiExecutorExample/Makefile @@ -0,0 +1,46 @@ +.PHONY: help start-openfga stop-openfga run clean + +help: + @echo "ApiExecutor Example - Makefile Commands" + @echo "" + @echo " make start-openfga - Start OpenFGA server in Docker on port 8080" + @echo " make stop-openfga - Stop the OpenFGA Docker container" + @echo " make run - Run the ApiExecutor example (requires OpenFGA running)" + @echo " make run-all - Start OpenFGA, run example, then stop OpenFGA" + @echo " make clean - Clean build artifacts" + @echo "" + +# Start OpenFGA server in Docker +start-openfga: + @echo "Starting OpenFGA server on localhost:8080..." + @docker run -d --name openfga-example -p 8080:8080 openfga/openfga:latest run + @echo "Waiting for OpenFGA to be ready..." + @sleep 3 + @curl -s http://localhost:8080/healthz || (echo "OpenFGA failed to start" && exit 1) + @echo "✅ OpenFGA is ready!" + +# Stop OpenFGA server +stop-openfga: + @echo "Stopping OpenFGA server..." + @docker stop openfga-example 2>/dev/null || true + @docker rm openfga-example 2>/dev/null || true + @echo "✅ OpenFGA stopped" + +# Run the example +run: + @echo "Running ApiExecutor example..." + @dotnet run --project ApiExecutorExample.csproj + +# Run everything: start server, run example, stop server +run-all: start-openfga + @echo "" + @$(MAKE) run + @echo "" + @$(MAKE) stop-openfga + +# Clean build artifacts +clean: + @echo "Cleaning build artifacts..." + @dotnet clean + @rm -rf bin obj + @echo "✅ Clean complete" diff --git a/example/ApiExecutorExample/Program.cs b/example/ApiExecutorExample/Program.cs new file mode 100644 index 00000000..acc495e4 --- /dev/null +++ b/example/ApiExecutorExample/Program.cs @@ -0,0 +1,342 @@ +using OpenFga.Sdk.Client; +using OpenFga.Sdk.Client.ApiExecutor; +using OpenFga.Sdk.Configuration; +using OpenFga.Sdk.Model; +using System.Net.Http; + +namespace ApiExecutorExample; + +/// +/// This example demonstrates how to use the ApiExecutor to make raw HTTP requests +/// to the OpenFGA API without using the SDK's typed methods. +/// +/// Prerequisites: Run an OpenFGA server on localhost:8080 +/// docker run -p 8080:8080 openfga/openfga:latest run +/// +class Program { + static async Task Main(string[] args) { + Console.WriteLine("=== OpenFGA ApiExecutor Example ===\n"); + + // Configure client to connect to local OpenFGA instance + var config = new ClientConfiguration { + ApiUrl = "http://localhost:8080" + }; + + using var client = new OpenFgaClient(config); + + try { + // Example 1: List stores using raw GET request + await ListStoresExample(client); + + // Example 2: Create a store using raw POST request with typed response + var storeId = await CreateStoreExample(client); + + // Example 3: Get store details using path parameters + await GetStoreExample(client, storeId); + + // Example 4: Create an authorization model + var modelId = await CreateAuthorizationModelExample(client, storeId); + + // Example 5: Write relationship tuples + await WriteTuplesExample(client, storeId); + + // Example 6: Read relationship tuples + await ReadTuplesExample(client, storeId); + + // Example 7: Check permissions + await CheckPermissionExample(client, storeId, modelId); + + // Example 8: Use raw JSON response instead of typed + await RawJsonResponseExample(client); + + // Example 9: Custom headers + await CustomHeadersExample(client); + + // Cleanup: Delete the store we created + await DeleteStoreExample(client, storeId); + + Console.WriteLine("\n=== All examples completed successfully! ==="); + } catch (Exception ex) { + Console.WriteLine($"\n❌ Error: {ex.Message}"); + Console.WriteLine("\nMake sure OpenFGA is running on localhost:8080"); + Console.WriteLine("Run: docker run -p 8080:8080 openfga/openfga:latest run"); + Environment.Exit(1); + } + } + + static async Task ListStoresExample(OpenFgaClient client) { + Console.WriteLine("📋 Example 1: List Stores"); + Console.WriteLine("Making GET request to /stores"); + + var request = ApiExecutorRequestBuilder + .Of(HttpMethod.Get, "/stores") + .Build(); + + var response = await client.GetApiExecutor().SendAsync(request); + + Console.WriteLine($"✅ Status: {response.StatusCode}"); + Console.WriteLine($" Found {response.Data.Stores?.Count ?? 0} store(s)"); + Console.WriteLine(); + } + + static async Task CreateStoreExample(OpenFgaClient client) { + Console.WriteLine("🏪 Example 2: Create Store"); + Console.WriteLine("Making POST request to /stores"); + + var storeName = "ApiExecutor-Example-" + DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); + var requestBody = new Dictionary { + { "name", storeName } + }; + + var request = ApiExecutorRequestBuilder + .Of(HttpMethod.Post, "/stores") + .Body(requestBody) + .Build(); + + var response = await client.GetApiExecutor().SendAsync(request); + + Console.WriteLine($"✅ Status: {response.StatusCode}"); + Console.WriteLine($" Store ID: {response.Data.Id}"); + Console.WriteLine($" Store Name: {response.Data.Name}"); + Console.WriteLine(); + + return response.Data.Id!; + } + + static async Task GetStoreExample(OpenFgaClient client, string storeId) { + Console.WriteLine("🔍 Example 3: Get Store Details"); + Console.WriteLine($"Making GET request to /stores/{{store_id}}"); + + var request = ApiExecutorRequestBuilder + .Of(HttpMethod.Get, "/stores/{store_id}") + .PathParam("store_id", storeId) + .Build(); + + var response = await client.GetApiExecutor().SendAsync(request); + + Console.WriteLine($"✅ Status: {response.StatusCode}"); + Console.WriteLine($" Store Name: {response.Data.Name}"); + Console.WriteLine($" Created At: {response.Data.CreatedAt}"); + Console.WriteLine(); + } + + static async Task CreateAuthorizationModelExample(OpenFgaClient client, string storeId) { + Console.WriteLine("📝 Example 4: Create Authorization Model"); + Console.WriteLine("Making POST request to /stores/{store_id}/authorization-models"); + + var requestBody = new Dictionary { + { "schema_version", "1.1" }, + { + "type_definitions", new List> { + new() { + { "type", "user" }, + { "relations", new Dictionary() } + }, + new() { + { "type", "document" }, + { + "relations", new Dictionary { + { + "reader", new Dictionary { + { "this", new Dictionary() } + } + }, + { + "writer", new Dictionary { + { "this", new Dictionary() } + } + } + } + }, + { + "metadata", new Dictionary { + { + "relations", new Dictionary { + { + "reader", new Dictionary { + { + "directly_related_user_types", new List> { + new() { { "type", "user" } } + } + } + } + }, + { + "writer", new Dictionary { + { + "directly_related_user_types", new List> { + new() { { "type", "user" } } + } + } + } + } + } + } + } + } + } + } + } + }; + + var request = ApiExecutorRequestBuilder + .Of(HttpMethod.Post, "/stores/{store_id}/authorization-models") + .PathParam("store_id", storeId) + .Body(requestBody) + .Build(); + + var response = await client.GetApiExecutor().SendAsync(request); + + Console.WriteLine($"✅ Status: {response.StatusCode}"); + Console.WriteLine($" Model ID: {response.Data.AuthorizationModelId}"); + Console.WriteLine(); + + return response.Data.AuthorizationModelId!; + } + + static async Task WriteTuplesExample(OpenFgaClient client, string storeId) { + Console.WriteLine("✍️ Example 5: Write Relationship Tuples"); + Console.WriteLine("Making POST request to /stores/{store_id}/write"); + + var requestBody = new Dictionary { + { + "writes", new Dictionary { + { + "tuple_keys", new List> { + new() { + { "user", "user:alice" }, + { "relation", "writer" }, + { "object", "document:roadmap" } + }, + new() { + { "user", "user:bob" }, + { "relation", "reader" }, + { "object", "document:roadmap" } + } + } + } + } + } + }; + + var request = ApiExecutorRequestBuilder + .Of(HttpMethod.Post, "/stores/{store_id}/write") + .PathParam("store_id", storeId) + .Body(requestBody) + .Build(); + + var response = await client.GetApiExecutor().SendAsync(request); + + Console.WriteLine($"✅ Status: {response.StatusCode}"); + Console.WriteLine(" Tuples written successfully"); + Console.WriteLine(); + } + + static async Task ReadTuplesExample(OpenFgaClient client, string storeId) { + Console.WriteLine("📖 Example 6: Read Relationship Tuples"); + Console.WriteLine("Making POST request to /stores/{store_id}/read"); + + var requestBody = new Dictionary { + { + "tuple_key", new Dictionary { + { "object", "document:roadmap" } + } + } + }; + + var request = ApiExecutorRequestBuilder + .Of(HttpMethod.Post, "/stores/{store_id}/read") + .PathParam("store_id", storeId) + .Body(requestBody) + .Build(); + + var response = await client.GetApiExecutor().SendAsync(request); + + Console.WriteLine($"✅ Status: {response.StatusCode}"); + Console.WriteLine($" Found {response.Data.Tuples?.Count ?? 0} tuple(s):"); + if (response.Data.Tuples != null) { + foreach (var tuple in response.Data.Tuples) { + Console.WriteLine($" - {tuple.Key.User} is {tuple.Key.Relation} of {tuple.Key.Object}"); + } + } + Console.WriteLine(); + } + + static async Task CheckPermissionExample(OpenFgaClient client, string storeId, string modelId) { + Console.WriteLine("🔐 Example 7: Check Permission"); + Console.WriteLine("Making POST request to /stores/{store_id}/check"); + + var requestBody = new Dictionary { + { "authorization_model_id", modelId }, + { + "tuple_key", new Dictionary { + { "user", "user:alice" }, + { "relation", "writer" }, + { "object", "document:roadmap" } + } + } + }; + + var request = ApiExecutorRequestBuilder + .Of(HttpMethod.Post, "/stores/{store_id}/check") + .PathParam("store_id", storeId) + .Body(requestBody) + .Build(); + + var response = await client.GetApiExecutor().SendAsync(request); + + Console.WriteLine($"✅ Status: {response.StatusCode}"); + Console.WriteLine($" Allowed: {response.Data.Allowed}"); + Console.WriteLine(); + } + + static async Task RawJsonResponseExample(OpenFgaClient client) { + Console.WriteLine("📄 Example 8: Raw JSON Response"); + Console.WriteLine("Getting response as raw JSON string instead of typed object"); + + var request = ApiExecutorRequestBuilder + .Of(HttpMethod.Get, "/stores") + .QueryParam("page_size", "5") + .Build(); + + // Use SendAsync without type parameter to get raw JSON string + var response = await client.GetApiExecutor().SendAsync(request); + + Console.WriteLine($"✅ Status: {response.StatusCode}"); + Console.WriteLine($" Raw JSON: {response.Data?.Substring(0, Math.Min(100, response.Data.Length))}..."); + Console.WriteLine(); + } + + static async Task CustomHeadersExample(OpenFgaClient client) { + Console.WriteLine("📨 Example 9: Custom Headers"); + Console.WriteLine("Making request with custom headers"); + + var request = ApiExecutorRequestBuilder + .Of(HttpMethod.Get, "/stores") + .Header("X-Custom-Header", "example-value") + .Header("X-Request-ID", Guid.NewGuid().ToString()) + .Build(); + + var response = await client.GetApiExecutor().SendAsync(request); + + Console.WriteLine($"✅ Status: {response.StatusCode}"); + Console.WriteLine(" Custom headers sent successfully"); + Console.WriteLine(); + } + + static async Task DeleteStoreExample(OpenFgaClient client, string storeId) { + Console.WriteLine("🗑️ Cleanup: Delete Store"); + Console.WriteLine($"Making DELETE request to /stores/{{store_id}}"); + + var request = ApiExecutorRequestBuilder + .Of(HttpMethod.Delete, "/stores/{store_id}") + .PathParam("store_id", storeId) + .Build(); + + var response = await client.GetApiExecutor().SendAsync(request); + + Console.WriteLine($"✅ Status: {response.StatusCode}"); + Console.WriteLine(" Store deleted successfully"); + Console.WriteLine(); + } +} diff --git a/example/ApiExecutorExample/README.md b/example/ApiExecutorExample/README.md new file mode 100644 index 00000000..40a9016e --- /dev/null +++ b/example/ApiExecutorExample/README.md @@ -0,0 +1,196 @@ +# ApiExecutor Example + +This example demonstrates how to use the `ApiExecutor` to make raw HTTP requests to the OpenFGA API without using the SDK's typed methods. This is useful when you need more control over the HTTP requests or want to call endpoints that aren't yet supported by the SDK's typed API. + +## What This Example Demonstrates + +1. **List Stores** - Making a GET request to list all stores +2. **Create Store** - Making a POST request with a typed response +3. **Get Store** - Using path parameters to get store details +4. **Create Authorization Model** - Creating an authorization model with custom request body +5. **Write Tuples** - Writing relationship tuples +6. **Read Tuples** - Reading relationship tuples with filters +7. **Check Permission** - Checking if a user has permission +8. **Raw JSON Response** - Getting responses as raw JSON strings +9. **Custom Headers** - Adding custom headers to requests + +## Prerequisites + +- .NET 8.0 SDK or later +- Docker (for running OpenFGA server) + +## Quick Start + +### Option 1: Using Make (Recommended) + +The easiest way to run this example: + +```bash +# Show available commands +make help + +# Run everything (start OpenFGA, run example, stop OpenFGA) +make run-all + +# Or run step by step: +make start-openfga # Start OpenFGA in Docker +make run # Run the example +make stop-openfga # Stop OpenFGA when done +``` + +### Option 2: Manual Setup + +1. **Start OpenFGA Server:** + ```bash + docker run -d --name openfga-example -p 8080:8080 openfga/openfga:latest run + ``` + +2. **Verify OpenFGA is running:** + ```bash + curl http://localhost:8080/healthz + # Should return: {"status":"SERVING"} + ``` + +3. **Run the example:** + ```bash + dotnet run + ``` + +4. **Stop OpenFGA when done:** + ```bash + docker stop openfga-example && docker rm openfga-example + ``` + +## Example Output + +``` +=== OpenFGA ApiExecutor Example === + +📋 Example 1: List Stores +Making GET request to /stores +✅ Status: OK + Found 0 store(s) + +🏪 Example 2: Create Store +Making POST request to /stores +✅ Status: Created + Store ID: 01JQWXYZ123ABC456DEF789GHJ + Store Name: ApiExecutor-Example-1738713600000 + +🔍 Example 3: Get Store Details +Making GET request to /stores/{store_id} +✅ Status: OK + Store Name: ApiExecutor-Example-1738713600000 + Created At: 2025-02-04T10:00:00Z + +📝 Example 4: Create Authorization Model +Making POST request to /stores/{store_id}/authorization-models +✅ Status: Created + Model ID: 01JQWXYZ789DEF123ABC456GHJ + +✍️ Example 5: Write Relationship Tuples +Making POST request to /stores/{store_id}/write +✅ Status: OK + Tuples written successfully + +📖 Example 6: Read Relationship Tuples +Making POST request to /stores/{store_id}/read +✅ Status: OK + Found 2 tuple(s): + - user:alice is writer of document:roadmap + - user:bob is reader of document:roadmap + +🔐 Example 7: Check Permission +Making POST request to /stores/{store_id}/check +✅ Status: OK + Allowed: True + +📄 Example 8: Raw JSON Response +Getting response as raw JSON string instead of typed object +✅ Status: OK + Raw JSON: {"stores":[],"continuation_token":""}... + +📨 Example 9: Custom Headers +Making request with custom headers +✅ Status: OK + Custom headers sent successfully + +🗑️ Cleanup: Delete Store +Making DELETE request to /stores/{store_id} +✅ Status: NoContent + Store deleted successfully + +=== All examples completed successfully! === +``` + +## Key Concepts + +### 1. Creating Requests + +Use `ApiExecutorRequestBuilder` to construct requests: + +```csharp +var request = ApiExecutorRequestBuilder + .Of(HttpMethod.Post, "/stores/{store_id}/write") + .PathParam("store_id", storeId) + .QueryParam("page_size", "10") + .Header("X-Custom-Header", "value") + .Body(requestBody) + .Build(); +``` + +### 2. Sending Requests + +Send requests using the ApiExecutor: + +```csharp +// With typed response +var response = await client.GetApiExecutor().SendAsync(request); + +// With raw JSON response +var response = await client.GetApiExecutor().SendAsync(request); +``` + +### 3. Working with Responses + +Access response data through the `ApiResponse` object: + +```csharp +Console.WriteLine($"Status: {response.StatusCode}"); +Console.WriteLine($"Success: {response.IsSuccessful}"); +Console.WriteLine($"Data: {response.Data}"); +Console.WriteLine($"Raw Response: {response.RawResponse}"); +Console.WriteLine($"Headers: {string.Join(", ", response.Headers.Keys)}"); +``` + +## When to Use ApiExecutor + +The ApiExecutor is useful when you need to: + +- Call OpenFGA API endpoints not yet available in the SDK's typed API +- Have fine-grained control over HTTP requests +- Work with custom or experimental API features +- Debug API interactions at the HTTP level +- Build custom abstractions on top of the OpenFGA API + +## Troubleshooting + +### OpenFGA Connection Failed + +If you see connection errors: +1. Verify OpenFGA is running: `curl http://localhost:8080/healthz` +2. Check Docker logs: `docker logs openfga-example` +3. Ensure port 8080 is not in use by another application + +### Build Errors + +Make sure you have .NET 8.0 SDK installed: +```bash +dotnet --version +``` + +## Learn More + +- [OpenFGA Documentation](https://openfga.dev/docs) +- [OpenFGA API Reference](https://openfga.dev/api/service) +- [OpenFGA SDK Documentation](https://github.com/openfga/dotnet-sdk) diff --git a/example/README.md b/example/README.md index 5f7c7a2b..a9ea598a 100644 --- a/example/README.md +++ b/example/README.md @@ -3,9 +3,19 @@ A set of Examples on how to call the OpenFGA .NET SDK ### Examples -Example 1: + +**Example 1:** A bare bones example. It creates a store, and runs a set of calls against it including creating a model, writing tuples and checking for access. +**StreamedListObjectsExample:** +Demonstrates how to use the StreamedListObjects API to efficiently list objects with streaming responses. + +**OpenTelemetryExample:** +Shows how to integrate OpenTelemetry for observability and tracing of OpenFGA SDK operations. + +**ApiExecutorExample:** +Demonstrates how to use the ApiExecutor to make raw HTTP requests to the OpenFGA API. This is useful when you need more control over requests or want to call endpoints not yet available in the SDK's typed API. Includes a Makefile for easy execution with a local OpenFGA server. + ### Running the Examples diff --git a/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorIntegrationTests.cs b/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorIntegrationTests.cs deleted file mode 100644 index fc023ea8..00000000 --- a/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorIntegrationTests.cs +++ /dev/null @@ -1,630 +0,0 @@ -using DotNet.Testcontainers.Builders; -using DotNet.Testcontainers.Containers; -using OpenFga.Sdk.Client; -using OpenFga.Sdk.Client.ApiExecutor; -using OpenFga.Sdk.Configuration; -using OpenFga.Sdk.Exceptions; -using OpenFga.Sdk.Model; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Http; -using System.Threading.Tasks; -using Xunit; - -namespace OpenFga.Sdk.Test.Client.ApiExecutor; - -/// -/// Integration tests for ApiExecutor functionality. -/// These tests demonstrate how to use API Executor to call OpenFGA endpoints -/// without using the SDK's typed methods. -/// Runs against an actual OpenFGA server using Testcontainers. -/// -public class ApiExecutorIntegrationTests : IAsyncLifetime { - private IContainer? _openFgaContainer; - private OpenFgaClient? _fga; - private const string OpenFgaImage = "openfga/openfga:v1.10.2"; - private const int OpenFgaPort = 8080; - - public async Task InitializeAsync() { - // Create and start OpenFGA container - _openFgaContainer = new ContainerBuilder() - .WithImage(OpenFgaImage) - .WithPortBinding(OpenFgaPort, true) - .WithWaitStrategy(Wait.ForUnixContainer().UntilHttpRequestIsSucceeded(r => r - .ForPort(OpenFgaPort) - .ForPath("/healthz") - )) - .Build(); - - await _openFgaContainer.StartAsync(); - - // Initialize OpenFGA client - var apiUrl = $"http://{_openFgaContainer.Hostname}:{_openFgaContainer.GetMappedPublicPort(OpenFgaPort)}"; - var config = new ClientConfiguration { - ApiUrl = apiUrl - }; - _fga = new OpenFgaClient(config); - } - - public async Task DisposeAsync() { - _fga?.Dispose(); - if (_openFgaContainer != null) { - await _openFgaContainer.DisposeAsync(); - } - } - - /// - /// Test listing stores using ApiExecutor instead of fga.ListStores(). - /// - [Fact] - public async Task RawRequest_ListStores() { - // Create a store first so we have something to list - var storeName = "test-store-" + DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); - await CreateStoreUsingRawRequest(storeName); - - // Use ApiExecutor to list stores (equivalent to GET /stores) - var request = ApiExecutorRequestBuilder - .Of(HttpMethod.Get, "/stores") - .Build(); - - var response = await _fga!.GetApiExecutor().SendAsync(request); - - // Verify response - Assert.NotNull(response); - Assert.Equal(System.Net.HttpStatusCode.OK, response.StatusCode); - Assert.True(response.IsSuccessful); - Assert.NotNull(response.Data); - Assert.NotNull(response.Data.Stores); - Assert.NotEmpty(response.Data.Stores); - - // Verify we can find our store - var foundStore = response.Data.Stores.Any(store => store.Name == storeName); - Assert.True(foundStore, "Should find the store we created"); - } - - /// - /// Test creating a store using ApiExecutor with typed response. - /// - [Fact] - public async Task RawRequest_CreateStore_TypedResponse() { - var storeName = "raw-test-store-" + DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); - - // Build request body - var requestBody = new Dictionary { - { "name", storeName } - }; - - // Use ApiExecutor to create store (equivalent to POST /stores) - var request = ApiExecutorRequestBuilder - .Of(HttpMethod.Post, "/stores") - .Body(requestBody) - .Build(); - - var response = await _fga!.GetApiExecutor().SendAsync(request); - - // Verify response - Assert.NotNull(response); - Assert.Equal(System.Net.HttpStatusCode.Created, response.StatusCode); - Assert.True(response.IsSuccessful); - Assert.NotNull(response.Data); - Assert.NotNull(response.Data.Id); - Assert.Equal(storeName, response.Data.Name); - } - - /// - /// Test creating a store using ApiExecutor with raw JSON string response. - /// - [Fact] - public async Task RawRequest_CreateStore_RawJsonResponse() { - var storeName = "raw-json-test-" + DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); - - // Build request body - var requestBody = new Dictionary { - { "name", storeName } - }; - - // Use ApiExecutor to create store and get raw JSON response - var request = ApiExecutorRequestBuilder - .Of(HttpMethod.Post, "/stores") - .Body(requestBody) - .Build(); - - var response = await _fga!.GetApiExecutor().SendAsync(request); - - // Verify response - Assert.NotNull(response); - Assert.Equal(System.Net.HttpStatusCode.Created, response.StatusCode); - Assert.True(response.IsSuccessful); - Assert.NotNull(response.Data); - Assert.NotNull(response.RawResponse); - - // Parse the JSON manually - var rawJson = response.Data; - Assert.Contains("\"id\"", rawJson); - Assert.Contains("\"name\"", rawJson); - Assert.Contains(storeName, rawJson); - } - - /// - /// Test getting a specific store using ApiExecutor with path parameters. - /// - [Fact] - public async Task RawRequest_GetStore_WithPathParams() { - // Create a store first - var storeName = "get-test-store-" + DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); - var storeId = await CreateStoreUsingRawRequest(storeName); - - // Use ApiExecutor to get store details (equivalent to GET /stores/{store_id}) - var request = ApiExecutorRequestBuilder - .Of(HttpMethod.Get, "/stores/{store_id}") - .PathParam("store_id", storeId) - .Build(); - - var response = await _fga!.GetApiExecutor().SendAsync(request); - - // Verify response - Assert.NotNull(response); - Assert.Equal(System.Net.HttpStatusCode.OK, response.StatusCode); - Assert.True(response.IsSuccessful); - Assert.NotNull(response.Data); - Assert.Equal(storeId, response.Data.Id); - Assert.Equal(storeName, response.Data.Name); - } - - /// - /// Test automatic {store_id} replacement when store ID is configured. - /// - [Fact] - public async Task RawRequest_AutomaticStoreIdReplacement() { - // Create a store and configure it - var storeName = "auto-store-" + DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); - var storeId = await CreateStoreUsingRawRequest(storeName); - _fga!.StoreId = storeId; - - // Use ApiExecutor WITHOUT providing store_id path param - it should be auto-replaced - var request = ApiExecutorRequestBuilder - .Of(HttpMethod.Get, "/stores/{store_id}") - .Build(); - - var response = await _fga.GetApiExecutor().SendAsync(request); - - // Verify response - Assert.NotNull(response); - Assert.Equal(System.Net.HttpStatusCode.OK, response.StatusCode); - Assert.True(response.IsSuccessful); - Assert.Equal(storeId, response.Data.Id); - - // Clean up - reset store ID - _fga.StoreId = null; - } - - /// - /// Test writing authorization model using ApiExecutor. - /// - [Fact] - public async Task RawRequest_WriteAuthorizationModel() { - // Create a store first - var storeName = "auth-model-test-" + DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); - var storeId = await CreateStoreUsingRawRequest(storeName); - _fga!.StoreId = storeId; - - // Build authorization model with proper metadata - var requestBody = new Dictionary { - { "schema_version", "1.1" }, - { - "type_definitions", new List> { - new Dictionary { - { "type", "user" }, - { "relations", new Dictionary() } - }, - new Dictionary { - { "type", "document" }, - { - "relations", new Dictionary { - { - "reader", new Dictionary { - { "this", new Dictionary() } - } - } - } - }, - { - "metadata", new Dictionary { - { - "relations", new Dictionary { - { - "reader", new Dictionary { - { - "directly_related_user_types", new List> { - new Dictionary { { "type", "user" } } - } - } - } - } - } - } - } - } - } - } - } - }; - - // Use ApiExecutor to write authorization model - var request = ApiExecutorRequestBuilder - .Of(HttpMethod.Post, "/stores/{store_id}/authorization-models") - .Body(requestBody) - .Build(); - - var response = await _fga.GetApiExecutor().SendAsync(request); - - // Verify response - Assert.NotNull(response); - Assert.Equal(System.Net.HttpStatusCode.Created, response.StatusCode); - Assert.True(response.IsSuccessful); - Assert.NotNull(response.Data); - Assert.NotNull(response.Data.AuthorizationModelId); - - // Clean up - _fga.StoreId = null; - } - - /// - /// Test reading authorization models with query parameters. - /// - [Fact] - public async Task RawRequest_ReadAuthorizationModels_WithQueryParams() { - // Create a store and write a model - var storeName = "read-models-test-" + DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); - var storeId = await CreateStoreUsingRawRequest(storeName); - _fga!.StoreId = storeId; - - // Create an authorization model first - await WriteSimpleAuthorizationModel(storeId); - - // Use ApiExecutor to read authorization models with query parameters - var request = ApiExecutorRequestBuilder - .Of(HttpMethod.Get, "/stores/{store_id}/authorization-models") - .QueryParam("page_size", "10") - .Build(); - - var response = await _fga.GetApiExecutor().SendAsync(request); - - // Verify response - Assert.NotNull(response); - Assert.Equal(System.Net.HttpStatusCode.OK, response.StatusCode); - Assert.True(response.IsSuccessful); - Assert.NotNull(response.Data); - Assert.NotNull(response.Data.AuthorizationModels); - Assert.NotEmpty(response.Data.AuthorizationModels); - - // Clean up - _fga.StoreId = null; - } - - /// - /// Test Check API using raw request. - /// - [Fact] - public async Task RawRequest_Check() { - // Setup: Create store and authorization model - var storeName = "check-test-" + DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); - var storeId = await CreateStoreUsingRawRequest(storeName); - _fga!.StoreId = storeId; - var modelId = await WriteSimpleAuthorizationModel(storeId); - - // Write a tuple - await WriteTupleUsingRawRequest(storeId, "user:alice", "reader", "document:budget"); - - // Use ApiExecutor to perform check - var checkBody = new Dictionary { - { "authorization_model_id", modelId }, - { - "tuple_key", new Dictionary { - { "user", "user:alice" }, - { "relation", "reader" }, - { "object", "document:budget" } - } - } - }; - - var request = ApiExecutorRequestBuilder - .Of(HttpMethod.Post, "/stores/{store_id}/check") - .Body(checkBody) - .Build(); - - var response = await _fga.GetApiExecutor().SendAsync(request); - - // Verify response - Assert.NotNull(response); - Assert.Equal(System.Net.HttpStatusCode.OK, response.StatusCode); - Assert.True(response.IsSuccessful); - Assert.NotNull(response.Data); - Assert.True(response.Data.Allowed, "Alice should be allowed to read the document"); - - // Clean up - _fga.StoreId = null; - } - - /// - /// Test custom headers with raw request. - /// - [Fact] - public async Task RawRequest_WithCustomHeaders() { - var storeName = "headers-test-" + DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); - - var requestBody = new Dictionary { - { "name", storeName } - }; - - // Use ApiExecutor with custom headers - var request = ApiExecutorRequestBuilder - .Of(HttpMethod.Post, "/stores") - .Body(requestBody) - .Header("X-Custom-Header", "custom-value") - .Header("X-Request-ID", "test-123") - .Build(); - - var response = await _fga!.GetApiExecutor().SendAsync(request); - - // Verify response - Assert.NotNull(response); - Assert.Equal(System.Net.HttpStatusCode.Created, response.StatusCode); - Assert.True(response.IsSuccessful); - } - - /// - /// Test error handling with raw request. - /// - [Fact] - public async Task RawRequest_ErrorHandling_NotFound() { - // Try to get a non-existent store - var request = ApiExecutorRequestBuilder - .Of(HttpMethod.Get, "/stores/{store_id}") - .PathParam("store_id", "non-existent-store-id") - .Build(); - - // Should throw an exception - await Assert.ThrowsAnyAsync(async () => - await _fga!.GetApiExecutor().SendAsync(request)); - } - - /// - /// Test list stores with pagination using query parameters. - /// - [Fact] - public async Task RawRequest_ListStores_WithPagination() { - // Create multiple stores - for (int i = 0; i < 3; i++) { - await CreateStoreUsingRawRequest("pagination-test-" + i + "-" + DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()); - // Small delay to ensure unique timestamps - await Task.Delay(10); - } - - // Use ApiExecutor to list stores with pagination - var request = ApiExecutorRequestBuilder - .Of(HttpMethod.Get, "/stores") - .QueryParam("page_size", "2") - .Build(); - - var response = await _fga!.GetApiExecutor().SendAsync(request); - - // Verify response - Assert.NotNull(response); - Assert.Equal(System.Net.HttpStatusCode.OK, response.StatusCode); - Assert.True(response.IsSuccessful); - Assert.NotNull(response.Data); - Assert.NotNull(response.Data.Stores); - } - - /// - /// Test Write API using raw request. - /// - [Fact] - public async Task RawRequest_Write_WriteTuples() { - // Setup: Create store and authorization model - var storeName = "write-test-" + DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); - var storeId = await CreateStoreUsingRawRequest(storeName); - _fga!.StoreId = storeId; - await WriteSimpleAuthorizationModel(storeId); - - // Use ApiExecutor to write tuples - var writeBody = new Dictionary { - { - "writes", new Dictionary { - { - "tuple_keys", new List> { - new Dictionary { - { "user", "user:bob" }, - { "relation", "reader" }, - { "object", "document:report" } - } - } - } - } - } - }; - - var request = ApiExecutorRequestBuilder - .Of(HttpMethod.Post, "/stores/{store_id}/write") - .Body(writeBody) - .Build(); - - var response = await _fga.GetApiExecutor().SendAsync(request); - - // Verify response - Assert.NotNull(response); - Assert.Equal(System.Net.HttpStatusCode.OK, response.StatusCode); - Assert.True(response.IsSuccessful); - - // Clean up - _fga.StoreId = null; - } - - /// - /// Test Read API using raw request. - /// - [Fact] - public async Task RawRequest_Read_ReadTuples() { - // Setup: Create store, authorization model, and write a tuple - var storeName = "read-test-" + DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); - var storeId = await CreateStoreUsingRawRequest(storeName); - _fga!.StoreId = storeId; - await WriteSimpleAuthorizationModel(storeId); - await WriteTupleUsingRawRequest(storeId, "user:charlie", "reader", "document:plan"); - - // Use ApiExecutor to read tuples - var readBody = new Dictionary { - { - "tuple_key", new Dictionary { - { "user", "user:charlie" }, - { "relation", "reader" }, - { "object", "document:plan" } - } - } - }; - - var request = ApiExecutorRequestBuilder - .Of(HttpMethod.Post, "/stores/{store_id}/read") - .Body(readBody) - .Build(); - - var response = await _fga.GetApiExecutor().SendAsync(request); - - // Verify response - Assert.NotNull(response); - Assert.Equal(System.Net.HttpStatusCode.OK, response.StatusCode); - Assert.True(response.IsSuccessful); - Assert.NotNull(response.Data); - Assert.NotNull(response.Data.Tuples); - Assert.NotEmpty(response.Data.Tuples); - - // Verify the tuple we wrote is present - var foundTuple = response.Data.Tuples.Any(tuple => - tuple.Key.User == "user:charlie" && - tuple.Key.Relation == "reader" && - tuple.Key.Object == "document:plan"); - Assert.True(foundTuple, "Should find the tuple we wrote"); - - // Clean up - _fga.StoreId = null; - } - - /// - /// Test Delete Store using raw request. - /// - [Fact] - public async Task RawRequest_DeleteStore() { - // Create a store first - var storeName = "delete-test-" + DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); - var storeId = await CreateStoreUsingRawRequest(storeName); - - // Use ApiExecutor to delete the store - var request = ApiExecutorRequestBuilder - .Of(HttpMethod.Delete, "/stores/{store_id}") - .PathParam("store_id", storeId) - .Build(); - - var response = await _fga!.GetApiExecutor().SendAsync(request); - - // Verify response - Assert.NotNull(response); - Assert.Equal(System.Net.HttpStatusCode.NoContent, response.StatusCode); - Assert.True(response.IsSuccessful); - } - - // Helper methods - - private async Task CreateStoreUsingRawRequest(string storeName) { - var requestBody = new Dictionary { - { "name", storeName } - }; - - var request = ApiExecutorRequestBuilder - .Of(HttpMethod.Post, "/stores") - .Body(requestBody) - .Build(); - - var response = await _fga!.GetApiExecutor().SendAsync(request); - return response.Data.Id; - } - - private async Task WriteSimpleAuthorizationModel(string storeId) { - var requestBody = new Dictionary { - { "schema_version", "1.1" }, - { - "type_definitions", new List> { - new Dictionary { - { "type", "user" }, - { "relations", new Dictionary() } - }, - new Dictionary { - { "type", "document" }, - { - "relations", new Dictionary { - { - "reader", new Dictionary { - { "this", new Dictionary() } - } - } - } - }, - { - "metadata", new Dictionary { - { - "relations", new Dictionary { - { - "reader", new Dictionary { - { - "directly_related_user_types", new List> { - new Dictionary { { "type", "user" } } - } - } - } - } - } - } - } - } - } - } - } - }; - - var request = ApiExecutorRequestBuilder - .Of(HttpMethod.Post, "/stores/{store_id}/authorization-models") - .PathParam("store_id", storeId) - .Body(requestBody) - .Build(); - - var response = await _fga!.GetApiExecutor().SendAsync(request); - return response.Data.AuthorizationModelId; - } - - private async Task WriteTupleUsingRawRequest(string storeId, string user, string relation, string obj) { - var requestBody = new Dictionary { - { - "writes", new Dictionary { - { - "tuple_keys", new List> { - new Dictionary { - { "user", user }, - { "relation", relation }, - { "object", obj } - } - } - } - } - } - }; - - var request = ApiExecutorRequestBuilder - .Of(HttpMethod.Post, "/stores/{store_id}/write") - .PathParam("store_id", storeId) - .Body(requestBody) - .Build(); - - await _fga!.GetApiExecutor().SendAsync(request); - } -} From b7552512dc98ecc691260f354a4036757aa8d519 Mon Sep 17 00:00:00 2001 From: SoulPancake Date: Wed, 4 Feb 2026 17:37:18 +0530 Subject: [PATCH 11/23] feat: address response tests comments --- .../Client/ApiExecutor/ApiResponseTests.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiResponseTests.cs b/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiResponseTests.cs index e4b6f9f4..47d8903e 100644 --- a/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiResponseTests.cs +++ b/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiResponseTests.cs @@ -89,10 +89,10 @@ public void FromHttpResponse_ContainsAllResponseHeaders() { var response = ApiResponse.FromHttpResponse(httpResponse, rawResponse, data); // Assert - Assert.True(response.Headers.ContainsKey("X-Request-Id")); - Assert.Equal("req-123", response.Headers["X-Request-Id"].First()); - Assert.True(response.Headers.ContainsKey("X-Trace-Id")); - Assert.Equal("trace-456", response.Headers["X-Trace-Id"].First()); + Assert.True(response.Headers.TryGetValue("X-Request-Id", out var requestId)); + Assert.Equal("req-123", requestId.First()); + Assert.True(response.Headers.TryGetValue("X-Trace-Id", out var traceId)); + Assert.Equal("trace-456", traceId.First()); } [Fact] @@ -110,8 +110,8 @@ public void FromHttpResponse_ContainsContentHeaders() { var response = ApiResponse.FromHttpResponse(httpResponse, rawResponse, data); // Assert - Assert.True(response.Headers.ContainsKey("Content-Type")); - Assert.Contains("application/json", response.Headers["Content-Type"].First()); + Assert.True(response.Headers.TryGetValue("Content-Type", out var contentType)); + Assert.Contains("application/json", contentType.First()); } [Fact] From bed99cbad69f8c48f2422905e7128154683ea386 Mon Sep 17 00:00:00 2001 From: SoulPancake Date: Wed, 4 Feb 2026 17:46:54 +0530 Subject: [PATCH 12/23] fix: codeql issues --- .../Client/ApiExecutor/ApiExecutorTests.cs | 8 ++++---- src/OpenFga.Sdk/Model/ReadRequest.cs | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorTests.cs b/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorTests.cs index 8a999242..6bd0e08c 100644 --- a/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorTests.cs +++ b/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorTests.cs @@ -62,7 +62,7 @@ public async Task SendAsync_ValidGetRequest_ReturnsSuccessResponse() { }; responseMessage.Headers.Add("X-Request-Id", "req-123"); - var (client, mockHandler) = CreateMockClient(responseMessage, req => + var (client, _) = CreateMockClient(responseMessage, req => req.Method == HttpMethod.Get && req.RequestUri.ToString().Contains("/stores/" + _storeId)); @@ -251,7 +251,7 @@ public async Task SendAsync_RawResponse_ReturnsJsonString() { Content = new StringContent(expectedJson, Encoding.UTF8, "application/json") }; - var (client, mockHandler) = CreateMockClient(responseMessage); + var (client, _) = CreateMockClient(responseMessage); var request = ApiExecutorRequestBuilder .Of(HttpMethod.Get, "/stores/{store_id}") @@ -283,7 +283,7 @@ public async Task SendAsync_ApiError_ThrowsFgaApiError() { "application/json") }; - var (client, mockHandler) = CreateMockClient(responseMessage); + var (client, _) = CreateMockClient(responseMessage); var request = ApiExecutorRequestBuilder .Of(HttpMethod.Post, "/stores/{store_id}/check") @@ -340,7 +340,7 @@ public async Task SendAsync_TypedResponse_DeserializesCorrectly() { "application/json") }; - var (client, mockHandler) = CreateMockClient(responseMessage); + var (client, _) = CreateMockClient(responseMessage); var request = ApiExecutorRequestBuilder .Of(HttpMethod.Post, "/stores/{store_id}/check") diff --git a/src/OpenFga.Sdk/Model/ReadRequest.cs b/src/OpenFga.Sdk/Model/ReadRequest.cs index 036c51e9..0ec8b327 100644 --- a/src/OpenFga.Sdk/Model/ReadRequest.cs +++ b/src/OpenFga.Sdk/Model/ReadRequest.cs @@ -189,13 +189,13 @@ public override int GetHashCode() public IEnumerable Validate(ValidationContext validationContext) { // PageSize (int) maximum - if (this.PageSize > (int)100) + if (this.PageSize > 100) { yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for PageSize, must be a value less than or equal to 100.", new [] { "PageSize" }); } // PageSize (int) minimum - if (this.PageSize < (int)1) + if (this.PageSize < 1) { yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for PageSize, must be a value greater than or equal to 1.", new [] { "PageSize" }); } From f4da59e0666b5538b1287defdfb41a5063219718 Mon Sep 17 00:00:00 2001 From: SoulPancake Date: Wed, 4 Feb 2026 17:54:56 +0530 Subject: [PATCH 13/23] fix: code fmt --- .../ApiExecutorRequestBuilderTests.cs | 2 +- .../Client/ApiExecutor/ApiExecutorTests.cs | 2 +- .../Client/ApiExecutor/ApiResponseTests.cs | 2 +- src/OpenFga.Sdk/Api/OpenFgaApi.cs | 2 +- .../Client/ApiExecutor/ApiExecutor.cs | 2 +- .../ApiExecutor/ApiExecutorRequestBuilder.cs | 2 +- .../Client/ApiExecutor/ApiResponse.cs | 2 +- src/OpenFga.Sdk/Client/Client.cs | 2 +- src/OpenFga.Sdk/Client/IOpenFgaClient.cs | 3 +- src/OpenFga.Sdk/Constants/FgaConstants.cs | 2 +- .../Model/AbortedMessageResponse.cs | 51 ++++------ src/OpenFga.Sdk/Model/Any.cs | 46 ++++------ src/OpenFga.Sdk/Model/Assertion.cs | 61 +++++------- src/OpenFga.Sdk/Model/AssertionTupleKey.cs | 80 ++++++---------- src/OpenFga.Sdk/Model/AuthErrorCode.cs | 14 +-- src/OpenFga.Sdk/Model/AuthorizationModel.cs | 70 +++++--------- src/OpenFga.Sdk/Model/BatchCheckItem.cs | 67 +++++--------- src/OpenFga.Sdk/Model/BatchCheckRequest.cs | 56 ++++------- src/OpenFga.Sdk/Model/BatchCheckResponse.cs | 46 ++++------ .../Model/BatchCheckSingleResult.cs | 48 ++++------ src/OpenFga.Sdk/Model/CheckError.cs | 50 ++++------ src/OpenFga.Sdk/Model/CheckRequest.cs | 71 ++++++-------- src/OpenFga.Sdk/Model/CheckRequestTupleKey.cs | 80 ++++++---------- src/OpenFga.Sdk/Model/CheckResponse.cs | 48 ++++------ src/OpenFga.Sdk/Model/Computed.cs | 49 ++++------ src/OpenFga.Sdk/Model/Condition.cs | 67 +++++--------- src/OpenFga.Sdk/Model/ConditionMetadata.cs | 51 ++++------ .../Model/ConditionParamTypeRef.cs | 48 ++++------ .../Model/ConsistencyPreference.cs | 14 +-- src/OpenFga.Sdk/Model/ContextualTupleKeys.cs | 49 ++++------ src/OpenFga.Sdk/Model/CreateStoreRequest.cs | 49 ++++------ src/OpenFga.Sdk/Model/CreateStoreResponse.cs | 67 +++++--------- src/OpenFga.Sdk/Model/Difference.cs | 57 ++++-------- src/OpenFga.Sdk/Model/ErrorCode.cs | 14 +-- src/OpenFga.Sdk/Model/ExpandRequest.cs | 61 +++++------- .../Model/ExpandRequestTupleKey.cs | 67 +++++--------- src/OpenFga.Sdk/Model/ExpandResponse.cs | 46 ++++------ src/OpenFga.Sdk/Model/FgaObject.cs | 57 ++++-------- src/OpenFga.Sdk/Model/ForbiddenResponse.cs | 48 ++++------ src/OpenFga.Sdk/Model/GetStoreResponse.cs | 72 ++++++--------- src/OpenFga.Sdk/Model/InternalErrorCode.cs | 14 +-- .../Model/InternalErrorMessageResponse.cs | 48 ++++------ src/OpenFga.Sdk/Model/Leaf.cs | 56 ++++------- src/OpenFga.Sdk/Model/ListObjectsRequest.cs | 92 +++++++------------ src/OpenFga.Sdk/Model/ListObjectsResponse.cs | 49 ++++------ src/OpenFga.Sdk/Model/ListStoresResponse.cs | 57 ++++-------- src/OpenFga.Sdk/Model/ListUsersRequest.cs | 82 ++++++----------- src/OpenFga.Sdk/Model/ListUsersResponse.cs | 49 ++++------ src/OpenFga.Sdk/Model/Metadata.cs | 56 ++++------- src/OpenFga.Sdk/Model/Node.cs | 69 +++++--------- src/OpenFga.Sdk/Model/Nodes.cs | 49 ++++------ src/OpenFga.Sdk/Model/NotFoundErrorCode.cs | 14 +-- src/OpenFga.Sdk/Model/NullValue.cs | 14 +-- src/OpenFga.Sdk/Model/ObjectRelation.cs | 51 ++++------ .../Model/PathUnknownErrorMessageResponse.cs | 48 ++++------ .../Model/ReadAssertionsResponse.cs | 54 ++++------- .../Model/ReadAuthorizationModelResponse.cs | 46 ++++------ .../Model/ReadAuthorizationModelsResponse.cs | 54 ++++------- src/OpenFga.Sdk/Model/ReadChangesResponse.cs | 54 ++++------- src/OpenFga.Sdk/Model/ReadRequest.cs | 65 +++++-------- src/OpenFga.Sdk/Model/ReadRequestTupleKey.cs | 71 ++++++-------- src/OpenFga.Sdk/Model/ReadResponse.cs | 57 ++++-------- src/OpenFga.Sdk/Model/RelationMetadata.cs | 56 ++++------- src/OpenFga.Sdk/Model/RelationReference.cs | 64 +++++-------- .../Model/RelationshipCondition.cs | 59 +++++------- src/OpenFga.Sdk/Model/SourceInfo.cs | 46 ++++------ src/OpenFga.Sdk/Model/Status.cs | 53 ++++------- src/OpenFga.Sdk/Model/Store.cs | 72 ++++++--------- ...reamResultOfStreamedListObjectsResponse.cs | 51 ++++------ .../Model/StreamedListObjectsResponse.cs | 49 ++++------ src/OpenFga.Sdk/Model/Tuple.cs | 54 ++++------- src/OpenFga.Sdk/Model/TupleChange.cs | 47 ++++------ src/OpenFga.Sdk/Model/TupleKey.cs | 85 +++++++---------- .../Model/TupleKeyWithoutCondition.cs | 80 ++++++---------- src/OpenFga.Sdk/Model/TupleOperation.cs | 14 +-- src/OpenFga.Sdk/Model/TupleToUserset.cs | 57 ++++-------- src/OpenFga.Sdk/Model/TypeDefinition.cs | 59 +++++------- src/OpenFga.Sdk/Model/TypeName.cs | 14 +-- src/OpenFga.Sdk/Model/TypedWildcard.cs | 49 ++++------ .../Model/UnauthenticatedResponse.cs | 48 ++++------ .../Model/UnprocessableContentErrorCode.cs | 14 +-- .../UnprocessableContentMessageResponse.cs | 48 ++++------ src/OpenFga.Sdk/Model/User.cs | 56 ++++------- src/OpenFga.Sdk/Model/UserTypeFilter.cs | 54 ++++------- src/OpenFga.Sdk/Model/Users.cs | 49 ++++------ src/OpenFga.Sdk/Model/Userset.cs | 71 ++++++-------- src/OpenFga.Sdk/Model/UsersetTree.cs | 46 ++++------ .../Model/UsersetTreeDifference.cs | 57 ++++-------- .../Model/UsersetTreeTupleToUserset.cs | 57 ++++-------- src/OpenFga.Sdk/Model/UsersetUser.cs | 65 +++++-------- src/OpenFga.Sdk/Model/Usersets.cs | 49 ++++------ .../Model/ValidationErrorMessageResponse.cs | 48 ++++------ .../Model/WriteAssertionsRequest.cs | 49 ++++------ .../Model/WriteAuthorizationModelRequest.cs | 62 +++++-------- .../Model/WriteAuthorizationModelResponse.cs | 49 ++++------ src/OpenFga.Sdk/Model/WriteRequest.cs | 56 ++++------- src/OpenFga.Sdk/Model/WriteRequestDeletes.cs | 54 ++++------- src/OpenFga.Sdk/Model/WriteRequestWrites.cs | 54 ++++------- 98 files changed, 1662 insertions(+), 3007 deletions(-) diff --git a/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorRequestBuilderTests.cs b/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorRequestBuilderTests.cs index 9c80dfe8..f280ad76 100644 --- a/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorRequestBuilderTests.cs +++ b/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorRequestBuilderTests.cs @@ -294,4 +294,4 @@ public void GetHeaders_ReturnsCustomHeaders() { Assert.Equal("value1", headers["X-Custom-Header"]); Assert.Equal("value2", headers["X-Another-Header"]); } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorTests.cs b/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorTests.cs index 6bd0e08c..0ebbd87b 100644 --- a/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorTests.cs +++ b/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorTests.cs @@ -425,4 +425,4 @@ public async Task SendAsync_WithCredentials_IncludesAuthorizationHeader() { ItExpr.IsAny() ); } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiResponseTests.cs b/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiResponseTests.cs index 47d8903e..f54b8dc6 100644 --- a/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiResponseTests.cs +++ b/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiResponseTests.cs @@ -166,4 +166,4 @@ public void RawResponse_PreservesOriginalContent() { // Assert Assert.Equal(rawJson, response.RawResponse); } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Api/OpenFgaApi.cs b/src/OpenFga.Sdk/Api/OpenFgaApi.cs index cabe57dd..456991ec 100644 --- a/src/OpenFga.Sdk/Api/OpenFgaApi.cs +++ b/src/OpenFga.Sdk/Api/OpenFgaApi.cs @@ -667,4 +667,4 @@ public async Task WriteAuthorizationModel(strin public void Dispose() { _apiClient.Dispose(); } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Client/ApiExecutor/ApiExecutor.cs b/src/OpenFga.Sdk/Client/ApiExecutor/ApiExecutor.cs index 5c81a9d8..654ee3b9 100644 --- a/src/OpenFga.Sdk/Client/ApiExecutor/ApiExecutor.cs +++ b/src/OpenFga.Sdk/Client/ApiExecutor/ApiExecutor.cs @@ -121,4 +121,4 @@ public void Dispose() { // ApiClient is owned by OpenFgaApi, so we don't dispose it here GC.SuppressFinalize(this); } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Client/ApiExecutor/ApiExecutorRequestBuilder.cs b/src/OpenFga.Sdk/Client/ApiExecutor/ApiExecutorRequestBuilder.cs index 1b5933d0..ec7d7788 100644 --- a/src/OpenFga.Sdk/Client/ApiExecutor/ApiExecutorRequestBuilder.cs +++ b/src/OpenFga.Sdk/Client/ApiExecutor/ApiExecutorRequestBuilder.cs @@ -169,4 +169,4 @@ internal RequestBuilder ToRequestBuilder(string basePath) { internal IDictionary GetHeaders() { return new Dictionary(_headers); } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Client/ApiExecutor/ApiResponse.cs b/src/OpenFga.Sdk/Client/ApiExecutor/ApiResponse.cs index eb94ecff..9771b356 100644 --- a/src/OpenFga.Sdk/Client/ApiExecutor/ApiResponse.cs +++ b/src/OpenFga.Sdk/Client/ApiExecutor/ApiResponse.cs @@ -100,4 +100,4 @@ private static IReadOnlyDictionary> ConvertHeaders( return headers; } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Client/Client.cs b/src/OpenFga.Sdk/Client/Client.cs index 28161dc5..1a3b2120 100644 --- a/src/OpenFga.Sdk/Client/Client.cs +++ b/src/OpenFga.Sdk/Client/Client.cs @@ -433,7 +433,7 @@ await api.Check( AuthorizationModelId = GetAuthorizationModelId(options), Consistency = options?.Consistency, }, options, cancellationToken); - + /// public async Task ClientBatchCheck(List body, IClientBatchCheckClientOptions? options = default, diff --git a/src/OpenFga.Sdk/Client/IOpenFgaClient.cs b/src/OpenFga.Sdk/Client/IOpenFgaClient.cs index 7c4cde86..7f591317 100644 --- a/src/OpenFga.Sdk/Client/IOpenFgaClient.cs +++ b/src/OpenFga.Sdk/Client/IOpenFgaClient.cs @@ -12,8 +12,7 @@ namespace OpenFga.Sdk.Client; /// /// This interface is provisioned to support unit testing scenarios by making mocking feasible. /// -public interface IOpenFgaClient -{ +public interface IOpenFgaClient { /// /// StoreId - The ID of the FGA store. /// diff --git a/src/OpenFga.Sdk/Constants/FgaConstants.cs b/src/OpenFga.Sdk/Constants/FgaConstants.cs index 43628439..53c1a8eb 100644 --- a/src/OpenFga.Sdk/Constants/FgaConstants.cs +++ b/src/OpenFga.Sdk/Constants/FgaConstants.cs @@ -153,4 +153,4 @@ public static class FgaConstants { /// Prime number used as a multiplier in hash code calculations. /// public const int HashCodeMultiplierPrimeNumber = 9923; -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/AbortedMessageResponse.cs b/src/OpenFga.Sdk/Model/AbortedMessageResponse.cs index 3ab5d026..3d5a62e7 100644 --- a/src/OpenFga.Sdk/Model/AbortedMessageResponse.cs +++ b/src/OpenFga.Sdk/Model/AbortedMessageResponse.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// AbortedMessageResponse /// [DataContract(Name = "AbortedMessageResponse")] - public partial class AbortedMessageResponse : IEquatable, IValidatableObject - { + public partial class AbortedMessageResponse : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public AbortedMessageResponse() - { + public AbortedMessageResponse() { this.AdditionalProperties = new Dictionary(); } @@ -44,8 +39,7 @@ public AbortedMessageResponse() /// /// code. /// message. - public AbortedMessageResponse(string code = default, string message = default) - { + public AbortedMessageResponse(string code = default, string message = default) { this.Code = code; this.Message = message; this.AdditionalProperties = new Dictionary(); @@ -78,8 +72,7 @@ public AbortedMessageResponse(string code = default, string message = default) /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -96,8 +89,7 @@ public static AbortedMessageResponse FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((AbortedMessageResponse)input); } @@ -107,18 +99,16 @@ public override bool Equals(object input) /// /// Instance of AbortedMessageResponse to be compared /// Boolean - public bool Equals(AbortedMessageResponse input) - { - if (input == null) - { + public bool Equals(AbortedMessageResponse input) { + if (input == null) { return false; } - return + return ( this.Code == input.Code || (this.Code != null && this.Code.Equals(input.Code)) - ) && + ) && ( this.Message == input.Message || (this.Message != null && @@ -131,21 +121,17 @@ public bool Equals(AbortedMessageResponse input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Code != null) - { + if (this.Code != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Code.GetHashCode(); } - if (this.Message != null) - { + if (this.Message != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Message.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -157,11 +143,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/Any.cs b/src/OpenFga.Sdk/Model/Any.cs index 26252275..d3000f78 100644 --- a/src/OpenFga.Sdk/Model/Any.cs +++ b/src/OpenFga.Sdk/Model/Any.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// Any /// [DataContract(Name = "Any")] - public partial class Any : IEquatable, IValidatableObject - { + public partial class Any : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public Any() - { + public Any() { this.AdditionalProperties = new Dictionary(); } @@ -43,8 +38,7 @@ public Any() /// Initializes a new instance of the class. /// /// type. - public Any(string type = default) - { + public Any(string type = default) { this.Type = type; this.AdditionalProperties = new Dictionary(); } @@ -68,8 +62,7 @@ public Any(string type = default) /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -86,8 +79,7 @@ public static Any FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((Any)input); } @@ -97,13 +89,11 @@ public override bool Equals(object input) /// /// Instance of Any to be compared /// Boolean - public bool Equals(Any input) - { - if (input == null) - { + public bool Equals(Any input) { + if (input == null) { return false; } - return + return ( this.Type == input.Type || (this.Type != null && @@ -116,17 +106,14 @@ public bool Equals(Any input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Type != null) - { + if (this.Type != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Type.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -138,11 +125,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/Assertion.cs b/src/OpenFga.Sdk/Model/Assertion.cs index 3ddf2325..cf2fd1d3 100644 --- a/src/OpenFga.Sdk/Model/Assertion.cs +++ b/src/OpenFga.Sdk/Model/Assertion.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// Assertion /// [DataContract(Name = "Assertion")] - public partial class Assertion : IEquatable, IValidatableObject - { + public partial class Assertion : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public Assertion() - { + public Assertion() { this.AdditionalProperties = new Dictionary(); } @@ -46,11 +41,9 @@ public Assertion() /// expectation (required). /// contextualTuples. /// Additional request context that will be used to evaluate any ABAC conditions encountered in the query evaluation.. - public Assertion(AssertionTupleKey tupleKey = default, bool expectation = default, List contextualTuples = default, Object context = default) - { + public Assertion(AssertionTupleKey tupleKey = default, bool expectation = default, List contextualTuples = default, Object context = default) { // to ensure "tupleKey" is required (not null) - if (tupleKey == null) - { + if (tupleKey == null) { throw new ArgumentNullException("tupleKey is a required property for Assertion and cannot be null"); } this.TupleKey = tupleKey; @@ -104,8 +97,7 @@ public Assertion(AssertionTupleKey tupleKey = default, bool expectation = defaul /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -122,8 +114,7 @@ public static Assertion FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((Assertion)input); } @@ -133,28 +124,26 @@ public override bool Equals(object input) /// /// Instance of Assertion to be compared /// Boolean - public bool Equals(Assertion input) - { - if (input == null) - { + public bool Equals(Assertion input) { + if (input == null) { return false; } - return + return ( this.TupleKey == input.TupleKey || (this.TupleKey != null && this.TupleKey.Equals(input.TupleKey)) - ) && + ) && ( this.Expectation == input.Expectation || this.Expectation.Equals(input.Expectation) - ) && + ) && ( this.ContextualTuples == input.ContextualTuples || this.ContextualTuples != null && input.ContextualTuples != null && this.ContextualTuples.SequenceEqual(input.ContextualTuples) - ) && + ) && ( this.Context == input.Context || (this.Context != null && @@ -167,26 +156,21 @@ public bool Equals(Assertion input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.TupleKey != null) - { + if (this.TupleKey != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.TupleKey.GetHashCode(); } hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Expectation.GetHashCode(); - if (this.ContextualTuples != null) - { + if (this.ContextualTuples != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.ContextualTuples.GetHashCode(); } - if (this.Context != null) - { + if (this.Context != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Context.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -198,11 +182,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/AssertionTupleKey.cs b/src/OpenFga.Sdk/Model/AssertionTupleKey.cs index 02ab2072..1277083d 100644 --- a/src/OpenFga.Sdk/Model/AssertionTupleKey.cs +++ b/src/OpenFga.Sdk/Model/AssertionTupleKey.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// AssertionTupleKey /// [DataContract(Name = "AssertionTupleKey")] - public partial class AssertionTupleKey : IEquatable, IValidatableObject - { + public partial class AssertionTupleKey : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public AssertionTupleKey() - { + public AssertionTupleKey() { this.AdditionalProperties = new Dictionary(); } @@ -45,23 +40,19 @@ public AssertionTupleKey() /// varObject (required). /// relation (required). /// user (required). - public AssertionTupleKey(string varObject = default, string relation = default, string user = default) - { + public AssertionTupleKey(string varObject = default, string relation = default, string user = default) { // to ensure "varObject" is required (not null) - if (varObject == null) - { + if (varObject == null) { throw new ArgumentNullException("varObject is a required property for AssertionTupleKey and cannot be null"); } this.Object = varObject; // to ensure "relation" is required (not null) - if (relation == null) - { + if (relation == null) { throw new ArgumentNullException("relation is a required property for AssertionTupleKey and cannot be null"); } this.Relation = relation; // to ensure "user" is required (not null) - if (user == null) - { + if (user == null) { throw new ArgumentNullException("user is a required property for AssertionTupleKey and cannot be null"); } this.User = user; @@ -103,8 +94,7 @@ public AssertionTupleKey(string varObject = default, string relation = default, /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -121,8 +111,7 @@ public static AssertionTupleKey FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((AssertionTupleKey)input); } @@ -132,23 +121,21 @@ public override bool Equals(object input) /// /// Instance of AssertionTupleKey to be compared /// Boolean - public bool Equals(AssertionTupleKey input) - { - if (input == null) - { + public bool Equals(AssertionTupleKey input) { + if (input == null) { return false; } - return + return ( this.Object == input.Object || (this.Object != null && this.Object.Equals(input.Object)) - ) && + ) && ( this.Relation == input.Relation || (this.Relation != null && this.Relation.Equals(input.Relation)) - ) && + ) && ( this.User == input.User || (this.User != null && @@ -161,25 +148,20 @@ public bool Equals(AssertionTupleKey input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Object != null) - { + if (this.Object != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Object.GetHashCode(); } - if (this.Relation != null) - { + if (this.Relation != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Relation.GetHashCode(); } - if (this.User != null) - { + if (this.User != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.User.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -191,24 +173,20 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { // Object (string) maxLength - if (this.Object != null && this.Object.Length > 256) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Object, length must be less than 256.", new [] { "Object" }); + if (this.Object != null && this.Object.Length > 256) { + yield return new ValidationResult("Invalid value for Object, length must be less than 256.", new[] { "Object" }); } // Relation (string) maxLength - if (this.Relation != null && this.Relation.Length > 50) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Relation, length must be less than 50.", new [] { "Relation" }); + if (this.Relation != null && this.Relation.Length > 50) { + yield return new ValidationResult("Invalid value for Relation, length must be less than 50.", new[] { "Relation" }); } // User (string) maxLength - if (this.User != null && this.User.Length > 512) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for User, length must be less than 512.", new [] { "User" }); + if (this.User != null && this.User.Length > 512) { + yield return new ValidationResult("Invalid value for User, length must be less than 512.", new[] { "User" }); } yield break; @@ -216,4 +194,4 @@ public override int GetHashCode() } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/AuthErrorCode.cs b/src/OpenFga.Sdk/Model/AuthErrorCode.cs index 8ac3a64a..f9dd1753 100644 --- a/src/OpenFga.Sdk/Model/AuthErrorCode.cs +++ b/src/OpenFga.Sdk/Model/AuthErrorCode.cs @@ -11,25 +11,21 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// Defines AuthErrorCode /// [JsonConverter(typeof(JsonStringEnumMemberConverter))] - public enum AuthErrorCode - { + public enum AuthErrorCode { /// /// Enum NoAuthError for value: no_auth_error /// @@ -86,4 +82,4 @@ public enum AuthErrorCode } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/AuthorizationModel.cs b/src/OpenFga.Sdk/Model/AuthorizationModel.cs index f0e0a4da..ca78cdec 100644 --- a/src/OpenFga.Sdk/Model/AuthorizationModel.cs +++ b/src/OpenFga.Sdk/Model/AuthorizationModel.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// AuthorizationModel /// [DataContract(Name = "AuthorizationModel")] - public partial class AuthorizationModel : IEquatable, IValidatableObject - { + public partial class AuthorizationModel : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public AuthorizationModel() - { + public AuthorizationModel() { this.AdditionalProperties = new Dictionary(); } @@ -46,23 +41,19 @@ public AuthorizationModel() /// schemaVersion (required). /// typeDefinitions (required). /// conditions. - public AuthorizationModel(string id = default, string schemaVersion = default, List typeDefinitions = default, Dictionary conditions = default) - { + public AuthorizationModel(string id = default, string schemaVersion = default, List typeDefinitions = default, Dictionary conditions = default) { // to ensure "id" is required (not null) - if (id == null) - { + if (id == null) { throw new ArgumentNullException("id is a required property for AuthorizationModel and cannot be null"); } this.Id = id; // to ensure "schemaVersion" is required (not null) - if (schemaVersion == null) - { + if (schemaVersion == null) { throw new ArgumentNullException("schemaVersion is a required property for AuthorizationModel and cannot be null"); } this.SchemaVersion = schemaVersion; // to ensure "typeDefinitions" is required (not null) - if (typeDefinitions == null) - { + if (typeDefinitions == null) { throw new ArgumentNullException("typeDefinitions is a required property for AuthorizationModel and cannot be null"); } this.TypeDefinitions = typeDefinitions; @@ -113,8 +104,7 @@ public AuthorizationModel(string id = default, string schemaVersion = default, L /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -131,8 +121,7 @@ public static AuthorizationModel FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((AuthorizationModel)input); } @@ -142,29 +131,27 @@ public override bool Equals(object input) /// /// Instance of AuthorizationModel to be compared /// Boolean - public bool Equals(AuthorizationModel input) - { - if (input == null) - { + public bool Equals(AuthorizationModel input) { + if (input == null) { return false; } - return + return ( this.Id == input.Id || (this.Id != null && this.Id.Equals(input.Id)) - ) && + ) && ( this.SchemaVersion == input.SchemaVersion || (this.SchemaVersion != null && this.SchemaVersion.Equals(input.SchemaVersion)) - ) && + ) && ( this.TypeDefinitions == input.TypeDefinitions || this.TypeDefinitions != null && input.TypeDefinitions != null && this.TypeDefinitions.SequenceEqual(input.TypeDefinitions) - ) && + ) && ( this.Conditions == input.Conditions || this.Conditions != null && @@ -178,29 +165,23 @@ public bool Equals(AuthorizationModel input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Id != null) - { + if (this.Id != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Id.GetHashCode(); } - if (this.SchemaVersion != null) - { + if (this.SchemaVersion != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.SchemaVersion.GetHashCode(); } - if (this.TypeDefinitions != null) - { + if (this.TypeDefinitions != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.TypeDefinitions.GetHashCode(); } - if (this.Conditions != null) - { + if (this.Conditions != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Conditions.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -212,11 +193,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/BatchCheckItem.cs b/src/OpenFga.Sdk/Model/BatchCheckItem.cs index 2a08a95d..b8697524 100644 --- a/src/OpenFga.Sdk/Model/BatchCheckItem.cs +++ b/src/OpenFga.Sdk/Model/BatchCheckItem.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// BatchCheckItem /// [DataContract(Name = "BatchCheckItem")] - public partial class BatchCheckItem : IEquatable, IValidatableObject - { + public partial class BatchCheckItem : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public BatchCheckItem() - { + public BatchCheckItem() { this.AdditionalProperties = new Dictionary(); } @@ -46,17 +41,14 @@ public BatchCheckItem() /// contextualTuples. /// context. /// correlation_id must be a string containing only letters, numbers, or hyphens, with length ≤ 36 characters. (required). - public BatchCheckItem(CheckRequestTupleKey tupleKey = default, ContextualTupleKeys contextualTuples = default, Object context = default, string correlationId = default) - { + public BatchCheckItem(CheckRequestTupleKey tupleKey = default, ContextualTupleKeys contextualTuples = default, Object context = default, string correlationId = default) { // to ensure "tupleKey" is required (not null) - if (tupleKey == null) - { + if (tupleKey == null) { throw new ArgumentNullException("tupleKey is a required property for BatchCheckItem and cannot be null"); } this.TupleKey = tupleKey; // to ensure "correlationId" is required (not null) - if (correlationId == null) - { + if (correlationId == null) { throw new ArgumentNullException("correlationId is a required property for BatchCheckItem and cannot be null"); } this.CorrelationId = correlationId; @@ -109,8 +101,7 @@ public BatchCheckItem(CheckRequestTupleKey tupleKey = default, ContextualTupleKe /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -127,8 +118,7 @@ public static BatchCheckItem FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((BatchCheckItem)input); } @@ -138,28 +128,26 @@ public override bool Equals(object input) /// /// Instance of BatchCheckItem to be compared /// Boolean - public bool Equals(BatchCheckItem input) - { - if (input == null) - { + public bool Equals(BatchCheckItem input) { + if (input == null) { return false; } - return + return ( this.TupleKey == input.TupleKey || (this.TupleKey != null && this.TupleKey.Equals(input.TupleKey)) - ) && + ) && ( this.ContextualTuples == input.ContextualTuples || (this.ContextualTuples != null && this.ContextualTuples.Equals(input.ContextualTuples)) - ) && + ) && ( this.Context == input.Context || (this.Context != null && this.Context.Equals(input.Context)) - ) && + ) && ( this.CorrelationId == input.CorrelationId || (this.CorrelationId != null && @@ -172,29 +160,23 @@ public bool Equals(BatchCheckItem input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.TupleKey != null) - { + if (this.TupleKey != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.TupleKey.GetHashCode(); } - if (this.ContextualTuples != null) - { + if (this.ContextualTuples != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.ContextualTuples.GetHashCode(); } - if (this.Context != null) - { + if (this.Context != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Context.GetHashCode(); } - if (this.CorrelationId != null) - { + if (this.CorrelationId != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.CorrelationId.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -206,11 +188,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/BatchCheckRequest.cs b/src/OpenFga.Sdk/Model/BatchCheckRequest.cs index 37281356..bc86ccd2 100644 --- a/src/OpenFga.Sdk/Model/BatchCheckRequest.cs +++ b/src/OpenFga.Sdk/Model/BatchCheckRequest.cs @@ -11,25 +11,21 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// BatchCheckRequest /// [DataContract(Name = "BatchCheck_request")] - public partial class BatchCheckRequest : IEquatable, IValidatableObject - { + public partial class BatchCheckRequest : IEquatable, IValidatableObject { /// /// Gets or Sets Consistency @@ -41,8 +37,7 @@ public partial class BatchCheckRequest : IEquatable, IValidat /// Initializes a new instance of the class. /// [JsonConstructor] - public BatchCheckRequest() - { + public BatchCheckRequest() { this.AdditionalProperties = new Dictionary(); } @@ -52,11 +47,9 @@ public BatchCheckRequest() /// checks (required). /// authorizationModelId. /// consistency. - public BatchCheckRequest(List checks = default, string authorizationModelId = default, ConsistencyPreference? consistency = default) - { + public BatchCheckRequest(List checks = default, string authorizationModelId = default, ConsistencyPreference? consistency = default) { // to ensure "checks" is required (not null) - if (checks == null) - { + if (checks == null) { throw new ArgumentNullException("checks is a required property for BatchCheckRequest and cannot be null"); } this.Checks = checks; @@ -92,8 +85,7 @@ public BatchCheckRequest(List checks = default, string authoriza /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -110,8 +102,7 @@ public static BatchCheckRequest FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((BatchCheckRequest)input); } @@ -121,24 +112,22 @@ public override bool Equals(object input) /// /// Instance of BatchCheckRequest to be compared /// Boolean - public bool Equals(BatchCheckRequest input) - { - if (input == null) - { + public bool Equals(BatchCheckRequest input) { + if (input == null) { return false; } - return + return ( this.Checks == input.Checks || this.Checks != null && input.Checks != null && this.Checks.SequenceEqual(input.Checks) - ) && + ) && ( this.AuthorizationModelId == input.AuthorizationModelId || (this.AuthorizationModelId != null && this.AuthorizationModelId.Equals(input.AuthorizationModelId)) - ) && + ) && ( this.Consistency == input.Consistency || this.Consistency.Equals(input.Consistency) @@ -150,22 +139,18 @@ public bool Equals(BatchCheckRequest input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Checks != null) - { + if (this.Checks != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Checks.GetHashCode(); } - if (this.AuthorizationModelId != null) - { + if (this.AuthorizationModelId != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AuthorizationModelId.GetHashCode(); } hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Consistency.GetHashCode(); - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -177,11 +162,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/BatchCheckResponse.cs b/src/OpenFga.Sdk/Model/BatchCheckResponse.cs index 91835f08..760e2551 100644 --- a/src/OpenFga.Sdk/Model/BatchCheckResponse.cs +++ b/src/OpenFga.Sdk/Model/BatchCheckResponse.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// BatchCheckResponse /// [DataContract(Name = "BatchCheckResponse")] - public partial class BatchCheckResponse : IEquatable, IValidatableObject - { + public partial class BatchCheckResponse : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public BatchCheckResponse() - { + public BatchCheckResponse() { this.AdditionalProperties = new Dictionary(); } @@ -43,8 +38,7 @@ public BatchCheckResponse() /// Initializes a new instance of the class. /// /// map keys are the correlation_id values from the BatchCheckItems in the request. - public BatchCheckResponse(Dictionary result = default) - { + public BatchCheckResponse(Dictionary result = default) { this.Result = result; this.AdditionalProperties = new Dictionary(); } @@ -69,8 +63,7 @@ public BatchCheckResponse(Dictionary result = de /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -87,8 +80,7 @@ public static BatchCheckResponse FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((BatchCheckResponse)input); } @@ -98,13 +90,11 @@ public override bool Equals(object input) /// /// Instance of BatchCheckResponse to be compared /// Boolean - public bool Equals(BatchCheckResponse input) - { - if (input == null) - { + public bool Equals(BatchCheckResponse input) { + if (input == null) { return false; } - return + return ( this.Result == input.Result || this.Result != null && @@ -118,17 +108,14 @@ public bool Equals(BatchCheckResponse input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Result != null) - { + if (this.Result != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Result.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -140,11 +127,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/BatchCheckSingleResult.cs b/src/OpenFga.Sdk/Model/BatchCheckSingleResult.cs index 1747af6d..ae2da0d9 100644 --- a/src/OpenFga.Sdk/Model/BatchCheckSingleResult.cs +++ b/src/OpenFga.Sdk/Model/BatchCheckSingleResult.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// BatchCheckSingleResult /// [DataContract(Name = "BatchCheckSingleResult")] - public partial class BatchCheckSingleResult : IEquatable, IValidatableObject - { + public partial class BatchCheckSingleResult : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public BatchCheckSingleResult() - { + public BatchCheckSingleResult() { this.AdditionalProperties = new Dictionary(); } @@ -44,8 +39,7 @@ public BatchCheckSingleResult() /// /// allowed. /// error. - public BatchCheckSingleResult(bool allowed = default, CheckError error = default) - { + public BatchCheckSingleResult(bool allowed = default, CheckError error = default) { this.Allowed = allowed; this.Error = error; this.AdditionalProperties = new Dictionary(); @@ -78,8 +72,7 @@ public BatchCheckSingleResult(bool allowed = default, CheckError error = default /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -96,8 +89,7 @@ public static BatchCheckSingleResult FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((BatchCheckSingleResult)input); } @@ -107,17 +99,15 @@ public override bool Equals(object input) /// /// Instance of BatchCheckSingleResult to be compared /// Boolean - public bool Equals(BatchCheckSingleResult input) - { - if (input == null) - { + public bool Equals(BatchCheckSingleResult input) { + if (input == null) { return false; } - return + return ( this.Allowed == input.Allowed || this.Allowed.Equals(input.Allowed) - ) && + ) && ( this.Error == input.Error || (this.Error != null && @@ -130,18 +120,15 @@ public bool Equals(BatchCheckSingleResult input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Allowed.GetHashCode(); - if (this.Error != null) - { + if (this.Error != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Error.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -153,11 +140,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/CheckError.cs b/src/OpenFga.Sdk/Model/CheckError.cs index d76efe03..ad35e8ae 100644 --- a/src/OpenFga.Sdk/Model/CheckError.cs +++ b/src/OpenFga.Sdk/Model/CheckError.cs @@ -11,25 +11,21 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// CheckError /// [DataContract(Name = "CheckError")] - public partial class CheckError : IEquatable, IValidatableObject - { + public partial class CheckError : IEquatable, IValidatableObject { /// /// Gets or Sets InputError @@ -48,8 +44,7 @@ public partial class CheckError : IEquatable, IValidatableObject /// Initializes a new instance of the class. /// [JsonConstructor] - public CheckError() - { + public CheckError() { this.AdditionalProperties = new Dictionary(); } @@ -59,8 +54,7 @@ public CheckError() /// inputError. /// internalError. /// message. - public CheckError(ErrorCode? inputError = default, InternalErrorCode? internalError = default, string message = default) - { + public CheckError(ErrorCode? inputError = default, InternalErrorCode? internalError = default, string message = default) { this.InputError = inputError; this.InternalError = internalError; this.Message = message; @@ -86,8 +80,7 @@ public CheckError(ErrorCode? inputError = default, InternalErrorCode? internalEr /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -104,8 +97,7 @@ public static CheckError FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((CheckError)input); } @@ -115,21 +107,19 @@ public override bool Equals(object input) /// /// Instance of CheckError to be compared /// Boolean - public bool Equals(CheckError input) - { - if (input == null) - { + public bool Equals(CheckError input) { + if (input == null) { return false; } - return + return ( this.InputError == input.InputError || this.InputError.Equals(input.InputError) - ) && + ) && ( this.InternalError == input.InternalError || this.InternalError.Equals(input.InternalError) - ) && + ) && ( this.Message == input.Message || (this.Message != null && @@ -142,19 +132,16 @@ public bool Equals(CheckError input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.InputError.GetHashCode(); hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.InternalError.GetHashCode(); - if (this.Message != null) - { + if (this.Message != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Message.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -166,11 +153,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/CheckRequest.cs b/src/OpenFga.Sdk/Model/CheckRequest.cs index 182b0c27..16f0ccb5 100644 --- a/src/OpenFga.Sdk/Model/CheckRequest.cs +++ b/src/OpenFga.Sdk/Model/CheckRequest.cs @@ -11,25 +11,21 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// CheckRequest /// [DataContract(Name = "Check_request")] - public partial class CheckRequest : IEquatable, IValidatableObject - { + public partial class CheckRequest : IEquatable, IValidatableObject { /// /// Gets or Sets Consistency @@ -41,8 +37,7 @@ public partial class CheckRequest : IEquatable, IValidatableObject /// Initializes a new instance of the class. /// [JsonConstructor] - public CheckRequest() - { + public CheckRequest() { this.AdditionalProperties = new Dictionary(); } @@ -54,11 +49,9 @@ public CheckRequest() /// authorizationModelId. /// Additional request context that will be used to evaluate any ABAC conditions encountered in the query evaluation.. /// consistency. - public CheckRequest(CheckRequestTupleKey tupleKey = default, ContextualTupleKeys contextualTuples = default, string authorizationModelId = default, Object context = default, ConsistencyPreference? consistency = default) - { + public CheckRequest(CheckRequestTupleKey tupleKey = default, ContextualTupleKeys contextualTuples = default, string authorizationModelId = default, Object context = default, ConsistencyPreference? consistency = default) { // to ensure "tupleKey" is required (not null) - if (tupleKey == null) - { + if (tupleKey == null) { throw new ArgumentNullException("tupleKey is a required property for CheckRequest and cannot be null"); } this.TupleKey = tupleKey; @@ -106,8 +99,7 @@ public CheckRequest(CheckRequestTupleKey tupleKey = default, ContextualTupleKeys /// Returns false as Trace should not be serialized given that it's read-only. /// /// false (boolean) - public bool ShouldSerializeTrace() - { + public bool ShouldSerializeTrace() { return false; } /// @@ -130,8 +122,7 @@ public bool ShouldSerializeTrace() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -148,8 +139,7 @@ public static CheckRequest FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((CheckRequest)input); } @@ -159,37 +149,35 @@ public override bool Equals(object input) /// /// Instance of CheckRequest to be compared /// Boolean - public bool Equals(CheckRequest input) - { - if (input == null) - { + public bool Equals(CheckRequest input) { + if (input == null) { return false; } - return + return ( this.TupleKey == input.TupleKey || (this.TupleKey != null && this.TupleKey.Equals(input.TupleKey)) - ) && + ) && ( this.ContextualTuples == input.ContextualTuples || (this.ContextualTuples != null && this.ContextualTuples.Equals(input.ContextualTuples)) - ) && + ) && ( this.AuthorizationModelId == input.AuthorizationModelId || (this.AuthorizationModelId != null && this.AuthorizationModelId.Equals(input.AuthorizationModelId)) - ) && + ) && ( this.Trace == input.Trace || this.Trace.Equals(input.Trace) - ) && + ) && ( this.Context == input.Context || (this.Context != null && this.Context.Equals(input.Context)) - ) && + ) && ( this.Consistency == input.Consistency || this.Consistency.Equals(input.Consistency) @@ -201,31 +189,25 @@ public bool Equals(CheckRequest input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.TupleKey != null) - { + if (this.TupleKey != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.TupleKey.GetHashCode(); } - if (this.ContextualTuples != null) - { + if (this.ContextualTuples != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.ContextualTuples.GetHashCode(); } - if (this.AuthorizationModelId != null) - { + if (this.AuthorizationModelId != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AuthorizationModelId.GetHashCode(); } hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Trace.GetHashCode(); - if (this.Context != null) - { + if (this.Context != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Context.GetHashCode(); } hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Consistency.GetHashCode(); - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -237,11 +219,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/CheckRequestTupleKey.cs b/src/OpenFga.Sdk/Model/CheckRequestTupleKey.cs index 6d3a3960..5fa08e22 100644 --- a/src/OpenFga.Sdk/Model/CheckRequestTupleKey.cs +++ b/src/OpenFga.Sdk/Model/CheckRequestTupleKey.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// CheckRequestTupleKey /// [DataContract(Name = "CheckRequestTupleKey")] - public partial class CheckRequestTupleKey : IEquatable, IValidatableObject - { + public partial class CheckRequestTupleKey : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public CheckRequestTupleKey() - { + public CheckRequestTupleKey() { this.AdditionalProperties = new Dictionary(); } @@ -45,23 +40,19 @@ public CheckRequestTupleKey() /// user (required). /// relation (required). /// varObject (required). - public CheckRequestTupleKey(string user = default, string relation = default, string varObject = default) - { + public CheckRequestTupleKey(string user = default, string relation = default, string varObject = default) { // to ensure "user" is required (not null) - if (user == null) - { + if (user == null) { throw new ArgumentNullException("user is a required property for CheckRequestTupleKey and cannot be null"); } this.User = user; // to ensure "relation" is required (not null) - if (relation == null) - { + if (relation == null) { throw new ArgumentNullException("relation is a required property for CheckRequestTupleKey and cannot be null"); } this.Relation = relation; // to ensure "varObject" is required (not null) - if (varObject == null) - { + if (varObject == null) { throw new ArgumentNullException("varObject is a required property for CheckRequestTupleKey and cannot be null"); } this.Object = varObject; @@ -103,8 +94,7 @@ public CheckRequestTupleKey(string user = default, string relation = default, st /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -121,8 +111,7 @@ public static CheckRequestTupleKey FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((CheckRequestTupleKey)input); } @@ -132,23 +121,21 @@ public override bool Equals(object input) /// /// Instance of CheckRequestTupleKey to be compared /// Boolean - public bool Equals(CheckRequestTupleKey input) - { - if (input == null) - { + public bool Equals(CheckRequestTupleKey input) { + if (input == null) { return false; } - return + return ( this.User == input.User || (this.User != null && this.User.Equals(input.User)) - ) && + ) && ( this.Relation == input.Relation || (this.Relation != null && this.Relation.Equals(input.Relation)) - ) && + ) && ( this.Object == input.Object || (this.Object != null && @@ -161,25 +148,20 @@ public bool Equals(CheckRequestTupleKey input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.User != null) - { + if (this.User != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.User.GetHashCode(); } - if (this.Relation != null) - { + if (this.Relation != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Relation.GetHashCode(); } - if (this.Object != null) - { + if (this.Object != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Object.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -191,24 +173,20 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { // User (string) maxLength - if (this.User != null && this.User.Length > 512) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for User, length must be less than 512.", new [] { "User" }); + if (this.User != null && this.User.Length > 512) { + yield return new ValidationResult("Invalid value for User, length must be less than 512.", new[] { "User" }); } // Relation (string) maxLength - if (this.Relation != null && this.Relation.Length > 50) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Relation, length must be less than 50.", new [] { "Relation" }); + if (this.Relation != null && this.Relation.Length > 50) { + yield return new ValidationResult("Invalid value for Relation, length must be less than 50.", new[] { "Relation" }); } // Object (string) maxLength - if (this.Object != null && this.Object.Length > 256) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Object, length must be less than 256.", new [] { "Object" }); + if (this.Object != null && this.Object.Length > 256) { + yield return new ValidationResult("Invalid value for Object, length must be less than 256.", new[] { "Object" }); } yield break; @@ -216,4 +194,4 @@ public override int GetHashCode() } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/CheckResponse.cs b/src/OpenFga.Sdk/Model/CheckResponse.cs index 09d34ade..a89d4e68 100644 --- a/src/OpenFga.Sdk/Model/CheckResponse.cs +++ b/src/OpenFga.Sdk/Model/CheckResponse.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// CheckResponse /// [DataContract(Name = "CheckResponse")] - public partial class CheckResponse : IEquatable, IValidatableObject - { + public partial class CheckResponse : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public CheckResponse() - { + public CheckResponse() { this.AdditionalProperties = new Dictionary(); } @@ -44,8 +39,7 @@ public CheckResponse() /// /// allowed. /// For internal use only.. - public CheckResponse(bool allowed = default, string resolution = default) - { + public CheckResponse(bool allowed = default, string resolution = default) { this.Allowed = allowed; this.Resolution = resolution; this.AdditionalProperties = new Dictionary(); @@ -79,8 +73,7 @@ public CheckResponse(bool allowed = default, string resolution = default) /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -97,8 +90,7 @@ public static CheckResponse FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((CheckResponse)input); } @@ -108,17 +100,15 @@ public override bool Equals(object input) /// /// Instance of CheckResponse to be compared /// Boolean - public bool Equals(CheckResponse input) - { - if (input == null) - { + public bool Equals(CheckResponse input) { + if (input == null) { return false; } - return + return ( this.Allowed == input.Allowed || this.Allowed.Equals(input.Allowed) - ) && + ) && ( this.Resolution == input.Resolution || (this.Resolution != null && @@ -131,18 +121,15 @@ public bool Equals(CheckResponse input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Allowed.GetHashCode(); - if (this.Resolution != null) - { + if (this.Resolution != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Resolution.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -154,11 +141,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/Computed.cs b/src/OpenFga.Sdk/Model/Computed.cs index 5745d4fa..08e311ec 100644 --- a/src/OpenFga.Sdk/Model/Computed.cs +++ b/src/OpenFga.Sdk/Model/Computed.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// Computed /// [DataContract(Name = "Computed")] - public partial class Computed : IEquatable, IValidatableObject - { + public partial class Computed : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public Computed() - { + public Computed() { this.AdditionalProperties = new Dictionary(); } @@ -43,11 +38,9 @@ public Computed() /// Initializes a new instance of the class. /// /// userset (required). - public Computed(string userset = default) - { + public Computed(string userset = default) { // to ensure "userset" is required (not null) - if (userset == null) - { + if (userset == null) { throw new ArgumentNullException("userset is a required property for Computed and cannot be null"); } this.Userset = userset; @@ -73,8 +66,7 @@ public Computed(string userset = default) /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -91,8 +83,7 @@ public static Computed FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((Computed)input); } @@ -102,13 +93,11 @@ public override bool Equals(object input) /// /// Instance of Computed to be compared /// Boolean - public bool Equals(Computed input) - { - if (input == null) - { + public bool Equals(Computed input) { + if (input == null) { return false; } - return + return ( this.Userset == input.Userset || (this.Userset != null && @@ -121,17 +110,14 @@ public bool Equals(Computed input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Userset != null) - { + if (this.Userset != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Userset.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -143,11 +129,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/Condition.cs b/src/OpenFga.Sdk/Model/Condition.cs index d6e26e93..6c8c6140 100644 --- a/src/OpenFga.Sdk/Model/Condition.cs +++ b/src/OpenFga.Sdk/Model/Condition.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// Condition /// [DataContract(Name = "Condition")] - public partial class Condition : IEquatable, IValidatableObject - { + public partial class Condition : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public Condition() - { + public Condition() { this.AdditionalProperties = new Dictionary(); } @@ -46,17 +41,14 @@ public Condition() /// A Google CEL expression, expressed as a string. (required). /// A map of parameter names to the parameter's defined type reference.. /// metadata. - public Condition(string name = default, string expression = default, Dictionary parameters = default, ConditionMetadata metadata = default) - { + public Condition(string name = default, string expression = default, Dictionary parameters = default, ConditionMetadata metadata = default) { // to ensure "name" is required (not null) - if (name == null) - { + if (name == null) { throw new ArgumentNullException("name is a required property for Condition and cannot be null"); } this.Name = name; // to ensure "expression" is required (not null) - if (expression == null) - { + if (expression == null) { throw new ArgumentNullException("expression is a required property for Condition and cannot be null"); } this.Expression = expression; @@ -110,8 +102,7 @@ public Condition(string name = default, string expression = default, Dictionary< /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -128,8 +119,7 @@ public static Condition FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((Condition)input); } @@ -139,29 +129,27 @@ public override bool Equals(object input) /// /// Instance of Condition to be compared /// Boolean - public bool Equals(Condition input) - { - if (input == null) - { + public bool Equals(Condition input) { + if (input == null) { return false; } - return + return ( this.Name == input.Name || (this.Name != null && this.Name.Equals(input.Name)) - ) && + ) && ( this.Expression == input.Expression || (this.Expression != null && this.Expression.Equals(input.Expression)) - ) && + ) && ( this.Parameters == input.Parameters || this.Parameters != null && input.Parameters != null && this.Parameters.SequenceEqual(input.Parameters) - ) && + ) && ( this.Metadata == input.Metadata || (this.Metadata != null && @@ -174,29 +162,23 @@ public bool Equals(Condition input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Name != null) - { + if (this.Name != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Name.GetHashCode(); } - if (this.Expression != null) - { + if (this.Expression != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Expression.GetHashCode(); } - if (this.Parameters != null) - { + if (this.Parameters != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Parameters.GetHashCode(); } - if (this.Metadata != null) - { + if (this.Metadata != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Metadata.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -208,11 +190,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/ConditionMetadata.cs b/src/OpenFga.Sdk/Model/ConditionMetadata.cs index 2f90f7af..4222a7a3 100644 --- a/src/OpenFga.Sdk/Model/ConditionMetadata.cs +++ b/src/OpenFga.Sdk/Model/ConditionMetadata.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// ConditionMetadata /// [DataContract(Name = "ConditionMetadata")] - public partial class ConditionMetadata : IEquatable, IValidatableObject - { + public partial class ConditionMetadata : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public ConditionMetadata() - { + public ConditionMetadata() { this.AdditionalProperties = new Dictionary(); } @@ -44,8 +39,7 @@ public ConditionMetadata() /// /// module. /// sourceInfo. - public ConditionMetadata(string module = default, SourceInfo sourceInfo = default) - { + public ConditionMetadata(string module = default, SourceInfo sourceInfo = default) { this.Module = module; this.SourceInfo = sourceInfo; this.AdditionalProperties = new Dictionary(); @@ -78,8 +72,7 @@ public ConditionMetadata(string module = default, SourceInfo sourceInfo = defaul /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -96,8 +89,7 @@ public static ConditionMetadata FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((ConditionMetadata)input); } @@ -107,18 +99,16 @@ public override bool Equals(object input) /// /// Instance of ConditionMetadata to be compared /// Boolean - public bool Equals(ConditionMetadata input) - { - if (input == null) - { + public bool Equals(ConditionMetadata input) { + if (input == null) { return false; } - return + return ( this.Module == input.Module || (this.Module != null && this.Module.Equals(input.Module)) - ) && + ) && ( this.SourceInfo == input.SourceInfo || (this.SourceInfo != null && @@ -131,21 +121,17 @@ public bool Equals(ConditionMetadata input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Module != null) - { + if (this.Module != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Module.GetHashCode(); } - if (this.SourceInfo != null) - { + if (this.SourceInfo != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.SourceInfo.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -157,11 +143,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/ConditionParamTypeRef.cs b/src/OpenFga.Sdk/Model/ConditionParamTypeRef.cs index 7b532db4..2e3fcfab 100644 --- a/src/OpenFga.Sdk/Model/ConditionParamTypeRef.cs +++ b/src/OpenFga.Sdk/Model/ConditionParamTypeRef.cs @@ -11,25 +11,21 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// ConditionParamTypeRef /// [DataContract(Name = "ConditionParamTypeRef")] - public partial class ConditionParamTypeRef : IEquatable, IValidatableObject - { + public partial class ConditionParamTypeRef : IEquatable, IValidatableObject { /// /// Gets or Sets TypeName @@ -41,8 +37,7 @@ public partial class ConditionParamTypeRef : IEquatable, /// Initializes a new instance of the class. /// [JsonConstructor] - public ConditionParamTypeRef() - { + public ConditionParamTypeRef() { this.AdditionalProperties = new Dictionary(); } @@ -51,8 +46,7 @@ public ConditionParamTypeRef() /// /// typeName (required). /// genericTypes. - public ConditionParamTypeRef(TypeName typeName = default, List genericTypes = default) - { + public ConditionParamTypeRef(TypeName typeName = default, List genericTypes = default) { this.TypeName = typeName; this.GenericTypes = genericTypes; this.AdditionalProperties = new Dictionary(); @@ -77,8 +71,7 @@ public ConditionParamTypeRef(TypeName typeName = default, List /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -95,8 +88,7 @@ public static ConditionParamTypeRef FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((ConditionParamTypeRef)input); } @@ -106,17 +98,15 @@ public override bool Equals(object input) /// /// Instance of ConditionParamTypeRef to be compared /// Boolean - public bool Equals(ConditionParamTypeRef input) - { - if (input == null) - { + public bool Equals(ConditionParamTypeRef input) { + if (input == null) { return false; } - return + return ( this.TypeName == input.TypeName || this.TypeName.Equals(input.TypeName) - ) && + ) && ( this.GenericTypes == input.GenericTypes || this.GenericTypes != null && @@ -130,18 +120,15 @@ public bool Equals(ConditionParamTypeRef input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.TypeName.GetHashCode(); - if (this.GenericTypes != null) - { + if (this.GenericTypes != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.GenericTypes.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -153,11 +140,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/ConsistencyPreference.cs b/src/OpenFga.Sdk/Model/ConsistencyPreference.cs index 80285867..559e218d 100644 --- a/src/OpenFga.Sdk/Model/ConsistencyPreference.cs +++ b/src/OpenFga.Sdk/Model/ConsistencyPreference.cs @@ -11,26 +11,22 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// Controls the consistency preferences when calling the query APIs. - UNSPECIFIED: Default if not set. Behavior will be the same as MINIMIZE_LATENCY. - MINIMIZE_LATENCY: Minimize latency at the potential expense of lower consistency. - HIGHER_CONSISTENCY: Prefer higher consistency, at the potential expense of increased latency. /// /// Controls the consistency preferences when calling the query APIs. - UNSPECIFIED: Default if not set. Behavior will be the same as MINIMIZE_LATENCY. - MINIMIZE_LATENCY: Minimize latency at the potential expense of lower consistency. - HIGHER_CONSISTENCY: Prefer higher consistency, at the potential expense of increased latency. [JsonConverter(typeof(JsonStringEnumMemberConverter))] - public enum ConsistencyPreference - { + public enum ConsistencyPreference { /// /// Enum UNSPECIFIED for value: UNSPECIFIED /// @@ -51,4 +47,4 @@ public enum ConsistencyPreference } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/ContextualTupleKeys.cs b/src/OpenFga.Sdk/Model/ContextualTupleKeys.cs index 81e55d8c..73b88a78 100644 --- a/src/OpenFga.Sdk/Model/ContextualTupleKeys.cs +++ b/src/OpenFga.Sdk/Model/ContextualTupleKeys.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// ContextualTupleKeys /// [DataContract(Name = "ContextualTupleKeys")] - public partial class ContextualTupleKeys : IEquatable, IValidatableObject - { + public partial class ContextualTupleKeys : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public ContextualTupleKeys() - { + public ContextualTupleKeys() { this.AdditionalProperties = new Dictionary(); } @@ -43,11 +38,9 @@ public ContextualTupleKeys() /// Initializes a new instance of the class. /// /// tupleKeys (required). - public ContextualTupleKeys(List tupleKeys = default) - { + public ContextualTupleKeys(List tupleKeys = default) { // to ensure "tupleKeys" is required (not null) - if (tupleKeys == null) - { + if (tupleKeys == null) { throw new ArgumentNullException("tupleKeys is a required property for ContextualTupleKeys and cannot be null"); } this.TupleKeys = tupleKeys; @@ -73,8 +66,7 @@ public ContextualTupleKeys(List tupleKeys = default) /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -91,8 +83,7 @@ public static ContextualTupleKeys FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((ContextualTupleKeys)input); } @@ -102,13 +93,11 @@ public override bool Equals(object input) /// /// Instance of ContextualTupleKeys to be compared /// Boolean - public bool Equals(ContextualTupleKeys input) - { - if (input == null) - { + public bool Equals(ContextualTupleKeys input) { + if (input == null) { return false; } - return + return ( this.TupleKeys == input.TupleKeys || this.TupleKeys != null && @@ -122,17 +111,14 @@ public bool Equals(ContextualTupleKeys input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.TupleKeys != null) - { + if (this.TupleKeys != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.TupleKeys.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -144,11 +130,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/CreateStoreRequest.cs b/src/OpenFga.Sdk/Model/CreateStoreRequest.cs index 5753ad19..340cdae9 100644 --- a/src/OpenFga.Sdk/Model/CreateStoreRequest.cs +++ b/src/OpenFga.Sdk/Model/CreateStoreRequest.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// CreateStoreRequest /// [DataContract(Name = "CreateStoreRequest")] - public partial class CreateStoreRequest : IEquatable, IValidatableObject - { + public partial class CreateStoreRequest : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public CreateStoreRequest() - { + public CreateStoreRequest() { this.AdditionalProperties = new Dictionary(); } @@ -43,11 +38,9 @@ public CreateStoreRequest() /// Initializes a new instance of the class. /// /// name (required). - public CreateStoreRequest(string name = default) - { + public CreateStoreRequest(string name = default) { // to ensure "name" is required (not null) - if (name == null) - { + if (name == null) { throw new ArgumentNullException("name is a required property for CreateStoreRequest and cannot be null"); } this.Name = name; @@ -73,8 +66,7 @@ public CreateStoreRequest(string name = default) /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -91,8 +83,7 @@ public static CreateStoreRequest FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((CreateStoreRequest)input); } @@ -102,13 +93,11 @@ public override bool Equals(object input) /// /// Instance of CreateStoreRequest to be compared /// Boolean - public bool Equals(CreateStoreRequest input) - { - if (input == null) - { + public bool Equals(CreateStoreRequest input) { + if (input == null) { return false; } - return + return ( this.Name == input.Name || (this.Name != null && @@ -121,17 +110,14 @@ public bool Equals(CreateStoreRequest input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Name != null) - { + if (this.Name != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Name.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -143,11 +129,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/CreateStoreResponse.cs b/src/OpenFga.Sdk/Model/CreateStoreResponse.cs index da47e24e..f516ca98 100644 --- a/src/OpenFga.Sdk/Model/CreateStoreResponse.cs +++ b/src/OpenFga.Sdk/Model/CreateStoreResponse.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// CreateStoreResponse /// [DataContract(Name = "CreateStoreResponse")] - public partial class CreateStoreResponse : IEquatable, IValidatableObject - { + public partial class CreateStoreResponse : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public CreateStoreResponse() - { + public CreateStoreResponse() { this.AdditionalProperties = new Dictionary(); } @@ -46,17 +41,14 @@ public CreateStoreResponse() /// name (required). /// createdAt (required). /// updatedAt (required). - public CreateStoreResponse(string id = default, string name = default, DateTime createdAt = default, DateTime updatedAt = default) - { + public CreateStoreResponse(string id = default, string name = default, DateTime createdAt = default, DateTime updatedAt = default) { // to ensure "id" is required (not null) - if (id == null) - { + if (id == null) { throw new ArgumentNullException("id is a required property for CreateStoreResponse and cannot be null"); } this.Id = id; // to ensure "name" is required (not null) - if (name == null) - { + if (name == null) { throw new ArgumentNullException("name is a required property for CreateStoreResponse and cannot be null"); } this.Name = name; @@ -108,8 +100,7 @@ public CreateStoreResponse(string id = default, string name = default, DateTime /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -126,8 +117,7 @@ public static CreateStoreResponse FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((CreateStoreResponse)input); } @@ -137,28 +127,26 @@ public override bool Equals(object input) /// /// Instance of CreateStoreResponse to be compared /// Boolean - public bool Equals(CreateStoreResponse input) - { - if (input == null) - { + public bool Equals(CreateStoreResponse input) { + if (input == null) { return false; } - return + return ( this.Id == input.Id || (this.Id != null && this.Id.Equals(input.Id)) - ) && + ) && ( this.Name == input.Name || (this.Name != null && this.Name.Equals(input.Name)) - ) && + ) && ( this.CreatedAt == input.CreatedAt || (this.CreatedAt != null && this.CreatedAt.Equals(input.CreatedAt)) - ) && + ) && ( this.UpdatedAt == input.UpdatedAt || (this.UpdatedAt != null && @@ -171,29 +159,23 @@ public bool Equals(CreateStoreResponse input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Id != null) - { + if (this.Id != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Id.GetHashCode(); } - if (this.Name != null) - { + if (this.Name != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Name.GetHashCode(); } - if (this.CreatedAt != null) - { + if (this.CreatedAt != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.CreatedAt.GetHashCode(); } - if (this.UpdatedAt != null) - { + if (this.UpdatedAt != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.UpdatedAt.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -205,11 +187,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/Difference.cs b/src/OpenFga.Sdk/Model/Difference.cs index 69c4b487..03946d44 100644 --- a/src/OpenFga.Sdk/Model/Difference.cs +++ b/src/OpenFga.Sdk/Model/Difference.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// Difference /// [DataContract(Name = "Difference")] - public partial class Difference : IEquatable, IValidatableObject - { + public partial class Difference : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public Difference() - { + public Difference() { this.AdditionalProperties = new Dictionary(); } @@ -44,17 +39,14 @@ public Difference() /// /// varBase (required). /// subtract (required). - public Difference(Userset varBase = default, Userset subtract = default) - { + public Difference(Userset varBase = default, Userset subtract = default) { // to ensure "varBase" is required (not null) - if (varBase == null) - { + if (varBase == null) { throw new ArgumentNullException("varBase is a required property for Difference and cannot be null"); } this.Base = varBase; // to ensure "subtract" is required (not null) - if (subtract == null) - { + if (subtract == null) { throw new ArgumentNullException("subtract is a required property for Difference and cannot be null"); } this.Subtract = subtract; @@ -88,8 +80,7 @@ public Difference(Userset varBase = default, Userset subtract = default) /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -106,8 +97,7 @@ public static Difference FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((Difference)input); } @@ -117,18 +107,16 @@ public override bool Equals(object input) /// /// Instance of Difference to be compared /// Boolean - public bool Equals(Difference input) - { - if (input == null) - { + public bool Equals(Difference input) { + if (input == null) { return false; } - return + return ( this.Base == input.Base || (this.Base != null && this.Base.Equals(input.Base)) - ) && + ) && ( this.Subtract == input.Subtract || (this.Subtract != null && @@ -141,21 +129,17 @@ public bool Equals(Difference input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Base != null) - { + if (this.Base != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Base.GetHashCode(); } - if (this.Subtract != null) - { + if (this.Subtract != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Subtract.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -167,11 +151,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/ErrorCode.cs b/src/OpenFga.Sdk/Model/ErrorCode.cs index 4b39b109..558dc3d0 100644 --- a/src/OpenFga.Sdk/Model/ErrorCode.cs +++ b/src/OpenFga.Sdk/Model/ErrorCode.cs @@ -11,25 +11,21 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// Defines ErrorCode /// [JsonConverter(typeof(JsonStringEnumMemberConverter))] - public enum ErrorCode - { + public enum ErrorCode { /// /// Enum NoError for value: no_error /// @@ -332,4 +328,4 @@ public enum ErrorCode } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/ExpandRequest.cs b/src/OpenFga.Sdk/Model/ExpandRequest.cs index 51b2cf26..0f9f62fd 100644 --- a/src/OpenFga.Sdk/Model/ExpandRequest.cs +++ b/src/OpenFga.Sdk/Model/ExpandRequest.cs @@ -11,25 +11,21 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// ExpandRequest /// [DataContract(Name = "Expand_request")] - public partial class ExpandRequest : IEquatable, IValidatableObject - { + public partial class ExpandRequest : IEquatable, IValidatableObject { /// /// Gets or Sets Consistency @@ -41,8 +37,7 @@ public partial class ExpandRequest : IEquatable, IValidatableObje /// Initializes a new instance of the class. /// [JsonConstructor] - public ExpandRequest() - { + public ExpandRequest() { this.AdditionalProperties = new Dictionary(); } @@ -53,11 +48,9 @@ public ExpandRequest() /// authorizationModelId. /// consistency. /// contextualTuples. - public ExpandRequest(ExpandRequestTupleKey tupleKey = default, string authorizationModelId = default, ConsistencyPreference? consistency = default, ContextualTupleKeys contextualTuples = default) - { + public ExpandRequest(ExpandRequestTupleKey tupleKey = default, string authorizationModelId = default, ConsistencyPreference? consistency = default, ContextualTupleKeys contextualTuples = default) { // to ensure "tupleKey" is required (not null) - if (tupleKey == null) - { + if (tupleKey == null) { throw new ArgumentNullException("tupleKey is a required property for ExpandRequest and cannot be null"); } this.TupleKey = tupleKey; @@ -102,8 +95,7 @@ public ExpandRequest(ExpandRequestTupleKey tupleKey = default, string authorizat /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -120,8 +112,7 @@ public static ExpandRequest FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((ExpandRequest)input); } @@ -131,27 +122,25 @@ public override bool Equals(object input) /// /// Instance of ExpandRequest to be compared /// Boolean - public bool Equals(ExpandRequest input) - { - if (input == null) - { + public bool Equals(ExpandRequest input) { + if (input == null) { return false; } - return + return ( this.TupleKey == input.TupleKey || (this.TupleKey != null && this.TupleKey.Equals(input.TupleKey)) - ) && + ) && ( this.AuthorizationModelId == input.AuthorizationModelId || (this.AuthorizationModelId != null && this.AuthorizationModelId.Equals(input.AuthorizationModelId)) - ) && + ) && ( this.Consistency == input.Consistency || this.Consistency.Equals(input.Consistency) - ) && + ) && ( this.ContextualTuples == input.ContextualTuples || (this.ContextualTuples != null && @@ -164,26 +153,21 @@ public bool Equals(ExpandRequest input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.TupleKey != null) - { + if (this.TupleKey != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.TupleKey.GetHashCode(); } - if (this.AuthorizationModelId != null) - { + if (this.AuthorizationModelId != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AuthorizationModelId.GetHashCode(); } hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Consistency.GetHashCode(); - if (this.ContextualTuples != null) - { + if (this.ContextualTuples != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.ContextualTuples.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -195,11 +179,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/ExpandRequestTupleKey.cs b/src/OpenFga.Sdk/Model/ExpandRequestTupleKey.cs index 456cab21..00f51b06 100644 --- a/src/OpenFga.Sdk/Model/ExpandRequestTupleKey.cs +++ b/src/OpenFga.Sdk/Model/ExpandRequestTupleKey.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// ExpandRequestTupleKey /// [DataContract(Name = "ExpandRequestTupleKey")] - public partial class ExpandRequestTupleKey : IEquatable, IValidatableObject - { + public partial class ExpandRequestTupleKey : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public ExpandRequestTupleKey() - { + public ExpandRequestTupleKey() { this.AdditionalProperties = new Dictionary(); } @@ -44,17 +39,14 @@ public ExpandRequestTupleKey() /// /// relation (required). /// varObject (required). - public ExpandRequestTupleKey(string relation = default, string varObject = default) - { + public ExpandRequestTupleKey(string relation = default, string varObject = default) { // to ensure "relation" is required (not null) - if (relation == null) - { + if (relation == null) { throw new ArgumentNullException("relation is a required property for ExpandRequestTupleKey and cannot be null"); } this.Relation = relation; // to ensure "varObject" is required (not null) - if (varObject == null) - { + if (varObject == null) { throw new ArgumentNullException("varObject is a required property for ExpandRequestTupleKey and cannot be null"); } this.Object = varObject; @@ -88,8 +80,7 @@ public ExpandRequestTupleKey(string relation = default, string varObject = defau /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -106,8 +97,7 @@ public static ExpandRequestTupleKey FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((ExpandRequestTupleKey)input); } @@ -117,18 +107,16 @@ public override bool Equals(object input) /// /// Instance of ExpandRequestTupleKey to be compared /// Boolean - public bool Equals(ExpandRequestTupleKey input) - { - if (input == null) - { + public bool Equals(ExpandRequestTupleKey input) { + if (input == null) { return false; } - return + return ( this.Relation == input.Relation || (this.Relation != null && this.Relation.Equals(input.Relation)) - ) && + ) && ( this.Object == input.Object || (this.Object != null && @@ -141,21 +129,17 @@ public bool Equals(ExpandRequestTupleKey input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Relation != null) - { + if (this.Relation != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Relation.GetHashCode(); } - if (this.Object != null) - { + if (this.Object != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Object.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -167,18 +151,15 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { // Relation (string) maxLength - if (this.Relation != null && this.Relation.Length > 50) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Relation, length must be less than 50.", new [] { "Relation" }); + if (this.Relation != null && this.Relation.Length > 50) { + yield return new ValidationResult("Invalid value for Relation, length must be less than 50.", new[] { "Relation" }); } // Object (string) maxLength - if (this.Object != null && this.Object.Length > 256) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Object, length must be less than 256.", new [] { "Object" }); + if (this.Object != null && this.Object.Length > 256) { + yield return new ValidationResult("Invalid value for Object, length must be less than 256.", new[] { "Object" }); } yield break; @@ -186,4 +167,4 @@ public override int GetHashCode() } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/ExpandResponse.cs b/src/OpenFga.Sdk/Model/ExpandResponse.cs index 47cc8ba5..bbb0bdca 100644 --- a/src/OpenFga.Sdk/Model/ExpandResponse.cs +++ b/src/OpenFga.Sdk/Model/ExpandResponse.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// ExpandResponse /// [DataContract(Name = "ExpandResponse")] - public partial class ExpandResponse : IEquatable, IValidatableObject - { + public partial class ExpandResponse : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public ExpandResponse() - { + public ExpandResponse() { this.AdditionalProperties = new Dictionary(); } @@ -43,8 +38,7 @@ public ExpandResponse() /// Initializes a new instance of the class. /// /// tree. - public ExpandResponse(UsersetTree tree = default) - { + public ExpandResponse(UsersetTree tree = default) { this.Tree = tree; this.AdditionalProperties = new Dictionary(); } @@ -68,8 +62,7 @@ public ExpandResponse(UsersetTree tree = default) /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -86,8 +79,7 @@ public static ExpandResponse FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((ExpandResponse)input); } @@ -97,13 +89,11 @@ public override bool Equals(object input) /// /// Instance of ExpandResponse to be compared /// Boolean - public bool Equals(ExpandResponse input) - { - if (input == null) - { + public bool Equals(ExpandResponse input) { + if (input == null) { return false; } - return + return ( this.Tree == input.Tree || (this.Tree != null && @@ -116,17 +106,14 @@ public bool Equals(ExpandResponse input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Tree != null) - { + if (this.Tree != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Tree.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -138,11 +125,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/FgaObject.cs b/src/OpenFga.Sdk/Model/FgaObject.cs index 93b99b50..3709185e 100644 --- a/src/OpenFga.Sdk/Model/FgaObject.cs +++ b/src/OpenFga.Sdk/Model/FgaObject.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// Object represents an OpenFGA Object. An Object is composed of a type and identifier (e.g. 'document:1') See https://openfga.dev/docs/concepts#what-is-an-object /// [DataContract(Name = "FgaObject")] - public partial class FgaObject : IEquatable, IValidatableObject - { + public partial class FgaObject : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public FgaObject() - { + public FgaObject() { this.AdditionalProperties = new Dictionary(); } @@ -44,17 +39,14 @@ public FgaObject() /// /// type (required). /// id (required). - public FgaObject(string type = default, string id = default) - { + public FgaObject(string type = default, string id = default) { // to ensure "type" is required (not null) - if (type == null) - { + if (type == null) { throw new ArgumentNullException("type is a required property for FgaObject and cannot be null"); } this.Type = type; // to ensure "id" is required (not null) - if (id == null) - { + if (id == null) { throw new ArgumentNullException("id is a required property for FgaObject and cannot be null"); } this.Id = id; @@ -88,8 +80,7 @@ public FgaObject(string type = default, string id = default) /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -106,8 +97,7 @@ public static FgaObject FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((FgaObject)input); } @@ -117,18 +107,16 @@ public override bool Equals(object input) /// /// Instance of FgaObject to be compared /// Boolean - public bool Equals(FgaObject input) - { - if (input == null) - { + public bool Equals(FgaObject input) { + if (input == null) { return false; } - return + return ( this.Type == input.Type || (this.Type != null && this.Type.Equals(input.Type)) - ) && + ) && ( this.Id == input.Id || (this.Id != null && @@ -141,21 +129,17 @@ public bool Equals(FgaObject input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Type != null) - { + if (this.Type != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Type.GetHashCode(); } - if (this.Id != null) - { + if (this.Id != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Id.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -167,11 +151,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/ForbiddenResponse.cs b/src/OpenFga.Sdk/Model/ForbiddenResponse.cs index b019278f..0776fb14 100644 --- a/src/OpenFga.Sdk/Model/ForbiddenResponse.cs +++ b/src/OpenFga.Sdk/Model/ForbiddenResponse.cs @@ -11,25 +11,21 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// ForbiddenResponse /// [DataContract(Name = "ForbiddenResponse")] - public partial class ForbiddenResponse : IEquatable, IValidatableObject - { + public partial class ForbiddenResponse : IEquatable, IValidatableObject { /// /// Gets or Sets Code @@ -41,8 +37,7 @@ public partial class ForbiddenResponse : IEquatable, IValidat /// Initializes a new instance of the class. /// [JsonConstructor] - public ForbiddenResponse() - { + public ForbiddenResponse() { this.AdditionalProperties = new Dictionary(); } @@ -51,8 +46,7 @@ public ForbiddenResponse() /// /// code. /// message. - public ForbiddenResponse(AuthErrorCode? code = default, string message = default) - { + public ForbiddenResponse(AuthErrorCode? code = default, string message = default) { this.Code = code; this.Message = message; this.AdditionalProperties = new Dictionary(); @@ -77,8 +71,7 @@ public ForbiddenResponse(AuthErrorCode? code = default, string message = default /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -95,8 +88,7 @@ public static ForbiddenResponse FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((ForbiddenResponse)input); } @@ -106,17 +98,15 @@ public override bool Equals(object input) /// /// Instance of ForbiddenResponse to be compared /// Boolean - public bool Equals(ForbiddenResponse input) - { - if (input == null) - { + public bool Equals(ForbiddenResponse input) { + if (input == null) { return false; } - return + return ( this.Code == input.Code || this.Code.Equals(input.Code) - ) && + ) && ( this.Message == input.Message || (this.Message != null && @@ -129,18 +119,15 @@ public bool Equals(ForbiddenResponse input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Code.GetHashCode(); - if (this.Message != null) - { + if (this.Message != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Message.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -152,11 +139,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/GetStoreResponse.cs b/src/OpenFga.Sdk/Model/GetStoreResponse.cs index 0fe8ef58..bde98f23 100644 --- a/src/OpenFga.Sdk/Model/GetStoreResponse.cs +++ b/src/OpenFga.Sdk/Model/GetStoreResponse.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// GetStoreResponse /// [DataContract(Name = "GetStoreResponse")] - public partial class GetStoreResponse : IEquatable, IValidatableObject - { + public partial class GetStoreResponse : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public GetStoreResponse() - { + public GetStoreResponse() { this.AdditionalProperties = new Dictionary(); } @@ -47,17 +42,14 @@ public GetStoreResponse() /// createdAt (required). /// updatedAt (required). /// deletedAt. - public GetStoreResponse(string id = default, string name = default, DateTime createdAt = default, DateTime updatedAt = default, DateTime deletedAt = default) - { + public GetStoreResponse(string id = default, string name = default, DateTime createdAt = default, DateTime updatedAt = default, DateTime deletedAt = default) { // to ensure "id" is required (not null) - if (id == null) - { + if (id == null) { throw new ArgumentNullException("id is a required property for GetStoreResponse and cannot be null"); } this.Id = id; // to ensure "name" is required (not null) - if (name == null) - { + if (name == null) { throw new ArgumentNullException("name is a required property for GetStoreResponse and cannot be null"); } this.Name = name; @@ -118,8 +110,7 @@ public GetStoreResponse(string id = default, string name = default, DateTime cre /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -136,8 +127,7 @@ public static GetStoreResponse FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((GetStoreResponse)input); } @@ -147,33 +137,31 @@ public override bool Equals(object input) /// /// Instance of GetStoreResponse to be compared /// Boolean - public bool Equals(GetStoreResponse input) - { - if (input == null) - { + public bool Equals(GetStoreResponse input) { + if (input == null) { return false; } - return + return ( this.Id == input.Id || (this.Id != null && this.Id.Equals(input.Id)) - ) && + ) && ( this.Name == input.Name || (this.Name != null && this.Name.Equals(input.Name)) - ) && + ) && ( this.CreatedAt == input.CreatedAt || (this.CreatedAt != null && this.CreatedAt.Equals(input.CreatedAt)) - ) && + ) && ( this.UpdatedAt == input.UpdatedAt || (this.UpdatedAt != null && this.UpdatedAt.Equals(input.UpdatedAt)) - ) && + ) && ( this.DeletedAt == input.DeletedAt || (this.DeletedAt != null && @@ -186,33 +174,26 @@ public bool Equals(GetStoreResponse input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Id != null) - { + if (this.Id != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Id.GetHashCode(); } - if (this.Name != null) - { + if (this.Name != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Name.GetHashCode(); } - if (this.CreatedAt != null) - { + if (this.CreatedAt != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.CreatedAt.GetHashCode(); } - if (this.UpdatedAt != null) - { + if (this.UpdatedAt != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.UpdatedAt.GetHashCode(); } - if (this.DeletedAt != null) - { + if (this.DeletedAt != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.DeletedAt.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -224,11 +205,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/InternalErrorCode.cs b/src/OpenFga.Sdk/Model/InternalErrorCode.cs index b5257463..6b9275c0 100644 --- a/src/OpenFga.Sdk/Model/InternalErrorCode.cs +++ b/src/OpenFga.Sdk/Model/InternalErrorCode.cs @@ -11,25 +11,21 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// Defines InternalErrorCode /// [JsonConverter(typeof(JsonStringEnumMemberConverter))] - public enum InternalErrorCode - { + public enum InternalErrorCode { /// /// Enum NoInternalError for value: no_internal_error /// @@ -92,4 +88,4 @@ public enum InternalErrorCode } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/InternalErrorMessageResponse.cs b/src/OpenFga.Sdk/Model/InternalErrorMessageResponse.cs index 0ee49199..87101e28 100644 --- a/src/OpenFga.Sdk/Model/InternalErrorMessageResponse.cs +++ b/src/OpenFga.Sdk/Model/InternalErrorMessageResponse.cs @@ -11,25 +11,21 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// InternalErrorMessageResponse /// [DataContract(Name = "InternalErrorMessageResponse")] - public partial class InternalErrorMessageResponse : IEquatable, IValidatableObject - { + public partial class InternalErrorMessageResponse : IEquatable, IValidatableObject { /// /// Gets or Sets Code @@ -41,8 +37,7 @@ public partial class InternalErrorMessageResponse : IEquatable class. /// [JsonConstructor] - public InternalErrorMessageResponse() - { + public InternalErrorMessageResponse() { this.AdditionalProperties = new Dictionary(); } @@ -51,8 +46,7 @@ public InternalErrorMessageResponse() /// /// code. /// message. - public InternalErrorMessageResponse(InternalErrorCode? code = default, string message = default) - { + public InternalErrorMessageResponse(InternalErrorCode? code = default, string message = default) { this.Code = code; this.Message = message; this.AdditionalProperties = new Dictionary(); @@ -77,8 +71,7 @@ public InternalErrorMessageResponse(InternalErrorCode? code = default, string me /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -95,8 +88,7 @@ public static InternalErrorMessageResponse FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((InternalErrorMessageResponse)input); } @@ -106,17 +98,15 @@ public override bool Equals(object input) /// /// Instance of InternalErrorMessageResponse to be compared /// Boolean - public bool Equals(InternalErrorMessageResponse input) - { - if (input == null) - { + public bool Equals(InternalErrorMessageResponse input) { + if (input == null) { return false; } - return + return ( this.Code == input.Code || this.Code.Equals(input.Code) - ) && + ) && ( this.Message == input.Message || (this.Message != null && @@ -129,18 +119,15 @@ public bool Equals(InternalErrorMessageResponse input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Code.GetHashCode(); - if (this.Message != null) - { + if (this.Message != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Message.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -152,11 +139,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/Leaf.cs b/src/OpenFga.Sdk/Model/Leaf.cs index 7dba1840..a8aea60f 100644 --- a/src/OpenFga.Sdk/Model/Leaf.cs +++ b/src/OpenFga.Sdk/Model/Leaf.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// A leaf node contains either - a set of users (which may be individual users, or usersets referencing other relations) - a computed node, which is the result of a computed userset value in the authorization model - a tupleToUserset nodes, containing the result of expanding a tupleToUserset value in a authorization model. /// [DataContract(Name = "Leaf")] - public partial class Leaf : IEquatable, IValidatableObject - { + public partial class Leaf : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public Leaf() - { + public Leaf() { this.AdditionalProperties = new Dictionary(); } @@ -45,8 +40,7 @@ public Leaf() /// users. /// computed. /// tupleToUserset. - public Leaf(Users users = default, Computed computed = default, UsersetTreeTupleToUserset tupleToUserset = default) - { + public Leaf(Users users = default, Computed computed = default, UsersetTreeTupleToUserset tupleToUserset = default) { this.Users = users; this.Computed = computed; this.TupleToUserset = tupleToUserset; @@ -88,8 +82,7 @@ public Leaf(Users users = default, Computed computed = default, UsersetTreeTuple /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -106,8 +99,7 @@ public static Leaf FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((Leaf)input); } @@ -117,23 +109,21 @@ public override bool Equals(object input) /// /// Instance of Leaf to be compared /// Boolean - public bool Equals(Leaf input) - { - if (input == null) - { + public bool Equals(Leaf input) { + if (input == null) { return false; } - return + return ( this.Users == input.Users || (this.Users != null && this.Users.Equals(input.Users)) - ) && + ) && ( this.Computed == input.Computed || (this.Computed != null && this.Computed.Equals(input.Computed)) - ) && + ) && ( this.TupleToUserset == input.TupleToUserset || (this.TupleToUserset != null && @@ -146,25 +136,20 @@ public bool Equals(Leaf input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Users != null) - { + if (this.Users != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Users.GetHashCode(); } - if (this.Computed != null) - { + if (this.Computed != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Computed.GetHashCode(); } - if (this.TupleToUserset != null) - { + if (this.TupleToUserset != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.TupleToUserset.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -176,11 +161,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/ListObjectsRequest.cs b/src/OpenFga.Sdk/Model/ListObjectsRequest.cs index 61ae22ac..76b64658 100644 --- a/src/OpenFga.Sdk/Model/ListObjectsRequest.cs +++ b/src/OpenFga.Sdk/Model/ListObjectsRequest.cs @@ -11,25 +11,21 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// ListObjectsRequest /// [DataContract(Name = "ListObjects_request")] - public partial class ListObjectsRequest : IEquatable, IValidatableObject - { + public partial class ListObjectsRequest : IEquatable, IValidatableObject { /// /// Gets or Sets Consistency @@ -41,8 +37,7 @@ public partial class ListObjectsRequest : IEquatable, IValid /// Initializes a new instance of the class. /// [JsonConstructor] - public ListObjectsRequest() - { + public ListObjectsRequest() { this.AdditionalProperties = new Dictionary(); } @@ -56,23 +51,19 @@ public ListObjectsRequest() /// contextualTuples. /// Additional request context that will be used to evaluate any ABAC conditions encountered in the query evaluation.. /// consistency. - public ListObjectsRequest(string authorizationModelId = default, string type = default, string relation = default, string user = default, ContextualTupleKeys contextualTuples = default, Object context = default, ConsistencyPreference? consistency = default) - { + public ListObjectsRequest(string authorizationModelId = default, string type = default, string relation = default, string user = default, ContextualTupleKeys contextualTuples = default, Object context = default, ConsistencyPreference? consistency = default) { // to ensure "type" is required (not null) - if (type == null) - { + if (type == null) { throw new ArgumentNullException("type is a required property for ListObjectsRequest and cannot be null"); } this.Type = type; // to ensure "relation" is required (not null) - if (relation == null) - { + if (relation == null) { throw new ArgumentNullException("relation is a required property for ListObjectsRequest and cannot be null"); } this.Relation = relation; // to ensure "user" is required (not null) - if (user == null) - { + if (user == null) { throw new ArgumentNullException("user is a required property for ListObjectsRequest and cannot be null"); } this.User = user; @@ -143,8 +134,7 @@ public ListObjectsRequest(string authorizationModelId = default, string type = d /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -161,8 +151,7 @@ public static ListObjectsRequest FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((ListObjectsRequest)input); } @@ -172,43 +161,41 @@ public override bool Equals(object input) /// /// Instance of ListObjectsRequest to be compared /// Boolean - public bool Equals(ListObjectsRequest input) - { - if (input == null) - { + public bool Equals(ListObjectsRequest input) { + if (input == null) { return false; } - return + return ( this.AuthorizationModelId == input.AuthorizationModelId || (this.AuthorizationModelId != null && this.AuthorizationModelId.Equals(input.AuthorizationModelId)) - ) && + ) && ( this.Type == input.Type || (this.Type != null && this.Type.Equals(input.Type)) - ) && + ) && ( this.Relation == input.Relation || (this.Relation != null && this.Relation.Equals(input.Relation)) - ) && + ) && ( this.User == input.User || (this.User != null && this.User.Equals(input.User)) - ) && + ) && ( this.ContextualTuples == input.ContextualTuples || (this.ContextualTuples != null && this.ContextualTuples.Equals(input.ContextualTuples)) - ) && + ) && ( this.Context == input.Context || (this.Context != null && this.Context.Equals(input.Context)) - ) && + ) && ( this.Consistency == input.Consistency || this.Consistency.Equals(input.Consistency) @@ -220,38 +207,30 @@ public bool Equals(ListObjectsRequest input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.AuthorizationModelId != null) - { + if (this.AuthorizationModelId != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AuthorizationModelId.GetHashCode(); } - if (this.Type != null) - { + if (this.Type != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Type.GetHashCode(); } - if (this.Relation != null) - { + if (this.Relation != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Relation.GetHashCode(); } - if (this.User != null) - { + if (this.User != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.User.GetHashCode(); } - if (this.ContextualTuples != null) - { + if (this.ContextualTuples != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.ContextualTuples.GetHashCode(); } - if (this.Context != null) - { + if (this.Context != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Context.GetHashCode(); } hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Consistency.GetHashCode(); - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -263,18 +242,15 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { // User (string) maxLength - if (this.User != null && this.User.Length > 512) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for User, length must be less than 512.", new [] { "User" }); + if (this.User != null && this.User.Length > 512) { + yield return new ValidationResult("Invalid value for User, length must be less than 512.", new[] { "User" }); } // User (string) minLength - if (this.User != null && this.User.Length < 1) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for User, length must be greater than 1.", new [] { "User" }); + if (this.User != null && this.User.Length < 1) { + yield return new ValidationResult("Invalid value for User, length must be greater than 1.", new[] { "User" }); } yield break; @@ -282,4 +258,4 @@ public override int GetHashCode() } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/ListObjectsResponse.cs b/src/OpenFga.Sdk/Model/ListObjectsResponse.cs index 6c8bc2f5..57b9e4b0 100644 --- a/src/OpenFga.Sdk/Model/ListObjectsResponse.cs +++ b/src/OpenFga.Sdk/Model/ListObjectsResponse.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// ListObjectsResponse /// [DataContract(Name = "ListObjectsResponse")] - public partial class ListObjectsResponse : IEquatable, IValidatableObject - { + public partial class ListObjectsResponse : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public ListObjectsResponse() - { + public ListObjectsResponse() { this.AdditionalProperties = new Dictionary(); } @@ -43,11 +38,9 @@ public ListObjectsResponse() /// Initializes a new instance of the class. /// /// objects (required). - public ListObjectsResponse(List objects = default) - { + public ListObjectsResponse(List objects = default) { // to ensure "objects" is required (not null) - if (objects == null) - { + if (objects == null) { throw new ArgumentNullException("objects is a required property for ListObjectsResponse and cannot be null"); } this.Objects = objects; @@ -73,8 +66,7 @@ public ListObjectsResponse(List objects = default) /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -91,8 +83,7 @@ public static ListObjectsResponse FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((ListObjectsResponse)input); } @@ -102,13 +93,11 @@ public override bool Equals(object input) /// /// Instance of ListObjectsResponse to be compared /// Boolean - public bool Equals(ListObjectsResponse input) - { - if (input == null) - { + public bool Equals(ListObjectsResponse input) { + if (input == null) { return false; } - return + return ( this.Objects == input.Objects || this.Objects != null && @@ -122,17 +111,14 @@ public bool Equals(ListObjectsResponse input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Objects != null) - { + if (this.Objects != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Objects.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -144,11 +130,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/ListStoresResponse.cs b/src/OpenFga.Sdk/Model/ListStoresResponse.cs index 990fd5bd..a14611e9 100644 --- a/src/OpenFga.Sdk/Model/ListStoresResponse.cs +++ b/src/OpenFga.Sdk/Model/ListStoresResponse.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// ListStoresResponse /// [DataContract(Name = "ListStoresResponse")] - public partial class ListStoresResponse : IEquatable, IValidatableObject - { + public partial class ListStoresResponse : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public ListStoresResponse() - { + public ListStoresResponse() { this.AdditionalProperties = new Dictionary(); } @@ -44,17 +39,14 @@ public ListStoresResponse() /// /// stores (required). /// The continuation token will be empty if there are no more stores. (required). - public ListStoresResponse(List stores = default, string continuationToken = default) - { + public ListStoresResponse(List stores = default, string continuationToken = default) { // to ensure "stores" is required (not null) - if (stores == null) - { + if (stores == null) { throw new ArgumentNullException("stores is a required property for ListStoresResponse and cannot be null"); } this.Stores = stores; // to ensure "continuationToken" is required (not null) - if (continuationToken == null) - { + if (continuationToken == null) { throw new ArgumentNullException("continuationToken is a required property for ListStoresResponse and cannot be null"); } this.ContinuationToken = continuationToken; @@ -89,8 +81,7 @@ public ListStoresResponse(List stores = default, string continuationToken /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -107,8 +98,7 @@ public static ListStoresResponse FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((ListStoresResponse)input); } @@ -118,19 +108,17 @@ public override bool Equals(object input) /// /// Instance of ListStoresResponse to be compared /// Boolean - public bool Equals(ListStoresResponse input) - { - if (input == null) - { + public bool Equals(ListStoresResponse input) { + if (input == null) { return false; } - return + return ( this.Stores == input.Stores || this.Stores != null && input.Stores != null && this.Stores.SequenceEqual(input.Stores) - ) && + ) && ( this.ContinuationToken == input.ContinuationToken || (this.ContinuationToken != null && @@ -143,21 +131,17 @@ public bool Equals(ListStoresResponse input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Stores != null) - { + if (this.Stores != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Stores.GetHashCode(); } - if (this.ContinuationToken != null) - { + if (this.ContinuationToken != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.ContinuationToken.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -169,11 +153,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/ListUsersRequest.cs b/src/OpenFga.Sdk/Model/ListUsersRequest.cs index 2438083c..53c56d0e 100644 --- a/src/OpenFga.Sdk/Model/ListUsersRequest.cs +++ b/src/OpenFga.Sdk/Model/ListUsersRequest.cs @@ -11,25 +11,21 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// ListUsersRequest /// [DataContract(Name = "ListUsers_request")] - public partial class ListUsersRequest : IEquatable, IValidatableObject - { + public partial class ListUsersRequest : IEquatable, IValidatableObject { /// /// Gets or Sets Consistency @@ -41,8 +37,7 @@ public partial class ListUsersRequest : IEquatable, IValidatab /// Initializes a new instance of the class. /// [JsonConstructor] - public ListUsersRequest() - { + public ListUsersRequest() { this.AdditionalProperties = new Dictionary(); } @@ -56,23 +51,19 @@ public ListUsersRequest() /// contextualTuples. /// Additional request context that will be used to evaluate any ABAC conditions encountered in the query evaluation.. /// consistency. - public ListUsersRequest(string authorizationModelId = default, FgaObject varObject = default, string relation = default, List userFilters = default, List contextualTuples = default, Object context = default, ConsistencyPreference? consistency = default) - { + public ListUsersRequest(string authorizationModelId = default, FgaObject varObject = default, string relation = default, List userFilters = default, List contextualTuples = default, Object context = default, ConsistencyPreference? consistency = default) { // to ensure "varObject" is required (not null) - if (varObject == null) - { + if (varObject == null) { throw new ArgumentNullException("varObject is a required property for ListUsersRequest and cannot be null"); } this.Object = varObject; // to ensure "relation" is required (not null) - if (relation == null) - { + if (relation == null) { throw new ArgumentNullException("relation is a required property for ListUsersRequest and cannot be null"); } this.Relation = relation; // to ensure "userFilters" is required (not null) - if (userFilters == null) - { + if (userFilters == null) { throw new ArgumentNullException("userFilters is a required property for ListUsersRequest and cannot be null"); } this.UserFilters = userFilters; @@ -144,8 +135,7 @@ public ListUsersRequest(string authorizationModelId = default, FgaObject varObje /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -162,8 +152,7 @@ public static ListUsersRequest FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((ListUsersRequest)input); } @@ -173,45 +162,43 @@ public override bool Equals(object input) /// /// Instance of ListUsersRequest to be compared /// Boolean - public bool Equals(ListUsersRequest input) - { - if (input == null) - { + public bool Equals(ListUsersRequest input) { + if (input == null) { return false; } - return + return ( this.AuthorizationModelId == input.AuthorizationModelId || (this.AuthorizationModelId != null && this.AuthorizationModelId.Equals(input.AuthorizationModelId)) - ) && + ) && ( this.Object == input.Object || (this.Object != null && this.Object.Equals(input.Object)) - ) && + ) && ( this.Relation == input.Relation || (this.Relation != null && this.Relation.Equals(input.Relation)) - ) && + ) && ( this.UserFilters == input.UserFilters || this.UserFilters != null && input.UserFilters != null && this.UserFilters.SequenceEqual(input.UserFilters) - ) && + ) && ( this.ContextualTuples == input.ContextualTuples || this.ContextualTuples != null && input.ContextualTuples != null && this.ContextualTuples.SequenceEqual(input.ContextualTuples) - ) && + ) && ( this.Context == input.Context || (this.Context != null && this.Context.Equals(input.Context)) - ) && + ) && ( this.Consistency == input.Consistency || this.Consistency.Equals(input.Consistency) @@ -223,38 +210,30 @@ public bool Equals(ListUsersRequest input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.AuthorizationModelId != null) - { + if (this.AuthorizationModelId != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AuthorizationModelId.GetHashCode(); } - if (this.Object != null) - { + if (this.Object != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Object.GetHashCode(); } - if (this.Relation != null) - { + if (this.Relation != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Relation.GetHashCode(); } - if (this.UserFilters != null) - { + if (this.UserFilters != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.UserFilters.GetHashCode(); } - if (this.ContextualTuples != null) - { + if (this.ContextualTuples != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.ContextualTuples.GetHashCode(); } - if (this.Context != null) - { + if (this.Context != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Context.GetHashCode(); } hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Consistency.GetHashCode(); - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -266,11 +245,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/ListUsersResponse.cs b/src/OpenFga.Sdk/Model/ListUsersResponse.cs index ea8d850d..e3a2ca28 100644 --- a/src/OpenFga.Sdk/Model/ListUsersResponse.cs +++ b/src/OpenFga.Sdk/Model/ListUsersResponse.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// ListUsersResponse /// [DataContract(Name = "ListUsersResponse")] - public partial class ListUsersResponse : IEquatable, IValidatableObject - { + public partial class ListUsersResponse : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public ListUsersResponse() - { + public ListUsersResponse() { this.AdditionalProperties = new Dictionary(); } @@ -43,11 +38,9 @@ public ListUsersResponse() /// Initializes a new instance of the class. /// /// users (required). - public ListUsersResponse(List users = default) - { + public ListUsersResponse(List users = default) { // to ensure "users" is required (not null) - if (users == null) - { + if (users == null) { throw new ArgumentNullException("users is a required property for ListUsersResponse and cannot be null"); } this.Users = users; @@ -73,8 +66,7 @@ public ListUsersResponse(List users = default) /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -91,8 +83,7 @@ public static ListUsersResponse FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((ListUsersResponse)input); } @@ -102,13 +93,11 @@ public override bool Equals(object input) /// /// Instance of ListUsersResponse to be compared /// Boolean - public bool Equals(ListUsersResponse input) - { - if (input == null) - { + public bool Equals(ListUsersResponse input) { + if (input == null) { return false; } - return + return ( this.Users == input.Users || this.Users != null && @@ -122,17 +111,14 @@ public bool Equals(ListUsersResponse input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Users != null) - { + if (this.Users != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Users.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -144,11 +130,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + 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 200c2ab1..ed14b16f 100644 --- a/src/OpenFga.Sdk/Model/Metadata.cs +++ b/src/OpenFga.Sdk/Model/Metadata.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// Metadata /// [DataContract(Name = "Metadata")] - public partial class Metadata : IEquatable, IValidatableObject - { + public partial class Metadata : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public Metadata() - { + public Metadata() { this.AdditionalProperties = new Dictionary(); } @@ -45,8 +40,7 @@ public Metadata() /// relations. /// module. /// sourceInfo. - public Metadata(Dictionary relations = default, string module = default, SourceInfo sourceInfo = default) - { + public Metadata(Dictionary relations = default, string module = default, SourceInfo sourceInfo = default) { this.Relations = relations; this.Module = module; this.SourceInfo = sourceInfo; @@ -88,8 +82,7 @@ public Metadata(Dictionary relations = default, string /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -106,8 +99,7 @@ public static Metadata FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((Metadata)input); } @@ -117,24 +109,22 @@ public override bool Equals(object input) /// /// Instance of Metadata to be compared /// Boolean - public bool Equals(Metadata input) - { - if (input == null) - { + public bool Equals(Metadata input) { + if (input == null) { return false; } - return + return ( this.Relations == input.Relations || 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 && @@ -147,25 +137,20 @@ public bool Equals(Metadata input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Relations != null) - { + if (this.Relations != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Relations.GetHashCode(); } - if (this.Module != null) - { + if (this.Module != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Module.GetHashCode(); } - if (this.SourceInfo != null) - { + if (this.SourceInfo != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.SourceInfo.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -177,11 +162,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/Node.cs b/src/OpenFga.Sdk/Model/Node.cs index 615c0f68..de47f4bb 100644 --- a/src/OpenFga.Sdk/Model/Node.cs +++ b/src/OpenFga.Sdk/Model/Node.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// Node /// [DataContract(Name = "Node")] - public partial class Node : IEquatable, IValidatableObject - { + public partial class Node : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public Node() - { + public Node() { this.AdditionalProperties = new Dictionary(); } @@ -47,11 +42,9 @@ public Node() /// difference. /// union. /// intersection. - public Node(string name = default, Leaf leaf = default, UsersetTreeDifference difference = default, Nodes union = default, Nodes intersection = default) - { + public Node(string name = default, Leaf leaf = default, UsersetTreeDifference difference = default, Nodes union = default, Nodes intersection = default) { // to ensure "name" is required (not null) - if (name == null) - { + if (name == null) { throw new ArgumentNullException("name is a required property for Node and cannot be null"); } this.Name = name; @@ -113,8 +106,7 @@ public Node(string name = default, Leaf leaf = default, UsersetTreeDifference di /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -131,8 +123,7 @@ public static Node FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((Node)input); } @@ -142,33 +133,31 @@ public override bool Equals(object input) /// /// Instance of Node to be compared /// Boolean - public bool Equals(Node input) - { - if (input == null) - { + public bool Equals(Node input) { + if (input == null) { return false; } - return + return ( this.Name == input.Name || (this.Name != null && this.Name.Equals(input.Name)) - ) && + ) && ( this.Leaf == input.Leaf || (this.Leaf != null && this.Leaf.Equals(input.Leaf)) - ) && + ) && ( this.Difference == input.Difference || (this.Difference != null && this.Difference.Equals(input.Difference)) - ) && + ) && ( this.Union == input.Union || (this.Union != null && this.Union.Equals(input.Union)) - ) && + ) && ( this.Intersection == input.Intersection || (this.Intersection != null && @@ -181,33 +170,26 @@ public bool Equals(Node input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Name != null) - { + if (this.Name != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Name.GetHashCode(); } - if (this.Leaf != null) - { + if (this.Leaf != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Leaf.GetHashCode(); } - if (this.Difference != null) - { + if (this.Difference != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Difference.GetHashCode(); } - if (this.Union != null) - { + if (this.Union != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Union.GetHashCode(); } - if (this.Intersection != null) - { + if (this.Intersection != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Intersection.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -219,11 +201,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/Nodes.cs b/src/OpenFga.Sdk/Model/Nodes.cs index 67c92fe3..75b8e132 100644 --- a/src/OpenFga.Sdk/Model/Nodes.cs +++ b/src/OpenFga.Sdk/Model/Nodes.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// Nodes /// [DataContract(Name = "Nodes")] - public partial class Nodes : IEquatable, IValidatableObject - { + public partial class Nodes : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public Nodes() - { + public Nodes() { this.AdditionalProperties = new Dictionary(); } @@ -43,11 +38,9 @@ public Nodes() /// Initializes a new instance of the class. /// /// varNodes (required). - public Nodes(List varNodes = default) - { + public Nodes(List varNodes = default) { // to ensure "varNodes" is required (not null) - if (varNodes == null) - { + if (varNodes == null) { throw new ArgumentNullException("varNodes is a required property for Nodes and cannot be null"); } this.VarNodes = varNodes; @@ -73,8 +66,7 @@ public Nodes(List varNodes = default) /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -91,8 +83,7 @@ public static Nodes FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((Nodes)input); } @@ -102,13 +93,11 @@ public override bool Equals(object input) /// /// Instance of Nodes to be compared /// Boolean - public bool Equals(Nodes input) - { - if (input == null) - { + public bool Equals(Nodes input) { + if (input == null) { return false; } - return + return ( this.VarNodes == input.VarNodes || this.VarNodes != null && @@ -122,17 +111,14 @@ public bool Equals(Nodes input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.VarNodes != null) - { + if (this.VarNodes != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.VarNodes.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -144,11 +130,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/NotFoundErrorCode.cs b/src/OpenFga.Sdk/Model/NotFoundErrorCode.cs index f4b7f167..e5c81a37 100644 --- a/src/OpenFga.Sdk/Model/NotFoundErrorCode.cs +++ b/src/OpenFga.Sdk/Model/NotFoundErrorCode.cs @@ -11,25 +11,21 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// Defines NotFoundErrorCode /// [JsonConverter(typeof(JsonStringEnumMemberConverter))] - public enum NotFoundErrorCode - { + public enum NotFoundErrorCode { /// /// Enum NoNotFoundError for value: no_not_found_error /// @@ -56,4 +52,4 @@ public enum NotFoundErrorCode } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/NullValue.cs b/src/OpenFga.Sdk/Model/NullValue.cs index a5186be6..5bc14416 100644 --- a/src/OpenFga.Sdk/Model/NullValue.cs +++ b/src/OpenFga.Sdk/Model/NullValue.cs @@ -11,26 +11,22 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// `NullValue` is a singleton enumeration to represent the null value for the `Value` type union. The JSON representation for `NullValue` is JSON `null`. - NULL_VALUE: Null value. /// /// `NullValue` is a singleton enumeration to represent the null value for the `Value` type union. The JSON representation for `NullValue` is JSON `null`. - NULL_VALUE: Null value. [JsonConverter(typeof(JsonStringEnumMemberConverter))] - public enum NullValue - { + public enum NullValue { /// /// Enum NULLVALUE for value: NULL_VALUE /// @@ -39,4 +35,4 @@ public enum NullValue } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/ObjectRelation.cs b/src/OpenFga.Sdk/Model/ObjectRelation.cs index 0936c143..9acabdda 100644 --- a/src/OpenFga.Sdk/Model/ObjectRelation.cs +++ b/src/OpenFga.Sdk/Model/ObjectRelation.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// ObjectRelation /// [DataContract(Name = "ObjectRelation")] - public partial class ObjectRelation : IEquatable, IValidatableObject - { + public partial class ObjectRelation : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public ObjectRelation() - { + public ObjectRelation() { this.AdditionalProperties = new Dictionary(); } @@ -44,8 +39,7 @@ public ObjectRelation() /// /// varObject. /// relation. - public ObjectRelation(string varObject = default, string relation = default) - { + public ObjectRelation(string varObject = default, string relation = default) { this.Object = varObject; this.Relation = relation; this.AdditionalProperties = new Dictionary(); @@ -78,8 +72,7 @@ public ObjectRelation(string varObject = default, string relation = default) /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -96,8 +89,7 @@ public static ObjectRelation FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((ObjectRelation)input); } @@ -107,18 +99,16 @@ public override bool Equals(object input) /// /// Instance of ObjectRelation to be compared /// Boolean - public bool Equals(ObjectRelation input) - { - if (input == null) - { + public bool Equals(ObjectRelation input) { + if (input == null) { return false; } - return + return ( this.Object == input.Object || (this.Object != null && this.Object.Equals(input.Object)) - ) && + ) && ( this.Relation == input.Relation || (this.Relation != null && @@ -131,21 +121,17 @@ public bool Equals(ObjectRelation input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Object != null) - { + if (this.Object != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Object.GetHashCode(); } - if (this.Relation != null) - { + if (this.Relation != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Relation.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -157,11 +143,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/PathUnknownErrorMessageResponse.cs b/src/OpenFga.Sdk/Model/PathUnknownErrorMessageResponse.cs index fa457f89..84373143 100644 --- a/src/OpenFga.Sdk/Model/PathUnknownErrorMessageResponse.cs +++ b/src/OpenFga.Sdk/Model/PathUnknownErrorMessageResponse.cs @@ -11,25 +11,21 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// PathUnknownErrorMessageResponse /// [DataContract(Name = "PathUnknownErrorMessageResponse")] - public partial class PathUnknownErrorMessageResponse : IEquatable, IValidatableObject - { + public partial class PathUnknownErrorMessageResponse : IEquatable, IValidatableObject { /// /// Gets or Sets Code @@ -41,8 +37,7 @@ public partial class PathUnknownErrorMessageResponse : IEquatable class. /// [JsonConstructor] - public PathUnknownErrorMessageResponse() - { + public PathUnknownErrorMessageResponse() { this.AdditionalProperties = new Dictionary(); } @@ -51,8 +46,7 @@ public PathUnknownErrorMessageResponse() /// /// code. /// message. - public PathUnknownErrorMessageResponse(NotFoundErrorCode? code = default, string message = default) - { + public PathUnknownErrorMessageResponse(NotFoundErrorCode? code = default, string message = default) { this.Code = code; this.Message = message; this.AdditionalProperties = new Dictionary(); @@ -77,8 +71,7 @@ public PathUnknownErrorMessageResponse(NotFoundErrorCode? code = default, string /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -95,8 +88,7 @@ public static PathUnknownErrorMessageResponse FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((PathUnknownErrorMessageResponse)input); } @@ -106,17 +98,15 @@ public override bool Equals(object input) /// /// Instance of PathUnknownErrorMessageResponse to be compared /// Boolean - public bool Equals(PathUnknownErrorMessageResponse input) - { - if (input == null) - { + public bool Equals(PathUnknownErrorMessageResponse input) { + if (input == null) { return false; } - return + return ( this.Code == input.Code || this.Code.Equals(input.Code) - ) && + ) && ( this.Message == input.Message || (this.Message != null && @@ -129,18 +119,15 @@ public bool Equals(PathUnknownErrorMessageResponse input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Code.GetHashCode(); - if (this.Message != null) - { + if (this.Message != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Message.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -152,11 +139,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/ReadAssertionsResponse.cs b/src/OpenFga.Sdk/Model/ReadAssertionsResponse.cs index bf9f2bd6..422ba901 100644 --- a/src/OpenFga.Sdk/Model/ReadAssertionsResponse.cs +++ b/src/OpenFga.Sdk/Model/ReadAssertionsResponse.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// ReadAssertionsResponse /// [DataContract(Name = "ReadAssertionsResponse")] - public partial class ReadAssertionsResponse : IEquatable, IValidatableObject - { + public partial class ReadAssertionsResponse : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public ReadAssertionsResponse() - { + public ReadAssertionsResponse() { this.AdditionalProperties = new Dictionary(); } @@ -44,11 +39,9 @@ public ReadAssertionsResponse() /// /// authorizationModelId (required). /// assertions. - public ReadAssertionsResponse(string authorizationModelId = default, List assertions = default) - { + public ReadAssertionsResponse(string authorizationModelId = default, List assertions = default) { // to ensure "authorizationModelId" is required (not null) - if (authorizationModelId == null) - { + if (authorizationModelId == null) { throw new ArgumentNullException("authorizationModelId is a required property for ReadAssertionsResponse and cannot be null"); } this.AuthorizationModelId = authorizationModelId; @@ -83,8 +76,7 @@ public ReadAssertionsResponse(string authorizationModelId = default, List /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -101,8 +93,7 @@ public static ReadAssertionsResponse FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((ReadAssertionsResponse)input); } @@ -112,18 +103,16 @@ public override bool Equals(object input) /// /// Instance of ReadAssertionsResponse to be compared /// Boolean - public bool Equals(ReadAssertionsResponse input) - { - if (input == null) - { + public bool Equals(ReadAssertionsResponse input) { + if (input == null) { return false; } - return + return ( this.AuthorizationModelId == input.AuthorizationModelId || (this.AuthorizationModelId != null && this.AuthorizationModelId.Equals(input.AuthorizationModelId)) - ) && + ) && ( this.Assertions == input.Assertions || this.Assertions != null && @@ -137,21 +126,17 @@ public bool Equals(ReadAssertionsResponse input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.AuthorizationModelId != null) - { + if (this.AuthorizationModelId != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AuthorizationModelId.GetHashCode(); } - if (this.Assertions != null) - { + if (this.Assertions != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Assertions.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -163,11 +148,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/ReadAuthorizationModelResponse.cs b/src/OpenFga.Sdk/Model/ReadAuthorizationModelResponse.cs index a4f56c1f..f138e3c4 100644 --- a/src/OpenFga.Sdk/Model/ReadAuthorizationModelResponse.cs +++ b/src/OpenFga.Sdk/Model/ReadAuthorizationModelResponse.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// ReadAuthorizationModelResponse /// [DataContract(Name = "ReadAuthorizationModelResponse")] - public partial class ReadAuthorizationModelResponse : IEquatable, IValidatableObject - { + public partial class ReadAuthorizationModelResponse : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public ReadAuthorizationModelResponse() - { + public ReadAuthorizationModelResponse() { this.AdditionalProperties = new Dictionary(); } @@ -43,8 +38,7 @@ public ReadAuthorizationModelResponse() /// Initializes a new instance of the class. /// /// authorizationModel. - public ReadAuthorizationModelResponse(AuthorizationModel authorizationModel = default) - { + public ReadAuthorizationModelResponse(AuthorizationModel authorizationModel = default) { this.AuthorizationModel = authorizationModel; this.AdditionalProperties = new Dictionary(); } @@ -68,8 +62,7 @@ public ReadAuthorizationModelResponse(AuthorizationModel authorizationModel = de /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -86,8 +79,7 @@ public static ReadAuthorizationModelResponse FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((ReadAuthorizationModelResponse)input); } @@ -97,13 +89,11 @@ public override bool Equals(object input) /// /// Instance of ReadAuthorizationModelResponse to be compared /// Boolean - public bool Equals(ReadAuthorizationModelResponse input) - { - if (input == null) - { + public bool Equals(ReadAuthorizationModelResponse input) { + if (input == null) { return false; } - return + return ( this.AuthorizationModel == input.AuthorizationModel || (this.AuthorizationModel != null && @@ -116,17 +106,14 @@ public bool Equals(ReadAuthorizationModelResponse input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.AuthorizationModel != null) - { + if (this.AuthorizationModel != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AuthorizationModel.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -138,11 +125,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/ReadAuthorizationModelsResponse.cs b/src/OpenFga.Sdk/Model/ReadAuthorizationModelsResponse.cs index 0e91eb44..83d57a47 100644 --- a/src/OpenFga.Sdk/Model/ReadAuthorizationModelsResponse.cs +++ b/src/OpenFga.Sdk/Model/ReadAuthorizationModelsResponse.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// ReadAuthorizationModelsResponse /// [DataContract(Name = "ReadAuthorizationModelsResponse")] - public partial class ReadAuthorizationModelsResponse : IEquatable, IValidatableObject - { + public partial class ReadAuthorizationModelsResponse : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public ReadAuthorizationModelsResponse() - { + public ReadAuthorizationModelsResponse() { this.AdditionalProperties = new Dictionary(); } @@ -44,11 +39,9 @@ public ReadAuthorizationModelsResponse() /// /// authorizationModels (required). /// The continuation token will be empty if there are no more models.. - public ReadAuthorizationModelsResponse(List authorizationModels = default, string continuationToken = default) - { + public ReadAuthorizationModelsResponse(List authorizationModels = default, string continuationToken = default) { // to ensure "authorizationModels" is required (not null) - if (authorizationModels == null) - { + if (authorizationModels == null) { throw new ArgumentNullException("authorizationModels is a required property for ReadAuthorizationModelsResponse and cannot be null"); } this.AuthorizationModels = authorizationModels; @@ -84,8 +77,7 @@ public ReadAuthorizationModelsResponse(List authorizationMod /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -102,8 +94,7 @@ public static ReadAuthorizationModelsResponse FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((ReadAuthorizationModelsResponse)input); } @@ -113,19 +104,17 @@ public override bool Equals(object input) /// /// Instance of ReadAuthorizationModelsResponse to be compared /// Boolean - public bool Equals(ReadAuthorizationModelsResponse input) - { - if (input == null) - { + public bool Equals(ReadAuthorizationModelsResponse input) { + if (input == null) { return false; } - return + return ( this.AuthorizationModels == input.AuthorizationModels || this.AuthorizationModels != null && input.AuthorizationModels != null && this.AuthorizationModels.SequenceEqual(input.AuthorizationModels) - ) && + ) && ( this.ContinuationToken == input.ContinuationToken || (this.ContinuationToken != null && @@ -138,21 +127,17 @@ public bool Equals(ReadAuthorizationModelsResponse input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.AuthorizationModels != null) - { + if (this.AuthorizationModels != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AuthorizationModels.GetHashCode(); } - if (this.ContinuationToken != null) - { + if (this.ContinuationToken != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.ContinuationToken.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -164,11 +149,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/ReadChangesResponse.cs b/src/OpenFga.Sdk/Model/ReadChangesResponse.cs index af5fb846..71394fad 100644 --- a/src/OpenFga.Sdk/Model/ReadChangesResponse.cs +++ b/src/OpenFga.Sdk/Model/ReadChangesResponse.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// ReadChangesResponse /// [DataContract(Name = "ReadChangesResponse")] - public partial class ReadChangesResponse : IEquatable, IValidatableObject - { + public partial class ReadChangesResponse : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public ReadChangesResponse() - { + public ReadChangesResponse() { this.AdditionalProperties = new Dictionary(); } @@ -44,11 +39,9 @@ public ReadChangesResponse() /// /// changes (required). /// The continuation token will be identical if there are no new changes.. - public ReadChangesResponse(List changes = default, string continuationToken = default) - { + public ReadChangesResponse(List changes = default, string continuationToken = default) { // to ensure "changes" is required (not null) - if (changes == null) - { + if (changes == null) { throw new ArgumentNullException("changes is a required property for ReadChangesResponse and cannot be null"); } this.Changes = changes; @@ -84,8 +77,7 @@ public ReadChangesResponse(List changes = default, string continuat /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -102,8 +94,7 @@ public static ReadChangesResponse FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((ReadChangesResponse)input); } @@ -113,19 +104,17 @@ public override bool Equals(object input) /// /// Instance of ReadChangesResponse to be compared /// Boolean - public bool Equals(ReadChangesResponse input) - { - if (input == null) - { + public bool Equals(ReadChangesResponse input) { + if (input == null) { return false; } - return + return ( this.Changes == input.Changes || this.Changes != null && input.Changes != null && this.Changes.SequenceEqual(input.Changes) - ) && + ) && ( this.ContinuationToken == input.ContinuationToken || (this.ContinuationToken != null && @@ -138,21 +127,17 @@ public bool Equals(ReadChangesResponse input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Changes != null) - { + if (this.Changes != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Changes.GetHashCode(); } - if (this.ContinuationToken != null) - { + if (this.ContinuationToken != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.ContinuationToken.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -164,11 +149,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/ReadRequest.cs b/src/OpenFga.Sdk/Model/ReadRequest.cs index 0ec8b327..530351e9 100644 --- a/src/OpenFga.Sdk/Model/ReadRequest.cs +++ b/src/OpenFga.Sdk/Model/ReadRequest.cs @@ -11,25 +11,21 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// ReadRequest /// [DataContract(Name = "Read_request")] - public partial class ReadRequest : IEquatable, IValidatableObject - { + public partial class ReadRequest : IEquatable, IValidatableObject { /// /// Gets or Sets Consistency @@ -41,8 +37,7 @@ public partial class ReadRequest : IEquatable, IValidatableObject /// Initializes a new instance of the class. /// [JsonConstructor] - public ReadRequest() - { + public ReadRequest() { this.AdditionalProperties = new Dictionary(); } @@ -53,8 +48,7 @@ public ReadRequest() /// pageSize. /// continuationToken. /// consistency. - public ReadRequest(ReadRequestTupleKey tupleKey = default, int pageSize = default, string continuationToken = default, ConsistencyPreference? consistency = default) - { + public ReadRequest(ReadRequestTupleKey tupleKey = default, int pageSize = default, string continuationToken = default, ConsistencyPreference? consistency = default) { this.TupleKey = tupleKey; this.PageSize = pageSize; this.ContinuationToken = continuationToken; @@ -97,8 +91,7 @@ public ReadRequest(ReadRequestTupleKey tupleKey = default, int pageSize = defaul /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -115,8 +108,7 @@ public static ReadRequest FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((ReadRequest)input); } @@ -126,27 +118,25 @@ public override bool Equals(object input) /// /// Instance of ReadRequest to be compared /// Boolean - public bool Equals(ReadRequest input) - { - if (input == null) - { + public bool Equals(ReadRequest input) { + if (input == null) { return false; } - return + return ( this.TupleKey == input.TupleKey || (this.TupleKey != null && this.TupleKey.Equals(input.TupleKey)) - ) && + ) && ( this.PageSize == input.PageSize || this.PageSize.Equals(input.PageSize) - ) && + ) && ( this.ContinuationToken == input.ContinuationToken || (this.ContinuationToken != null && this.ContinuationToken.Equals(input.ContinuationToken)) - ) && + ) && ( this.Consistency == input.Consistency || this.Consistency.Equals(input.Consistency) @@ -158,23 +148,19 @@ public bool Equals(ReadRequest input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.TupleKey != null) - { + if (this.TupleKey != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.TupleKey.GetHashCode(); } hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.PageSize.GetHashCode(); - if (this.ContinuationToken != null) - { + if (this.ContinuationToken != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.ContinuationToken.GetHashCode(); } hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Consistency.GetHashCode(); - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -186,18 +172,15 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { // PageSize (int) maximum - if (this.PageSize > 100) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for PageSize, must be a value less than or equal to 100.", new [] { "PageSize" }); + if (this.PageSize > 100) { + yield return new ValidationResult("Invalid value for PageSize, must be a value less than or equal to 100.", new[] { "PageSize" }); } // PageSize (int) minimum - if (this.PageSize < 1) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for PageSize, must be a value greater than or equal to 1.", new [] { "PageSize" }); + if (this.PageSize < 1) { + yield return new ValidationResult("Invalid value for PageSize, must be a value greater than or equal to 1.", new[] { "PageSize" }); } yield break; @@ -205,4 +188,4 @@ public override int GetHashCode() } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/ReadRequestTupleKey.cs b/src/OpenFga.Sdk/Model/ReadRequestTupleKey.cs index 7078fade..cc14f320 100644 --- a/src/OpenFga.Sdk/Model/ReadRequestTupleKey.cs +++ b/src/OpenFga.Sdk/Model/ReadRequestTupleKey.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// ReadRequestTupleKey /// [DataContract(Name = "ReadRequestTupleKey")] - public partial class ReadRequestTupleKey : IEquatable, IValidatableObject - { + public partial class ReadRequestTupleKey : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public ReadRequestTupleKey() - { + public ReadRequestTupleKey() { this.AdditionalProperties = new Dictionary(); } @@ -45,8 +40,7 @@ public ReadRequestTupleKey() /// user. /// relation. /// varObject. - public ReadRequestTupleKey(string user = default, string relation = default, string varObject = default) - { + public ReadRequestTupleKey(string user = default, string relation = default, string varObject = default) { this.User = user; this.Relation = relation; this.Object = varObject; @@ -88,8 +82,7 @@ public ReadRequestTupleKey(string user = default, string relation = default, str /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -106,8 +99,7 @@ public static ReadRequestTupleKey FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((ReadRequestTupleKey)input); } @@ -117,23 +109,21 @@ public override bool Equals(object input) /// /// Instance of ReadRequestTupleKey to be compared /// Boolean - public bool Equals(ReadRequestTupleKey input) - { - if (input == null) - { + public bool Equals(ReadRequestTupleKey input) { + if (input == null) { return false; } - return + return ( this.User == input.User || (this.User != null && this.User.Equals(input.User)) - ) && + ) && ( this.Relation == input.Relation || (this.Relation != null && this.Relation.Equals(input.Relation)) - ) && + ) && ( this.Object == input.Object || (this.Object != null && @@ -146,25 +136,20 @@ public bool Equals(ReadRequestTupleKey input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.User != null) - { + if (this.User != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.User.GetHashCode(); } - if (this.Relation != null) - { + if (this.Relation != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Relation.GetHashCode(); } - if (this.Object != null) - { + if (this.Object != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Object.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -176,24 +161,20 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { // User (string) maxLength - if (this.User != null && this.User.Length > 512) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for User, length must be less than 512.", new [] { "User" }); + if (this.User != null && this.User.Length > 512) { + yield return new ValidationResult("Invalid value for User, length must be less than 512.", new[] { "User" }); } // Relation (string) maxLength - if (this.Relation != null && this.Relation.Length > 50) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Relation, length must be less than 50.", new [] { "Relation" }); + if (this.Relation != null && this.Relation.Length > 50) { + yield return new ValidationResult("Invalid value for Relation, length must be less than 50.", new[] { "Relation" }); } // Object (string) maxLength - if (this.Object != null && this.Object.Length > 256) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Object, length must be less than 256.", new [] { "Object" }); + if (this.Object != null && this.Object.Length > 256) { + yield return new ValidationResult("Invalid value for Object, length must be less than 256.", new[] { "Object" }); } yield break; @@ -201,4 +182,4 @@ public override int GetHashCode() } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/ReadResponse.cs b/src/OpenFga.Sdk/Model/ReadResponse.cs index 135dfe37..c6893269 100644 --- a/src/OpenFga.Sdk/Model/ReadResponse.cs +++ b/src/OpenFga.Sdk/Model/ReadResponse.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// ReadResponse /// [DataContract(Name = "ReadResponse")] - public partial class ReadResponse : IEquatable, IValidatableObject - { + public partial class ReadResponse : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public ReadResponse() - { + public ReadResponse() { this.AdditionalProperties = new Dictionary(); } @@ -44,17 +39,14 @@ public ReadResponse() /// /// tuples (required). /// The continuation token will be empty if there are no more tuples. (required). - public ReadResponse(List tuples = default, string continuationToken = default) - { + public ReadResponse(List tuples = default, string continuationToken = default) { // to ensure "tuples" is required (not null) - if (tuples == null) - { + if (tuples == null) { throw new ArgumentNullException("tuples is a required property for ReadResponse and cannot be null"); } this.Tuples = tuples; // to ensure "continuationToken" is required (not null) - if (continuationToken == null) - { + if (continuationToken == null) { throw new ArgumentNullException("continuationToken is a required property for ReadResponse and cannot be null"); } this.ContinuationToken = continuationToken; @@ -89,8 +81,7 @@ public ReadResponse(List tuples = default, string continuationToken = def /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -107,8 +98,7 @@ public static ReadResponse FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((ReadResponse)input); } @@ -118,19 +108,17 @@ public override bool Equals(object input) /// /// Instance of ReadResponse to be compared /// Boolean - public bool Equals(ReadResponse input) - { - if (input == null) - { + public bool Equals(ReadResponse input) { + if (input == null) { return false; } - return + return ( this.Tuples == input.Tuples || this.Tuples != null && input.Tuples != null && this.Tuples.SequenceEqual(input.Tuples) - ) && + ) && ( this.ContinuationToken == input.ContinuationToken || (this.ContinuationToken != null && @@ -143,21 +131,17 @@ public bool Equals(ReadResponse input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Tuples != null) - { + if (this.Tuples != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Tuples.GetHashCode(); } - if (this.ContinuationToken != null) - { + if (this.ContinuationToken != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.ContinuationToken.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -169,11 +153,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/RelationMetadata.cs b/src/OpenFga.Sdk/Model/RelationMetadata.cs index 7f592510..d405362e 100644 --- a/src/OpenFga.Sdk/Model/RelationMetadata.cs +++ b/src/OpenFga.Sdk/Model/RelationMetadata.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// RelationMetadata /// [DataContract(Name = "RelationMetadata")] - public partial class RelationMetadata : IEquatable, IValidatableObject - { + public partial class RelationMetadata : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public RelationMetadata() - { + public RelationMetadata() { this.AdditionalProperties = new Dictionary(); } @@ -45,8 +40,7 @@ public RelationMetadata() /// directlyRelatedUserTypes. /// module. /// sourceInfo. - public RelationMetadata(List directlyRelatedUserTypes = default, string module = default, SourceInfo sourceInfo = default) - { + public RelationMetadata(List directlyRelatedUserTypes = default, string module = default, SourceInfo sourceInfo = default) { this.DirectlyRelatedUserTypes = directlyRelatedUserTypes; this.Module = module; this.SourceInfo = sourceInfo; @@ -88,8 +82,7 @@ public RelationMetadata(List directlyRelatedUserTypes = defau /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -106,8 +99,7 @@ public static RelationMetadata FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((RelationMetadata)input); } @@ -117,24 +109,22 @@ public override bool Equals(object input) /// /// Instance of RelationMetadata to be compared /// Boolean - public bool Equals(RelationMetadata input) - { - if (input == null) - { + public bool Equals(RelationMetadata input) { + if (input == null) { return false; } - return + return ( this.DirectlyRelatedUserTypes == input.DirectlyRelatedUserTypes || 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 && @@ -147,25 +137,20 @@ public bool Equals(RelationMetadata input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.DirectlyRelatedUserTypes != null) - { + if (this.DirectlyRelatedUserTypes != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.DirectlyRelatedUserTypes.GetHashCode(); } - if (this.Module != null) - { + if (this.Module != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Module.GetHashCode(); } - if (this.SourceInfo != null) - { + if (this.SourceInfo != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.SourceInfo.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -177,11 +162,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/RelationReference.cs b/src/OpenFga.Sdk/Model/RelationReference.cs index a9e2631d..2391da3c 100644 --- a/src/OpenFga.Sdk/Model/RelationReference.cs +++ b/src/OpenFga.Sdk/Model/RelationReference.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// RelationReference represents a relation of a particular object type (e.g. 'document#viewer'). /// [DataContract(Name = "RelationReference")] - public partial class RelationReference : IEquatable, IValidatableObject - { + public partial class RelationReference : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public RelationReference() - { + public RelationReference() { this.AdditionalProperties = new Dictionary(); } @@ -46,11 +41,9 @@ public RelationReference() /// relation. /// wildcard. /// The name of a condition that is enforced over the allowed relation.. - public RelationReference(string type = default, string relation = default, Object wildcard = default, string condition = default) - { + public RelationReference(string type = default, string relation = default, Object wildcard = default, string condition = default) { // to ensure "type" is required (not null) - if (type == null) - { + if (type == null) { throw new ArgumentNullException("type is a required property for RelationReference and cannot be null"); } this.Type = type; @@ -104,8 +97,7 @@ public RelationReference(string type = default, string relation = default, Objec /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -122,8 +114,7 @@ public static RelationReference FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((RelationReference)input); } @@ -133,28 +124,26 @@ public override bool Equals(object input) /// /// Instance of RelationReference to be compared /// Boolean - public bool Equals(RelationReference input) - { - if (input == null) - { + public bool Equals(RelationReference input) { + if (input == null) { return false; } - return + return ( this.Type == input.Type || (this.Type != null && this.Type.Equals(input.Type)) - ) && + ) && ( this.Relation == input.Relation || (this.Relation != null && this.Relation.Equals(input.Relation)) - ) && + ) && ( this.Wildcard == input.Wildcard || (this.Wildcard != null && this.Wildcard.Equals(input.Wildcard)) - ) && + ) && ( this.Condition == input.Condition || (this.Condition != null && @@ -167,29 +156,23 @@ public bool Equals(RelationReference input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Type != null) - { + if (this.Type != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Type.GetHashCode(); } - if (this.Relation != null) - { + if (this.Relation != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Relation.GetHashCode(); } - if (this.Wildcard != null) - { + if (this.Wildcard != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Wildcard.GetHashCode(); } - if (this.Condition != null) - { + if (this.Condition != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Condition.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -201,11 +184,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/RelationshipCondition.cs b/src/OpenFga.Sdk/Model/RelationshipCondition.cs index 4ce10fc5..851ebb50 100644 --- a/src/OpenFga.Sdk/Model/RelationshipCondition.cs +++ b/src/OpenFga.Sdk/Model/RelationshipCondition.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// RelationshipCondition /// [DataContract(Name = "RelationshipCondition")] - public partial class RelationshipCondition : IEquatable, IValidatableObject - { + public partial class RelationshipCondition : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public RelationshipCondition() - { + public RelationshipCondition() { this.AdditionalProperties = new Dictionary(); } @@ -44,11 +39,9 @@ public RelationshipCondition() /// /// A reference (by name) of the relationship condition defined in the authorization model. (required). /// Additional context/data to persist along with the condition. The keys must match the parameters defined by the condition, and the value types must match the parameter type definitions.. - public RelationshipCondition(string name = default, Object context = default) - { + public RelationshipCondition(string name = default, Object context = default) { // to ensure "name" is required (not null) - if (name == null) - { + if (name == null) { throw new ArgumentNullException("name is a required property for RelationshipCondition and cannot be null"); } this.Name = name; @@ -85,8 +78,7 @@ public RelationshipCondition(string name = default, Object context = default) /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -103,8 +95,7 @@ public static RelationshipCondition FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((RelationshipCondition)input); } @@ -114,18 +105,16 @@ public override bool Equals(object input) /// /// Instance of RelationshipCondition to be compared /// Boolean - public bool Equals(RelationshipCondition input) - { - if (input == null) - { + public bool Equals(RelationshipCondition input) { + if (input == null) { return false; } - return + return ( this.Name == input.Name || (this.Name != null && this.Name.Equals(input.Name)) - ) && + ) && ( this.Context == input.Context || (this.Context != null && @@ -138,21 +127,17 @@ public bool Equals(RelationshipCondition input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Name != null) - { + if (this.Name != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Name.GetHashCode(); } - if (this.Context != null) - { + if (this.Context != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Context.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -164,12 +149,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { // Name (string) maxLength - if (this.Name != null && this.Name.Length > 256) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Name, length must be less than 256.", new [] { "Name" }); + if (this.Name != null && this.Name.Length > 256) { + yield return new ValidationResult("Invalid value for Name, length must be less than 256.", new[] { "Name" }); } yield break; @@ -177,4 +160,4 @@ public override int GetHashCode() } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/SourceInfo.cs b/src/OpenFga.Sdk/Model/SourceInfo.cs index 081f3f27..0b8e5c41 100644 --- a/src/OpenFga.Sdk/Model/SourceInfo.cs +++ b/src/OpenFga.Sdk/Model/SourceInfo.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// SourceInfo /// [DataContract(Name = "SourceInfo")] - public partial class SourceInfo : IEquatable, IValidatableObject - { + public partial class SourceInfo : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public SourceInfo() - { + public SourceInfo() { this.AdditionalProperties = new Dictionary(); } @@ -43,8 +38,7 @@ public SourceInfo() /// Initializes a new instance of the class. /// /// file. - public SourceInfo(string file = default) - { + public SourceInfo(string file = default) { this.File = file; this.AdditionalProperties = new Dictionary(); } @@ -68,8 +62,7 @@ public SourceInfo(string file = default) /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -86,8 +79,7 @@ public static SourceInfo FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((SourceInfo)input); } @@ -97,13 +89,11 @@ public override bool Equals(object input) /// /// Instance of SourceInfo to be compared /// Boolean - public bool Equals(SourceInfo input) - { - if (input == null) - { + public bool Equals(SourceInfo input) { + if (input == null) { return false; } - return + return ( this.File == input.File || (this.File != null && @@ -116,17 +106,14 @@ public bool Equals(SourceInfo input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.File != null) - { + if (this.File != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.File.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -138,11 +125,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/Status.cs b/src/OpenFga.Sdk/Model/Status.cs index 8939193c..ac4230d0 100644 --- a/src/OpenFga.Sdk/Model/Status.cs +++ b/src/OpenFga.Sdk/Model/Status.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// Status /// [DataContract(Name = "Status")] - public partial class Status : IEquatable, IValidatableObject - { + public partial class Status : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public Status() - { + public Status() { this.AdditionalProperties = new Dictionary(); } @@ -45,8 +40,7 @@ public Status() /// code. /// message. /// details. - public Status(int code = default, string message = default, List details = default) - { + public Status(int code = default, string message = default, List details = default) { this.Code = code; this.Message = message; this.Details = details; @@ -88,8 +82,7 @@ public Status(int code = default, string message = default, List details = /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -106,8 +99,7 @@ public static Status FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((Status)input); } @@ -117,22 +109,20 @@ public override bool Equals(object input) /// /// Instance of Status to be compared /// Boolean - public bool Equals(Status input) - { - if (input == null) - { + public bool Equals(Status input) { + if (input == null) { return false; } - return + return ( this.Code == input.Code || this.Code.Equals(input.Code) - ) && + ) && ( this.Message == input.Message || (this.Message != null && this.Message.Equals(input.Message)) - ) && + ) && ( this.Details == input.Details || this.Details != null && @@ -146,22 +136,18 @@ public bool Equals(Status input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Code.GetHashCode(); - if (this.Message != null) - { + if (this.Message != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Message.GetHashCode(); } - if (this.Details != null) - { + if (this.Details != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Details.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -173,11 +159,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/Store.cs b/src/OpenFga.Sdk/Model/Store.cs index 3e81ea70..6c39279b 100644 --- a/src/OpenFga.Sdk/Model/Store.cs +++ b/src/OpenFga.Sdk/Model/Store.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// Store /// [DataContract(Name = "Store")] - public partial class Store : IEquatable, IValidatableObject - { + public partial class Store : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public Store() - { + public Store() { this.AdditionalProperties = new Dictionary(); } @@ -47,17 +42,14 @@ public Store() /// createdAt (required). /// updatedAt (required). /// deletedAt. - public Store(string id = default, string name = default, DateTime createdAt = default, DateTime updatedAt = default, DateTime deletedAt = default) - { + public Store(string id = default, string name = default, DateTime createdAt = default, DateTime updatedAt = default, DateTime deletedAt = default) { // to ensure "id" is required (not null) - if (id == null) - { + if (id == null) { throw new ArgumentNullException("id is a required property for Store and cannot be null"); } this.Id = id; // to ensure "name" is required (not null) - if (name == null) - { + if (name == null) { throw new ArgumentNullException("name is a required property for Store and cannot be null"); } this.Name = name; @@ -118,8 +110,7 @@ public Store(string id = default, string name = default, DateTime createdAt = de /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -136,8 +127,7 @@ public static Store FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((Store)input); } @@ -147,33 +137,31 @@ public override bool Equals(object input) /// /// Instance of Store to be compared /// Boolean - public bool Equals(Store input) - { - if (input == null) - { + public bool Equals(Store input) { + if (input == null) { return false; } - return + return ( this.Id == input.Id || (this.Id != null && this.Id.Equals(input.Id)) - ) && + ) && ( this.Name == input.Name || (this.Name != null && this.Name.Equals(input.Name)) - ) && + ) && ( this.CreatedAt == input.CreatedAt || (this.CreatedAt != null && this.CreatedAt.Equals(input.CreatedAt)) - ) && + ) && ( this.UpdatedAt == input.UpdatedAt || (this.UpdatedAt != null && this.UpdatedAt.Equals(input.UpdatedAt)) - ) && + ) && ( this.DeletedAt == input.DeletedAt || (this.DeletedAt != null && @@ -186,33 +174,26 @@ public bool Equals(Store input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Id != null) - { + if (this.Id != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Id.GetHashCode(); } - if (this.Name != null) - { + if (this.Name != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Name.GetHashCode(); } - if (this.CreatedAt != null) - { + if (this.CreatedAt != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.CreatedAt.GetHashCode(); } - if (this.UpdatedAt != null) - { + if (this.UpdatedAt != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.UpdatedAt.GetHashCode(); } - if (this.DeletedAt != null) - { + if (this.DeletedAt != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.DeletedAt.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -224,11 +205,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/StreamResultOfStreamedListObjectsResponse.cs b/src/OpenFga.Sdk/Model/StreamResultOfStreamedListObjectsResponse.cs index 255f055d..0b8fbef7 100644 --- a/src/OpenFga.Sdk/Model/StreamResultOfStreamedListObjectsResponse.cs +++ b/src/OpenFga.Sdk/Model/StreamResultOfStreamedListObjectsResponse.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// StreamResultOfStreamedListObjectsResponse /// [DataContract(Name = "Stream_result_of_StreamedListObjectsResponse")] - public partial class StreamResultOfStreamedListObjectsResponse : IEquatable, IValidatableObject - { + public partial class StreamResultOfStreamedListObjectsResponse : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public StreamResultOfStreamedListObjectsResponse() - { + public StreamResultOfStreamedListObjectsResponse() { this.AdditionalProperties = new Dictionary(); } @@ -44,8 +39,7 @@ public StreamResultOfStreamedListObjectsResponse() /// /// result. /// error. - public StreamResultOfStreamedListObjectsResponse(StreamedListObjectsResponse result = default, Status error = default) - { + public StreamResultOfStreamedListObjectsResponse(StreamedListObjectsResponse result = default, Status error = default) { this.Result = result; this.Error = error; this.AdditionalProperties = new Dictionary(); @@ -78,8 +72,7 @@ public StreamResultOfStreamedListObjectsResponse(StreamedListObjectsResponse res /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -96,8 +89,7 @@ public static StreamResultOfStreamedListObjectsResponse FromJson(string jsonStri /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((StreamResultOfStreamedListObjectsResponse)input); } @@ -107,18 +99,16 @@ public override bool Equals(object input) /// /// Instance of StreamResultOfStreamedListObjectsResponse to be compared /// Boolean - public bool Equals(StreamResultOfStreamedListObjectsResponse input) - { - if (input == null) - { + public bool Equals(StreamResultOfStreamedListObjectsResponse input) { + if (input == null) { return false; } - return + return ( this.Result == input.Result || (this.Result != null && this.Result.Equals(input.Result)) - ) && + ) && ( this.Error == input.Error || (this.Error != null && @@ -131,21 +121,17 @@ public bool Equals(StreamResultOfStreamedListObjectsResponse input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Result != null) - { + if (this.Result != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Result.GetHashCode(); } - if (this.Error != null) - { + if (this.Error != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Error.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -157,11 +143,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/StreamedListObjectsResponse.cs b/src/OpenFga.Sdk/Model/StreamedListObjectsResponse.cs index 80a00e8d..8681f9db 100644 --- a/src/OpenFga.Sdk/Model/StreamedListObjectsResponse.cs +++ b/src/OpenFga.Sdk/Model/StreamedListObjectsResponse.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// The response for a StreamedListObjects RPC. /// [DataContract(Name = "StreamedListObjectsResponse")] - public partial class StreamedListObjectsResponse : IEquatable, IValidatableObject - { + public partial class StreamedListObjectsResponse : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public StreamedListObjectsResponse() - { + public StreamedListObjectsResponse() { this.AdditionalProperties = new Dictionary(); } @@ -43,11 +38,9 @@ public StreamedListObjectsResponse() /// Initializes a new instance of the class. /// /// varObject (required). - public StreamedListObjectsResponse(string varObject = default) - { + public StreamedListObjectsResponse(string varObject = default) { // to ensure "varObject" is required (not null) - if (varObject == null) - { + if (varObject == null) { throw new ArgumentNullException("varObject is a required property for StreamedListObjectsResponse and cannot be null"); } this.Object = varObject; @@ -73,8 +66,7 @@ public StreamedListObjectsResponse(string varObject = default) /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -91,8 +83,7 @@ public static StreamedListObjectsResponse FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((StreamedListObjectsResponse)input); } @@ -102,13 +93,11 @@ public override bool Equals(object input) /// /// Instance of StreamedListObjectsResponse to be compared /// Boolean - public bool Equals(StreamedListObjectsResponse input) - { - if (input == null) - { + public bool Equals(StreamedListObjectsResponse input) { + if (input == null) { return false; } - return + return ( this.Object == input.Object || (this.Object != null && @@ -121,17 +110,14 @@ public bool Equals(StreamedListObjectsResponse input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Object != null) - { + if (this.Object != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Object.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -143,11 +129,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/Tuple.cs b/src/OpenFga.Sdk/Model/Tuple.cs index 155e1ab8..dbe7190e 100644 --- a/src/OpenFga.Sdk/Model/Tuple.cs +++ b/src/OpenFga.Sdk/Model/Tuple.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// Tuple /// [DataContract(Name = "Tuple")] - public partial class Tuple : IEquatable, IValidatableObject - { + public partial class Tuple : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public Tuple() - { + public Tuple() { this.AdditionalProperties = new Dictionary(); } @@ -44,11 +39,9 @@ public Tuple() /// /// key (required). /// timestamp (required). - public Tuple(TupleKey key = default, DateTime timestamp = default) - { + public Tuple(TupleKey key = default, DateTime timestamp = default) { // to ensure "key" is required (not null) - if (key == null) - { + if (key == null) { throw new ArgumentNullException("key is a required property for Tuple and cannot be null"); } this.Key = key; @@ -83,8 +76,7 @@ public Tuple(TupleKey key = default, DateTime timestamp = default) /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -101,8 +93,7 @@ public static Tuple FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((Tuple)input); } @@ -112,18 +103,16 @@ public override bool Equals(object input) /// /// Instance of Tuple to be compared /// Boolean - public bool Equals(Tuple input) - { - if (input == null) - { + public bool Equals(Tuple input) { + if (input == null) { return false; } - return + return ( this.Key == input.Key || (this.Key != null && this.Key.Equals(input.Key)) - ) && + ) && ( this.Timestamp == input.Timestamp || (this.Timestamp != null && @@ -136,21 +125,17 @@ public bool Equals(Tuple input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Key != null) - { + if (this.Key != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Key.GetHashCode(); } - if (this.Timestamp != null) - { + if (this.Timestamp != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Timestamp.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -162,11 +147,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/TupleChange.cs b/src/OpenFga.Sdk/Model/TupleChange.cs index bcbf0efd..c99fb4cc 100644 --- a/src/OpenFga.Sdk/Model/TupleChange.cs +++ b/src/OpenFga.Sdk/Model/TupleChange.cs @@ -11,25 +11,21 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// TupleChange /// [DataContract(Name = "TupleChange")] - public partial class TupleChange : IEquatable, IValidatableObject - { + public partial class TupleChange : IEquatable, IValidatableObject { /// /// Gets or Sets Operation @@ -41,8 +37,7 @@ public partial class TupleChange : IEquatable, IValidatableObject /// Initializes a new instance of the class. /// [JsonConstructor] - public TupleChange() - { + public TupleChange() { this.AdditionalProperties = new Dictionary(); } @@ -52,11 +47,9 @@ public TupleChange() /// tupleKey (required). /// operation (required). /// timestamp (required). - public TupleChange(TupleKey tupleKey = default, TupleOperation operation = default, DateTime timestamp = default) - { + public TupleChange(TupleKey tupleKey = default, TupleOperation operation = default, DateTime timestamp = default) { // to ensure "tupleKey" is required (not null) - if (tupleKey == null) - { + if (tupleKey == null) { throw new ArgumentNullException("tupleKey is a required property for TupleChange and cannot be null"); } this.TupleKey = tupleKey; @@ -92,8 +85,7 @@ public TupleChange(TupleKey tupleKey = default, TupleOperation operation = defau /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -110,8 +102,7 @@ public static TupleChange FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((TupleChange)input); } @@ -121,10 +112,8 @@ public override bool Equals(object input) /// /// Instance of TupleChange to be compared /// Boolean - public bool Equals(TupleChange input) - { - if (input == null) - { + public bool Equals(TupleChange input) { + if (input == null) { return false; } return @@ -147,19 +136,16 @@ public bool Equals(TupleChange input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.TupleKey != null) - { + if (this.TupleKey != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.TupleKey.GetHashCode(); } hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Operation.GetHashCode(); hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Timestamp.GetHashCode(); - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -171,11 +157,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/TupleKey.cs b/src/OpenFga.Sdk/Model/TupleKey.cs index 9ac525ad..b429ad2d 100644 --- a/src/OpenFga.Sdk/Model/TupleKey.cs +++ b/src/OpenFga.Sdk/Model/TupleKey.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// TupleKey /// [DataContract(Name = "TupleKey")] - public partial class TupleKey : IEquatable, IValidatableObject - { + public partial class TupleKey : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public TupleKey() - { + public TupleKey() { this.AdditionalProperties = new Dictionary(); } @@ -46,23 +41,19 @@ public TupleKey() /// relation (required). /// varObject (required). /// condition. - public TupleKey(string user = default, string relation = default, string varObject = default, RelationshipCondition condition = default) - { + public TupleKey(string user = default, string relation = default, string varObject = default, RelationshipCondition condition = default) { // to ensure "user" is required (not null) - if (user == null) - { + if (user == null) { throw new ArgumentNullException("user is a required property for TupleKey and cannot be null"); } this.User = user; // to ensure "relation" is required (not null) - if (relation == null) - { + if (relation == null) { throw new ArgumentNullException("relation is a required property for TupleKey and cannot be null"); } this.Relation = relation; // to ensure "varObject" is required (not null) - if (varObject == null) - { + if (varObject == null) { throw new ArgumentNullException("varObject is a required property for TupleKey and cannot be null"); } this.Object = varObject; @@ -113,8 +104,7 @@ public TupleKey(string user = default, string relation = default, string varObje /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -131,8 +121,7 @@ public static TupleKey FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((TupleKey)input); } @@ -142,28 +131,26 @@ public override bool Equals(object input) /// /// Instance of TupleKey to be compared /// Boolean - public bool Equals(TupleKey input) - { - if (input == null) - { + public bool Equals(TupleKey input) { + if (input == null) { return false; } - return + return ( this.User == input.User || (this.User != null && this.User.Equals(input.User)) - ) && + ) && ( this.Relation == input.Relation || (this.Relation != null && this.Relation.Equals(input.Relation)) - ) && + ) && ( this.Object == input.Object || (this.Object != null && this.Object.Equals(input.Object)) - ) && + ) && ( this.Condition == input.Condition || (this.Condition != null && @@ -176,29 +163,23 @@ public bool Equals(TupleKey input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.User != null) - { + if (this.User != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.User.GetHashCode(); } - if (this.Relation != null) - { + if (this.Relation != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Relation.GetHashCode(); } - if (this.Object != null) - { + if (this.Object != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Object.GetHashCode(); } - if (this.Condition != null) - { + if (this.Condition != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Condition.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -210,24 +191,20 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { // User (string) maxLength - if (this.User != null && this.User.Length > 512) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for User, length must be less than 512.", new [] { "User" }); + if (this.User != null && this.User.Length > 512) { + yield return new ValidationResult("Invalid value for User, length must be less than 512.", new[] { "User" }); } // Relation (string) maxLength - if (this.Relation != null && this.Relation.Length > 50) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Relation, length must be less than 50.", new [] { "Relation" }); + if (this.Relation != null && this.Relation.Length > 50) { + yield return new ValidationResult("Invalid value for Relation, length must be less than 50.", new[] { "Relation" }); } // Object (string) maxLength - if (this.Object != null && this.Object.Length > 256) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Object, length must be less than 256.", new [] { "Object" }); + if (this.Object != null && this.Object.Length > 256) { + yield return new ValidationResult("Invalid value for Object, length must be less than 256.", new[] { "Object" }); } yield break; @@ -235,4 +212,4 @@ public override int GetHashCode() } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/TupleKeyWithoutCondition.cs b/src/OpenFga.Sdk/Model/TupleKeyWithoutCondition.cs index a3c948ae..6555b75c 100644 --- a/src/OpenFga.Sdk/Model/TupleKeyWithoutCondition.cs +++ b/src/OpenFga.Sdk/Model/TupleKeyWithoutCondition.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// TupleKeyWithoutCondition /// [DataContract(Name = "TupleKeyWithoutCondition")] - public partial class TupleKeyWithoutCondition : IEquatable, IValidatableObject - { + public partial class TupleKeyWithoutCondition : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public TupleKeyWithoutCondition() - { + public TupleKeyWithoutCondition() { this.AdditionalProperties = new Dictionary(); } @@ -45,23 +40,19 @@ public TupleKeyWithoutCondition() /// user (required). /// relation (required). /// varObject (required). - public TupleKeyWithoutCondition(string user = default, string relation = default, string varObject = default) - { + public TupleKeyWithoutCondition(string user = default, string relation = default, string varObject = default) { // to ensure "user" is required (not null) - if (user == null) - { + if (user == null) { throw new ArgumentNullException("user is a required property for TupleKeyWithoutCondition and cannot be null"); } this.User = user; // to ensure "relation" is required (not null) - if (relation == null) - { + if (relation == null) { throw new ArgumentNullException("relation is a required property for TupleKeyWithoutCondition and cannot be null"); } this.Relation = relation; // to ensure "varObject" is required (not null) - if (varObject == null) - { + if (varObject == null) { throw new ArgumentNullException("varObject is a required property for TupleKeyWithoutCondition and cannot be null"); } this.Object = varObject; @@ -103,8 +94,7 @@ public TupleKeyWithoutCondition(string user = default, string relation = default /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -121,8 +111,7 @@ public static TupleKeyWithoutCondition FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((TupleKeyWithoutCondition)input); } @@ -132,23 +121,21 @@ public override bool Equals(object input) /// /// Instance of TupleKeyWithoutCondition to be compared /// Boolean - public bool Equals(TupleKeyWithoutCondition input) - { - if (input == null) - { + public bool Equals(TupleKeyWithoutCondition input) { + if (input == null) { return false; } - return + return ( this.User == input.User || (this.User != null && this.User.Equals(input.User)) - ) && + ) && ( this.Relation == input.Relation || (this.Relation != null && this.Relation.Equals(input.Relation)) - ) && + ) && ( this.Object == input.Object || (this.Object != null && @@ -161,25 +148,20 @@ public bool Equals(TupleKeyWithoutCondition input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.User != null) - { + if (this.User != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.User.GetHashCode(); } - if (this.Relation != null) - { + if (this.Relation != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Relation.GetHashCode(); } - if (this.Object != null) - { + if (this.Object != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Object.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -191,24 +173,20 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { // User (string) maxLength - if (this.User != null && this.User.Length > 512) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for User, length must be less than 512.", new [] { "User" }); + if (this.User != null && this.User.Length > 512) { + yield return new ValidationResult("Invalid value for User, length must be less than 512.", new[] { "User" }); } // Relation (string) maxLength - if (this.Relation != null && this.Relation.Length > 50) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Relation, length must be less than 50.", new [] { "Relation" }); + if (this.Relation != null && this.Relation.Length > 50) { + yield return new ValidationResult("Invalid value for Relation, length must be less than 50.", new[] { "Relation" }); } // Object (string) maxLength - if (this.Object != null && this.Object.Length > 256) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Object, length must be less than 256.", new [] { "Object" }); + if (this.Object != null && this.Object.Length > 256) { + yield return new ValidationResult("Invalid value for Object, length must be less than 256.", new[] { "Object" }); } yield break; @@ -216,4 +194,4 @@ public override int GetHashCode() } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/TupleOperation.cs b/src/OpenFga.Sdk/Model/TupleOperation.cs index 49cedad2..66b2794f 100644 --- a/src/OpenFga.Sdk/Model/TupleOperation.cs +++ b/src/OpenFga.Sdk/Model/TupleOperation.cs @@ -11,25 +11,21 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// Defines TupleOperation /// [JsonConverter(typeof(JsonStringEnumMemberConverter))] - public enum TupleOperation - { + public enum TupleOperation { /// /// Enum TUPLEOPERATIONWRITE for value: TUPLE_OPERATION_WRITE /// @@ -44,4 +40,4 @@ public enum TupleOperation } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/TupleToUserset.cs b/src/OpenFga.Sdk/Model/TupleToUserset.cs index f9881e41..51b38fbf 100644 --- a/src/OpenFga.Sdk/Model/TupleToUserset.cs +++ b/src/OpenFga.Sdk/Model/TupleToUserset.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// TupleToUserset /// [DataContract(Name = "TupleToUserset")] - public partial class TupleToUserset : IEquatable, IValidatableObject - { + public partial class TupleToUserset : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public TupleToUserset() - { + public TupleToUserset() { this.AdditionalProperties = new Dictionary(); } @@ -44,17 +39,14 @@ public TupleToUserset() /// /// tupleset (required). /// computedUserset (required). - public TupleToUserset(ObjectRelation tupleset = default, ObjectRelation computedUserset = default) - { + public TupleToUserset(ObjectRelation tupleset = default, ObjectRelation computedUserset = default) { // to ensure "tupleset" is required (not null) - if (tupleset == null) - { + if (tupleset == null) { throw new ArgumentNullException("tupleset is a required property for TupleToUserset and cannot be null"); } this.Tupleset = tupleset; // to ensure "computedUserset" is required (not null) - if (computedUserset == null) - { + if (computedUserset == null) { throw new ArgumentNullException("computedUserset is a required property for TupleToUserset and cannot be null"); } this.ComputedUserset = computedUserset; @@ -88,8 +80,7 @@ public TupleToUserset(ObjectRelation tupleset = default, ObjectRelation computed /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -106,8 +97,7 @@ public static TupleToUserset FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((TupleToUserset)input); } @@ -117,18 +107,16 @@ public override bool Equals(object input) /// /// Instance of TupleToUserset to be compared /// Boolean - public bool Equals(TupleToUserset input) - { - if (input == null) - { + public bool Equals(TupleToUserset input) { + if (input == null) { return false; } - return + return ( this.Tupleset == input.Tupleset || (this.Tupleset != null && this.Tupleset.Equals(input.Tupleset)) - ) && + ) && ( this.ComputedUserset == input.ComputedUserset || (this.ComputedUserset != null && @@ -141,21 +129,17 @@ public bool Equals(TupleToUserset input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Tupleset != null) - { + if (this.Tupleset != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Tupleset.GetHashCode(); } - if (this.ComputedUserset != null) - { + if (this.ComputedUserset != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.ComputedUserset.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -167,11 +151,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/TypeDefinition.cs b/src/OpenFga.Sdk/Model/TypeDefinition.cs index f3573538..bcbc9c71 100644 --- a/src/OpenFga.Sdk/Model/TypeDefinition.cs +++ b/src/OpenFga.Sdk/Model/TypeDefinition.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// TypeDefinition /// [DataContract(Name = "TypeDefinition")] - public partial class TypeDefinition : IEquatable, IValidatableObject - { + public partial class TypeDefinition : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public TypeDefinition() - { + public TypeDefinition() { this.AdditionalProperties = new Dictionary(); } @@ -45,11 +40,9 @@ public TypeDefinition() /// type (required). /// relations. /// metadata. - public TypeDefinition(string type = default, Dictionary relations = default, Metadata metadata = default) - { + public TypeDefinition(string type = default, Dictionary relations = default, Metadata metadata = default) { // to ensure "type" is required (not null) - if (type == null) - { + if (type == null) { throw new ArgumentNullException("type is a required property for TypeDefinition and cannot be null"); } this.Type = type; @@ -93,8 +86,7 @@ public TypeDefinition(string type = default, Dictionary relatio /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -111,8 +103,7 @@ public static TypeDefinition FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((TypeDefinition)input); } @@ -122,24 +113,22 @@ public override bool Equals(object input) /// /// Instance of TypeDefinition to be compared /// Boolean - public bool Equals(TypeDefinition input) - { - if (input == null) - { + public bool Equals(TypeDefinition input) { + if (input == null) { return false; } - return + return ( this.Type == input.Type || (this.Type != null && this.Type.Equals(input.Type)) - ) && + ) && ( this.Relations == input.Relations || this.Relations != null && input.Relations != null && this.Relations.SequenceEqual(input.Relations) - ) && + ) && ( this.Metadata == input.Metadata || (this.Metadata != null && @@ -152,25 +141,20 @@ public bool Equals(TypeDefinition input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Type != null) - { + if (this.Type != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Type.GetHashCode(); } - if (this.Relations != null) - { + if (this.Relations != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Relations.GetHashCode(); } - if (this.Metadata != null) - { + if (this.Metadata != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Metadata.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -182,11 +166,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/TypeName.cs b/src/OpenFga.Sdk/Model/TypeName.cs index 3d7b1d4f..be58945b 100644 --- a/src/OpenFga.Sdk/Model/TypeName.cs +++ b/src/OpenFga.Sdk/Model/TypeName.cs @@ -11,25 +11,21 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// Defines TypeName /// [JsonConverter(typeof(JsonStringEnumMemberConverter))] - public enum TypeName - { + public enum TypeName { /// /// Enum TYPENAMEUNSPECIFIED for value: TYPE_NAME_UNSPECIFIED /// @@ -104,4 +100,4 @@ public enum TypeName } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/TypedWildcard.cs b/src/OpenFga.Sdk/Model/TypedWildcard.cs index 188c8aa2..8acffdb4 100644 --- a/src/OpenFga.Sdk/Model/TypedWildcard.cs +++ b/src/OpenFga.Sdk/Model/TypedWildcard.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// Type bound public access. Normally represented using the `<type>:*` syntax `employee:*` represents every object of type `employee`, including those not currently present in the system See https://openfga.dev/docs/concepts#what-is-type-bound-public-access /// [DataContract(Name = "TypedWildcard")] - public partial class TypedWildcard : IEquatable, IValidatableObject - { + public partial class TypedWildcard : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public TypedWildcard() - { + public TypedWildcard() { this.AdditionalProperties = new Dictionary(); } @@ -43,11 +38,9 @@ public TypedWildcard() /// Initializes a new instance of the class. /// /// type (required). - public TypedWildcard(string type = default) - { + public TypedWildcard(string type = default) { // to ensure "type" is required (not null) - if (type == null) - { + if (type == null) { throw new ArgumentNullException("type is a required property for TypedWildcard and cannot be null"); } this.Type = type; @@ -73,8 +66,7 @@ public TypedWildcard(string type = default) /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -91,8 +83,7 @@ public static TypedWildcard FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((TypedWildcard)input); } @@ -102,13 +93,11 @@ public override bool Equals(object input) /// /// Instance of TypedWildcard to be compared /// Boolean - public bool Equals(TypedWildcard input) - { - if (input == null) - { + public bool Equals(TypedWildcard input) { + if (input == null) { return false; } - return + return ( this.Type == input.Type || (this.Type != null && @@ -121,17 +110,14 @@ public bool Equals(TypedWildcard input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Type != null) - { + if (this.Type != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Type.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -143,11 +129,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/UnauthenticatedResponse.cs b/src/OpenFga.Sdk/Model/UnauthenticatedResponse.cs index 1be5689d..f5cdf742 100644 --- a/src/OpenFga.Sdk/Model/UnauthenticatedResponse.cs +++ b/src/OpenFga.Sdk/Model/UnauthenticatedResponse.cs @@ -11,25 +11,21 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// UnauthenticatedResponse /// [DataContract(Name = "UnauthenticatedResponse")] - public partial class UnauthenticatedResponse : IEquatable, IValidatableObject - { + public partial class UnauthenticatedResponse : IEquatable, IValidatableObject { /// /// Gets or Sets Code @@ -41,8 +37,7 @@ public partial class UnauthenticatedResponse : IEquatable class. /// [JsonConstructor] - public UnauthenticatedResponse() - { + public UnauthenticatedResponse() { this.AdditionalProperties = new Dictionary(); } @@ -51,8 +46,7 @@ public UnauthenticatedResponse() /// /// code. /// message. - public UnauthenticatedResponse(ErrorCode? code = default, string message = default) - { + public UnauthenticatedResponse(ErrorCode? code = default, string message = default) { this.Code = code; this.Message = message; this.AdditionalProperties = new Dictionary(); @@ -77,8 +71,7 @@ public UnauthenticatedResponse(ErrorCode? code = default, string message = defau /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -95,8 +88,7 @@ public static UnauthenticatedResponse FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((UnauthenticatedResponse)input); } @@ -106,17 +98,15 @@ public override bool Equals(object input) /// /// Instance of UnauthenticatedResponse to be compared /// Boolean - public bool Equals(UnauthenticatedResponse input) - { - if (input == null) - { + public bool Equals(UnauthenticatedResponse input) { + if (input == null) { return false; } - return + return ( this.Code == input.Code || this.Code.Equals(input.Code) - ) && + ) && ( this.Message == input.Message || (this.Message != null && @@ -129,18 +119,15 @@ public bool Equals(UnauthenticatedResponse input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Code.GetHashCode(); - if (this.Message != null) - { + if (this.Message != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Message.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -152,11 +139,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/UnprocessableContentErrorCode.cs b/src/OpenFga.Sdk/Model/UnprocessableContentErrorCode.cs index af05fbf2..2dc572aa 100644 --- a/src/OpenFga.Sdk/Model/UnprocessableContentErrorCode.cs +++ b/src/OpenFga.Sdk/Model/UnprocessableContentErrorCode.cs @@ -11,25 +11,21 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// Defines UnprocessableContentErrorCode /// [JsonConverter(typeof(JsonStringEnumMemberConverter))] - public enum UnprocessableContentErrorCode - { + public enum UnprocessableContentErrorCode { /// /// Enum NoThrottledErrorCode for value: no_throttled_error_code /// @@ -44,4 +40,4 @@ public enum UnprocessableContentErrorCode } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/UnprocessableContentMessageResponse.cs b/src/OpenFga.Sdk/Model/UnprocessableContentMessageResponse.cs index 5f72af88..04995916 100644 --- a/src/OpenFga.Sdk/Model/UnprocessableContentMessageResponse.cs +++ b/src/OpenFga.Sdk/Model/UnprocessableContentMessageResponse.cs @@ -11,25 +11,21 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// UnprocessableContentMessageResponse /// [DataContract(Name = "UnprocessableContentMessageResponse")] - public partial class UnprocessableContentMessageResponse : IEquatable, IValidatableObject - { + public partial class UnprocessableContentMessageResponse : IEquatable, IValidatableObject { /// /// Gets or Sets Code @@ -41,8 +37,7 @@ public partial class UnprocessableContentMessageResponse : IEquatable class. /// [JsonConstructor] - public UnprocessableContentMessageResponse() - { + public UnprocessableContentMessageResponse() { this.AdditionalProperties = new Dictionary(); } @@ -51,8 +46,7 @@ public UnprocessableContentMessageResponse() /// /// code. /// message. - public UnprocessableContentMessageResponse(UnprocessableContentErrorCode? code = default, string message = default) - { + public UnprocessableContentMessageResponse(UnprocessableContentErrorCode? code = default, string message = default) { this.Code = code; this.Message = message; this.AdditionalProperties = new Dictionary(); @@ -77,8 +71,7 @@ public UnprocessableContentMessageResponse(UnprocessableContentErrorCode? code = /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -95,8 +88,7 @@ public static UnprocessableContentMessageResponse FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((UnprocessableContentMessageResponse)input); } @@ -106,17 +98,15 @@ public override bool Equals(object input) /// /// Instance of UnprocessableContentMessageResponse to be compared /// Boolean - public bool Equals(UnprocessableContentMessageResponse input) - { - if (input == null) - { + public bool Equals(UnprocessableContentMessageResponse input) { + if (input == null) { return false; } - return + return ( this.Code == input.Code || this.Code.Equals(input.Code) - ) && + ) && ( this.Message == input.Message || (this.Message != null && @@ -129,18 +119,15 @@ public bool Equals(UnprocessableContentMessageResponse input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Code.GetHashCode(); - if (this.Message != null) - { + if (this.Message != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Message.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -152,11 +139,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/User.cs b/src/OpenFga.Sdk/Model/User.cs index 919224c7..2e079111 100644 --- a/src/OpenFga.Sdk/Model/User.cs +++ b/src/OpenFga.Sdk/Model/User.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// User. Represents any possible value for a user (subject or principal). Can be a: - Specific user object e.g.: 'user:will', 'folder:marketing', 'org:contoso', ...) - Specific userset (e.g. 'group:engineering#member') - Public-typed wildcard (e.g. 'user:*') See https://openfga.dev/docs/concepts#what-is-a-user /// [DataContract(Name = "User")] - public partial class User : IEquatable, IValidatableObject - { + public partial class User : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public User() - { + public User() { this.AdditionalProperties = new Dictionary(); } @@ -45,8 +40,7 @@ public User() /// varObject. /// userset. /// wildcard. - public User(FgaObject varObject = default, UsersetUser userset = default, TypedWildcard wildcard = default) - { + public User(FgaObject varObject = default, UsersetUser userset = default, TypedWildcard wildcard = default) { this.Object = varObject; this.Userset = userset; this.Wildcard = wildcard; @@ -88,8 +82,7 @@ public User(FgaObject varObject = default, UsersetUser userset = default, TypedW /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -106,8 +99,7 @@ public static User FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((User)input); } @@ -117,23 +109,21 @@ public override bool Equals(object input) /// /// Instance of User to be compared /// Boolean - public bool Equals(User input) - { - if (input == null) - { + public bool Equals(User input) { + if (input == null) { return false; } - return + return ( this.Object == input.Object || (this.Object != null && this.Object.Equals(input.Object)) - ) && + ) && ( this.Userset == input.Userset || (this.Userset != null && this.Userset.Equals(input.Userset)) - ) && + ) && ( this.Wildcard == input.Wildcard || (this.Wildcard != null && @@ -146,25 +136,20 @@ public bool Equals(User input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Object != null) - { + if (this.Object != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Object.GetHashCode(); } - if (this.Userset != null) - { + if (this.Userset != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Userset.GetHashCode(); } - if (this.Wildcard != null) - { + if (this.Wildcard != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Wildcard.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -176,11 +161,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/UserTypeFilter.cs b/src/OpenFga.Sdk/Model/UserTypeFilter.cs index 7298f03b..4e7981a2 100644 --- a/src/OpenFga.Sdk/Model/UserTypeFilter.cs +++ b/src/OpenFga.Sdk/Model/UserTypeFilter.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// UserTypeFilter /// [DataContract(Name = "UserTypeFilter")] - public partial class UserTypeFilter : IEquatable, IValidatableObject - { + public partial class UserTypeFilter : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public UserTypeFilter() - { + public UserTypeFilter() { this.AdditionalProperties = new Dictionary(); } @@ -44,11 +39,9 @@ public UserTypeFilter() /// /// type (required). /// relation. - public UserTypeFilter(string type = default, string relation = default) - { + public UserTypeFilter(string type = default, string relation = default) { // to ensure "type" is required (not null) - if (type == null) - { + if (type == null) { throw new ArgumentNullException("type is a required property for UserTypeFilter and cannot be null"); } this.Type = type; @@ -83,8 +76,7 @@ public UserTypeFilter(string type = default, string relation = default) /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -101,8 +93,7 @@ public static UserTypeFilter FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((UserTypeFilter)input); } @@ -112,18 +103,16 @@ public override bool Equals(object input) /// /// Instance of UserTypeFilter to be compared /// Boolean - public bool Equals(UserTypeFilter input) - { - if (input == null) - { + public bool Equals(UserTypeFilter input) { + if (input == null) { return false; } - return + return ( this.Type == input.Type || (this.Type != null && this.Type.Equals(input.Type)) - ) && + ) && ( this.Relation == input.Relation || (this.Relation != null && @@ -136,21 +125,17 @@ public bool Equals(UserTypeFilter input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Type != null) - { + if (this.Type != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Type.GetHashCode(); } - if (this.Relation != null) - { + if (this.Relation != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Relation.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -162,11 +147,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/Users.cs b/src/OpenFga.Sdk/Model/Users.cs index 6fd8b1dd..4d67b00b 100644 --- a/src/OpenFga.Sdk/Model/Users.cs +++ b/src/OpenFga.Sdk/Model/Users.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// Users /// [DataContract(Name = "Users")] - public partial class Users : IEquatable, IValidatableObject - { + public partial class Users : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public Users() - { + public Users() { this.AdditionalProperties = new Dictionary(); } @@ -43,11 +38,9 @@ public Users() /// Initializes a new instance of the class. /// /// varUsers (required). - public Users(List varUsers = default) - { + public Users(List varUsers = default) { // to ensure "varUsers" is required (not null) - if (varUsers == null) - { + if (varUsers == null) { throw new ArgumentNullException("varUsers is a required property for Users and cannot be null"); } this.VarUsers = varUsers; @@ -73,8 +66,7 @@ public Users(List varUsers = default) /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -91,8 +83,7 @@ public static Users FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((Users)input); } @@ -102,13 +93,11 @@ public override bool Equals(object input) /// /// Instance of Users to be compared /// Boolean - public bool Equals(Users input) - { - if (input == null) - { + public bool Equals(Users input) { + if (input == null) { return false; } - return + return ( this.VarUsers == input.VarUsers || this.VarUsers != null && @@ -122,17 +111,14 @@ public bool Equals(Users input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.VarUsers != null) - { + if (this.VarUsers != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.VarUsers.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -144,11 +130,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/Userset.cs b/src/OpenFga.Sdk/Model/Userset.cs index 32bbfb69..cd7e8098 100644 --- a/src/OpenFga.Sdk/Model/Userset.cs +++ b/src/OpenFga.Sdk/Model/Userset.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// Userset /// [DataContract(Name = "Userset")] - public partial class Userset : IEquatable, IValidatableObject - { + public partial class Userset : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public Userset() - { + public Userset() { this.AdditionalProperties = new Dictionary(); } @@ -48,8 +43,7 @@ public Userset() /// union. /// intersection. /// difference. - public Userset(Object varThis = default, ObjectRelation computedUserset = default, TupleToUserset tupleToUserset = default, Usersets union = default, Usersets intersection = default, Difference difference = default) - { + public Userset(Object varThis = default, ObjectRelation computedUserset = default, TupleToUserset tupleToUserset = default, Usersets union = default, Usersets intersection = default, Difference difference = default) { this.This = varThis; this.ComputedUserset = computedUserset; this.TupleToUserset = tupleToUserset; @@ -119,8 +113,7 @@ public Userset(Object varThis = default, ObjectRelation computedUserset = defaul /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -137,8 +130,7 @@ public static Userset FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((Userset)input); } @@ -148,38 +140,36 @@ public override bool Equals(object input) /// /// Instance of Userset to be compared /// Boolean - public bool Equals(Userset input) - { - if (input == null) - { + public bool Equals(Userset input) { + if (input == null) { return false; } - return + return ( this.This == input.This || (this.This != null && this.This.Equals(input.This)) - ) && + ) && ( this.ComputedUserset == input.ComputedUserset || (this.ComputedUserset != null && this.ComputedUserset.Equals(input.ComputedUserset)) - ) && + ) && ( this.TupleToUserset == input.TupleToUserset || (this.TupleToUserset != null && this.TupleToUserset.Equals(input.TupleToUserset)) - ) && + ) && ( this.Union == input.Union || (this.Union != null && this.Union.Equals(input.Union)) - ) && + ) && ( this.Intersection == input.Intersection || (this.Intersection != null && this.Intersection.Equals(input.Intersection)) - ) && + ) && ( this.Difference == input.Difference || (this.Difference != null && @@ -192,37 +182,29 @@ public bool Equals(Userset input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.This != null) - { + if (this.This != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.This.GetHashCode(); } - if (this.ComputedUserset != null) - { + if (this.ComputedUserset != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.ComputedUserset.GetHashCode(); } - if (this.TupleToUserset != null) - { + if (this.TupleToUserset != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.TupleToUserset.GetHashCode(); } - if (this.Union != null) - { + if (this.Union != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Union.GetHashCode(); } - if (this.Intersection != null) - { + if (this.Intersection != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Intersection.GetHashCode(); } - if (this.Difference != null) - { + if (this.Difference != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Difference.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -234,11 +216,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/UsersetTree.cs b/src/OpenFga.Sdk/Model/UsersetTree.cs index 89ba8116..9b0d2680 100644 --- a/src/OpenFga.Sdk/Model/UsersetTree.cs +++ b/src/OpenFga.Sdk/Model/UsersetTree.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// A UsersetTree contains the result of an Expansion. /// [DataContract(Name = "UsersetTree")] - public partial class UsersetTree : IEquatable, IValidatableObject - { + public partial class UsersetTree : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public UsersetTree() - { + public UsersetTree() { this.AdditionalProperties = new Dictionary(); } @@ -43,8 +38,7 @@ public UsersetTree() /// Initializes a new instance of the class. /// /// root. - public UsersetTree(Node root = default) - { + public UsersetTree(Node root = default) { this.Root = root; this.AdditionalProperties = new Dictionary(); } @@ -68,8 +62,7 @@ public UsersetTree(Node root = default) /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -86,8 +79,7 @@ public static UsersetTree FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((UsersetTree)input); } @@ -97,13 +89,11 @@ public override bool Equals(object input) /// /// Instance of UsersetTree to be compared /// Boolean - public bool Equals(UsersetTree input) - { - if (input == null) - { + public bool Equals(UsersetTree input) { + if (input == null) { return false; } - return + return ( this.Root == input.Root || (this.Root != null && @@ -116,17 +106,14 @@ public bool Equals(UsersetTree input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Root != null) - { + if (this.Root != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Root.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -138,11 +125,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/UsersetTreeDifference.cs b/src/OpenFga.Sdk/Model/UsersetTreeDifference.cs index 3151aeb2..7513c29d 100644 --- a/src/OpenFga.Sdk/Model/UsersetTreeDifference.cs +++ b/src/OpenFga.Sdk/Model/UsersetTreeDifference.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// UsersetTreeDifference /// [DataContract(Name = "UsersetTree.Difference")] - public partial class UsersetTreeDifference : IEquatable, IValidatableObject - { + public partial class UsersetTreeDifference : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public UsersetTreeDifference() - { + public UsersetTreeDifference() { this.AdditionalProperties = new Dictionary(); } @@ -44,17 +39,14 @@ public UsersetTreeDifference() /// /// varBase (required). /// subtract (required). - public UsersetTreeDifference(Node varBase = default, Node subtract = default) - { + public UsersetTreeDifference(Node varBase = default, Node subtract = default) { // to ensure "varBase" is required (not null) - if (varBase == null) - { + if (varBase == null) { throw new ArgumentNullException("varBase is a required property for UsersetTreeDifference and cannot be null"); } this.Base = varBase; // to ensure "subtract" is required (not null) - if (subtract == null) - { + if (subtract == null) { throw new ArgumentNullException("subtract is a required property for UsersetTreeDifference and cannot be null"); } this.Subtract = subtract; @@ -88,8 +80,7 @@ public UsersetTreeDifference(Node varBase = default, Node subtract = default) /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -106,8 +97,7 @@ public static UsersetTreeDifference FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((UsersetTreeDifference)input); } @@ -117,18 +107,16 @@ public override bool Equals(object input) /// /// Instance of UsersetTreeDifference to be compared /// Boolean - public bool Equals(UsersetTreeDifference input) - { - if (input == null) - { + public bool Equals(UsersetTreeDifference input) { + if (input == null) { return false; } - return + return ( this.Base == input.Base || (this.Base != null && this.Base.Equals(input.Base)) - ) && + ) && ( this.Subtract == input.Subtract || (this.Subtract != null && @@ -141,21 +129,17 @@ public bool Equals(UsersetTreeDifference input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Base != null) - { + if (this.Base != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Base.GetHashCode(); } - if (this.Subtract != null) - { + if (this.Subtract != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Subtract.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -167,11 +151,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/UsersetTreeTupleToUserset.cs b/src/OpenFga.Sdk/Model/UsersetTreeTupleToUserset.cs index ff0b486c..bbbcef1d 100644 --- a/src/OpenFga.Sdk/Model/UsersetTreeTupleToUserset.cs +++ b/src/OpenFga.Sdk/Model/UsersetTreeTupleToUserset.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// UsersetTreeTupleToUserset /// [DataContract(Name = "UsersetTree.TupleToUserset")] - public partial class UsersetTreeTupleToUserset : IEquatable, IValidatableObject - { + public partial class UsersetTreeTupleToUserset : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public UsersetTreeTupleToUserset() - { + public UsersetTreeTupleToUserset() { this.AdditionalProperties = new Dictionary(); } @@ -44,17 +39,14 @@ public UsersetTreeTupleToUserset() /// /// tupleset (required). /// computed (required). - public UsersetTreeTupleToUserset(string tupleset = default, List computed = default) - { + public UsersetTreeTupleToUserset(string tupleset = default, List computed = default) { // to ensure "tupleset" is required (not null) - if (tupleset == null) - { + if (tupleset == null) { throw new ArgumentNullException("tupleset is a required property for UsersetTreeTupleToUserset and cannot be null"); } this.Tupleset = tupleset; // to ensure "computed" is required (not null) - if (computed == null) - { + if (computed == null) { throw new ArgumentNullException("computed is a required property for UsersetTreeTupleToUserset and cannot be null"); } this.Computed = computed; @@ -88,8 +80,7 @@ public UsersetTreeTupleToUserset(string tupleset = default, List compu /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -106,8 +97,7 @@ public static UsersetTreeTupleToUserset FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((UsersetTreeTupleToUserset)input); } @@ -117,18 +107,16 @@ public override bool Equals(object input) /// /// Instance of UsersetTreeTupleToUserset to be compared /// Boolean - public bool Equals(UsersetTreeTupleToUserset input) - { - if (input == null) - { + public bool Equals(UsersetTreeTupleToUserset input) { + if (input == null) { return false; } - return + return ( this.Tupleset == input.Tupleset || (this.Tupleset != null && this.Tupleset.Equals(input.Tupleset)) - ) && + ) && ( this.Computed == input.Computed || this.Computed != null && @@ -142,21 +130,17 @@ public bool Equals(UsersetTreeTupleToUserset input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Tupleset != null) - { + if (this.Tupleset != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Tupleset.GetHashCode(); } - if (this.Computed != null) - { + if (this.Computed != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Computed.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -168,11 +152,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/UsersetUser.cs b/src/OpenFga.Sdk/Model/UsersetUser.cs index 2d584e98..f1c262b6 100644 --- a/src/OpenFga.Sdk/Model/UsersetUser.cs +++ b/src/OpenFga.Sdk/Model/UsersetUser.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// Userset. A set or group of users, represented in the `<type>:<id>#<relation>` format `group:fga#member` represents all members of group FGA, not to be confused by `group:fga` which represents the group itself as a specific object. See: https://openfga.dev/docs/modeling/building-blocks/usersets#what-is-a-userset /// [DataContract(Name = "UsersetUser")] - public partial class UsersetUser : IEquatable, IValidatableObject - { + public partial class UsersetUser : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public UsersetUser() - { + public UsersetUser() { this.AdditionalProperties = new Dictionary(); } @@ -45,23 +40,19 @@ public UsersetUser() /// type (required). /// id (required). /// relation (required). - public UsersetUser(string type = default, string id = default, string relation = default) - { + public UsersetUser(string type = default, string id = default, string relation = default) { // to ensure "type" is required (not null) - if (type == null) - { + if (type == null) { throw new ArgumentNullException("type is a required property for UsersetUser and cannot be null"); } this.Type = type; // to ensure "id" is required (not null) - if (id == null) - { + if (id == null) { throw new ArgumentNullException("id is a required property for UsersetUser and cannot be null"); } this.Id = id; // to ensure "relation" is required (not null) - if (relation == null) - { + if (relation == null) { throw new ArgumentNullException("relation is a required property for UsersetUser and cannot be null"); } this.Relation = relation; @@ -103,8 +94,7 @@ public UsersetUser(string type = default, string id = default, string relation = /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -121,8 +111,7 @@ public static UsersetUser FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((UsersetUser)input); } @@ -132,23 +121,21 @@ public override bool Equals(object input) /// /// Instance of UsersetUser to be compared /// Boolean - public bool Equals(UsersetUser input) - { - if (input == null) - { + public bool Equals(UsersetUser input) { + if (input == null) { return false; } - return + return ( this.Type == input.Type || (this.Type != null && this.Type.Equals(input.Type)) - ) && + ) && ( this.Id == input.Id || (this.Id != null && this.Id.Equals(input.Id)) - ) && + ) && ( this.Relation == input.Relation || (this.Relation != null && @@ -161,25 +148,20 @@ public bool Equals(UsersetUser input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Type != null) - { + if (this.Type != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Type.GetHashCode(); } - if (this.Id != null) - { + if (this.Id != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Id.GetHashCode(); } - if (this.Relation != null) - { + if (this.Relation != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Relation.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -191,11 +173,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/Usersets.cs b/src/OpenFga.Sdk/Model/Usersets.cs index 6d6d02be..0321098f 100644 --- a/src/OpenFga.Sdk/Model/Usersets.cs +++ b/src/OpenFga.Sdk/Model/Usersets.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// Usersets /// [DataContract(Name = "Usersets")] - public partial class Usersets : IEquatable, IValidatableObject - { + public partial class Usersets : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public Usersets() - { + public Usersets() { this.AdditionalProperties = new Dictionary(); } @@ -43,11 +38,9 @@ public Usersets() /// Initializes a new instance of the class. /// /// child (required). - public Usersets(List child = default) - { + public Usersets(List child = default) { // to ensure "child" is required (not null) - if (child == null) - { + if (child == null) { throw new ArgumentNullException("child is a required property for Usersets and cannot be null"); } this.Child = child; @@ -73,8 +66,7 @@ public Usersets(List child = default) /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -91,8 +83,7 @@ public static Usersets FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((Usersets)input); } @@ -102,13 +93,11 @@ public override bool Equals(object input) /// /// Instance of Usersets to be compared /// Boolean - public bool Equals(Usersets input) - { - if (input == null) - { + public bool Equals(Usersets input) { + if (input == null) { return false; } - return + return ( this.Child == input.Child || this.Child != null && @@ -122,17 +111,14 @@ public bool Equals(Usersets input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Child != null) - { + if (this.Child != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Child.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -144,11 +130,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/ValidationErrorMessageResponse.cs b/src/OpenFga.Sdk/Model/ValidationErrorMessageResponse.cs index a59e2d94..4f6e0add 100644 --- a/src/OpenFga.Sdk/Model/ValidationErrorMessageResponse.cs +++ b/src/OpenFga.Sdk/Model/ValidationErrorMessageResponse.cs @@ -11,25 +11,21 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// ValidationErrorMessageResponse /// [DataContract(Name = "ValidationErrorMessageResponse")] - public partial class ValidationErrorMessageResponse : IEquatable, IValidatableObject - { + public partial class ValidationErrorMessageResponse : IEquatable, IValidatableObject { /// /// Gets or Sets Code @@ -41,8 +37,7 @@ public partial class ValidationErrorMessageResponse : IEquatable class. /// [JsonConstructor] - public ValidationErrorMessageResponse() - { + public ValidationErrorMessageResponse() { this.AdditionalProperties = new Dictionary(); } @@ -51,8 +46,7 @@ public ValidationErrorMessageResponse() /// /// code. /// message. - public ValidationErrorMessageResponse(ErrorCode? code = default, string message = default) - { + public ValidationErrorMessageResponse(ErrorCode? code = default, string message = default) { this.Code = code; this.Message = message; this.AdditionalProperties = new Dictionary(); @@ -77,8 +71,7 @@ public ValidationErrorMessageResponse(ErrorCode? code = default, string message /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -95,8 +88,7 @@ public static ValidationErrorMessageResponse FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((ValidationErrorMessageResponse)input); } @@ -106,17 +98,15 @@ public override bool Equals(object input) /// /// Instance of ValidationErrorMessageResponse to be compared /// Boolean - public bool Equals(ValidationErrorMessageResponse input) - { - if (input == null) - { + public bool Equals(ValidationErrorMessageResponse input) { + if (input == null) { return false; } - return + return ( this.Code == input.Code || this.Code.Equals(input.Code) - ) && + ) && ( this.Message == input.Message || (this.Message != null && @@ -129,18 +119,15 @@ public bool Equals(ValidationErrorMessageResponse input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Code.GetHashCode(); - if (this.Message != null) - { + if (this.Message != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Message.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -152,11 +139,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/WriteAssertionsRequest.cs b/src/OpenFga.Sdk/Model/WriteAssertionsRequest.cs index 96d1f7fc..07aac532 100644 --- a/src/OpenFga.Sdk/Model/WriteAssertionsRequest.cs +++ b/src/OpenFga.Sdk/Model/WriteAssertionsRequest.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// WriteAssertionsRequest /// [DataContract(Name = "WriteAssertions_request")] - public partial class WriteAssertionsRequest : IEquatable, IValidatableObject - { + public partial class WriteAssertionsRequest : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public WriteAssertionsRequest() - { + public WriteAssertionsRequest() { this.AdditionalProperties = new Dictionary(); } @@ -43,11 +38,9 @@ public WriteAssertionsRequest() /// Initializes a new instance of the class. /// /// assertions (required). - public WriteAssertionsRequest(List assertions = default) - { + public WriteAssertionsRequest(List assertions = default) { // to ensure "assertions" is required (not null) - if (assertions == null) - { + if (assertions == null) { throw new ArgumentNullException("assertions is a required property for WriteAssertionsRequest and cannot be null"); } this.Assertions = assertions; @@ -73,8 +66,7 @@ public WriteAssertionsRequest(List assertions = default) /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -91,8 +83,7 @@ public static WriteAssertionsRequest FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((WriteAssertionsRequest)input); } @@ -102,13 +93,11 @@ public override bool Equals(object input) /// /// Instance of WriteAssertionsRequest to be compared /// Boolean - public bool Equals(WriteAssertionsRequest input) - { - if (input == null) - { + public bool Equals(WriteAssertionsRequest input) { + if (input == null) { return false; } - return + return ( this.Assertions == input.Assertions || this.Assertions != null && @@ -122,17 +111,14 @@ public bool Equals(WriteAssertionsRequest input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Assertions != null) - { + if (this.Assertions != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Assertions.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -144,11 +130,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/WriteAuthorizationModelRequest.cs b/src/OpenFga.Sdk/Model/WriteAuthorizationModelRequest.cs index 5f31d60e..242ecd4a 100644 --- a/src/OpenFga.Sdk/Model/WriteAuthorizationModelRequest.cs +++ b/src/OpenFga.Sdk/Model/WriteAuthorizationModelRequest.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// WriteAuthorizationModelRequest /// [DataContract(Name = "WriteAuthorizationModel_request")] - public partial class WriteAuthorizationModelRequest : IEquatable, IValidatableObject - { + public partial class WriteAuthorizationModelRequest : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public WriteAuthorizationModelRequest() - { + public WriteAuthorizationModelRequest() { this.AdditionalProperties = new Dictionary(); } @@ -45,17 +40,14 @@ public WriteAuthorizationModelRequest() /// typeDefinitions (required). /// schemaVersion (required). /// conditions. - public WriteAuthorizationModelRequest(List typeDefinitions = default, string schemaVersion = default, Dictionary conditions = default) - { + public WriteAuthorizationModelRequest(List typeDefinitions = default, string schemaVersion = default, Dictionary conditions = default) { // to ensure "typeDefinitions" is required (not null) - if (typeDefinitions == null) - { + if (typeDefinitions == null) { throw new ArgumentNullException("typeDefinitions is a required property for WriteAuthorizationModelRequest and cannot be null"); } this.TypeDefinitions = typeDefinitions; // to ensure "schemaVersion" is required (not null) - if (schemaVersion == null) - { + if (schemaVersion == null) { throw new ArgumentNullException("schemaVersion is a required property for WriteAuthorizationModelRequest and cannot be null"); } this.SchemaVersion = schemaVersion; @@ -98,8 +90,7 @@ public WriteAuthorizationModelRequest(List typeDefinitions = def /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -116,8 +107,7 @@ public static WriteAuthorizationModelRequest FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((WriteAuthorizationModelRequest)input); } @@ -127,24 +117,22 @@ public override bool Equals(object input) /// /// Instance of WriteAuthorizationModelRequest to be compared /// Boolean - public bool Equals(WriteAuthorizationModelRequest input) - { - if (input == null) - { + public bool Equals(WriteAuthorizationModelRequest input) { + if (input == null) { return false; } - return + return ( this.TypeDefinitions == input.TypeDefinitions || this.TypeDefinitions != null && input.TypeDefinitions != null && this.TypeDefinitions.SequenceEqual(input.TypeDefinitions) - ) && + ) && ( this.SchemaVersion == input.SchemaVersion || (this.SchemaVersion != null && this.SchemaVersion.Equals(input.SchemaVersion)) - ) && + ) && ( this.Conditions == input.Conditions || this.Conditions != null && @@ -158,25 +146,20 @@ public bool Equals(WriteAuthorizationModelRequest input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.TypeDefinitions != null) - { + if (this.TypeDefinitions != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.TypeDefinitions.GetHashCode(); } - if (this.SchemaVersion != null) - { + if (this.SchemaVersion != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.SchemaVersion.GetHashCode(); } - if (this.Conditions != null) - { + if (this.Conditions != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Conditions.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -188,11 +171,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/WriteAuthorizationModelResponse.cs b/src/OpenFga.Sdk/Model/WriteAuthorizationModelResponse.cs index cfb595e8..fee43cda 100644 --- a/src/OpenFga.Sdk/Model/WriteAuthorizationModelResponse.cs +++ b/src/OpenFga.Sdk/Model/WriteAuthorizationModelResponse.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// WriteAuthorizationModelResponse /// [DataContract(Name = "WriteAuthorizationModelResponse")] - public partial class WriteAuthorizationModelResponse : IEquatable, IValidatableObject - { + public partial class WriteAuthorizationModelResponse : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public WriteAuthorizationModelResponse() - { + public WriteAuthorizationModelResponse() { this.AdditionalProperties = new Dictionary(); } @@ -43,11 +38,9 @@ public WriteAuthorizationModelResponse() /// Initializes a new instance of the class. /// /// authorizationModelId (required). - public WriteAuthorizationModelResponse(string authorizationModelId = default) - { + public WriteAuthorizationModelResponse(string authorizationModelId = default) { // to ensure "authorizationModelId" is required (not null) - if (authorizationModelId == null) - { + if (authorizationModelId == null) { throw new ArgumentNullException("authorizationModelId is a required property for WriteAuthorizationModelResponse and cannot be null"); } this.AuthorizationModelId = authorizationModelId; @@ -73,8 +66,7 @@ public WriteAuthorizationModelResponse(string authorizationModelId = default) /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -91,8 +83,7 @@ public static WriteAuthorizationModelResponse FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((WriteAuthorizationModelResponse)input); } @@ -102,13 +93,11 @@ public override bool Equals(object input) /// /// Instance of WriteAuthorizationModelResponse to be compared /// Boolean - public bool Equals(WriteAuthorizationModelResponse input) - { - if (input == null) - { + public bool Equals(WriteAuthorizationModelResponse input) { + if (input == null) { return false; } - return + return ( this.AuthorizationModelId == input.AuthorizationModelId || (this.AuthorizationModelId != null && @@ -121,17 +110,14 @@ public bool Equals(WriteAuthorizationModelResponse input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.AuthorizationModelId != null) - { + if (this.AuthorizationModelId != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AuthorizationModelId.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -143,11 +129,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/WriteRequest.cs b/src/OpenFga.Sdk/Model/WriteRequest.cs index 5d3d7563..20ed9c70 100644 --- a/src/OpenFga.Sdk/Model/WriteRequest.cs +++ b/src/OpenFga.Sdk/Model/WriteRequest.cs @@ -11,31 +11,26 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// WriteRequest /// [DataContract(Name = "Write_request")] - public partial class WriteRequest : IEquatable, IValidatableObject - { + public partial class WriteRequest : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// [JsonConstructor] - public WriteRequest() - { + public WriteRequest() { this.AdditionalProperties = new Dictionary(); } @@ -45,8 +40,7 @@ public WriteRequest() /// writes. /// deletes. /// authorizationModelId. - public WriteRequest(WriteRequestWrites writes = default, WriteRequestDeletes deletes = default, string authorizationModelId = default) - { + public WriteRequest(WriteRequestWrites writes = default, WriteRequestDeletes deletes = default, string authorizationModelId = default) { this.Writes = writes; this.Deletes = deletes; this.AuthorizationModelId = authorizationModelId; @@ -88,8 +82,7 @@ public WriteRequest(WriteRequestWrites writes = default, WriteRequestDeletes del /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -106,8 +99,7 @@ public static WriteRequest FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((WriteRequest)input); } @@ -117,23 +109,21 @@ public override bool Equals(object input) /// /// Instance of WriteRequest to be compared /// Boolean - public bool Equals(WriteRequest input) - { - if (input == null) - { + public bool Equals(WriteRequest input) { + if (input == null) { return false; } - return + return ( this.Writes == input.Writes || (this.Writes != null && this.Writes.Equals(input.Writes)) - ) && + ) && ( this.Deletes == input.Deletes || (this.Deletes != null && this.Deletes.Equals(input.Deletes)) - ) && + ) && ( this.AuthorizationModelId == input.AuthorizationModelId || (this.AuthorizationModelId != null && @@ -146,25 +136,20 @@ public bool Equals(WriteRequest input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.Writes != null) - { + if (this.Writes != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Writes.GetHashCode(); } - if (this.Deletes != null) - { + if (this.Deletes != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.Deletes.GetHashCode(); } - if (this.AuthorizationModelId != null) - { + if (this.AuthorizationModelId != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AuthorizationModelId.GetHashCode(); } - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -176,11 +161,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/WriteRequestDeletes.cs b/src/OpenFga.Sdk/Model/WriteRequestDeletes.cs index c0caa43a..ff707ce6 100644 --- a/src/OpenFga.Sdk/Model/WriteRequestDeletes.cs +++ b/src/OpenFga.Sdk/Model/WriteRequestDeletes.cs @@ -11,32 +11,27 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// WriteRequestDeletes /// [DataContract(Name = "WriteRequestDeletes")] - public partial class WriteRequestDeletes : IEquatable, IValidatableObject - { + public partial class WriteRequestDeletes : IEquatable, IValidatableObject { /// /// On 'error', the API returns an error when deleting a tuple that does not exist. On 'ignore', deletes of non-existent tuples are treated as no-ops. /// /// On 'error', the API returns an error when deleting a tuple that does not exist. On 'ignore', deletes of non-existent tuples are treated as no-ops. [JsonConverter(typeof(JsonStringEnumMemberConverter))] - public enum OnMissingEnum - { + public enum OnMissingEnum { /// /// Enum Error for value: error /// @@ -63,8 +58,7 @@ public enum OnMissingEnum /// Initializes a new instance of the class. /// [JsonConstructor] - public WriteRequestDeletes() - { + public WriteRequestDeletes() { this.AdditionalProperties = new Dictionary(); } @@ -73,11 +67,9 @@ public WriteRequestDeletes() /// /// tupleKeys (required). /// On 'error', the API returns an error when deleting a tuple that does not exist. On 'ignore', deletes of non-existent tuples are treated as no-ops. (default to OnMissingEnum.Error). - public WriteRequestDeletes(List tupleKeys = default, OnMissingEnum? onMissing = OnMissingEnum.Error) - { + public WriteRequestDeletes(List tupleKeys = default, OnMissingEnum? onMissing = OnMissingEnum.Error) { // to ensure "tupleKeys" is required (not null) - if (tupleKeys == null) - { + if (tupleKeys == null) { throw new ArgumentNullException("tupleKeys is a required property for WriteRequestDeletes and cannot be null"); } this.TupleKeys = tupleKeys; @@ -104,8 +96,7 @@ public WriteRequestDeletes(List tupleKeys = default, O /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -122,8 +113,7 @@ public static WriteRequestDeletes FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((WriteRequestDeletes)input); } @@ -133,19 +123,17 @@ public override bool Equals(object input) /// /// Instance of WriteRequestDeletes to be compared /// Boolean - public bool Equals(WriteRequestDeletes input) - { - if (input == null) - { + public bool Equals(WriteRequestDeletes input) { + if (input == null) { return false; } - return + return ( this.TupleKeys == input.TupleKeys || this.TupleKeys != null && input.TupleKeys != null && this.TupleKeys.SequenceEqual(input.TupleKeys) - ) && + ) && ( this.OnMissing == input.OnMissing || this.OnMissing.Equals(input.OnMissing) @@ -157,18 +145,15 @@ public bool Equals(WriteRequestDeletes input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.TupleKeys != null) - { + if (this.TupleKeys != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.TupleKeys.GetHashCode(); } hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.OnMissing.GetHashCode(); - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -180,11 +165,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Model/WriteRequestWrites.cs b/src/OpenFga.Sdk/Model/WriteRequestWrites.cs index 8b798d36..69c59045 100644 --- a/src/OpenFga.Sdk/Model/WriteRequestWrites.cs +++ b/src/OpenFga.Sdk/Model/WriteRequestWrites.cs @@ -11,32 +11,27 @@ // +using OpenFga.Sdk.Constants; using System; using System.Collections.Generic; -using System.Linq; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; - -using OpenFga.Sdk.Constants; - -namespace OpenFga.Sdk.Model -{ +namespace OpenFga.Sdk.Model { /// /// WriteRequestWrites /// [DataContract(Name = "WriteRequestWrites")] - public partial class WriteRequestWrites : IEquatable, IValidatableObject - { + public partial class WriteRequestWrites : IEquatable, IValidatableObject { /// /// On 'error' ( or unspecified ), the API returns an error if an identical tuple already exists. On 'ignore', identical writes are treated as no-ops (matching on user, relation, object, and RelationshipCondition). /// /// On 'error' ( or unspecified ), the API returns an error if an identical tuple already exists. On 'ignore', identical writes are treated as no-ops (matching on user, relation, object, and RelationshipCondition). [JsonConverter(typeof(JsonStringEnumMemberConverter))] - public enum OnDuplicateEnum - { + public enum OnDuplicateEnum { /// /// Enum Error for value: error /// @@ -63,8 +58,7 @@ public enum OnDuplicateEnum /// Initializes a new instance of the class. /// [JsonConstructor] - public WriteRequestWrites() - { + public WriteRequestWrites() { this.AdditionalProperties = new Dictionary(); } @@ -73,11 +67,9 @@ public WriteRequestWrites() /// /// tupleKeys (required). /// On 'error' ( or unspecified ), the API returns an error if an identical tuple already exists. On 'ignore', identical writes are treated as no-ops (matching on user, relation, object, and RelationshipCondition). (default to OnDuplicateEnum.Error). - public WriteRequestWrites(List tupleKeys = default, OnDuplicateEnum? onDuplicate = OnDuplicateEnum.Error) - { + public WriteRequestWrites(List tupleKeys = default, OnDuplicateEnum? onDuplicate = OnDuplicateEnum.Error) { // to ensure "tupleKeys" is required (not null) - if (tupleKeys == null) - { + if (tupleKeys == null) { throw new ArgumentNullException("tupleKeys is a required property for WriteRequestWrites and cannot be null"); } this.TupleKeys = tupleKeys; @@ -104,8 +96,7 @@ public WriteRequestWrites(List tupleKeys = default, OnDuplicateEnum? o /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() - { + public virtual string ToJson() { return JsonSerializer.Serialize(this); } @@ -122,8 +113,7 @@ public static WriteRequestWrites FromJson(string jsonString) { /// /// Object to be compared /// Boolean - public override bool Equals(object input) - { + public override bool Equals(object input) { if (input == null || input.GetType() != this.GetType()) return false; return this.Equals((WriteRequestWrites)input); } @@ -133,19 +123,17 @@ public override bool Equals(object input) /// /// Instance of WriteRequestWrites to be compared /// Boolean - public bool Equals(WriteRequestWrites input) - { - if (input == null) - { + public bool Equals(WriteRequestWrites input) { + if (input == null) { return false; } - return + return ( this.TupleKeys == input.TupleKeys || this.TupleKeys != null && input.TupleKeys != null && this.TupleKeys.SequenceEqual(input.TupleKeys) - ) && + ) && ( this.OnDuplicate == input.OnDuplicate || this.OnDuplicate.Equals(input.OnDuplicate) @@ -157,18 +145,15 @@ public bool Equals(WriteRequestWrites input) /// Gets the hash code /// /// Hash code - public override int GetHashCode() - { + public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = FgaConstants.HashCodeBasePrimeNumber; - if (this.TupleKeys != null) - { + if (this.TupleKeys != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.TupleKeys.GetHashCode(); } hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.OnDuplicate.GetHashCode(); - if (this.AdditionalProperties != null) - { + if (this.AdditionalProperties != null) { hashCode = (hashCode * FgaConstants.HashCodeMultiplierPrimeNumber) + this.AdditionalProperties.GetHashCode(); } return hashCode; @@ -180,11 +165,10 @@ public override int GetHashCode() /// /// Validation context /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } -} +} \ No newline at end of file From ae98e7fac93aa3d32f27562f0829e48d790b21cc Mon Sep 17 00:00:00 2001 From: SoulPancake Date: Wed, 4 Feb 2026 18:29:30 +0530 Subject: [PATCH 14/23] feat: address coderabbit nit comments --- example/ApiExecutorExample/Makefile | 2 +- example/ApiExecutorExample/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/example/ApiExecutorExample/Makefile b/example/ApiExecutorExample/Makefile index 0e5c58c1..624eb94f 100644 --- a/example/ApiExecutorExample/Makefile +++ b/example/ApiExecutorExample/Makefile @@ -1,4 +1,4 @@ -.PHONY: help start-openfga stop-openfga run clean +.PHONY: help start-openfga stop-openfga run run-all clean help: @echo "ApiExecutor Example - Makefile Commands" diff --git a/example/ApiExecutorExample/README.md b/example/ApiExecutorExample/README.md index 40a9016e..1ccbe496 100644 --- a/example/ApiExecutorExample/README.md +++ b/example/ApiExecutorExample/README.md @@ -63,7 +63,7 @@ make stop-openfga # Stop OpenFGA when done ## Example Output -``` +```text === OpenFGA ApiExecutor Example === 📋 Example 1: List Stores From b15f27ee4d7784998553ab5149c05c54e8c4e8e8 Mon Sep 17 00:00:00 2001 From: Anurag Bandyopadhyay Date: Tue, 17 Feb 2026 19:53:37 +0530 Subject: [PATCH 15/23] fix: lambda param --- src/OpenFga.Sdk/ApiClient/ApiClient.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenFga.Sdk/ApiClient/ApiClient.cs b/src/OpenFga.Sdk/ApiClient/ApiClient.cs index 0d1134bd..475f2c2f 100644 --- a/src/OpenFga.Sdk/ApiClient/ApiClient.cs +++ b/src/OpenFga.Sdk/ApiClient/ApiClient.cs @@ -140,9 +140,9 @@ internal async Task> SendRequestWithWrapperAsync + var response = await Retry(async (attemptCount) => await _baseClient.SendRequestAsync(requestBuilder, mergedHeaders, apiName, - cancellationToken)); + attemptCount, cancellationToken)); sw.Stop(); metrics.BuildForResponse(apiName, response.rawResponse, requestBuilder, sw, From 5aae9e4b4af1961a79bc61410efd8830edb65971 Mon Sep 17 00:00:00 2001 From: SoulPancake Date: Wed, 18 Feb 2026 09:32:54 +0530 Subject: [PATCH 16/23] fix: refactor to APIClient and re-use req builder --- .../ApiExecutorRequestBuilderTests.cs | 297 ------------------ .../Client/ApiExecutor/ApiExecutorTests.cs | 273 ++++++++++------ .../Client/ApiExecutor/ApiResponseTests.cs | 2 +- src/OpenFga.Sdk/ApiClient/ApiClient.cs | 126 +++++--- .../ApiExecutor => ApiClient}/ApiResponse.cs | 9 +- src/OpenFga.Sdk/ApiClient/RequestBuilder.cs | 92 ++++++ .../Client/ApiExecutor/ApiExecutor.cs | 124 -------- .../ApiExecutor/ApiExecutorRequestBuilder.cs | 172 ---------- src/OpenFga.Sdk/Client/Client.cs | 20 +- 9 files changed, 376 insertions(+), 739 deletions(-) delete mode 100644 src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorRequestBuilderTests.cs rename src/OpenFga.Sdk/{Client/ApiExecutor => ApiClient}/ApiResponse.cs (95%) delete mode 100644 src/OpenFga.Sdk/Client/ApiExecutor/ApiExecutor.cs delete mode 100644 src/OpenFga.Sdk/Client/ApiExecutor/ApiExecutorRequestBuilder.cs diff --git a/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorRequestBuilderTests.cs b/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorRequestBuilderTests.cs deleted file mode 100644 index f280ad76..00000000 --- a/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorRequestBuilderTests.cs +++ /dev/null @@ -1,297 +0,0 @@ -using OpenFga.Sdk.Client.ApiExecutor; -using OpenFga.Sdk.Exceptions; -using System; -using System.Net.Http; -using Xunit; - -namespace OpenFga.Sdk.Test.Client.ApiExecutor; - -public class ApiExecutorRequestBuilderTests { - [Fact] - public void Of_ValidMethodAndPath_ReturnsBuilder() { - // Act - var builder = ApiExecutorRequestBuilder.Of(HttpMethod.Get, "/stores"); - - // Assert - Assert.NotNull(builder); - Assert.Equal(HttpMethod.Get, builder.Method); - Assert.Equal("/stores", builder.PathTemplate); - } - - [Fact] - public void Of_NullMethod_ThrowsArgumentNullException() { - // Act & Assert - var exception = Assert.Throws(() => - ApiExecutorRequestBuilder.Of(null, "/stores")); - Assert.Contains("method", exception.Message, StringComparison.OrdinalIgnoreCase); - } - - [Fact] - public void Of_NullPath_ThrowsArgumentNullException() { - // Act & Assert - var exception = Assert.Throws(() => - ApiExecutorRequestBuilder.Of(HttpMethod.Get, null)); - Assert.Contains("path", exception.Message, StringComparison.OrdinalIgnoreCase); - } - - [Fact] - public void Of_EmptyPath_ThrowsArgumentException() { - // Act & Assert - var exception = Assert.Throws(() => - ApiExecutorRequestBuilder.Of(HttpMethod.Get, "")); - Assert.Contains("path", exception.Message, StringComparison.OrdinalIgnoreCase); - } - - [Fact] - public void Of_WhitespacePath_ThrowsArgumentException() { - // Act & Assert - var exception = Assert.Throws(() => - ApiExecutorRequestBuilder.Of(HttpMethod.Get, " ")); - Assert.Contains("path", exception.Message, StringComparison.OrdinalIgnoreCase); - } - - [Fact] - public void Of_PathWithoutLeadingSlash_ThrowsArgumentException() { - // Act & Assert - var exception = Assert.Throws(() => - ApiExecutorRequestBuilder.Of(HttpMethod.Get, "stores")); - Assert.Contains("must start with '/'", exception.Message, StringComparison.OrdinalIgnoreCase); - } - - [Fact] - public void PathParam_ValidKeyValue_StoresParameter() { - // Arrange - var builder = ApiExecutorRequestBuilder.Of(HttpMethod.Post, "/stores/{store_id}/check"); - - // Act - var result = builder.PathParam("store_id", "store123"); - - // Assert - Assert.Same(builder, result); // Verify fluent chaining - } - - [Fact] - public void PathParam_NullKey_ThrowsArgumentException() { - // Arrange - var builder = ApiExecutorRequestBuilder.Of(HttpMethod.Post, "/stores/{store_id}/check"); - - // Act & Assert - var exception = Assert.Throws(() => - builder.PathParam(null, "value")); - Assert.Contains("key", exception.Message, StringComparison.OrdinalIgnoreCase); - } - - [Fact] - public void PathParam_EmptyKey_ThrowsArgumentException() { - // Arrange - var builder = ApiExecutorRequestBuilder.Of(HttpMethod.Post, "/stores/{store_id}/check"); - - // Act & Assert - var exception = Assert.Throws(() => - builder.PathParam("", "value")); - Assert.Contains("key", exception.Message, StringComparison.OrdinalIgnoreCase); - } - - [Fact] - public void PathParam_NullValue_ThrowsArgumentNullException() { - // Arrange - var builder = ApiExecutorRequestBuilder.Of(HttpMethod.Post, "/stores/{store_id}/check"); - - // Act & Assert - var exception = Assert.Throws(() => - builder.PathParam("store_id", null)); - Assert.Contains("value", exception.Message, StringComparison.OrdinalIgnoreCase); - } - - [Fact] - public void QueryParam_ValidKeyValue_StoresParameter() { - // Arrange - var builder = ApiExecutorRequestBuilder.Of(HttpMethod.Get, "/stores"); - - // Act - var result = builder.QueryParam("page_size", "20"); - - // Assert - Assert.Same(builder, result); // Verify fluent chaining - } - - [Fact] - public void QueryParam_NullKey_ThrowsArgumentException() { - // Arrange - var builder = ApiExecutorRequestBuilder.Of(HttpMethod.Get, "/stores"); - - // Act & Assert - var exception = Assert.Throws(() => - builder.QueryParam(null, "value")); - Assert.Contains("key", exception.Message, StringComparison.OrdinalIgnoreCase); - } - - [Fact] - public void QueryParam_NullValue_ThrowsArgumentNullException() { - // Arrange - var builder = ApiExecutorRequestBuilder.Of(HttpMethod.Get, "/stores"); - - // Act & Assert - var exception = Assert.Throws(() => - builder.QueryParam("page_size", null)); - Assert.Contains("value", exception.Message, StringComparison.OrdinalIgnoreCase); - } - - [Fact] - public void Header_ValidKeyValue_StoresHeader() { - // Arrange - var builder = ApiExecutorRequestBuilder.Of(HttpMethod.Post, "/stores"); - - // Act - var result = builder.Header("X-Custom-Header", "custom-value"); - - // Assert - Assert.Same(builder, result); // Verify fluent chaining - } - - [Fact] - public void Header_ReservedHeader_ThrowsArgumentException() { - // Arrange - var builder = ApiExecutorRequestBuilder.Of(HttpMethod.Post, "/stores"); - - // Act & Assert - Authorization is a reserved header - var exception = Assert.Throws(() => - builder.Header("Authorization", "Bearer token")); - Assert.Contains("reserved", exception.Message, StringComparison.OrdinalIgnoreCase); - } - - [Fact] - public void Header_NullKey_ThrowsArgumentException() { - // Arrange - var builder = ApiExecutorRequestBuilder.Of(HttpMethod.Post, "/stores"); - - // Act & Assert - var exception = Assert.Throws(() => - builder.Header(null, "value")); - Assert.Contains("key", exception.Message, StringComparison.OrdinalIgnoreCase); - } - - [Fact] - public void Header_NullValue_ThrowsArgumentException() { - // Arrange - var builder = ApiExecutorRequestBuilder.Of(HttpMethod.Post, "/stores"); - - // Act & Assert - var exception = Assert.Throws(() => - builder.Header("X-Custom-Header", null)); - Assert.Contains("value", exception.Message, StringComparison.OrdinalIgnoreCase); - } - - [Fact] - public void Header_InvalidCharacters_ThrowsArgumentException() { - // Arrange - var builder = ApiExecutorRequestBuilder.Of(HttpMethod.Post, "/stores"); - - // Act & Assert - CR/LF characters are not allowed - var exception = Assert.Throws(() => - builder.Header("X-Custom-Header", "value\r\nwith newline")); - Assert.Contains("invalid characters", exception.Message, StringComparison.OrdinalIgnoreCase); - } - - [Fact] - public void Body_ValidObject_StoresBody() { - // Arrange - var builder = ApiExecutorRequestBuilder.Of(HttpMethod.Post, "/stores"); - var body = new { name = "test-store" }; - - // Act - var result = builder.Body(body); - - // Assert - Assert.Same(builder, result); // Verify fluent chaining - } - - [Fact] - public void Body_NullObject_StoresNull() { - // Arrange - var builder = ApiExecutorRequestBuilder.Of(HttpMethod.Post, "/stores"); - - // Act - var result = builder.Body(null); - - // Assert - Assert.Same(builder, result); - } - - [Fact] - public void Build_WithValidRequest_ReturnsBuilder() { - // Arrange - var builder = ApiExecutorRequestBuilder.Of(HttpMethod.Post, "/stores/{store_id}/check") - .PathParam("store_id", "store123") - .QueryParam("page_size", "20") - .Header("X-Custom-Header", "value") - .Body(new { user = "user:anne" }); - - // Act - var result = builder.Build(); - - // Assert - Assert.Same(builder, result); - } - - [Fact] - public void FluentChaining_AllMethods_ReturnsBuilder() { - // Act - var builder = ApiExecutorRequestBuilder - .Of(HttpMethod.Post, "/stores/{store_id}/check") - .PathParam("store_id", "store123") - .QueryParam("page_size", "20") - .Header("X-Custom-Header", "value") - .Body(new { user = "user:anne" }) - .Build(); - - // Assert - Assert.NotNull(builder); - Assert.Equal(HttpMethod.Post, builder.Method); - Assert.Equal("/stores/{store_id}/check", builder.PathTemplate); - } - - [Fact] - public void ToRequestBuilder_ConvertsCorrectly() { - // Arrange - var builder = ApiExecutorRequestBuilder - .Of(HttpMethod.Post, "/stores/{store_id}/check") - .PathParam("store_id", "store123") - .QueryParam("page_size", "20") - .Body(new { user = "user:anne" }) - .Build(); - - // Act - var requestBuilder = builder.ToRequestBuilder("https://api.fga.example"); - - // Assert - Assert.NotNull(requestBuilder); - Assert.Equal(HttpMethod.Post, requestBuilder.Method); - Assert.Equal("https://api.fga.example", requestBuilder.BasePath); - Assert.Equal("/stores/{store_id}/check", requestBuilder.PathTemplate); - Assert.True(requestBuilder.PathParameters.TryGetValue("store_id", out var storeIdValue)); - Assert.Equal("store123", storeIdValue); - Assert.True(requestBuilder.QueryParameters.TryGetValue("page_size", out var pageSizeValue)); - Assert.Equal("20", pageSizeValue); - Assert.NotNull(requestBuilder.Body); - } - - [Fact] - public void GetHeaders_ReturnsCustomHeaders() { - // Arrange - var builder = ApiExecutorRequestBuilder - .Of(HttpMethod.Post, "/stores") - .Header("X-Custom-Header", "value1") - .Header("X-Another-Header", "value2") - .Build(); - - // Act - var headers = builder.GetHeaders(); - - // Assert - Assert.NotNull(headers); - Assert.Equal(2, headers.Count); - Assert.Equal("value1", headers["X-Custom-Header"]); - Assert.Equal("value2", headers["X-Another-Header"]); - } -} \ No newline at end of file diff --git a/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorTests.cs b/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorTests.cs index 0ebbd87b..cb2b2252 100644 --- a/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorTests.cs +++ b/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorTests.cs @@ -1,7 +1,7 @@ using Moq; using Moq.Protected; +using OpenFga.Sdk.ApiClient; using OpenFga.Sdk.Client; -using OpenFga.Sdk.Client.ApiExecutor; using OpenFga.Sdk.Client.Model; using OpenFga.Sdk.Configuration; using OpenFga.Sdk.Exceptions; @@ -50,7 +50,7 @@ public void Dispose() { } [Fact] - public async Task SendAsync_ValidGetRequest_ReturnsSuccessResponse() { + public async Task ExecuteAsync_ValidGetRequest_ReturnsSuccessResponse() { // Arrange var expectedResponse = new { id = _storeId, name = "test-store" }; using var responseMessage = new HttpResponseMessage { @@ -66,13 +66,16 @@ public async Task SendAsync_ValidGetRequest_ReturnsSuccessResponse() { req.Method == HttpMethod.Get && req.RequestUri.ToString().Contains("/stores/" + _storeId)); - var request = ApiExecutorRequestBuilder - .Of(HttpMethod.Get, "/stores/{store_id}") - .PathParam("store_id", _storeId) - .Build(); + var requestBuilder = new RequestBuilder { + Method = HttpMethod.Get, + BasePath = _apiUrl, + PathTemplate = "/stores/{store_id}", + PathParameters = new Dictionary { { "store_id", _storeId } }, + QueryParameters = new Dictionary() + }; // Act - var response = await client.GetApiExecutor().SendAsync(request); + var response = await client.GetApiClient().ExecuteAsync(requestBuilder, "GetStore"); // Assert Assert.NotNull(response); @@ -84,7 +87,7 @@ public async Task SendAsync_ValidGetRequest_ReturnsSuccessResponse() { } [Fact] - public async Task SendAsync_ValidPostRequest_ReturnsSuccessResponse() { + public async Task ExecuteAsync_ValidPostRequest_ReturnsSuccessResponse() { // Arrange var requestBody = new { user = "user:anne", relation = "reader", @object = "document:2021-budget" }; var expectedResponse = new { allowed = true }; @@ -100,14 +103,17 @@ public async Task SendAsync_ValidPostRequest_ReturnsSuccessResponse() { req.Method == HttpMethod.Post && req.RequestUri.ToString().Contains("/stores/" + _storeId + "/check")); - var request = ApiExecutorRequestBuilder - .Of(HttpMethod.Post, "/stores/{store_id}/check") - .PathParam("store_id", _storeId) - .Body(requestBody) - .Build(); + var requestBuilder = new RequestBuilder { + Method = HttpMethod.Post, + BasePath = _apiUrl, + PathTemplate = "/stores/{store_id}/check", + PathParameters = new Dictionary { { "store_id", _storeId } }, + QueryParameters = new Dictionary(), + Body = requestBody + }; // Act - var response = await client.GetApiExecutor().SendAsync(request); + var response = await client.GetApiClient().ExecuteAsync(requestBuilder, "Check"); // Assert Assert.NotNull(response); @@ -117,7 +123,7 @@ public async Task SendAsync_ValidPostRequest_ReturnsSuccessResponse() { } [Fact] - public async Task SendAsync_WithPathParams_ReplacesInUrl() { + public async Task ExecuteAsync_WithPathParams_ReplacesInUrl() { // Arrange using var responseMessage = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, @@ -127,13 +133,16 @@ public async Task SendAsync_WithPathParams_ReplacesInUrl() { var (client, mockHandler) = CreateMockClient(responseMessage, req => req.RequestUri.ToString().Contains("/stores/" + _storeId + "/check")); - var request = ApiExecutorRequestBuilder - .Of(HttpMethod.Post, "/stores/{store_id}/check") - .PathParam("store_id", _storeId) - .Build(); + var requestBuilder = new RequestBuilder { + Method = HttpMethod.Post, + BasePath = _apiUrl, + PathTemplate = "/stores/{store_id}/check", + PathParameters = new Dictionary { { "store_id", _storeId } }, + QueryParameters = new Dictionary() + }; // Act - await client.GetApiExecutor().SendAsync(request); + await client.GetApiClient().ExecuteAsync(requestBuilder, "Check"); // Assert mockHandler.Protected().Verify( @@ -146,7 +155,7 @@ public async Task SendAsync_WithPathParams_ReplacesInUrl() { } [Fact] - public async Task SendAsync_WithQueryParams_AppendsToUrl() { + public async Task ExecuteAsync_WithQueryParams_AppendsToUrl() { // Arrange using var responseMessage = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, @@ -157,14 +166,19 @@ public async Task SendAsync_WithQueryParams_AppendsToUrl() { req.RequestUri.ToString().Contains("page_size=20") && req.RequestUri.ToString().Contains("continuation_token=abc123")); - var request = ApiExecutorRequestBuilder - .Of(HttpMethod.Get, "/stores") - .QueryParam("page_size", "20") - .QueryParam("continuation_token", "abc123") - .Build(); + var requestBuilder = new RequestBuilder { + Method = HttpMethod.Get, + BasePath = _apiUrl, + PathTemplate = "/stores", + PathParameters = new Dictionary(), + QueryParameters = new Dictionary { + { "page_size", "20" }, + { "continuation_token", "abc123" } + } + }; // Act - await client.GetApiExecutor().SendAsync(request); + await client.GetApiClient().ExecuteAsync(requestBuilder, "ListStores"); // Assert mockHandler.Protected().Verify( @@ -178,7 +192,7 @@ public async Task SendAsync_WithQueryParams_AppendsToUrl() { } [Fact] - public async Task SendAsync_WithCustomHeaders_IncludesInRequest() { + public async Task ExecuteAsync_WithCustomHeaders_IncludesInRequest() { // Arrange using var responseMessage = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, @@ -187,14 +201,23 @@ public async Task SendAsync_WithCustomHeaders_IncludesInRequest() { var (client, mockHandler) = CreateMockClient(responseMessage); - var request = ApiExecutorRequestBuilder - .Of(HttpMethod.Post, "/stores") - .Header("X-Custom-Header", "custom-value") - .Header("X-Another-Header", "another-value") - .Build(); + var requestBuilder = new RequestBuilder { + Method = HttpMethod.Post, + BasePath = _apiUrl, + PathTemplate = "/stores", + PathParameters = new Dictionary(), + QueryParameters = new Dictionary() + }; + + var options = new ClientRequestOptions { + Headers = new Dictionary { + { "X-Custom-Header", "custom-value" }, + { "X-Another-Header", "another-value" } + } + }; // Act - await client.GetApiExecutor().SendAsync(request); + await client.GetApiClient().ExecuteAsync(requestBuilder, "CreateStore", options); // Assert mockHandler.Protected().Verify( @@ -210,7 +233,7 @@ public async Task SendAsync_WithCustomHeaders_IncludesInRequest() { } [Fact] - public async Task SendAsync_WithBody_SerializesToJson() { + public async Task ExecuteAsync_WithBody_SerializesToJson() { // Arrange var requestBody = new { name = "test-store" }; using var responseMessage = new HttpResponseMessage { @@ -223,13 +246,17 @@ public async Task SendAsync_WithBody_SerializesToJson() { var (client, mockHandler) = CreateMockClient(responseMessage); - var request = ApiExecutorRequestBuilder - .Of(HttpMethod.Post, "/stores") - .Body(requestBody) - .Build(); + var requestBuilder = new RequestBuilder { + Method = HttpMethod.Post, + BasePath = _apiUrl, + PathTemplate = "/stores", + PathParameters = new Dictionary(), + QueryParameters = new Dictionary(), + Body = requestBody + }; // Act - await client.GetApiExecutor().SendAsync(request); + await client.GetApiClient().ExecuteAsync(requestBuilder, "CreateStore"); // Assert mockHandler.Protected().Verify( @@ -243,7 +270,7 @@ public async Task SendAsync_WithBody_SerializesToJson() { } [Fact] - public async Task SendAsync_RawResponse_ReturnsJsonString() { + public async Task ExecuteAsync_RawResponse_ReturnsJsonString() { // Arrange var expectedJson = "{\"id\":\"123\",\"name\":\"test\"}"; using var responseMessage = new HttpResponseMessage { @@ -253,13 +280,16 @@ public async Task SendAsync_RawResponse_ReturnsJsonString() { var (client, _) = CreateMockClient(responseMessage); - var request = ApiExecutorRequestBuilder - .Of(HttpMethod.Get, "/stores/{store_id}") - .PathParam("store_id", _storeId) - .Build(); + var requestBuilder = new RequestBuilder { + Method = HttpMethod.Get, + BasePath = _apiUrl, + PathTemplate = "/stores/{store_id}", + PathParameters = new Dictionary { { "store_id", _storeId } }, + QueryParameters = new Dictionary() + }; // Act - var response = await client.GetApiExecutor().SendAsync(request); + var response = await client.GetApiClient().ExecuteAsync(requestBuilder, "GetStore"); // Assert Assert.NotNull(response); @@ -269,7 +299,7 @@ public async Task SendAsync_RawResponse_ReturnsJsonString() { } [Fact] - public async Task SendAsync_ApiError_ThrowsFgaApiError() { + public async Task ExecuteAsync_ApiError_ThrowsFgaApiError() { // Arrange var errorResponse = new { code = "invalid_request", @@ -285,32 +315,21 @@ public async Task SendAsync_ApiError_ThrowsFgaApiError() { var (client, _) = CreateMockClient(responseMessage); - var request = ApiExecutorRequestBuilder - .Of(HttpMethod.Post, "/stores/{store_id}/check") - .PathParam("store_id", _storeId) - .Build(); - - // Act & Assert - await Assert.ThrowsAsync(async () => - await client.GetApiExecutor().SendAsync(request)); - } - - [Fact] - public async Task SendAsync_NullRequest_ThrowsArgumentNullException() { - // Arrange - var config = new ClientConfiguration { - ApiUrl = _apiUrl, - StoreId = _storeId + var requestBuilder = new RequestBuilder { + Method = HttpMethod.Post, + BasePath = _apiUrl, + PathTemplate = "/stores/{store_id}/check", + PathParameters = new Dictionary { { "store_id", _storeId } }, + QueryParameters = new Dictionary() }; - var client = new OpenFgaClient(config); // Act & Assert - await Assert.ThrowsAsync(async () => - await client.GetApiExecutor().SendAsync(null)); + await Assert.ThrowsAsync(async () => + await client.GetApiClient().ExecuteAsync(requestBuilder, "Check")); } [Fact] - public void ApiExecutor_CalledMultipleTimes_ReturnsSameInstance() { + public void GetApiClient_CalledMultipleTimes_ReturnsSameInstance() { // Arrange var config = new ClientConfiguration { ApiUrl = _apiUrl, @@ -319,15 +338,15 @@ public void ApiExecutor_CalledMultipleTimes_ReturnsSameInstance() { var client = new OpenFgaClient(config); // Act - var executor1 = client.GetApiExecutor(); - var executor2 = client.GetApiExecutor(); + var apiClient1 = client.GetApiClient(); + var apiClient2 = client.GetApiClient(); // Assert - Assert.Same(executor1, executor2); + Assert.Same(apiClient1, apiClient2); } [Fact] - public async Task SendAsync_TypedResponse_DeserializesCorrectly() { + public async Task ExecuteAsync_TypedResponse_DeserializesCorrectly() { // Arrange var expectedResponse = new CheckResponse { Allowed = true @@ -342,14 +361,17 @@ public async Task SendAsync_TypedResponse_DeserializesCorrectly() { var (client, _) = CreateMockClient(responseMessage); - var request = ApiExecutorRequestBuilder - .Of(HttpMethod.Post, "/stores/{store_id}/check") - .PathParam("store_id", _storeId) - .Body(new { user = "user:anne", relation = "reader", @object = "document:test" }) - .Build(); + var requestBuilder = new RequestBuilder { + Method = HttpMethod.Post, + BasePath = _apiUrl, + PathTemplate = "/stores/{store_id}/check", + PathParameters = new Dictionary { { "store_id", _storeId } }, + QueryParameters = new Dictionary(), + Body = new { user = "user:anne", relation = "reader", @object = "document:test" } + }; // Act - var response = await client.GetApiExecutor().SendAsync(request); + var response = await client.GetApiClient().ExecuteAsync(requestBuilder, "Check"); // Assert Assert.NotNull(response); @@ -358,7 +380,7 @@ public async Task SendAsync_TypedResponse_DeserializesCorrectly() { } [Fact] - public async Task SendAsync_CancellationToken_CancelsRequest() { + public async Task ExecuteAsync_CancellationToken_CancelsRequest() { // Arrange using var cts = new CancellationTokenSource(); cts.Cancel(); // Cancel immediately @@ -369,17 +391,21 @@ public async Task SendAsync_CancellationToken_CancelsRequest() { }; var client = new OpenFgaClient(config); - var request = ApiExecutorRequestBuilder - .Of(HttpMethod.Get, "/stores") - .Build(); + var requestBuilder = new RequestBuilder { + Method = HttpMethod.Get, + BasePath = _apiUrl, + PathTemplate = "/stores", + PathParameters = new Dictionary(), + QueryParameters = new Dictionary() + }; // Act & Assert await Assert.ThrowsAnyAsync(async () => - await client.GetApiExecutor().SendAsync(request, cts.Token)); + await client.GetApiClient().ExecuteAsync(requestBuilder, "ListStores", null, cts.Token)); } [Fact] - public async Task SendAsync_WithCredentials_IncludesAuthorizationHeader() { + public async Task ExecuteAsync_WithCredentials_IncludesAuthorizationHeader() { // Arrange using var responseMessage = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, @@ -407,12 +433,16 @@ public async Task SendAsync_WithCredentials_IncludesAuthorizationHeader() { }; var client = new OpenFgaClient(config, new HttpClient(mockHandler.Object)); - var request = ApiExecutorRequestBuilder - .Of(HttpMethod.Get, "/stores") - .Build(); + var requestBuilder = new RequestBuilder { + Method = HttpMethod.Get, + BasePath = _apiUrl, + PathTemplate = "/stores", + PathParameters = new Dictionary(), + QueryParameters = new Dictionary() + }; // Act - await client.GetApiExecutor().SendAsync(request); + await client.GetApiClient().ExecuteAsync(requestBuilder, "ListStores"); // Assert mockHandler.Protected().Verify( @@ -425,4 +455,71 @@ public async Task SendAsync_WithCredentials_IncludesAuthorizationHeader() { ItExpr.IsAny() ); } -} \ No newline at end of file + + [Fact] + public async Task ExecuteAsync_UsingFluentApi_WorksCorrectly() { + // Arrange + var expectedResponse = new { id = _storeId, name = "test-store" }; + using var responseMessage = new HttpResponseMessage { + StatusCode = HttpStatusCode.OK, + Content = new StringContent( + JsonSerializer.Serialize(expectedResponse), + Encoding.UTF8, + "application/json") + }; + + var (client, _) = CreateMockClient(responseMessage, req => + req.Method == HttpMethod.Get && + req.RequestUri.ToString().Contains("/stores/" + _storeId)); + + // Demonstrate the new fluent API inspired by ApiExecutorRequestBuilder + var requestBuilder = RequestBuilder + .Create(HttpMethod.Get, _apiUrl, "/stores/{store_id}") + .WithPathParameter("store_id", _storeId); + + // Act + var response = await client.GetApiClient().ExecuteAsync(requestBuilder, "GetStore"); + + // Assert + Assert.NotNull(response); + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.True(response.IsSuccessful); + Assert.NotNull(response.Data); + Assert.Contains("test-store", response.RawResponse); + } + + [Fact] + public async Task ExecuteAsync_FluentApiWithMultipleParams_WorksCorrectly() { + // Arrange + var requestBody = new { user = "user:anne", relation = "reader", @object = "document:2021-budget" }; + var expectedResponse = new { allowed = true }; + using var responseMessage = new HttpResponseMessage { + StatusCode = HttpStatusCode.OK, + Content = new StringContent( + JsonSerializer.Serialize(expectedResponse), + Encoding.UTF8, + "application/json") + }; + + var (client, _) = CreateMockClient(responseMessage, req => + req.Method == HttpMethod.Post && + req.RequestUri.ToString().Contains("/stores/" + _storeId + "/check") && + req.RequestUri.ToString().Contains("consistency=")); + + // Fluent API with method chaining + var requestBuilder = RequestBuilder + .Create(HttpMethod.Post, _apiUrl, "/stores/{store_id}/check") + .WithPathParameter("store_id", _storeId) + .WithQueryParameter("consistency", "HIGHER_CONSISTENCY") + .WithBody(requestBody); + + // Act + var response = await client.GetApiClient().ExecuteAsync(requestBuilder, "Check"); + + // Assert + Assert.NotNull(response); + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.True(response.IsSuccessful); + } +} + diff --git a/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiResponseTests.cs b/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiResponseTests.cs index f54b8dc6..5731fa6e 100644 --- a/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiResponseTests.cs +++ b/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiResponseTests.cs @@ -1,4 +1,4 @@ -using OpenFga.Sdk.Client.ApiExecutor; +using OpenFga.Sdk.ApiClient; using System.Collections.Generic; using System.Linq; using System.Net; diff --git a/src/OpenFga.Sdk/ApiClient/ApiClient.cs b/src/OpenFga.Sdk/ApiClient/ApiClient.cs index 475f2c2f..4537d238 100644 --- a/src/OpenFga.Sdk/ApiClient/ApiClient.cs +++ b/src/OpenFga.Sdk/ApiClient/ApiClient.cs @@ -111,46 +111,6 @@ await _baseClient.SendRequestAsync(requestBuilder, additionalHeaders return response.responseContent; } - /// - /// Internal method that returns the full ResponseWrapper including raw response. - /// Used by ApiExecutor to provide both raw and typed response data. - /// - /// - /// - /// Additional headers to merge with auth headers - /// - /// Request Type - /// Response Type - /// The full ResponseWrapper with raw response and deserialized content - /// - internal async Task> SendRequestWithWrapperAsync( - RequestBuilder requestBuilder, - string apiName, - IDictionary? additionalHeaders = null, - CancellationToken cancellationToken = default) { - var sw = Stopwatch.StartNew(); - - var authToken = await GetAuthenticationTokenAsync(apiName); - var mergedHeaders = BuildHeaders(_configuration, authToken, null); - - // Merge additional headers (from ApiExecutor) with auth headers - if (additionalHeaders != null) { - foreach (var header in additionalHeaders) { - mergedHeaders[header.Key] = header.Value; - } - } - - var response = await Retry(async (attemptCount) => - await _baseClient.SendRequestAsync(requestBuilder, mergedHeaders, apiName, - attemptCount, cancellationToken)); - - sw.Stop(); - metrics.BuildForResponse(apiName, response.rawResponse, requestBuilder, sw, - response.retryCount); - - return response; - } - /// /// Handles getting the access token, calling the API, and potentially retrying (use for requests that return no /// content) @@ -306,5 +266,91 @@ private void PopulateRetryMetadata(FgaApiError error, int attemptCount) { } } + /// + /// Executes an API request using RequestBuilder and returns an ApiResponse with full response details. + /// This provides a lower-level API for custom requests while leveraging authentication, retry logic, and error handling. + /// + /// The type of the request body + /// The type of the response body + /// The request builder containing request details + /// The API name for telemetry and error reporting + /// Request options including custom headers + /// Cancellation token + /// An ApiResponse containing status code, headers, raw response, and typed data + /// Thrown when authentication fails + /// Thrown when the API returns an error response + public async Task> ExecuteAsync( + RequestBuilder requestBuilder, + string apiName, + IRequestOptions? options = null, + CancellationToken cancellationToken = default) { + + var responseWrapper = await ExecuteRequestWithWrapperAsync( + requestBuilder, apiName, options, cancellationToken); + + var rawResponse = await responseWrapper.rawResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + + return ApiResponse.FromHttpResponse( + responseWrapper.rawResponse, + rawResponse, + responseWrapper.responseContent); + } + + /// + /// Executes an API request using RequestBuilder and returns an ApiResponse with raw JSON string. + /// This variant is useful when you want to process the JSON response manually. + /// + /// The type of the request body + /// The request builder containing request details + /// The API name for telemetry and error reporting + /// Request options including custom headers + /// Cancellation token + /// An ApiResponse with the raw JSON response as the Data property + /// Thrown when authentication fails + /// Thrown when the API returns an error response + public async Task> ExecuteAsync( + RequestBuilder requestBuilder, + string apiName, + IRequestOptions? options = null, + CancellationToken cancellationToken = default) { + + // Use object as intermediate type to avoid strong typing + var responseWrapper = await ExecuteRequestWithWrapperAsync( + requestBuilder, apiName, options, cancellationToken); + + var rawResponse = await responseWrapper.rawResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + + return ApiResponse.FromHttpResponse( + responseWrapper.rawResponse, + rawResponse, + rawResponse); + } + + /// + /// Private helper method that executes a request and returns the ResponseWrapper. + /// This consolidates common logic used by both ExecuteAsync overloads. + /// + private async Task> ExecuteRequestWithWrapperAsync( + RequestBuilder requestBuilder, + string apiName, + IRequestOptions? options, + CancellationToken cancellationToken) { + + var sw = Stopwatch.StartNew(); + + var authToken = await GetAuthenticationTokenAsync(apiName); + var additionalHeaders = BuildHeaders(_configuration, authToken, options); + + var response = await Retry(async (attemptCount) => + await _baseClient.SendRequestAsync(requestBuilder, additionalHeaders, apiName, + attemptCount, cancellationToken)); + + sw.Stop(); + metrics.BuildForResponse(apiName, response.rawResponse, requestBuilder, sw, + response.retryCount); + + return response; + } + public void Dispose() => _baseClient.Dispose(); } \ No newline at end of file diff --git a/src/OpenFga.Sdk/Client/ApiExecutor/ApiResponse.cs b/src/OpenFga.Sdk/ApiClient/ApiResponse.cs similarity index 95% rename from src/OpenFga.Sdk/Client/ApiExecutor/ApiResponse.cs rename to src/OpenFga.Sdk/ApiClient/ApiResponse.cs index 9771b356..89e4fe3f 100644 --- a/src/OpenFga.Sdk/Client/ApiExecutor/ApiResponse.cs +++ b/src/OpenFga.Sdk/ApiClient/ApiResponse.cs @@ -1,13 +1,13 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Net; using System.Net.Http; -namespace OpenFga.Sdk.Client.ApiExecutor; +namespace OpenFga.Sdk.ApiClient; /// -/// Represents the response from an API Executor request, containing both raw and typed response data. +/// Represents the response from an API request executed via ApiClient.ExecuteAsync, +/// containing both raw and typed response data. /// /// The type of the deserialized response data public class ApiResponse { @@ -100,4 +100,5 @@ private static IReadOnlyDictionary> ConvertHeaders( return headers; } -} \ No newline at end of file +} + diff --git a/src/OpenFga.Sdk/ApiClient/RequestBuilder.cs b/src/OpenFga.Sdk/ApiClient/RequestBuilder.cs index 02d70374..2cd55954 100644 --- a/src/OpenFga.Sdk/ApiClient/RequestBuilder.cs +++ b/src/OpenFga.Sdk/ApiClient/RequestBuilder.cs @@ -10,6 +10,8 @@ namespace OpenFga.Sdk.ApiClient; /// +/// Builder for constructing HTTP requests with support for path parameters, query parameters, and request bodies. +/// Can be used with object initializer syntax or fluent builder methods. /// /// Type of the Request Body public class RequestBuilder { @@ -28,6 +30,96 @@ public RequestBuilder() { public TReq? Body { get; set; } + /// + /// Creates a new RequestBuilder with the specified HTTP method, base path, and path template. + /// This is an alternative to object initializer syntax that provides better validation. + /// + /// The HTTP method (e.g., GET, POST, PUT, DELETE) + /// The base URL for the API (e.g., "https://api.fga.example") + /// The path template (e.g., "/stores/{store_id}/check") + /// A new RequestBuilder instance + /// Thrown when method, basePath, or pathTemplate is null + /// Thrown when basePath or pathTemplate is empty or whitespace + public static RequestBuilder Create(HttpMethod method, string basePath, string pathTemplate) { + if (method == null) { + throw new ArgumentNullException(nameof(method), "HTTP method cannot be null"); + } + + if (basePath == null) { + throw new ArgumentNullException(nameof(basePath), "Base path cannot be null"); + } + + if (string.IsNullOrWhiteSpace(basePath)) { + throw new ArgumentException("Base path cannot be empty or whitespace", nameof(basePath)); + } + + if (pathTemplate == null) { + throw new ArgumentNullException(nameof(pathTemplate), "Path template cannot be null"); + } + + if (string.IsNullOrWhiteSpace(pathTemplate)) { + throw new ArgumentException("Path template cannot be empty or whitespace", nameof(pathTemplate)); + } + + return new RequestBuilder { + Method = method, + BasePath = basePath, + PathTemplate = pathTemplate + }; + } + + /// + /// Adds a path parameter to the request. The parameter will replace {key} in the path template. + /// + /// The parameter name (without braces) + /// The parameter value + /// This builder instance for method chaining + /// Thrown when key is null, empty, or whitespace + /// Thrown when value is null + public RequestBuilder WithPathParameter(string key, string value) { + if (string.IsNullOrWhiteSpace(key)) { + throw new ArgumentException("Path parameter key cannot be null, empty, or whitespace", nameof(key)); + } + + if (value == null) { + throw new ArgumentNullException(nameof(value), $"Path parameter value for key '{key}' cannot be null"); + } + + PathParameters[key] = value; + return this; + } + + /// + /// Adds a query parameter to the request. The parameter will be appended to the URL as ?key=value. + /// + /// The query parameter name + /// The query parameter value + /// This builder instance for method chaining + /// Thrown when key is null, empty, or whitespace + /// Thrown when value is null + public RequestBuilder WithQueryParameter(string key, string value) { + if (string.IsNullOrWhiteSpace(key)) { + throw new ArgumentException("Query parameter key cannot be null, empty, or whitespace", nameof(key)); + } + + if (value == null) { + throw new ArgumentNullException(nameof(value), $"Query parameter value for key '{key}' cannot be null"); + } + + QueryParameters[key] = value; + return this; + } + + /// + /// Sets the request body. The body will be JSON-serialized when sent. + /// + /// The request body object (will be serialized to JSON) + /// This builder instance for method chaining + public RequestBuilder WithBody(TReq? body) { + Body = body; + return this; + } + public string? JsonBody => Body == null ? null : JsonSerializer.Serialize(Body); public HttpContent? FormEncodedBody { diff --git a/src/OpenFga.Sdk/Client/ApiExecutor/ApiExecutor.cs b/src/OpenFga.Sdk/Client/ApiExecutor/ApiExecutor.cs deleted file mode 100644 index 654ee3b9..00000000 --- a/src/OpenFga.Sdk/Client/ApiExecutor/ApiExecutor.cs +++ /dev/null @@ -1,124 +0,0 @@ -using OpenFga.Sdk.ApiClient; -using OpenFga.Sdk.Configuration; -using System; -using System.Text.Json; -using System.Threading; -using System.Threading.Tasks; - -namespace OpenFga.Sdk.Client.ApiExecutor; - -/// -/// Provides the ability to execute arbitrary API requests against the OpenFGA API. -/// Automatically leverages SDK authentication, retry logic, and error handling. -/// -public class ApiExecutor : IDisposable { - private readonly ApiClient.ApiClient _apiClient; - private readonly Configuration.Configuration _configuration; - - /// - /// Initializes a new instance of the ApiExecutor class. - /// - /// The API client for handling requests - /// The SDK configuration - internal ApiExecutor( - ApiClient.ApiClient apiClient, - Configuration.Configuration configuration) { - _apiClient = apiClient ?? throw new ArgumentNullException(nameof(apiClient)); - _configuration = configuration ?? throw new ArgumentNullException(nameof(configuration)); - } - - /// - /// Sends an API request and returns a typed response. - /// - /// The type to deserialize the response to - /// The request builder containing the request details - /// Cancellation token - /// An ApiResponse containing status, headers, raw response, and typed data - /// Thrown when request is null - /// Thrown when the request is invalid - /// Thrown when the API returns an error response - public async Task> SendAsync( - ApiExecutorRequestBuilder request, - CancellationToken cancellationToken = default) { - if (request == null) { - throw new ArgumentNullException(nameof(request)); - } - - // Validate the request - request.Build(); - - // Convert to internal RequestBuilder - var requestBuilder = request.ToRequestBuilder(_configuration.BasePath); - - // Get custom headers from the request - var customHeaders = request.GetHeaders(); - - // Send the request and get the full ResponseWrapper - var responseWrapper = await _apiClient.SendRequestWithWrapperAsync( - requestBuilder, - "ApiExecutor", - customHeaders, - cancellationToken).ConfigureAwait(false); - - // Read the raw response body - var rawResponse = await responseWrapper.rawResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - - // Create and return ApiResponse - return ApiResponse.FromHttpResponse( - responseWrapper.rawResponse, - rawResponse, - responseWrapper.responseContent); - } - - /// - /// Sends an API request and returns a response with raw JSON string as data. - /// Useful when you want to process the JSON response manually. - /// - /// The request builder containing the request details - /// Cancellation token - /// An ApiResponse with the raw JSON response as the Data property - /// Thrown when request is null - /// Thrown when the request is invalid - /// Thrown when the API returns an error response - public async Task> SendAsync( - ApiExecutorRequestBuilder request, - CancellationToken cancellationToken = default) { - if (request == null) { - throw new ArgumentNullException(nameof(request)); - } - - // Validate the request - request.Build(); - - // Convert to internal RequestBuilder - var requestBuilder = request.ToRequestBuilder(_configuration.BasePath); - - // Get custom headers from the request - var customHeaders = request.GetHeaders(); - - // Send the request and get the full ResponseWrapper - // Use JsonElement as intermediate type to avoid double deserialization - var responseWrapper = await _apiClient.SendRequestWithWrapperAsync( - requestBuilder, - "ApiExecutor", - customHeaders, - cancellationToken).ConfigureAwait(false); - - // Read the raw response body - var rawResponse = await responseWrapper.rawResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - - // Create and return ApiResponse with raw JSON as both RawResponse and Data - return ApiResponse.FromHttpResponse( - responseWrapper.rawResponse, - rawResponse, - rawResponse); - } - - /// - /// Disposes of resources used by the ApiExecutor. - /// - public void Dispose() { - // ApiClient is owned by OpenFgaApi, so we don't dispose it here - GC.SuppressFinalize(this); - } -} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Client/ApiExecutor/ApiExecutorRequestBuilder.cs b/src/OpenFga.Sdk/Client/ApiExecutor/ApiExecutorRequestBuilder.cs deleted file mode 100644 index ec7d7788..00000000 --- a/src/OpenFga.Sdk/Client/ApiExecutor/ApiExecutorRequestBuilder.cs +++ /dev/null @@ -1,172 +0,0 @@ -using OpenFga.Sdk.ApiClient; -using OpenFga.Sdk.Exceptions; -using System; -using System.Collections.Generic; -using System.Net.Http; - -namespace OpenFga.Sdk.Client.ApiExecutor; - -/// -/// A fluent builder for constructing API requests to be executed via the ApiExecutor. -/// -public class ApiExecutorRequestBuilder { - /// - /// Gets the HTTP method for this request. - /// - public HttpMethod Method { get; private set; } - - /// - /// Gets the path template for this request (e.g., "/stores/{store_id}/check"). - /// - public string PathTemplate { get; private set; } - - private readonly Dictionary _pathParams = new Dictionary(); - private readonly Dictionary _queryParams = new Dictionary(); - private readonly Dictionary _headers = new Dictionary(); - private object? _body; - - /// - /// Private constructor to enforce usage of the Of() factory method. - /// - private ApiExecutorRequestBuilder() { } - - /// - /// Creates a new ApiExecutorRequestBuilder with the specified HTTP method and path. - /// - /// The HTTP method (e.g., GET, POST, PUT, DELETE) - /// The path template (e.g., "/stores/{store_id}/check") - /// A new ApiExecutorRequestBuilder instance - /// Thrown when method or path is null - /// Thrown when path is empty or whitespace - public static ApiExecutorRequestBuilder Of(HttpMethod method, string path) { - if (method == null) { - throw new ArgumentNullException(nameof(method), "HTTP method cannot be null"); - } - - if (path == null) { - throw new ArgumentNullException(nameof(path), "Path cannot be null"); - } - - if (string.IsNullOrWhiteSpace(path)) { - throw new ArgumentException("Path cannot be empty or whitespace", nameof(path)); - } - - if (!path.StartsWith("/")) { - throw new ArgumentException("Path must start with '/'", nameof(path)); - } - - return new ApiExecutorRequestBuilder { - Method = method, - PathTemplate = path - }; - } - - /// - /// Adds a path parameter to the request. The parameter will replace {key} in the path template. - /// - /// The parameter name (without braces) - /// The parameter value - /// This builder instance for method chaining - /// Thrown when key is null, empty, or whitespace - /// Thrown when value is null - public ApiExecutorRequestBuilder PathParam(string key, string value) { - if (string.IsNullOrWhiteSpace(key)) { - throw new ArgumentException("Path parameter key cannot be null, empty, or whitespace", nameof(key)); - } - - if (value == null) { - throw new ArgumentNullException(nameof(value), $"Path parameter value for key '{key}' cannot be null"); - } - - _pathParams[key] = value; - return this; - } - - /// - /// Adds a query parameter to the request. The parameter will be appended to the URL as ?key=value. - /// - /// The query parameter name - /// The query parameter value - /// This builder instance for method chaining - /// Thrown when key is null, empty, or whitespace - /// Thrown when value is null - public ApiExecutorRequestBuilder QueryParam(string key, string value) { - if (string.IsNullOrWhiteSpace(key)) { - throw new ArgumentException("Query parameter key cannot be null, empty, or whitespace", nameof(key)); - } - - if (value == null) { - throw new ArgumentNullException(nameof(value), $"Query parameter value for key '{key}' cannot be null"); - } - - _queryParams[key] = value; - return this; - } - - /// - /// Adds a custom header to the request. - /// - /// The header name - /// The header value - /// This builder instance for method chaining - /// Thrown when the header is reserved or invalid - public ApiExecutorRequestBuilder Header(string key, string value) { - // Validate using the existing Configuration.ValidateHeaders method - var headers = new Dictionary { { key, value } }; - Configuration.Configuration.ValidateHeaders(headers, "header"); - - _headers[key] = value; - return this; - } - - /// - /// Sets the request body. The body will be JSON-serialized when sent. - /// - /// The request body object (will be serialized to JSON) - /// This builder instance for method chaining - public ApiExecutorRequestBuilder Body(object? body) { - _body = body; - return this; - } - - /// - /// Validates and finalizes the builder. Call this method before passing to ApiExecutor. - /// - /// This builder instance - /// Thrown when the builder state is invalid - public ApiExecutorRequestBuilder Build() { - if (Method == null) { - throw new FgaValidationError("HTTP method must be specified. Use ApiExecutorRequestBuilder.Of() to create a builder."); - } - - if (string.IsNullOrWhiteSpace(PathTemplate)) { - throw new FgaValidationError("Path template must be specified. Use ApiExecutorRequestBuilder.Of() to create a builder."); - } - - return this; - } - - /// - /// Converts this ApiExecutorRequestBuilder to an internal RequestBuilder for API execution. - /// - /// The base path/URL for the API - /// A RequestBuilder configured for the API client - internal RequestBuilder ToRequestBuilder(string basePath) { - return new RequestBuilder { - Method = this.Method, - BasePath = basePath, - PathTemplate = this.PathTemplate, - PathParameters = new Dictionary(_pathParams), - QueryParameters = new Dictionary(_queryParams), - Body = _body - }; - } - - /// - /// Gets the custom headers for this request. - /// - /// A dictionary of custom headers - internal IDictionary GetHeaders() { - return new Dictionary(_headers); - } -} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Client/Client.cs b/src/OpenFga.Sdk/Client/Client.cs index 1a3b2120..4df919c9 100644 --- a/src/OpenFga.Sdk/Client/Client.cs +++ b/src/OpenFga.Sdk/Client/Client.cs @@ -22,7 +22,6 @@ namespace OpenFga.Sdk.Client; public class OpenFgaClient : IOpenFgaClient, IDisposable { private readonly ClientConfiguration _configuration; protected OpenFgaApi api; - private readonly Lazy _apiExecutor; public OpenFgaClient( ClientConfiguration configuration, @@ -31,9 +30,6 @@ public OpenFgaClient( configuration.EnsureValid(); _configuration = configuration; api = new OpenFgaApi(_configuration, httpClient); - _apiExecutor = new Lazy(() => new ApiExecutor.ApiExecutor( - api.ApiClientInternal, - _configuration)); } /// @@ -49,19 +45,17 @@ public string? AuthorizationModelId { } /// - /// Gets the ApiExecutor for making custom API requests. - /// The ApiExecutor allows you to call arbitrary OpenFGA API endpoints while - /// automatically leveraging the SDK's authentication, retry logic, and error handling. + /// Gets the underlying ApiClient for making custom API requests. + /// The ApiClient allows you to call arbitrary OpenFGA API endpoints using RequestBuilder + /// while automatically leveraging the SDK's authentication, retry logic, and error handling. + /// Use ApiClient.ExecuteAsync() methods for custom requests that return full response details. /// - /// An ApiExecutor instance - public ApiExecutor.ApiExecutor GetApiExecutor() { - return _apiExecutor.Value; + /// The ApiClient instance used by this client + public ApiClient.ApiClient GetApiClient() { + return api.ApiClientInternal; } public void Dispose() { - if (_apiExecutor.IsValueCreated) { - _apiExecutor.Value?.Dispose(); - } api.Dispose(); } From 43de9e2d80af60bdfc30aa143796c02ebd47e7d1 Mon Sep 17 00:00:00 2001 From: SoulPancake Date: Wed, 18 Feb 2026 10:10:46 +0530 Subject: [PATCH 17/23] fix: examples to use ExecuteAsync --- README.md | 65 +++++ example/ApiExecutorExample/Program.cs | 228 ++++++++++++------ example/ApiExecutorExample/README.md | 206 +++++++++++++--- example/README.md | 4 +- .../Client/ApiExecutor/ApiExecutorTests.cs | 3 +- src/OpenFga.Sdk/ApiClient/ApiResponse.cs | 3 +- 6 files changed, 384 insertions(+), 125 deletions(-) diff --git a/README.md b/README.md index a758b24c..56081364 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,7 @@ This is an autogenerated SDK for OpenFGA. It provides a wrapper around the [Open - [Assertions](#assertions) - [Read Assertions](#read-assertions) - [Write Assertions](#write-assertions) + - [Calling Other Endpoints](#calling-other-endpoints) - [Retries](#retries) - [API Endpoints](#api-endpoints) - [Models](#models) @@ -969,6 +970,70 @@ var body = new List() {new ClientAssertion() { await fgaClient.WriteAssertions(body, options); ``` +### Calling Other Endpoints + +For advanced use cases where you need to call API endpoints not yet available in the SDK's typed methods, or when you need access to full response details (status code, headers, raw response), you can use `ApiClient.ExecuteAsync()`. + +#### Basic Usage + +```csharp +using OpenFga.Sdk.ApiClient; +using FgaApiClient = OpenFga.Sdk.ApiClient.ApiClient; + +var client = new OpenFgaClient(configuration); +var apiClient = client.GetApiClient(); + +// Build a request using RequestBuilder +var request = new RequestBuilder { + Method = HttpMethod.Get, + BasePath = configuration.ApiUrl, + PathTemplate = "/stores/{store_id}", + PathParameters = new Dictionary { { "store_id", storeId } }, + QueryParameters = new Dictionary() +}; + +// Execute and get full response details +var response = await apiClient.ExecuteAsync(request, "GetStore"); + +// Access response details +Console.WriteLine($"Status: {response.StatusCode}"); +Console.WriteLine($"Headers: {response.Headers.Count}"); +Console.WriteLine($"Raw JSON: {response.RawResponse}"); +Console.WriteLine($"Data: {response.Data.Name}"); +``` + +#### Fluent API Style + +You can also use a fluent API for cleaner request building: + +```csharp +var request = RequestBuilder + .Create(HttpMethod.Post, configuration.ApiUrl, "/stores/{store_id}/check") + .WithPathParameter("store_id", storeId) + .WithQueryParameter("consistency", "HIGHER_CONSISTENCY") + .WithBody(checkRequest); + +var response = await apiClient.ExecuteAsync(request, "Check"); +``` + +#### Custom Headers + +```csharp +var options = new ClientRequestOptions { + Headers = new Dictionary { + { "X-Custom-Header", "value" }, + { "X-Trace-Id", traceId } + } +}; + +var response = await apiClient.ExecuteAsync( + request, + "CustomEndpoint", + options +); +``` + +For a complete example with all features, see the [Custom API Requests Example](./example/ApiExecutorExample/). ### Retries diff --git a/example/ApiExecutorExample/Program.cs b/example/ApiExecutorExample/Program.cs index acc495e4..f9e7f867 100644 --- a/example/ApiExecutorExample/Program.cs +++ b/example/ApiExecutorExample/Program.cs @@ -1,21 +1,23 @@ +using OpenFga.Sdk.ApiClient; using OpenFga.Sdk.Client; -using OpenFga.Sdk.Client.ApiExecutor; +using OpenFga.Sdk.Client.Model; using OpenFga.Sdk.Configuration; using OpenFga.Sdk.Model; using System.Net.Http; +using FgaApiClient = OpenFga.Sdk.ApiClient.ApiClient; namespace ApiExecutorExample; /// -/// This example demonstrates how to use the ApiExecutor to make raw HTTP requests -/// to the OpenFGA API without using the SDK's typed methods. +/// This example demonstrates how to use ApiClient.ExecuteAsync to make custom HTTP requests +/// to the OpenFGA API with full response details (status code, headers, raw response, typed data). /// /// Prerequisites: Run an OpenFGA server on localhost:8080 /// docker run -p 8080:8080 openfga/openfga:latest run /// class Program { static async Task Main(string[] args) { - Console.WriteLine("=== OpenFGA ApiExecutor Example ===\n"); + Console.WriteLine("=== OpenFGA Custom API Requests Example ===\n"); // Configure client to connect to local OpenFGA instance var config = new ClientConfiguration { @@ -23,37 +25,41 @@ static async Task Main(string[] args) { }; using var client = new OpenFgaClient(config); + var apiClient = client.GetApiClient(); // Get the ApiClient for custom requests try { // Example 1: List stores using raw GET request - await ListStoresExample(client); + await ListStoresExample(apiClient, config.ApiUrl); // Example 2: Create a store using raw POST request with typed response - var storeId = await CreateStoreExample(client); + var storeId = await CreateStoreExample(apiClient, config.ApiUrl); // Example 3: Get store details using path parameters - await GetStoreExample(client, storeId); + await GetStoreExample(apiClient, config.ApiUrl, storeId); // Example 4: Create an authorization model - var modelId = await CreateAuthorizationModelExample(client, storeId); + var modelId = await CreateAuthorizationModelExample(apiClient, config.ApiUrl, storeId); // Example 5: Write relationship tuples - await WriteTuplesExample(client, storeId); + await WriteTuplesExample(apiClient, config.ApiUrl, storeId); // Example 6: Read relationship tuples - await ReadTuplesExample(client, storeId); + await ReadTuplesExample(apiClient, config.ApiUrl, storeId); // Example 7: Check permissions - await CheckPermissionExample(client, storeId, modelId); + await CheckPermissionExample(apiClient, config.ApiUrl, storeId, modelId); // Example 8: Use raw JSON response instead of typed - await RawJsonResponseExample(client); + await RawJsonResponseExample(apiClient, config.ApiUrl); // Example 9: Custom headers - await CustomHeadersExample(client); + await CustomHeadersExample(apiClient, config.ApiUrl); + + // Example 10: Fluent API for building requests + await FluentApiExample(apiClient, config.ApiUrl); // Cleanup: Delete the store we created - await DeleteStoreExample(client, storeId); + await DeleteStoreExample(apiClient, config.ApiUrl, storeId); Console.WriteLine("\n=== All examples completed successfully! ==="); } catch (Exception ex) { @@ -64,22 +70,27 @@ static async Task Main(string[] args) { } } - static async Task ListStoresExample(OpenFgaClient client) { + static async Task ListStoresExample(FgaApiClient apiClient, string basePath) { Console.WriteLine("📋 Example 1: List Stores"); Console.WriteLine("Making GET request to /stores"); - var request = ApiExecutorRequestBuilder - .Of(HttpMethod.Get, "/stores") - .Build(); + var request = new RequestBuilder { + Method = HttpMethod.Get, + BasePath = basePath, + PathTemplate = "/stores", + PathParameters = new Dictionary(), + QueryParameters = new Dictionary() + }; - var response = await client.GetApiExecutor().SendAsync(request); + var response = await apiClient.ExecuteAsync(request, "ListStores"); Console.WriteLine($"✅ Status: {response.StatusCode}"); + Console.WriteLine($" Is Successful: {response.IsSuccessful}"); Console.WriteLine($" Found {response.Data.Stores?.Count ?? 0} store(s)"); Console.WriteLine(); } - static async Task CreateStoreExample(OpenFgaClient client) { + static async Task CreateStoreExample(FgaApiClient apiClient, string basePath) { Console.WriteLine("🏪 Example 2: Create Store"); Console.WriteLine("Making POST request to /stores"); @@ -88,39 +99,48 @@ static async Task CreateStoreExample(OpenFgaClient client) { { "name", storeName } }; - var request = ApiExecutorRequestBuilder - .Of(HttpMethod.Post, "/stores") - .Body(requestBody) - .Build(); + var request = new RequestBuilder { + Method = HttpMethod.Post, + BasePath = basePath, + PathTemplate = "/stores", + PathParameters = new Dictionary(), + QueryParameters = new Dictionary(), + Body = requestBody + }; - var response = await client.GetApiExecutor().SendAsync(request); + var response = await apiClient.ExecuteAsync(request, "CreateStore"); Console.WriteLine($"✅ Status: {response.StatusCode}"); Console.WriteLine($" Store ID: {response.Data.Id}"); Console.WriteLine($" Store Name: {response.Data.Name}"); + Console.WriteLine($" Raw Response Length: {response.RawResponse.Length} chars"); Console.WriteLine(); return response.Data.Id!; } - static async Task GetStoreExample(OpenFgaClient client, string storeId) { + static async Task GetStoreExample(FgaApiClient apiClient, string basePath, string storeId) { Console.WriteLine("🔍 Example 3: Get Store Details"); Console.WriteLine($"Making GET request to /stores/{{store_id}}"); - var request = ApiExecutorRequestBuilder - .Of(HttpMethod.Get, "/stores/{store_id}") - .PathParam("store_id", storeId) - .Build(); + var request = new RequestBuilder { + Method = HttpMethod.Get, + BasePath = basePath, + PathTemplate = "/stores/{store_id}", + PathParameters = new Dictionary { { "store_id", storeId } }, + QueryParameters = new Dictionary() + }; - var response = await client.GetApiExecutor().SendAsync(request); + var response = await apiClient.ExecuteAsync(request, "GetStore"); Console.WriteLine($"✅ Status: {response.StatusCode}"); Console.WriteLine($" Store Name: {response.Data.Name}"); Console.WriteLine($" Created At: {response.Data.CreatedAt}"); + Console.WriteLine($" Response Headers: {response.Headers.Count}"); Console.WriteLine(); } - static async Task CreateAuthorizationModelExample(OpenFgaClient client, string storeId) { + static async Task CreateAuthorizationModelExample(FgaApiClient apiClient, string basePath, string storeId) { Console.WriteLine("📝 Example 4: Create Authorization Model"); Console.WriteLine("Making POST request to /stores/{store_id}/authorization-models"); @@ -179,13 +199,16 @@ static async Task CreateAuthorizationModelExample(OpenFgaClient client, } }; - var request = ApiExecutorRequestBuilder - .Of(HttpMethod.Post, "/stores/{store_id}/authorization-models") - .PathParam("store_id", storeId) - .Body(requestBody) - .Build(); + var request = new RequestBuilder { + Method = HttpMethod.Post, + BasePath = basePath, + PathTemplate = "/stores/{store_id}/authorization-models", + PathParameters = new Dictionary { { "store_id", storeId } }, + QueryParameters = new Dictionary(), + Body = requestBody + }; - var response = await client.GetApiExecutor().SendAsync(request); + var response = await apiClient.ExecuteAsync(request, "WriteAuthorizationModel"); Console.WriteLine($"✅ Status: {response.StatusCode}"); Console.WriteLine($" Model ID: {response.Data.AuthorizationModelId}"); @@ -194,7 +217,7 @@ static async Task CreateAuthorizationModelExample(OpenFgaClient client, return response.Data.AuthorizationModelId!; } - static async Task WriteTuplesExample(OpenFgaClient client, string storeId) { + static async Task WriteTuplesExample(FgaApiClient apiClient, string basePath, string storeId) { Console.WriteLine("✍️ Example 5: Write Relationship Tuples"); Console.WriteLine("Making POST request to /stores/{store_id}/write"); @@ -219,20 +242,23 @@ static async Task WriteTuplesExample(OpenFgaClient client, string storeId) { } }; - var request = ApiExecutorRequestBuilder - .Of(HttpMethod.Post, "/stores/{store_id}/write") - .PathParam("store_id", storeId) - .Body(requestBody) - .Build(); + var request = new RequestBuilder { + Method = HttpMethod.Post, + BasePath = basePath, + PathTemplate = "/stores/{store_id}/write", + PathParameters = new Dictionary { { "store_id", storeId } }, + QueryParameters = new Dictionary(), + Body = requestBody + }; - var response = await client.GetApiExecutor().SendAsync(request); + var response = await apiClient.ExecuteAsync(request, "Write"); Console.WriteLine($"✅ Status: {response.StatusCode}"); Console.WriteLine(" Tuples written successfully"); Console.WriteLine(); } - static async Task ReadTuplesExample(OpenFgaClient client, string storeId) { + static async Task ReadTuplesExample(FgaApiClient apiClient, string basePath, string storeId) { Console.WriteLine("📖 Example 6: Read Relationship Tuples"); Console.WriteLine("Making POST request to /stores/{store_id}/read"); @@ -244,13 +270,16 @@ static async Task ReadTuplesExample(OpenFgaClient client, string storeId) { } }; - var request = ApiExecutorRequestBuilder - .Of(HttpMethod.Post, "/stores/{store_id}/read") - .PathParam("store_id", storeId) - .Body(requestBody) - .Build(); + var request = new RequestBuilder { + Method = HttpMethod.Post, + BasePath = basePath, + PathTemplate = "/stores/{store_id}/read", + PathParameters = new Dictionary { { "store_id", storeId } }, + QueryParameters = new Dictionary(), + Body = requestBody + }; - var response = await client.GetApiExecutor().SendAsync(request); + var response = await apiClient.ExecuteAsync(request, "Read"); Console.WriteLine($"✅ Status: {response.StatusCode}"); Console.WriteLine($" Found {response.Data.Tuples?.Count ?? 0} tuple(s):"); @@ -262,7 +291,7 @@ static async Task ReadTuplesExample(OpenFgaClient client, string storeId) { Console.WriteLine(); } - static async Task CheckPermissionExample(OpenFgaClient client, string storeId, string modelId) { + static async Task CheckPermissionExample(FgaApiClient apiClient, string basePath, string storeId, string modelId) { Console.WriteLine("🔐 Example 7: Check Permission"); Console.WriteLine("Making POST request to /stores/{store_id}/check"); @@ -277,63 +306,102 @@ static async Task CheckPermissionExample(OpenFgaClient client, string storeId, s } }; - var request = ApiExecutorRequestBuilder - .Of(HttpMethod.Post, "/stores/{store_id}/check") - .PathParam("store_id", storeId) - .Body(requestBody) - .Build(); + var request = new RequestBuilder { + Method = HttpMethod.Post, + BasePath = basePath, + PathTemplate = "/stores/{store_id}/check", + PathParameters = new Dictionary { { "store_id", storeId } }, + QueryParameters = new Dictionary(), + Body = requestBody + }; - var response = await client.GetApiExecutor().SendAsync(request); + var response = await apiClient.ExecuteAsync(request, "Check"); Console.WriteLine($"✅ Status: {response.StatusCode}"); Console.WriteLine($" Allowed: {response.Data.Allowed}"); Console.WriteLine(); } - static async Task RawJsonResponseExample(OpenFgaClient client) { + static async Task RawJsonResponseExample(FgaApiClient apiClient, string basePath) { Console.WriteLine("📄 Example 8: Raw JSON Response"); Console.WriteLine("Getting response as raw JSON string instead of typed object"); - var request = ApiExecutorRequestBuilder - .Of(HttpMethod.Get, "/stores") - .QueryParam("page_size", "5") - .Build(); + var request = new RequestBuilder { + Method = HttpMethod.Get, + BasePath = basePath, + PathTemplate = "/stores", + PathParameters = new Dictionary(), + QueryParameters = new Dictionary { { "page_size", "5" } } + }; - // Use SendAsync without type parameter to get raw JSON string - var response = await client.GetApiExecutor().SendAsync(request); + // Use ExecuteAsync without second type parameter to get raw JSON string + var response = await apiClient.ExecuteAsync(request, "ListStores"); Console.WriteLine($"✅ Status: {response.StatusCode}"); - Console.WriteLine($" Raw JSON: {response.Data?.Substring(0, Math.Min(100, response.Data.Length))}..."); + Console.WriteLine($" Raw JSON (first 100 chars): {response.Data?.Substring(0, Math.Min(100, response.Data.Length))}..."); + Console.WriteLine($" RawResponse and Data are the same: {response.RawResponse == response.Data}"); Console.WriteLine(); } - static async Task CustomHeadersExample(OpenFgaClient client) { + static async Task CustomHeadersExample(FgaApiClient apiClient, string basePath) { Console.WriteLine("📨 Example 9: Custom Headers"); Console.WriteLine("Making request with custom headers"); - var request = ApiExecutorRequestBuilder - .Of(HttpMethod.Get, "/stores") - .Header("X-Custom-Header", "example-value") - .Header("X-Request-ID", Guid.NewGuid().ToString()) - .Build(); + var request = new RequestBuilder { + Method = HttpMethod.Get, + BasePath = basePath, + PathTemplate = "/stores", + PathParameters = new Dictionary(), + QueryParameters = new Dictionary() + }; - var response = await client.GetApiExecutor().SendAsync(request); + // Pass custom headers via ClientRequestOptions + var options = new ClientRequestOptions { + Headers = new Dictionary { + { "X-Custom-Header", "example-value" }, + { "X-Request-ID", Guid.NewGuid().ToString() } + } + }; + + var response = await apiClient.ExecuteAsync(request, "ListStores", options); Console.WriteLine($"✅ Status: {response.StatusCode}"); Console.WriteLine(" Custom headers sent successfully"); + Console.WriteLine($" Response has {response.Headers.Count} headers"); + Console.WriteLine(); + } + + static async Task FluentApiExample(FgaApiClient apiClient, string basePath) { + Console.WriteLine("🎯 Example 10: Fluent API for Request Building"); + Console.WriteLine("Using the enhanced RequestBuilder with fluent methods"); + + // Use the new fluent API - much cleaner! + var request = RequestBuilder + .Create(HttpMethod.Get, basePath, "/stores") + .WithQueryParameter("page_size", "10") + .WithQueryParameter("continuation_token", ""); + + var response = await apiClient.ExecuteAsync(request, "ListStores"); + + Console.WriteLine($"✅ Status: {response.StatusCode}"); + Console.WriteLine($" Found {response.Data.Stores?.Count ?? 0} store(s) using fluent API"); + Console.WriteLine(" Note: Fluent API provides better validation and cleaner syntax!"); Console.WriteLine(); } - static async Task DeleteStoreExample(OpenFgaClient client, string storeId) { + static async Task DeleteStoreExample(FgaApiClient apiClient, string basePath, string storeId) { Console.WriteLine("🗑️ Cleanup: Delete Store"); Console.WriteLine($"Making DELETE request to /stores/{{store_id}}"); - var request = ApiExecutorRequestBuilder - .Of(HttpMethod.Delete, "/stores/{store_id}") - .PathParam("store_id", storeId) - .Build(); + var request = new RequestBuilder { + Method = HttpMethod.Delete, + BasePath = basePath, + PathTemplate = "/stores/{store_id}", + PathParameters = new Dictionary { { "store_id", storeId } }, + QueryParameters = new Dictionary() + }; - var response = await client.GetApiExecutor().SendAsync(request); + var response = await apiClient.ExecuteAsync(request, "DeleteStore"); Console.WriteLine($"✅ Status: {response.StatusCode}"); Console.WriteLine(" Store deleted successfully"); diff --git a/example/ApiExecutorExample/README.md b/example/ApiExecutorExample/README.md index 1ccbe496..1bc136f5 100644 --- a/example/ApiExecutorExample/README.md +++ b/example/ApiExecutorExample/README.md @@ -1,6 +1,6 @@ -# ApiExecutor Example +# Custom API Requests Example -This example demonstrates how to use the `ApiExecutor` to make raw HTTP requests to the OpenFGA API without using the SDK's typed methods. This is useful when you need more control over the HTTP requests or want to call endpoints that aren't yet supported by the SDK's typed API. +This example demonstrates how to use `ApiClient.ExecuteAsync()` to make custom HTTP requests to the OpenFGA API with full response details (status code, headers, raw response, typed data). This is useful when you need more control over HTTP requests or want to call endpoints that aren't yet supported by the SDK's typed API. ## What This Example Demonstrates @@ -12,7 +12,52 @@ This example demonstrates how to use the `ApiExecutor` to make raw HTTP requests 6. **Read Tuples** - Reading relationship tuples with filters 7. **Check Permission** - Checking if a user has permission 8. **Raw JSON Response** - Getting responses as raw JSON strings -9. **Custom Headers** - Adding custom headers to requests +9. **Custom Headers** - Adding custom headers to requests via ClientRequestOptions +10. **Fluent API** - Using the enhanced RequestBuilder with fluent methods + +## Key Concepts + +### ApiClient.ExecuteAsync vs Standard SDK Methods + +The SDK provides two ways to interact with the OpenFGA API: + +1. **Standard SDK Methods** (recommended for most use cases): + ```csharp + var response = await client.Check(checkRequest); + ``` + +2. **Custom API Requests** (for advanced scenarios): + ```csharp + var apiClient = client.GetApiClient(); + var request = RequestBuilder.Create(...); + var response = await apiClient.ExecuteAsync(request, "Check"); + // Now you have: response.StatusCode, response.Headers, response.RawResponse, response.Data + ``` + +### RequestBuilder: Two Styles + +You can build requests using either style: + +**Object Initializer** (compatible with existing patterns): +```csharp +var request = new RequestBuilder { + Method = HttpMethod.Post, + BasePath = config.ApiUrl, + PathTemplate = "/stores/{store_id}/check", + PathParameters = new Dictionary { { "store_id", storeId } }, + QueryParameters = new Dictionary(), + Body = requestBody +}; +``` + +**Fluent API** (enhanced developer experience): +```csharp +var request = RequestBuilder + .Create(HttpMethod.Post, config.ApiUrl, "/stores/{store_id}/check") + .WithPathParameter("store_id", storeId) + .WithQueryParameter("timeout", "30s") + .WithBody(requestBody); +``` ## Prerequisites @@ -64,11 +109,12 @@ make stop-openfga # Stop OpenFGA when done ## Example Output ```text -=== OpenFGA ApiExecutor Example === +=== OpenFGA Custom API Requests Example === 📋 Example 1: List Stores Making GET request to /stores ✅ Status: OK + Is Successful: True Found 0 store(s) 🏪 Example 2: Create Store @@ -76,12 +122,14 @@ Making POST request to /stores ✅ Status: Created Store ID: 01JQWXYZ123ABC456DEF789GHJ Store Name: ApiExecutor-Example-1738713600000 + Raw Response Length: 245 chars 🔍 Example 3: Get Store Details Making GET request to /stores/{store_id} ✅ Status: OK Store Name: ApiExecutor-Example-1738713600000 Created At: 2025-02-04T10:00:00Z + Response Headers: 8 📝 Example 4: Create Authorization Model Making POST request to /stores/{store_id}/authorization-models @@ -108,12 +156,20 @@ Making POST request to /stores/{store_id}/check 📄 Example 8: Raw JSON Response Getting response as raw JSON string instead of typed object ✅ Status: OK - Raw JSON: {"stores":[],"continuation_token":""}... + Raw JSON (first 100 chars): {"stores":[],"continuation_token":""}... + RawResponse and Data are the same: True 📨 Example 9: Custom Headers Making request with custom headers ✅ Status: OK Custom headers sent successfully + Response has 8 headers + +🎯 Example 10: Fluent API for Request Building +Using the enhanced RequestBuilder with fluent methods +✅ Status: OK + Found 0 store(s) using fluent API + Note: Fluent API provides better validation and cleaner syntax! 🗑️ Cleanup: Delete Store Making DELETE request to /stores/{store_id} @@ -123,57 +179,129 @@ Making DELETE request to /stores/{store_id} === All examples completed successfully! === ``` -## Key Concepts - -### 1. Creating Requests +## Architecture -Use `ApiExecutorRequestBuilder` to construct requests: +### How It Works -```csharp -var request = ApiExecutorRequestBuilder - .Of(HttpMethod.Post, "/stores/{store_id}/write") - .PathParam("store_id", storeId) - .QueryParam("page_size", "10") - .Header("X-Custom-Header", "value") - .Body(requestBody) - .Build(); +``` +OpenFgaClient + └── GetApiClient() → ApiClient (core building block) + └── ExecuteAsync() → Full response details + ├── Authentication (OAuth/ApiToken) + ├── Retry logic with exponential backoff + ├── Error handling + └── Metrics & telemetry + +RequestBuilder + ├── Object initializer (existing style) + └── Fluent API (enhanced style) ``` -### 2. Sending Requests +### Benefits of ExecuteAsync -Send requests using the ApiExecutor: +1. **Full Response Access** + - `response.StatusCode` - HTTP status code + - `response.Headers` - All response headers + - `response.RawResponse` - Raw JSON string + - `response.Data` - Strongly-typed response object + - `response.IsSuccessful` - Quick success check -```csharp -// With typed response -var response = await client.GetApiExecutor().SendAsync(request); +2. **Shared Infrastructure** + - Same authentication as standard SDK methods + - Same retry logic with exponential backoff + - Same error handling and exceptions + - Same metrics and telemetry -// With raw JSON response -var response = await client.GetApiExecutor().SendAsync(request); -``` +3. **Flexibility** + - Call any OpenFGA endpoint + - Add custom headers via `ClientRequestOptions` + - Get raw JSON or strongly-typed responses + - Use path and query parameters easily + +## When to Use Custom API Requests -### 3. Working with Responses +### Use Standard SDK Methods When: +- The operation is available in the SDK (Check, Write, Read, etc.) +- You don't need access to response headers +- You want the simplest API -Access response data through the `ApiResponse` object: +### Use ApiClient.ExecuteAsync When: +- Calling endpoints not yet in the SDK +- You need response headers or status codes +- Building custom integrations +- Need fine-grained control over requests +- Working with experimental API features +## Code Examples + +### Basic Request ```csharp +using OpenFga.Sdk.ApiClient; +using OpenFga.Sdk.Client; +using OpenFga.Sdk.Configuration; +using OpenFga.Sdk.Model; +// Optional: Use an alias to avoid namespace/class name conflicts +using FgaApiClient = OpenFga.Sdk.ApiClient.ApiClient; + +var client = new OpenFgaClient(config); +var apiClient = client.GetApiClient(); + +var request = new RequestBuilder { + Method = HttpMethod.Get, + BasePath = config.ApiUrl, + PathTemplate = "/stores", + PathParameters = new Dictionary(), + QueryParameters = new Dictionary() +}; + +var response = await apiClient.ExecuteAsync( + request, + "ListStores" +); + Console.WriteLine($"Status: {response.StatusCode}"); -Console.WriteLine($"Success: {response.IsSuccessful}"); -Console.WriteLine($"Data: {response.Data}"); -Console.WriteLine($"Raw Response: {response.RawResponse}"); -Console.WriteLine($"Headers: {string.Join(", ", response.Headers.Keys)}"); +Console.WriteLine($"Stores: {response.Data.Stores.Count}"); +``` + +> **Note:** If you get namespace conflicts with `ApiClient`, you can use a type alias: +> ```csharp +> using FgaApiClient = OpenFga.Sdk.ApiClient.ApiClient; +> ``` +> Then use `FgaApiClient` as the type in your method signatures. + +### Fluent API Style +```csharp +var request = RequestBuilder + .Create(HttpMethod.Post, config.ApiUrl, "/stores/{store_id}/check") + .WithPathParameter("store_id", storeId) + .WithQueryParameter("timeout", "30s") + .WithBody(new { + tuple_key = new { user = "user:anne", relation = "reader", @object = "doc:1" } + }); + +var response = await apiClient.ExecuteAsync( + request, + "Check", + new ClientRequestOptions { + Headers = new Dictionary { + { "X-Trace-Id", traceId } + } + } +); ``` -## When to Use ApiExecutor +### Raw JSON Response +```csharp +// When you want the raw JSON without deserialization +var response = await apiClient.ExecuteAsync(request, "CustomEndpoint"); +string json = response.Data; // Raw JSON string +``` -The ApiExecutor is useful when you need to: +## Resources -- Call OpenFGA API endpoints not yet available in the SDK's typed API -- Have fine-grained control over HTTP requests -- Work with custom or experimental API features -- Debug API interactions at the HTTP level -- Build custom abstractions on top of the OpenFGA API +- [OpenFGA API Documentation](https://openfga.dev/api) -## Troubleshooting +## Common Issues ### OpenFGA Connection Failed diff --git a/example/README.md b/example/README.md index a9ea598a..f4cf043d 100644 --- a/example/README.md +++ b/example/README.md @@ -13,8 +13,8 @@ Demonstrates how to use the StreamedListObjects API to efficiently list objects **OpenTelemetryExample:** Shows how to integrate OpenTelemetry for observability and tracing of OpenFGA SDK operations. -**ApiExecutorExample:** -Demonstrates how to use the ApiExecutor to make raw HTTP requests to the OpenFGA API. This is useful when you need more control over requests or want to call endpoints not yet available in the SDK's typed API. Includes a Makefile for easy execution with a local OpenFGA server. +**Custom API Requests Example:** +Demonstrates how to use `ApiClient.ExecuteAsync()` to make custom HTTP requests to the OpenFGA API with full response details. This is useful when you need more control over requests or want to call endpoints not yet available in the SDK's typed API. Includes a Makefile for easy execution with a local OpenFGA server. ### Running the Examples diff --git a/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorTests.cs b/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorTests.cs index cb2b2252..31cc324e 100644 --- a/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorTests.cs +++ b/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorTests.cs @@ -521,5 +521,4 @@ public async Task ExecuteAsync_FluentApiWithMultipleParams_WorksCorrectly() { Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.True(response.IsSuccessful); } -} - +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/ApiClient/ApiResponse.cs b/src/OpenFga.Sdk/ApiClient/ApiResponse.cs index 89e4fe3f..175f23ac 100644 --- a/src/OpenFga.Sdk/ApiClient/ApiResponse.cs +++ b/src/OpenFga.Sdk/ApiClient/ApiResponse.cs @@ -100,5 +100,4 @@ private static IReadOnlyDictionary> ConvertHeaders( return headers; } -} - +} \ No newline at end of file From d37e9866f5f21276e03ce0ee6f014ad5296ca938 Mon Sep 17 00:00:00 2001 From: SoulPancake Date: Wed, 18 Feb 2026 14:55:35 +0530 Subject: [PATCH 18/23] feat: add APIExecutor wrapper --- README.md | 52 +++++++++-- example/ApiExecutorExample/Program.cs | 71 ++++++++------- example/ApiExecutorExample/README.md | 14 +-- example/README.md | 4 +- .../Client/ApiExecutor/ApiExecutorTests.cs | 30 +++---- src/OpenFga.Sdk/ApiClient/ApiClient.cs | 18 ++++ src/OpenFga.Sdk/ApiClient/ApiExecutor.cs | 90 +++++++++++++++++++ src/OpenFga.Sdk/Client/Client.cs | 23 +++-- 8 files changed, 231 insertions(+), 71 deletions(-) create mode 100644 src/OpenFga.Sdk/ApiClient/ApiExecutor.cs diff --git a/README.md b/README.md index 56081364..6805d83e 100644 --- a/README.md +++ b/README.md @@ -978,10 +978,9 @@ For advanced use cases where you need to call API endpoints not yet available in ```csharp using OpenFga.Sdk.ApiClient; -using FgaApiClient = OpenFga.Sdk.ApiClient.ApiClient; var client = new OpenFgaClient(configuration); -var apiClient = client.GetApiClient(); +var executor = client.ApiExecutor; // Build a request using RequestBuilder var request = new RequestBuilder { @@ -993,7 +992,14 @@ var request = new RequestBuilder { }; // Execute and get full response details -var response = await apiClient.ExecuteAsync(request, "GetStore"); +var response = await executor.ExecuteAsync(request, "GetStore"); + +// Always check if the request was successful +if (!response.IsSuccessful) { + Console.WriteLine($"Request failed: {response.StatusCode}"); + Console.WriteLine($"Error: {response.RawResponse}"); + return; +} // Access response details Console.WriteLine($"Status: {response.StatusCode}"); @@ -1013,7 +1019,7 @@ var request = RequestBuilder .WithQueryParameter("consistency", "HIGHER_CONSISTENCY") .WithBody(checkRequest); -var response = await apiClient.ExecuteAsync(request, "Check"); +var response = await executor.ExecuteAsync(request, "Check"); ``` #### Custom Headers @@ -1026,14 +1032,48 @@ var options = new ClientRequestOptions { } }; -var response = await apiClient.ExecuteAsync( +var response = await executor.ExecuteAsync( request, "CustomEndpoint", options ); ``` -For a complete example with all features, see the [Custom API Requests Example](./example/ApiExecutorExample/). +#### Error Handling + +Always check `response.IsSuccessful` and handle different status codes appropriately: + +```csharp +var response = await executor.ExecuteAsync(request, "GetStore"); + +if (!response.IsSuccessful) +{ + switch ((int)response.StatusCode) + { + case 404: + Console.WriteLine("Store not found"); + break; + case 401: + Console.WriteLine("Unauthorized - check your credentials"); + break; + case 429: + Console.WriteLine("Rate limited - retry after delay"); + break; + case >= 500: + Console.WriteLine($"Server error: {response.RawResponse}"); + break; + default: + Console.WriteLine($"Request failed: {response.StatusCode}"); + break; + } + return; +} + +// Safe to use response.Data here +Console.WriteLine($"Store Name: {response.Data.Name}"); +``` + +For a complete example with all features, see the [ApiExecutor Example](./example/ApiExecutorExample/). ### Retries diff --git a/example/ApiExecutorExample/Program.cs b/example/ApiExecutorExample/Program.cs index f9e7f867..109b5e79 100644 --- a/example/ApiExecutorExample/Program.cs +++ b/example/ApiExecutorExample/Program.cs @@ -4,12 +4,11 @@ using OpenFga.Sdk.Configuration; using OpenFga.Sdk.Model; using System.Net.Http; -using FgaApiClient = OpenFga.Sdk.ApiClient.ApiClient; namespace ApiExecutorExample; /// -/// This example demonstrates how to use ApiClient.ExecuteAsync to make custom HTTP requests +/// This example demonstrates how to use ApiExecutor to make custom HTTP requests /// to the OpenFGA API with full response details (status code, headers, raw response, typed data). /// /// Prerequisites: Run an OpenFGA server on localhost:8080 @@ -25,41 +24,41 @@ static async Task Main(string[] args) { }; using var client = new OpenFgaClient(config); - var apiClient = client.GetApiClient(); // Get the ApiClient for custom requests + var executor = client.ApiExecutor; // Get the ApiExecutor for custom requests try { // Example 1: List stores using raw GET request - await ListStoresExample(apiClient, config.ApiUrl); + await ListStoresExample(executor, config.ApiUrl); // Example 2: Create a store using raw POST request with typed response - var storeId = await CreateStoreExample(apiClient, config.ApiUrl); + var storeId = await CreateStoreExample(executor, config.ApiUrl); // Example 3: Get store details using path parameters - await GetStoreExample(apiClient, config.ApiUrl, storeId); + await GetStoreExample(executor, config.ApiUrl, storeId); // Example 4: Create an authorization model - var modelId = await CreateAuthorizationModelExample(apiClient, config.ApiUrl, storeId); + var modelId = await CreateAuthorizationModelExample(executor, config.ApiUrl, storeId); // Example 5: Write relationship tuples - await WriteTuplesExample(apiClient, config.ApiUrl, storeId); + await WriteTuplesExample(executor, config.ApiUrl, storeId); // Example 6: Read relationship tuples - await ReadTuplesExample(apiClient, config.ApiUrl, storeId); + await ReadTuplesExample(executor, config.ApiUrl, storeId); // Example 7: Check permissions - await CheckPermissionExample(apiClient, config.ApiUrl, storeId, modelId); + await CheckPermissionExample(executor, config.ApiUrl, storeId, modelId); // Example 8: Use raw JSON response instead of typed - await RawJsonResponseExample(apiClient, config.ApiUrl); + await RawJsonResponseExample(executor, config.ApiUrl); // Example 9: Custom headers - await CustomHeadersExample(apiClient, config.ApiUrl); + await CustomHeadersExample(executor, config.ApiUrl); // Example 10: Fluent API for building requests - await FluentApiExample(apiClient, config.ApiUrl); + await FluentApiExample(executor, config.ApiUrl); // Cleanup: Delete the store we created - await DeleteStoreExample(apiClient, config.ApiUrl, storeId); + await DeleteStoreExample(executor, config.ApiUrl, storeId); Console.WriteLine("\n=== All examples completed successfully! ==="); } catch (Exception ex) { @@ -70,7 +69,7 @@ static async Task Main(string[] args) { } } - static async Task ListStoresExample(FgaApiClient apiClient, string basePath) { + static async Task ListStoresExample(ApiExecutor executor, string basePath) { Console.WriteLine("📋 Example 1: List Stores"); Console.WriteLine("Making GET request to /stores"); @@ -82,7 +81,7 @@ static async Task ListStoresExample(FgaApiClient apiClient, string basePath) { QueryParameters = new Dictionary() }; - var response = await apiClient.ExecuteAsync(request, "ListStores"); + var response = await executor.ExecuteAsync(request, "ListStores"); Console.WriteLine($"✅ Status: {response.StatusCode}"); Console.WriteLine($" Is Successful: {response.IsSuccessful}"); @@ -90,7 +89,7 @@ static async Task ListStoresExample(FgaApiClient apiClient, string basePath) { Console.WriteLine(); } - static async Task CreateStoreExample(FgaApiClient apiClient, string basePath) { + static async Task CreateStoreExample(ApiExecutor executor, string basePath) { Console.WriteLine("🏪 Example 2: Create Store"); Console.WriteLine("Making POST request to /stores"); @@ -108,7 +107,7 @@ static async Task CreateStoreExample(FgaApiClient apiClient, string base Body = requestBody }; - var response = await apiClient.ExecuteAsync(request, "CreateStore"); + var response = await executor.ExecuteAsync(request, "CreateStore"); Console.WriteLine($"✅ Status: {response.StatusCode}"); Console.WriteLine($" Store ID: {response.Data.Id}"); @@ -119,7 +118,7 @@ static async Task CreateStoreExample(FgaApiClient apiClient, string base return response.Data.Id!; } - static async Task GetStoreExample(FgaApiClient apiClient, string basePath, string storeId) { + static async Task GetStoreExample(ApiExecutor executor, string basePath, string storeId) { Console.WriteLine("🔍 Example 3: Get Store Details"); Console.WriteLine($"Making GET request to /stores/{{store_id}}"); @@ -131,7 +130,7 @@ static async Task GetStoreExample(FgaApiClient apiClient, string basePath, strin QueryParameters = new Dictionary() }; - var response = await apiClient.ExecuteAsync(request, "GetStore"); + var response = await executor.ExecuteAsync(request, "GetStore"); Console.WriteLine($"✅ Status: {response.StatusCode}"); Console.WriteLine($" Store Name: {response.Data.Name}"); @@ -140,7 +139,7 @@ static async Task GetStoreExample(FgaApiClient apiClient, string basePath, strin Console.WriteLine(); } - static async Task CreateAuthorizationModelExample(FgaApiClient apiClient, string basePath, string storeId) { + static async Task CreateAuthorizationModelExample(ApiExecutor executor, string basePath, string storeId) { Console.WriteLine("📝 Example 4: Create Authorization Model"); Console.WriteLine("Making POST request to /stores/{store_id}/authorization-models"); @@ -208,7 +207,7 @@ static async Task CreateAuthorizationModelExample(FgaApiClient apiClient Body = requestBody }; - var response = await apiClient.ExecuteAsync(request, "WriteAuthorizationModel"); + var response = await executor.ExecuteAsync(request, "WriteAuthorizationModel"); Console.WriteLine($"✅ Status: {response.StatusCode}"); Console.WriteLine($" Model ID: {response.Data.AuthorizationModelId}"); @@ -217,7 +216,7 @@ static async Task CreateAuthorizationModelExample(FgaApiClient apiClient return response.Data.AuthorizationModelId!; } - static async Task WriteTuplesExample(FgaApiClient apiClient, string basePath, string storeId) { + static async Task WriteTuplesExample(ApiExecutor executor, string basePath, string storeId) { Console.WriteLine("✍️ Example 5: Write Relationship Tuples"); Console.WriteLine("Making POST request to /stores/{store_id}/write"); @@ -251,14 +250,14 @@ static async Task WriteTuplesExample(FgaApiClient apiClient, string basePath, st Body = requestBody }; - var response = await apiClient.ExecuteAsync(request, "Write"); + var response = await executor.ExecuteAsync(request, "Write"); Console.WriteLine($"✅ Status: {response.StatusCode}"); Console.WriteLine(" Tuples written successfully"); Console.WriteLine(); } - static async Task ReadTuplesExample(FgaApiClient apiClient, string basePath, string storeId) { + static async Task ReadTuplesExample(ApiExecutor executor, string basePath, string storeId) { Console.WriteLine("📖 Example 6: Read Relationship Tuples"); Console.WriteLine("Making POST request to /stores/{store_id}/read"); @@ -279,7 +278,7 @@ static async Task ReadTuplesExample(FgaApiClient apiClient, string basePath, str Body = requestBody }; - var response = await apiClient.ExecuteAsync(request, "Read"); + var response = await executor.ExecuteAsync(request, "Read"); Console.WriteLine($"✅ Status: {response.StatusCode}"); Console.WriteLine($" Found {response.Data.Tuples?.Count ?? 0} tuple(s):"); @@ -291,7 +290,7 @@ static async Task ReadTuplesExample(FgaApiClient apiClient, string basePath, str Console.WriteLine(); } - static async Task CheckPermissionExample(FgaApiClient apiClient, string basePath, string storeId, string modelId) { + static async Task CheckPermissionExample(ApiExecutor executor, string basePath, string storeId, string modelId) { Console.WriteLine("🔐 Example 7: Check Permission"); Console.WriteLine("Making POST request to /stores/{store_id}/check"); @@ -315,14 +314,14 @@ static async Task CheckPermissionExample(FgaApiClient apiClient, string basePath Body = requestBody }; - var response = await apiClient.ExecuteAsync(request, "Check"); + var response = await executor.ExecuteAsync(request, "Check"); Console.WriteLine($"✅ Status: {response.StatusCode}"); Console.WriteLine($" Allowed: {response.Data.Allowed}"); Console.WriteLine(); } - static async Task RawJsonResponseExample(FgaApiClient apiClient, string basePath) { + static async Task RawJsonResponseExample(ApiExecutor executor, string basePath) { Console.WriteLine("📄 Example 8: Raw JSON Response"); Console.WriteLine("Getting response as raw JSON string instead of typed object"); @@ -335,7 +334,7 @@ static async Task RawJsonResponseExample(FgaApiClient apiClient, string basePath }; // Use ExecuteAsync without second type parameter to get raw JSON string - var response = await apiClient.ExecuteAsync(request, "ListStores"); + var response = await executor.ExecuteAsync(request, "ListStores"); Console.WriteLine($"✅ Status: {response.StatusCode}"); Console.WriteLine($" Raw JSON (first 100 chars): {response.Data?.Substring(0, Math.Min(100, response.Data.Length))}..."); @@ -343,7 +342,7 @@ static async Task RawJsonResponseExample(FgaApiClient apiClient, string basePath Console.WriteLine(); } - static async Task CustomHeadersExample(FgaApiClient apiClient, string basePath) { + static async Task CustomHeadersExample(ApiExecutor executor, string basePath) { Console.WriteLine("📨 Example 9: Custom Headers"); Console.WriteLine("Making request with custom headers"); @@ -363,7 +362,7 @@ static async Task CustomHeadersExample(FgaApiClient apiClient, string basePath) } }; - var response = await apiClient.ExecuteAsync(request, "ListStores", options); + var response = await executor.ExecuteAsync(request, "ListStores", options); Console.WriteLine($"✅ Status: {response.StatusCode}"); Console.WriteLine(" Custom headers sent successfully"); @@ -371,7 +370,7 @@ static async Task CustomHeadersExample(FgaApiClient apiClient, string basePath) Console.WriteLine(); } - static async Task FluentApiExample(FgaApiClient apiClient, string basePath) { + static async Task FluentApiExample(ApiExecutor executor, string basePath) { Console.WriteLine("🎯 Example 10: Fluent API for Request Building"); Console.WriteLine("Using the enhanced RequestBuilder with fluent methods"); @@ -381,7 +380,7 @@ static async Task FluentApiExample(FgaApiClient apiClient, string basePath) { .WithQueryParameter("page_size", "10") .WithQueryParameter("continuation_token", ""); - var response = await apiClient.ExecuteAsync(request, "ListStores"); + var response = await executor.ExecuteAsync(request, "ListStores"); Console.WriteLine($"✅ Status: {response.StatusCode}"); Console.WriteLine($" Found {response.Data.Stores?.Count ?? 0} store(s) using fluent API"); @@ -389,7 +388,7 @@ static async Task FluentApiExample(FgaApiClient apiClient, string basePath) { Console.WriteLine(); } - static async Task DeleteStoreExample(FgaApiClient apiClient, string basePath, string storeId) { + static async Task DeleteStoreExample(ApiExecutor executor, string basePath, string storeId) { Console.WriteLine("🗑️ Cleanup: Delete Store"); Console.WriteLine($"Making DELETE request to /stores/{{store_id}}"); @@ -401,7 +400,7 @@ static async Task DeleteStoreExample(FgaApiClient apiClient, string basePath, st QueryParameters = new Dictionary() }; - var response = await apiClient.ExecuteAsync(request, "DeleteStore"); + var response = await executor.ExecuteAsync(request, "DeleteStore"); Console.WriteLine($"✅ Status: {response.StatusCode}"); Console.WriteLine(" Store deleted successfully"); diff --git a/example/ApiExecutorExample/README.md b/example/ApiExecutorExample/README.md index 1bc136f5..20ff0264 100644 --- a/example/ApiExecutorExample/README.md +++ b/example/ApiExecutorExample/README.md @@ -1,6 +1,6 @@ # Custom API Requests Example -This example demonstrates how to use `ApiClient.ExecuteAsync()` to make custom HTTP requests to the OpenFGA API with full response details (status code, headers, raw response, typed data). This is useful when you need more control over HTTP requests or want to call endpoints that aren't yet supported by the SDK's typed API. +This example demonstrates how to use `ApiExecutor` to make custom HTTP requests to the OpenFGA API with full response details (status code, headers, raw response, typed data). This is useful when you need more control over HTTP requests or want to call endpoints that aren't yet supported by the SDK's typed API. ## What This Example Demonstrates @@ -28,9 +28,9 @@ The SDK provides two ways to interact with the OpenFGA API: 2. **Custom API Requests** (for advanced scenarios): ```csharp - var apiClient = client.GetApiClient(); + var executor = client.ApiExecutor; var request = RequestBuilder.Create(...); - var response = await apiClient.ExecuteAsync(request, "Check"); + var response = await executor.ExecuteAsync(request, "Check"); // Now you have: response.StatusCode, response.Headers, response.RawResponse, response.Data ``` @@ -244,7 +244,7 @@ using OpenFga.Sdk.Model; using FgaApiClient = OpenFga.Sdk.ApiClient.ApiClient; var client = new OpenFgaClient(config); -var apiClient = client.GetApiClient(); +var executor = client.ApiExecutor; var request = new RequestBuilder { Method = HttpMethod.Get, @@ -254,7 +254,7 @@ var request = new RequestBuilder { QueryParameters = new Dictionary() }; -var response = await apiClient.ExecuteAsync( +var response = await executor.ExecuteAsync( request, "ListStores" ); @@ -279,7 +279,7 @@ var request = RequestBuilder tuple_key = new { user = "user:anne", relation = "reader", @object = "doc:1" } }); -var response = await apiClient.ExecuteAsync( +var response = await executor.ExecuteAsync( request, "Check", new ClientRequestOptions { @@ -293,7 +293,7 @@ var response = await apiClient.ExecuteAsync( ### Raw JSON Response ```csharp // When you want the raw JSON without deserialization -var response = await apiClient.ExecuteAsync(request, "CustomEndpoint"); +var response = await executor.ExecuteAsync(request, "CustomEndpoint"); string json = response.Data; // Raw JSON string ``` diff --git a/example/README.md b/example/README.md index f4cf043d..301151ac 100644 --- a/example/README.md +++ b/example/README.md @@ -13,8 +13,8 @@ Demonstrates how to use the StreamedListObjects API to efficiently list objects **OpenTelemetryExample:** Shows how to integrate OpenTelemetry for observability and tracing of OpenFGA SDK operations. -**Custom API Requests Example:** -Demonstrates how to use `ApiClient.ExecuteAsync()` to make custom HTTP requests to the OpenFGA API with full response details. This is useful when you need more control over requests or want to call endpoints not yet available in the SDK's typed API. Includes a Makefile for easy execution with a local OpenFGA server. +**ApiExecutor Example:** +Demonstrates how to use the `ApiExecutor` to make custom HTTP requests to the OpenFGA API with full response details. This is useful when you need more control over requests or want to call endpoints not yet available in the SDK's typed API. Includes a Makefile for easy execution with a local OpenFGA server. ### Running the Examples diff --git a/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorTests.cs b/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorTests.cs index 31cc324e..0bcad9e1 100644 --- a/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorTests.cs +++ b/src/OpenFga.Sdk.Test/Client/ApiExecutor/ApiExecutorTests.cs @@ -75,7 +75,7 @@ public async Task ExecuteAsync_ValidGetRequest_ReturnsSuccessResponse() { }; // Act - var response = await client.GetApiClient().ExecuteAsync(requestBuilder, "GetStore"); + var response = await client.ApiExecutor.ExecuteAsync(requestBuilder, "GetStore"); // Assert Assert.NotNull(response); @@ -113,7 +113,7 @@ public async Task ExecuteAsync_ValidPostRequest_ReturnsSuccessResponse() { }; // Act - var response = await client.GetApiClient().ExecuteAsync(requestBuilder, "Check"); + var response = await client.ApiExecutor.ExecuteAsync(requestBuilder, "Check"); // Assert Assert.NotNull(response); @@ -142,7 +142,7 @@ public async Task ExecuteAsync_WithPathParams_ReplacesInUrl() { }; // Act - await client.GetApiClient().ExecuteAsync(requestBuilder, "Check"); + await client.ApiExecutor.ExecuteAsync(requestBuilder, "Check"); // Assert mockHandler.Protected().Verify( @@ -178,7 +178,7 @@ public async Task ExecuteAsync_WithQueryParams_AppendsToUrl() { }; // Act - await client.GetApiClient().ExecuteAsync(requestBuilder, "ListStores"); + await client.ApiExecutor.ExecuteAsync(requestBuilder, "ListStores"); // Assert mockHandler.Protected().Verify( @@ -217,7 +217,7 @@ public async Task ExecuteAsync_WithCustomHeaders_IncludesInRequest() { }; // Act - await client.GetApiClient().ExecuteAsync(requestBuilder, "CreateStore", options); + await client.ApiExecutor.ExecuteAsync(requestBuilder, "CreateStore", options); // Assert mockHandler.Protected().Verify( @@ -256,7 +256,7 @@ public async Task ExecuteAsync_WithBody_SerializesToJson() { }; // Act - await client.GetApiClient().ExecuteAsync(requestBuilder, "CreateStore"); + await client.ApiExecutor.ExecuteAsync(requestBuilder, "CreateStore"); // Assert mockHandler.Protected().Verify( @@ -289,7 +289,7 @@ public async Task ExecuteAsync_RawResponse_ReturnsJsonString() { }; // Act - var response = await client.GetApiClient().ExecuteAsync(requestBuilder, "GetStore"); + var response = await client.ApiExecutor.ExecuteAsync(requestBuilder, "GetStore"); // Assert Assert.NotNull(response); @@ -325,7 +325,7 @@ public async Task ExecuteAsync_ApiError_ThrowsFgaApiError() { // Act & Assert await Assert.ThrowsAsync(async () => - await client.GetApiClient().ExecuteAsync(requestBuilder, "Check")); + await client.ApiExecutor.ExecuteAsync(requestBuilder, "Check")); } [Fact] @@ -338,8 +338,8 @@ public void GetApiClient_CalledMultipleTimes_ReturnsSameInstance() { var client = new OpenFgaClient(config); // Act - var apiClient1 = client.GetApiClient(); - var apiClient2 = client.GetApiClient(); + var apiClient1 = client.ApiExecutor; + var apiClient2 = client.ApiExecutor; // Assert Assert.Same(apiClient1, apiClient2); @@ -371,7 +371,7 @@ public async Task ExecuteAsync_TypedResponse_DeserializesCorrectly() { }; // Act - var response = await client.GetApiClient().ExecuteAsync(requestBuilder, "Check"); + var response = await client.ApiExecutor.ExecuteAsync(requestBuilder, "Check"); // Assert Assert.NotNull(response); @@ -401,7 +401,7 @@ public async Task ExecuteAsync_CancellationToken_CancelsRequest() { // Act & Assert await Assert.ThrowsAnyAsync(async () => - await client.GetApiClient().ExecuteAsync(requestBuilder, "ListStores", null, cts.Token)); + await client.ApiExecutor.ExecuteAsync(requestBuilder, "ListStores", null, cts.Token)); } [Fact] @@ -442,7 +442,7 @@ public async Task ExecuteAsync_WithCredentials_IncludesAuthorizationHeader() { }; // Act - await client.GetApiClient().ExecuteAsync(requestBuilder, "ListStores"); + await client.ApiExecutor.ExecuteAsync(requestBuilder, "ListStores"); // Assert mockHandler.Protected().Verify( @@ -478,7 +478,7 @@ public async Task ExecuteAsync_UsingFluentApi_WorksCorrectly() { .WithPathParameter("store_id", _storeId); // Act - var response = await client.GetApiClient().ExecuteAsync(requestBuilder, "GetStore"); + var response = await client.ApiExecutor.ExecuteAsync(requestBuilder, "GetStore"); // Assert Assert.NotNull(response); @@ -514,7 +514,7 @@ public async Task ExecuteAsync_FluentApiWithMultipleParams_WorksCorrectly() { .WithBody(requestBody); // Act - var response = await client.GetApiClient().ExecuteAsync(requestBuilder, "Check"); + var response = await client.ApiExecutor.ExecuteAsync(requestBuilder, "Check"); // Assert Assert.NotNull(response); diff --git a/src/OpenFga.Sdk/ApiClient/ApiClient.cs b/src/OpenFga.Sdk/ApiClient/ApiClient.cs index 4537d238..e93ede1a 100644 --- a/src/OpenFga.Sdk/ApiClient/ApiClient.cs +++ b/src/OpenFga.Sdk/ApiClient/ApiClient.cs @@ -22,6 +22,7 @@ public class ApiClient : IDisposable { private readonly OAuth2Client? _oauth2Client; private readonly Metrics metrics; private readonly RetryHandler _retryHandler; + private readonly Lazy _apiExecutor; /// /// Initializes a new instance of the class. @@ -34,6 +35,7 @@ public ApiClient(Configuration.Configuration configuration, HttpClient? userHttp metrics = new Metrics(_configuration); _baseClient = new BaseClient(configuration, userHttpClient, metrics); _retryHandler = new RetryHandler(new RetryParams { MaxRetry = _configuration.MaxRetry, MinWaitInMs = _configuration.MinWaitInMs }); + _apiExecutor = new Lazy(() => new ApiExecutor(this)); if (_configuration.Credentials == null) { return; @@ -55,6 +57,22 @@ public ApiClient(Configuration.Configuration configuration, HttpClient? userHttp } } + /// + /// Gets the ApiExecutor for making custom API requests. + /// Use this when you need to call OpenFGA API endpoints not yet available in the SDK's typed methods, + /// or when you need access to full response details (status code, headers, raw response). + /// + /// + /// + /// var executor = apiClient.ApiExecutor; + /// var request = RequestBuilder<object> + /// .Create(HttpMethod.Get, config.ApiUrl, "/stores/{store_id}") + /// .WithPathParameter("store_id", storeId); + /// var response = await executor.ExecuteAsync<object, GetStoreResponse>(request, "GetStore"); + /// + /// + public ApiExecutor ApiExecutor => _apiExecutor.Value; + /// /// Gets the authentication token based on the configured credentials method. /// For OAuth (ClientCredentials), fetches token from OAuth2Client. diff --git a/src/OpenFga.Sdk/ApiClient/ApiExecutor.cs b/src/OpenFga.Sdk/ApiClient/ApiExecutor.cs new file mode 100644 index 00000000..bd6bd2b5 --- /dev/null +++ b/src/OpenFga.Sdk/ApiClient/ApiExecutor.cs @@ -0,0 +1,90 @@ +using System.Threading; +using System.Threading.Tasks; +using OpenFga.Sdk.Client.Model; +using OpenFga.Sdk.Model; + +namespace OpenFga.Sdk.ApiClient; + +/// +/// Provides methods to execute custom API requests against the OpenFGA API. +/// Use this when you need to call endpoints not yet available in the SDK's typed methods, +/// or when you need access to full response details (status code, headers, raw response). +/// +public class ApiExecutor { + private readonly ApiClient _apiClient; + + internal ApiExecutor(ApiClient apiClient) { + _apiClient = apiClient; + } + + /// + /// Executes an API request using RequestBuilder and returns an ApiResponse with full response details. + /// This provides a lower-level API for custom requests while leveraging authentication, retry logic, and error handling. + /// + /// The type of the request body + /// The type of the response body. Must be a type that can be deserialized from JSON. + /// The request builder containing request details (path, parameters, body, etc.) + /// The API name for telemetry and error reporting + /// Optional request options including custom headers + /// Cancellation token + /// An ApiResponse containing status code, headers, raw response, and typed data + /// Thrown when authentication fails + /// Thrown when the API returns an error response + /// + /// + /// var executor = client.ApiExecutor; + /// var request = RequestBuilder<object> + /// .Create(HttpMethod.Get, config.ApiUrl, "/stores/{store_id}") + /// .WithPathParameter("store_id", storeId); + /// var response = await executor.ExecuteAsync<object, GetStoreResponse>(request, "GetStore"); + /// if (response.IsSuccessful) { + /// Console.WriteLine($"Store: {response.Data.Name}"); + /// } + /// + /// + public async Task> ExecuteAsync( + RequestBuilder requestBuilder, + string apiName, + IRequestOptions? options = null, + CancellationToken cancellationToken = default) { + return await _apiClient.ExecuteAsync( + requestBuilder, + apiName, + options, + cancellationToken); + } + + /// + /// Executes an API request using RequestBuilder and returns an ApiResponse with raw JSON string. + /// This variant is useful when you want to process the JSON response manually without deserialization. + /// + /// The type of the request body + /// The request builder containing request details + /// The API name for telemetry and error reporting + /// Optional request options including custom headers + /// Cancellation token + /// An ApiResponse with the raw JSON response as the Data property + /// Thrown when authentication fails + /// Thrown when the API returns an error response + /// + /// + /// var executor = client.ApiExecutor; + /// var request = new RequestBuilder<object> { /* ... */ }; + /// var response = await executor.ExecuteAsync(request, "CustomEndpoint"); + /// string rawJson = response.Data; // Raw JSON string + /// + /// + public async Task> ExecuteAsync( + RequestBuilder requestBuilder, + string apiName, + IRequestOptions? options = null, + CancellationToken cancellationToken = default) { + return await _apiClient.ExecuteAsync( + requestBuilder, + apiName, + options, + cancellationToken); + } +} + + diff --git a/src/OpenFga.Sdk/Client/Client.cs b/src/OpenFga.Sdk/Client/Client.cs index 4df919c9..40796671 100644 --- a/src/OpenFga.Sdk/Client/Client.cs +++ b/src/OpenFga.Sdk/Client/Client.cs @@ -45,13 +45,26 @@ public string? AuthorizationModelId { } /// - /// Gets the underlying ApiClient for making custom API requests. - /// The ApiClient allows you to call arbitrary OpenFGA API endpoints using RequestBuilder - /// while automatically leveraging the SDK's authentication, retry logic, and error handling. - /// Use ApiClient.ExecuteAsync() methods for custom requests that return full response details. + /// Gets the ApiExecutor for making custom API requests. + /// Use this when you need to call OpenFGA API endpoints not yet available in the SDK's typed methods, + /// or when you need access to full response details (status code, headers, raw response). + /// + /// + /// + /// var executor = client.ApiExecutor; + /// var request = RequestBuilder<object> + /// .Create(HttpMethod.Get, config.ApiUrl, "/stores/{store_id}") + /// .WithPathParameter("store_id", storeId); + /// var response = await executor.ExecuteAsync<object, GetStoreResponse>(request, "GetStore"); + /// + /// + public ApiClient.ApiExecutor ApiExecutor => api.ApiClientInternal.ApiExecutor; + + /// + /// Gets the underlying ApiClient (internal use). /// /// The ApiClient instance used by this client - public ApiClient.ApiClient GetApiClient() { + internal ApiClient.ApiClient GetApiClient() { return api.ApiClientInternal; } From 51c8bd7e496f00c3b30fc49cf43bcde2e12768d4 Mon Sep 17 00:00:00 2001 From: SoulPancake Date: Wed, 18 Feb 2026 15:08:55 +0530 Subject: [PATCH 19/23] fix: dedupe sendReqAsyncInternal --- src/OpenFga.Sdk/ApiClient/ApiClient.cs | 41 +++++++------------------- 1 file changed, 10 insertions(+), 31 deletions(-) diff --git a/src/OpenFga.Sdk/ApiClient/ApiClient.cs b/src/OpenFga.Sdk/ApiClient/ApiClient.cs index e93ede1a..287bb9db 100644 --- a/src/OpenFga.Sdk/ApiClient/ApiClient.cs +++ b/src/OpenFga.Sdk/ApiClient/ApiClient.cs @@ -113,19 +113,8 @@ public ApiClient(Configuration.Configuration configuration, HttpClient? userHttp public async Task SendRequestAsync(RequestBuilder requestBuilder, string apiName, IRequestOptions? options = null, CancellationToken cancellationToken = default) { - var sw = Stopwatch.StartNew(); - - var authToken = await GetAuthenticationTokenAsync(apiName); - var additionalHeaders = BuildHeaders(_configuration, authToken, options); - - var response = await Retry(async (attemptCount) => - await _baseClient.SendRequestAsync(requestBuilder, additionalHeaders, apiName, - attemptCount, cancellationToken)); - - sw.Stop(); - metrics.BuildForResponse(apiName, response.rawResponse, requestBuilder, sw, - response.retryCount); - + var response = await SendRequestInternalAsync( + requestBuilder, apiName, options, cancellationToken); return response.responseContent; } @@ -141,18 +130,8 @@ await _baseClient.SendRequestAsync(requestBuilder, additionalHeaders public async Task SendRequestAsync(RequestBuilder requestBuilder, string apiName, IRequestOptions? options = null, CancellationToken cancellationToken = default) { - var sw = Stopwatch.StartNew(); - - var authToken = await GetAuthenticationTokenAsync(apiName); - var additionalHeaders = BuildHeaders(_configuration, authToken, options); - - var response = await Retry(async (attemptCount) => - await _baseClient.SendRequestAsync(requestBuilder, additionalHeaders, apiName, - attemptCount, cancellationToken)); - - sw.Stop(); - metrics.BuildForResponse(apiName, response.rawResponse, requestBuilder, sw, - response.retryCount); + await SendRequestInternalAsync( + requestBuilder, apiName, options, cancellationToken); } /// @@ -286,7 +265,7 @@ private void PopulateRetryMetadata(FgaApiError error, int attemptCount) { /// /// Executes an API request using RequestBuilder and returns an ApiResponse with full response details. - /// This provides a lower-level API for custom requests while leveraging authentication, retry logic, and error handling. + /// This builds on top of SendRequestAsync by wrapping the response with additional metadata. /// /// The type of the request body /// The type of the response body @@ -303,7 +282,7 @@ public async Task> ExecuteAsync( IRequestOptions? options = null, CancellationToken cancellationToken = default) { - var responseWrapper = await ExecuteRequestWithWrapperAsync( + var responseWrapper = await SendRequestInternalAsync( requestBuilder, apiName, options, cancellationToken); var rawResponse = await responseWrapper.rawResponse.Content.ReadAsStringAsync().ConfigureAwait(false); @@ -333,7 +312,7 @@ public async Task> ExecuteAsync( CancellationToken cancellationToken = default) { // Use object as intermediate type to avoid strong typing - var responseWrapper = await ExecuteRequestWithWrapperAsync( + var responseWrapper = await SendRequestInternalAsync( requestBuilder, apiName, options, cancellationToken); var rawResponse = await responseWrapper.rawResponse.Content.ReadAsStringAsync().ConfigureAwait(false); @@ -345,10 +324,10 @@ public async Task> ExecuteAsync( } /// - /// Private helper method that executes a request and returns the ResponseWrapper. - /// This consolidates common logic used by both ExecuteAsync overloads. + /// Core private method that handles authentication, retry logic, and metrics. + /// Both SendRequestAsync and ExecuteAsync build on top of this shared implementation. /// - private async Task> ExecuteRequestWithWrapperAsync( + private async Task> SendRequestInternalAsync( RequestBuilder requestBuilder, string apiName, IRequestOptions? options, From 19bbc21bfd219f6d8647d7a2f31ba5193c5b82a5 Mon Sep 17 00:00:00 2001 From: SoulPancake Date: Wed, 18 Feb 2026 15:13:47 +0530 Subject: [PATCH 20/23] fix: make fmt --- src/OpenFga.Sdk/ApiClient/ApiExecutor.cs | 10 ++++------ src/OpenFga.Sdk/Client/Client.cs | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/OpenFga.Sdk/ApiClient/ApiExecutor.cs b/src/OpenFga.Sdk/ApiClient/ApiExecutor.cs index bd6bd2b5..73f286ae 100644 --- a/src/OpenFga.Sdk/ApiClient/ApiExecutor.cs +++ b/src/OpenFga.Sdk/ApiClient/ApiExecutor.cs @@ -1,7 +1,7 @@ -using System.Threading; -using System.Threading.Tasks; using OpenFga.Sdk.Client.Model; using OpenFga.Sdk.Model; +using System.Threading; +using System.Threading.Tasks; namespace OpenFga.Sdk.ApiClient; @@ -79,12 +79,10 @@ public async Task> ExecuteAsync( string apiName, IRequestOptions? options = null, CancellationToken cancellationToken = default) { - return await _apiClient.ExecuteAsync( + return await _apiClient.ExecuteAsync( requestBuilder, apiName, options, cancellationToken); } -} - - +} \ No newline at end of file diff --git a/src/OpenFga.Sdk/Client/Client.cs b/src/OpenFga.Sdk/Client/Client.cs index 40796671..731c0b5b 100644 --- a/src/OpenFga.Sdk/Client/Client.cs +++ b/src/OpenFga.Sdk/Client/Client.cs @@ -58,7 +58,7 @@ public string? AuthorizationModelId { /// var response = await executor.ExecuteAsync<object, GetStoreResponse>(request, "GetStore"); /// /// - public ApiClient.ApiExecutor ApiExecutor => api.ApiClientInternal.ApiExecutor; + public ApiExecutor ApiExecutor => api.ApiClientInternal.ApiExecutor; /// /// Gets the underlying ApiClient (internal use). From 6af20d08b80764ec8a7454a7cb8d9d09a0efc136 Mon Sep 17 00:00:00 2001 From: SoulPancake Date: Wed, 18 Feb 2026 17:58:41 +0530 Subject: [PATCH 21/23] feat: add changelog, remove testcontainers --- CHANGELOG.md | 2 +- src/OpenFga.Sdk.Test/OpenFga.Sdk.Test.csproj | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ea2626f..a2dc2a0d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ ## [Unreleased](https://github.com/openfga/dotnet-sdk/compare/v0.9.1...HEAD) ### Added -- feat: add ApiExecutor for raw requests +- feat: add ApiExecutor for raw requests (#176) - feat: add `FromJson()` methods to `ClientWriteAuthorizationModelRequest` and `ClientCreateStoreRequest` to enable loading from JSON string (#180) - feat: report a per call HTTP metric (#173) diff --git a/src/OpenFga.Sdk.Test/OpenFga.Sdk.Test.csproj b/src/OpenFga.Sdk.Test/OpenFga.Sdk.Test.csproj index c0ed438c..ed80cdcc 100644 --- a/src/OpenFga.Sdk.Test/OpenFga.Sdk.Test.csproj +++ b/src/OpenFga.Sdk.Test/OpenFga.Sdk.Test.csproj @@ -61,7 +61,6 @@ all runtime; build; native; contentfiles; analyzers - all From 644f4a3188c48251c257f6417e92a3492e27d268 Mon Sep 17 00:00:00 2001 From: Anurag Bandyopadhyay Date: Mon, 23 Feb 2026 20:51:51 +0530 Subject: [PATCH 22/23] feat: use APIExecutor for openfgaapi --- CHANGELOG.md | 15 +++++ .../ApiClient/ApiClientTests.cs | 8 +-- src/OpenFga.Sdk/Api/OpenFgaApi.cs | 64 +++++++++---------- src/OpenFga.Sdk/ApiClient/ApiClient.cs | 38 +---------- 4 files changed, 52 insertions(+), 73 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a2dc2a0d..844d07e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,21 @@ - feat: add `FromJson()` methods to `ClientWriteAuthorizationModelRequest` and `ClientCreateStoreRequest` to enable loading from JSON string (#180) - feat: report a per call HTTP metric (#173) +### Breaking Changes + +> [!WARNING] +> - **`ApiClient.SendRequestAsync` removed**: If you were calling `SendRequestAsync` directly on `ApiClient`, switch to `ApiExecutor.ExecuteAsync`: +> +> Before: +> ```csharp +> var result = await apiClient.SendRequestAsync(requestBuilder, "ApiName"); +> ``` +> +> After: +> ```csharp +> var result = (await apiClient.ApiExecutor.ExecuteAsync(requestBuilder, "ApiName")).Data; +> ``` + ## v0.9.1 ### [0.9.1](https://github.com/openfga/dotnet-sdk/compare/v0.9.0...v0.9.1) (2026-01-26) diff --git a/src/OpenFga.Sdk.Test/ApiClient/ApiClientTests.cs b/src/OpenFga.Sdk.Test/ApiClient/ApiClientTests.cs index 9ed1e3f7..9813111a 100644 --- a/src/OpenFga.Sdk.Test/ApiClient/ApiClientTests.cs +++ b/src/OpenFga.Sdk.Test/ApiClient/ApiClientTests.cs @@ -156,7 +156,7 @@ public async Task ApiClient_WithApiToken_SendsAuthorizationHeader() { Body = null }; - await apiClient.SendRequestAsync( + await apiClient.ApiExecutor.ExecuteAsync( requestBuilder, "ReadAuthorizationModels" ); @@ -237,7 +237,7 @@ public async Task ApiClient_WithOAuth_SendsAuthorizationHeader() { Body = null }; - await apiClient.SendRequestAsync( + await apiClient.ApiExecutor.ExecuteAsync( requestBuilder, "ReadAuthorizationModels" ); @@ -285,7 +285,7 @@ public async Task ApiClient_WithNoCredentials_SendsNoAuthorizationHeader() { Body = null }; - await apiClient.SendRequestAsync( + await apiClient.ApiExecutor.ExecuteAsync( requestBuilder, "ReadAuthorizationModels" ); @@ -365,7 +365,7 @@ public async Task ApiClient_WithApiToken_CustomHeadersInOptions() { } }; - await apiClient.SendRequestAsync( + await apiClient.ApiExecutor.ExecuteAsync( requestBuilder, "ReadAuthorizationModels", options diff --git a/src/OpenFga.Sdk/Api/OpenFgaApi.cs b/src/OpenFga.Sdk/Api/OpenFgaApi.cs index 456991ec..470f4cb2 100644 --- a/src/OpenFga.Sdk/Api/OpenFgaApi.cs +++ b/src/OpenFga.Sdk/Api/OpenFgaApi.cs @@ -75,8 +75,8 @@ public async Task BatchCheck(string storeId, BatchCheckReque QueryParameters = queryParams, }; - return await _apiClient.SendRequestAsync(requestBuilder, - "BatchCheck", options, cancellationToken); + return (await _apiClient.ApiExecutor.ExecuteAsync(requestBuilder, + "BatchCheck", options, cancellationToken)).Data!; } /// @@ -108,8 +108,8 @@ public async Task Check(string storeId, CheckRequest body, IReque QueryParameters = queryParams, }; - return await _apiClient.SendRequestAsync(requestBuilder, - "Check", options, cancellationToken); + return (await _apiClient.ApiExecutor.ExecuteAsync(requestBuilder, + "Check", options, cancellationToken)).Data!; } /// @@ -134,8 +134,8 @@ public async Task CreateStore(CreateStoreRequest body, IReq QueryParameters = queryParams, }; - return await _apiClient.SendRequestAsync(requestBuilder, - "CreateStore", options, cancellationToken); + return (await _apiClient.ApiExecutor.ExecuteAsync(requestBuilder, + "CreateStore", options, cancellationToken)).Data!; } /// @@ -165,7 +165,7 @@ public async Task DeleteStore(string storeId, IRequestOptions? options = null, C QueryParameters = queryParams, }; - await _apiClient.SendRequestAsync(requestBuilder, + await _apiClient.ApiExecutor.ExecuteAsync(requestBuilder, "DeleteStore", options, cancellationToken); } @@ -198,8 +198,8 @@ public async Task Expand(string storeId, ExpandRequest body, IRe QueryParameters = queryParams, }; - return await _apiClient.SendRequestAsync(requestBuilder, - "Expand", options, cancellationToken); + return (await _apiClient.ApiExecutor.ExecuteAsync(requestBuilder, + "Expand", options, cancellationToken)).Data!; } /// @@ -229,8 +229,8 @@ public async Task GetStore(string storeId, IRequestOptions? op QueryParameters = queryParams, }; - return await _apiClient.SendRequestAsync(requestBuilder, - "GetStore", options, cancellationToken); + return (await _apiClient.ApiExecutor.ExecuteAsync(requestBuilder, + "GetStore", options, cancellationToken)).Data!; } /// @@ -262,8 +262,8 @@ public async Task ListObjects(string storeId, ListObjectsRe QueryParameters = queryParams, }; - return await _apiClient.SendRequestAsync(requestBuilder, - "ListObjects", options, cancellationToken); + return (await _apiClient.ApiExecutor.ExecuteAsync(requestBuilder, + "ListObjects", options, cancellationToken)).Data!; } /// @@ -298,8 +298,8 @@ public async Task ListObjects(string storeId, ListObjectsRe QueryParameters = queryParams, }; - return await _apiClient.SendRequestAsync(requestBuilder, - "ListStores", options, cancellationToken); + return (await _apiClient.ApiExecutor.ExecuteAsync(requestBuilder, + "ListStores", options, cancellationToken)).Data!; } /// @@ -331,8 +331,8 @@ public async Task ListUsers(string storeId, ListUsersRequest QueryParameters = queryParams, }; - return await _apiClient.SendRequestAsync(requestBuilder, - "ListUsers", options, cancellationToken); + return (await _apiClient.ApiExecutor.ExecuteAsync(requestBuilder, + "ListUsers", options, cancellationToken)).Data!; } /// @@ -364,8 +364,8 @@ public async Task Read(string storeId, ReadRequest body, IRequestO QueryParameters = queryParams, }; - return await _apiClient.SendRequestAsync(requestBuilder, - "Read", options, cancellationToken); + return (await _apiClient.ApiExecutor.ExecuteAsync(requestBuilder, + "Read", options, cancellationToken)).Data!; } /// @@ -399,8 +399,8 @@ public async Task ReadAssertions(string storeId, string QueryParameters = queryParams, }; - return await _apiClient.SendRequestAsync(requestBuilder, - "ReadAssertions", options, cancellationToken); + return (await _apiClient.ApiExecutor.ExecuteAsync(requestBuilder, + "ReadAssertions", options, cancellationToken)).Data!; } /// @@ -434,8 +434,8 @@ public async Task ReadAuthorizationModel(string QueryParameters = queryParams, }; - return await _apiClient.SendRequestAsync(requestBuilder, - "ReadAuthorizationModel", options, cancellationToken); + return (await _apiClient.ApiExecutor.ExecuteAsync(requestBuilder, + "ReadAuthorizationModel", options, cancellationToken)).Data!; } /// @@ -473,8 +473,8 @@ public async Task ReadAuthorizationModel(string QueryParameters = queryParams, }; - return await _apiClient.SendRequestAsync(requestBuilder, - "ReadAuthorizationModels", options, cancellationToken); + return (await _apiClient.ApiExecutor.ExecuteAsync(requestBuilder, + "ReadAuthorizationModels", options, cancellationToken)).Data!; } /// @@ -521,8 +521,8 @@ public async Task ReadAuthorizationModel(string QueryParameters = queryParams, }; - return await _apiClient.SendRequestAsync(requestBuilder, - "ReadChanges", options, cancellationToken); + return (await _apiClient.ApiExecutor.ExecuteAsync(requestBuilder, + "ReadChanges", options, cancellationToken)).Data!; } /// @@ -589,8 +589,8 @@ public async Task Write(string storeId, WriteRequest body, IRequestOptio QueryParameters = queryParams, }; - return await _apiClient.SendRequestAsync(requestBuilder, - "Write", options, cancellationToken); + return (await _apiClient.ApiExecutor.ExecuteAsync(requestBuilder, + "Write", options, cancellationToken)).Data!; } /// @@ -626,7 +626,7 @@ public async Task WriteAssertions(string storeId, string authorizationModelId, W QueryParameters = queryParams, }; - await _apiClient.SendRequestAsync(requestBuilder, + await _apiClient.ApiExecutor.ExecuteAsync(requestBuilder, "WriteAssertions", options, cancellationToken); } @@ -659,8 +659,8 @@ public async Task WriteAuthorizationModel(strin QueryParameters = queryParams, }; - return await _apiClient.SendRequestAsync(requestBuilder, - "WriteAuthorizationModel", options, cancellationToken); + return (await _apiClient.ApiExecutor.ExecuteAsync(requestBuilder, + "WriteAuthorizationModel", options, cancellationToken)).Data!; } diff --git a/src/OpenFga.Sdk/ApiClient/ApiClient.cs b/src/OpenFga.Sdk/ApiClient/ApiClient.cs index 287bb9db..5b7d9956 100644 --- a/src/OpenFga.Sdk/ApiClient/ApiClient.cs +++ b/src/OpenFga.Sdk/ApiClient/ApiClient.cs @@ -98,41 +98,6 @@ public ApiClient(Configuration.Configuration configuration, HttpClient? userHttp return null; } - /// - /// Handles getting the access token, calling the API, and potentially retrying - /// Based on: - /// https://github.com/auth0/auth0.net/blob/595ae80ccad8aa7764b80d26d2ef12f8b35bbeff/src/Auth0.ManagementApi/HttpClientManagementConnection.cs#L67 - /// - /// - /// - /// Request options. - /// - /// Response Type - /// - /// - public async Task SendRequestAsync(RequestBuilder requestBuilder, string apiName, - IRequestOptions? options = null, - CancellationToken cancellationToken = default) { - var response = await SendRequestInternalAsync( - requestBuilder, apiName, options, cancellationToken); - return response.responseContent; - } - - /// - /// Handles getting the access token, calling the API, and potentially retrying (use for requests that return no - /// content) - /// - /// - /// - /// Request options. - /// - /// - public async Task SendRequestAsync(RequestBuilder requestBuilder, string apiName, - IRequestOptions? options = null, - CancellationToken cancellationToken = default) { - await SendRequestInternalAsync( - requestBuilder, apiName, options, cancellationToken); - } /// /// Handles streaming requests that return IAsyncEnumerable. @@ -265,7 +230,6 @@ private void PopulateRetryMetadata(FgaApiError error, int attemptCount) { /// /// Executes an API request using RequestBuilder and returns an ApiResponse with full response details. - /// This builds on top of SendRequestAsync by wrapping the response with additional metadata. /// /// The type of the request body /// The type of the response body @@ -325,7 +289,7 @@ public async Task> ExecuteAsync( /// /// Core private method that handles authentication, retry logic, and metrics. - /// Both SendRequestAsync and ExecuteAsync build on top of this shared implementation. + /// ExecuteAsync builds on top of this shared implementation. /// private async Task> SendRequestInternalAsync( RequestBuilder requestBuilder, From 8d8f8e927d5e2cc6a24d6379a639017f1b676680 Mon Sep 17 00:00:00 2001 From: Anurag Bandyopadhyay Date: Mon, 23 Feb 2026 21:00:39 +0530 Subject: [PATCH 23/23] fix: add nullcheck --- src/OpenFga.Sdk/ApiClient/ApiClient.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/OpenFga.Sdk/ApiClient/ApiClient.cs b/src/OpenFga.Sdk/ApiClient/ApiClient.cs index 5b7d9956..65cc7d77 100644 --- a/src/OpenFga.Sdk/ApiClient/ApiClient.cs +++ b/src/OpenFga.Sdk/ApiClient/ApiClient.cs @@ -249,7 +249,9 @@ public async Task> ExecuteAsync( var responseWrapper = await SendRequestInternalAsync( requestBuilder, apiName, options, cancellationToken); - var rawResponse = await responseWrapper.rawResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + var rawResponse = responseWrapper.rawResponse.Content != null + ? await responseWrapper.rawResponse.Content.ReadAsStringAsync().ConfigureAwait(false) + : string.Empty; return ApiResponse.FromHttpResponse( responseWrapper.rawResponse, @@ -279,7 +281,9 @@ public async Task> ExecuteAsync( var responseWrapper = await SendRequestInternalAsync( requestBuilder, apiName, options, cancellationToken); - var rawResponse = await responseWrapper.rawResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + var rawResponse = responseWrapper.rawResponse.Content != null + ? await responseWrapper.rawResponse.Content.ReadAsStringAsync().ConfigureAwait(false) + : string.Empty; return ApiResponse.FromHttpResponse( responseWrapper.rawResponse,