From e8ebc7e04be30b62ed454e89b0979527dfb19fe0 Mon Sep 17 00:00:00 2001 From: tae0y Date: Sat, 24 Aug 2024 13:32:32 +0900 Subject: [PATCH 1/5] add admin event list endpoint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - admin 글로벌 태그 추가 - endpointurl 추가 및 request/response 정의 - 테스트 수행 (swagger-cli, doenet-tests/*) --- .../Endpoints/AdminEndpointUrls.cs | 22 ++-- .../Endpoints/AdminEventEndpoints.cs | 119 +++++++++++------- .../Filters/OpenApiTagFilter.cs | 43 +++---- src/AzureOpenAIProxy.ApiApp/Program.cs | 91 +++++++------- .../AdminGetEventListOpenApiTests.cs | 14 +++ 5 files changed, 172 insertions(+), 117 deletions(-) create mode 100644 test/AzureOpenAIProxy.AppHost.Tests/ApiApp/Endpoints/AdminGetEventListOpenApiTests.cs diff --git a/src/AzureOpenAIProxy.ApiApp/Endpoints/AdminEndpointUrls.cs b/src/AzureOpenAIProxy.ApiApp/Endpoints/AdminEndpointUrls.cs index 3fdb5d0c..f026e8ff 100644 --- a/src/AzureOpenAIProxy.ApiApp/Endpoints/AdminEndpointUrls.cs +++ b/src/AzureOpenAIProxy.ApiApp/Endpoints/AdminEndpointUrls.cs @@ -1,9 +1,15 @@ -namespace AzureOpenAIProxy.ApiApp.Endpoints; - -public static class AdminEndpointUrls -{ - /// - /// Declares the admin event details endpoint. - /// - public const string AdminEventDetails = "/admin/events/{eventId}"; +namespace AzureOpenAIProxy.ApiApp.Endpoints; + +public static class AdminEndpointUrls +{ + /// + /// Declares the admin event details endpoint. + /// + public const string AdminEventDetails = "/admin/events/{eventId}"; + + /// + /// Declares the admin event list endpoint. + /// + //TODO: [tae0y] endpoint 이름 정하기 /admin/events or /admin/eventlist + public const string AdminEventList = "/admin/eventlist"; } \ No newline at end of file diff --git a/src/AzureOpenAIProxy.ApiApp/Endpoints/AdminEventEndpoints.cs b/src/AzureOpenAIProxy.ApiApp/Endpoints/AdminEventEndpoints.cs index d64ac5f0..cd08fea1 100644 --- a/src/AzureOpenAIProxy.ApiApp/Endpoints/AdminEventEndpoints.cs +++ b/src/AzureOpenAIProxy.ApiApp/Endpoints/AdminEventEndpoints.cs @@ -1,43 +1,76 @@ -using AzureOpenAIProxy.ApiApp.Models; - -using Microsoft.AspNetCore.Mvc; - -namespace AzureOpenAIProxy.ApiApp.Endpoints; - -/// -/// This represents the endpoint entity for get event details by admin -/// -public static class AdminEventEndpoints -{ - /// - /// Adds the get event details by admin endpoint - /// - /// instance. - /// Returns instance. - public static RouteHandlerBuilder AddAdminEvents(this WebApplication app) - { - // Todo: Issue #19 https://github.com/aliencube/azure-openai-sdk-proxy/issues/19 - // Need authorization by admin - var builder = app.MapGet(AdminEndpointUrls.AdminEventDetails, ( - [FromRoute] string eventId) => - { - // Todo: Issue #208 https://github.com/aliencube/azure-openai-sdk-proxy/issues/208 - return Results.Ok(); - // Todo: Issue #208 - }) - .Produces(statusCode: StatusCodes.Status200OK, contentType: "application/json") - .Produces(statusCode: StatusCodes.Status401Unauthorized) - .Produces(statusCode: StatusCodes.Status500InternalServerError, contentType: "text/plain") - .WithTags("admin") - .WithName("GetAdminEventDetails") - .WithOpenApi(operation => - { - operation.Summary = "Gets event details from the given event ID"; - operation.Description = "This endpoint gets the event details from the given event ID."; - - return operation; - }); - - return builder; - } -} +using AzureOpenAIProxy.ApiApp.Models; + +using Microsoft.AspNetCore.Mvc; + +namespace AzureOpenAIProxy.ApiApp.Endpoints; + +/// +/// This represents the endpoint entity for get event details by admin +/// +public static class AdminEventEndpoints +{ + /// + /// Adds the get event details by admin endpoint + /// + /// instance. + /// Returns instance. + public static RouteHandlerBuilder AddAdminEvents(this WebApplication app) + { + // Todo: Issue #19 https://github.com/aliencube/azure-openai-sdk-proxy/issues/19 + // Need authorization by admin + var builder = app.MapGet(AdminEndpointUrls.AdminEventDetails, ( + [FromRoute] string eventId) => + { + // Todo: Issue #208 https://github.com/aliencube/azure-openai-sdk-proxy/issues/208 + return Results.Ok(); + // Todo: Issue #208 + }) + .Produces(statusCode: StatusCodes.Status200OK, contentType: "application/json") + .Produces(statusCode: StatusCodes.Status401Unauthorized) + .Produces(statusCode: StatusCodes.Status500InternalServerError, contentType: "text/plain") + .WithTags("admin") + .WithName("GetAdminEventDetails") + .WithOpenApi(operation => + { + operation.Summary = "Gets event details from the given event ID"; + operation.Description = "This endpoint gets the event details from the given event ID."; + + return operation; + }); + + return builder; + } + + /// + /// Adds the get event lists by admin endpoint + /// + /// instance. + /// Returns instance. + public static RouteHandlerBuilder AddAdminEventList(this WebApplication app) + { + // Todo: Issue #19 https://github.com/aliencube/azure-openai-sdk-proxy/issues/19 + // Need authorization by admin + //TODO: [tae0y] 파라미터 없이 이벤트를 전체 조회하는게 맞는가? + var builder = app.MapGet(AdminEndpointUrls.AdminEventList, () => + { + // Todo: Issue #218 https://github.com/aliencube/azure-openai-sdk-proxy/issues/218 + return Results.Ok(); + // Todo: Issue #218 + }) + //TODO: [tae0y] 이벤트 목록 조회할때는 불필요한 필드가 많은데 어떻게 처리할까? + .Produces>(statusCode: StatusCodes.Status200OK, contentType: "application/json") + .Produces(statusCode: StatusCodes.Status401Unauthorized) + .Produces(statusCode: StatusCodes.Status500InternalServerError, contentType: "text/plain") + .WithTags("admin") + .WithName("GetAdminEventList") + .WithOpenApi(operation => + { + operation.Summary = "Gets all event list"; + operation.Description = "This endpoint gets all event list"; + + return operation; + }); + + return builder; + } +} \ No newline at end of file diff --git a/src/AzureOpenAIProxy.ApiApp/Filters/OpenApiTagFilter.cs b/src/AzureOpenAIProxy.ApiApp/Filters/OpenApiTagFilter.cs index c1d6ec6a..196c87fb 100644 --- a/src/AzureOpenAIProxy.ApiApp/Filters/OpenApiTagFilter.cs +++ b/src/AzureOpenAIProxy.ApiApp/Filters/OpenApiTagFilter.cs @@ -1,21 +1,22 @@ -using Microsoft.OpenApi.Models; - -using Swashbuckle.AspNetCore.SwaggerGen; - -namespace AzureOpenAIProxy.ApiApp.Filters; - -/// -/// This represents the document filter entity for global tags. -/// -public class OpenApiTagFilter : IDocumentFilter -{ - /// - public void Apply(OpenApiDocument swaggerDoc, DocumentFilterContext context) - { - swaggerDoc.Tags = - [ - new OpenApiTag { Name = "weather", Description = "Weather forecast operations" }, - new OpenApiTag { Name = "openai", Description = "Azure OpenAI operations" }, - ]; - } -} +using Microsoft.OpenApi.Models; + +using Swashbuckle.AspNetCore.SwaggerGen; + +namespace AzureOpenAIProxy.ApiApp.Filters; + +/// +/// This represents the document filter entity for global tags. +/// +public class OpenApiTagFilter : IDocumentFilter +{ + /// + public void Apply(OpenApiDocument swaggerDoc, DocumentFilterContext context) + { + swaggerDoc.Tags = + [ + new OpenApiTag { Name = "weather", Description = "Weather forecast operations" }, + new OpenApiTag { Name = "openai", Description = "Azure OpenAI operations" }, + new OpenApiTag { Name = "admin", Description = "Admin for organizing events" } + ]; + } +} diff --git a/src/AzureOpenAIProxy.ApiApp/Program.cs b/src/AzureOpenAIProxy.ApiApp/Program.cs index 2331dc75..4335c684 100644 --- a/src/AzureOpenAIProxy.ApiApp/Program.cs +++ b/src/AzureOpenAIProxy.ApiApp/Program.cs @@ -1,45 +1,46 @@ -using AzureOpenAIProxy.ApiApp.Endpoints; -using AzureOpenAIProxy.ApiApp.Extensions; - -var builder = WebApplication.CreateBuilder(args); - -builder.AddServiceDefaults(); - -// Add KeyVault service -builder.Services.AddKeyVaultService(); - -// Add Azure OpenAI service. -builder.Services.AddOpenAIService(); - -// Add OpenAPI service -builder.Services.AddOpenApiService(); - -var app = builder.Build(); - -app.MapDefaultEndpoints(); - -// https://stackoverflow.com/questions/76962735/how-do-i-set-a-prefix-in-my-asp-net-core-7-web-api-for-all-endpoints -var basePath = "/api"; -app.UsePathBase(basePath); -app.UseRouting(); - -// Configure the HTTP request pipeline. -// Use Swagger UI -app.UseSwaggerUI(basePath); - -// Enable buffering -app.Use(async (context, next) => -{ - context.Request.EnableBuffering(); - await next.Invoke(); -}); - -app.UseHttpsRedirection(); - -app.AddWeatherForecast(); -app.AddChatCompletions(); - -// Admin Endpoints -app.AddAdminEvents(); - -await app.RunAsync(); +using AzureOpenAIProxy.ApiApp.Endpoints; +using AzureOpenAIProxy.ApiApp.Extensions; + +var builder = WebApplication.CreateBuilder(args); + +builder.AddServiceDefaults(); + +// Add KeyVault service +builder.Services.AddKeyVaultService(); + +// Add Azure OpenAI service. +builder.Services.AddOpenAIService(); + +// Add OpenAPI service +builder.Services.AddOpenApiService(); + +var app = builder.Build(); + +app.MapDefaultEndpoints(); + +// https://stackoverflow.com/questions/76962735/how-do-i-set-a-prefix-in-my-asp-net-core-7-web-api-for-all-endpoints +var basePath = "/api"; +app.UsePathBase(basePath); +app.UseRouting(); + +// Configure the HTTP request pipeline. +// Use Swagger UI +app.UseSwaggerUI(basePath); + +// Enable buffering +app.Use(async (context, next) => +{ + context.Request.EnableBuffering(); + await next.Invoke(); +}); + +app.UseHttpsRedirection(); + +app.AddWeatherForecast(); +app.AddChatCompletions(); + +// Admin Endpoints +app.AddAdminEvents(); +app.AddAdminEventList(); + +await app.RunAsync(); diff --git a/test/AzureOpenAIProxy.AppHost.Tests/ApiApp/Endpoints/AdminGetEventListOpenApiTests.cs b/test/AzureOpenAIProxy.AppHost.Tests/ApiApp/Endpoints/AdminGetEventListOpenApiTests.cs new file mode 100644 index 00000000..775fa303 --- /dev/null +++ b/test/AzureOpenAIProxy.AppHost.Tests/ApiApp/Endpoints/AdminGetEventListOpenApiTests.cs @@ -0,0 +1,14 @@ +using System.Text.Json; + +using AzureOpenAIProxy.AppHost.Tests.Fixtures; + +using FluentAssertions; + +using IdentityModel.Client; + +namespace AzureOpenAIProxy.AppHost.Tests.ApiApp.Endpoints; + +public class AdminGetEventListOpenApiTests(AspireAppHostFixture host) : IClassFixture +{ + // TODO: [tae0y] 테스트코드 작성하기 +} \ No newline at end of file From 4426e5ca326c964815db7902a4382d64b913fd87 Mon Sep 17 00:00:00 2001 From: tae0y Date: Sat, 24 Aug 2024 14:27:33 +0900 Subject: [PATCH 2/5] add tests --- .../AdminGetEventListOpenApiTests.cs | 114 ++++++++++++++++++ 1 file changed, 114 insertions(+) diff --git a/test/AzureOpenAIProxy.AppHost.Tests/ApiApp/Endpoints/AdminGetEventListOpenApiTests.cs b/test/AzureOpenAIProxy.AppHost.Tests/ApiApp/Endpoints/AdminGetEventListOpenApiTests.cs index 775fa303..6400eb22 100644 --- a/test/AzureOpenAIProxy.AppHost.Tests/ApiApp/Endpoints/AdminGetEventListOpenApiTests.cs +++ b/test/AzureOpenAIProxy.AppHost.Tests/ApiApp/Endpoints/AdminGetEventListOpenApiTests.cs @@ -11,4 +11,118 @@ namespace AzureOpenAIProxy.AppHost.Tests.ApiApp.Endpoints; public class AdminGetEventListOpenApiTests(AspireAppHostFixture host) : IClassFixture { // TODO: [tae0y] 테스트코드 작성하기 + [Fact] + public async Task Given_Resource_When_Invoked_Endpoint_Then_It_Should_Return_Path() + { + // Arrange + using var httpClient = host.App!.CreateHttpClient("apiapp"); + + // Act + var json = await httpClient.GetStringAsync("/swagger/v1.0.0/swagger.json"); + var openapi = JsonSerializer.Deserialize(json); + + // Assert + var result = openapi!.RootElement.GetProperty("paths") + .TryGetProperty("/admin/eventlist", out var property) ? property : default; + result.ValueKind.Should().Be(JsonValueKind.Object); + } + + [Fact] + public async Task Given_Resource_When_Invoked_Endpoint_Then_It_Should_Return_Verb() + { + // Arrange + using var httpClient = host.App!.CreateHttpClient("apiapp"); + + // Act + var json = await httpClient.GetStringAsync("/swagger/v1.0.0/swagger.json"); + var openapi = JsonSerializer.Deserialize(json); + + // Assert + var result = openapi!.RootElement.GetProperty("paths") + .GetProperty("/admin/eventlist") + .TryGetProperty("get", out var property) ? property : default; + result.ValueKind.Should().Be(JsonValueKind.Object); + } + + [Theory] + [InlineData("admin")] + public async Task Given_Resource_When_Invoked_Endpoint_Then_It_Should_Return_Tags(string tag) + { + // Arrange + using var httpClient = host.App!.CreateHttpClient("apiapp"); + + // Act + var json = await httpClient.GetStringAsync("/swagger/v1.0.0/swagger.json"); + var openapi = JsonSerializer.Deserialize(json); + + // Assert + var result = openapi!.RootElement.GetProperty("paths") + .GetProperty("/admin/eventlist") + .GetProperty("get") + .TryGetProperty("tags", out var property) ? property : default; + result.ValueKind.Should().Be(JsonValueKind.Array); + result.EnumerateArray().Select(p => p.GetString()).Should().Contain(tag); + } + + [Theory] + [InlineData("summary")] + [InlineData("description")] + [InlineData("operationId")] + public async Task Given_Resource_When_Invoked_Endpoint_Then_It_Should_Return_Value(string attribute) + { + // Arrange + using var httpClient = host.App!.CreateHttpClient("apiapp"); + + // Act + var json = await httpClient.GetStringAsync("/swagger/v1.0.0/swagger.json"); + var openapi = JsonSerializer.Deserialize(json); + + // Assert + var result = openapi!.RootElement.GetProperty("paths") + .GetProperty("/admin/eventlist") + .GetProperty("get") + .TryGetProperty(attribute, out var property) ? property : default; + result.ValueKind.Should().Be(JsonValueKind.String); + } + + [Theory] + [InlineData("responses")] + public async Task Given_Resource_When_Invoked_Endpoint_Then_It_Should_Return_Object(string attribute) + { + // Arrange + using var httpClient = host.App!.CreateHttpClient("apiapp"); + + // Act + var json = await httpClient.GetStringAsync("/swagger/v1.0.0/swagger.json"); + var openapi = JsonSerializer.Deserialize(json); + + // Assert + var result = openapi!.RootElement.GetProperty("paths") + .GetProperty("/admin/eventlist") + .GetProperty("get") + .TryGetProperty(attribute, out var property) ? property : default; + result.ValueKind.Should().Be(JsonValueKind.Object); + } + + [Theory] + [InlineData("200")] + [InlineData("401")] + [InlineData("500")] + public async Task Given_Resource_When_Invoked_Endpoint_Then_It_Should_Return_Response(string attribute) + { + // Arrange + using var httpClient = host.App!.CreateHttpClient("apiapp"); + + // Act + var json = await httpClient.GetStringAsync("/swagger/v1.0.0/swagger.json"); + var openapi = JsonSerializer.Deserialize(json); + + // Assert + var result = openapi!.RootElement.GetProperty("paths") + .GetProperty("/admin/eventlist") + .GetProperty("get") + .GetProperty("responses") + .TryGetProperty(attribute, out var property) ? property : default; + result.ValueKind.Should().Be(JsonValueKind.Object); + } } \ No newline at end of file From 147de61e9bec8b7de50944e4bad5e22b6dda193c Mon Sep 17 00:00:00 2001 From: tae0y Date: Sat, 24 Aug 2024 14:40:59 +0900 Subject: [PATCH 3/5] =?UTF-8?q?endpoint=20=EC=9D=B4=EB=A6=84=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Endpoints/AdminEndpointUrls.cs | 2 +- .../Endpoints/AdminEventEndpoints.cs | 6 +++--- ...enApiTests.cs => AdminGetEventsOpenApiTests.cs} | 14 +++++++------- 3 files changed, 11 insertions(+), 11 deletions(-) rename test/AzureOpenAIProxy.AppHost.Tests/ApiApp/Endpoints/{AdminGetEventListOpenApiTests.cs => AdminGetEventsOpenApiTests.cs} (93%) diff --git a/src/AzureOpenAIProxy.ApiApp/Endpoints/AdminEndpointUrls.cs b/src/AzureOpenAIProxy.ApiApp/Endpoints/AdminEndpointUrls.cs index f026e8ff..367981f4 100644 --- a/src/AzureOpenAIProxy.ApiApp/Endpoints/AdminEndpointUrls.cs +++ b/src/AzureOpenAIProxy.ApiApp/Endpoints/AdminEndpointUrls.cs @@ -11,5 +11,5 @@ public static class AdminEndpointUrls /// Declares the admin event list endpoint. /// //TODO: [tae0y] endpoint 이름 정하기 /admin/events or /admin/eventlist - public const string AdminEventList = "/admin/eventlist"; + public const string AdminEventList = "/admin/events"; } \ No newline at end of file diff --git a/src/AzureOpenAIProxy.ApiApp/Endpoints/AdminEventEndpoints.cs b/src/AzureOpenAIProxy.ApiApp/Endpoints/AdminEventEndpoints.cs index cd08fea1..0f2374d4 100644 --- a/src/AzureOpenAIProxy.ApiApp/Endpoints/AdminEventEndpoints.cs +++ b/src/AzureOpenAIProxy.ApiApp/Endpoints/AdminEventEndpoints.cs @@ -62,11 +62,11 @@ public static RouteHandlerBuilder AddAdminEventList(this WebApplication app) .Produces(statusCode: StatusCodes.Status401Unauthorized) .Produces(statusCode: StatusCodes.Status500InternalServerError, contentType: "text/plain") .WithTags("admin") - .WithName("GetAdminEventList") + .WithName("GetAdminEvents") .WithOpenApi(operation => { - operation.Summary = "Gets all event list"; - operation.Description = "This endpoint gets all event list"; + operation.Summary = "Gets all events"; + operation.Description = "This endpoint gets all events"; return operation; }); diff --git a/test/AzureOpenAIProxy.AppHost.Tests/ApiApp/Endpoints/AdminGetEventListOpenApiTests.cs b/test/AzureOpenAIProxy.AppHost.Tests/ApiApp/Endpoints/AdminGetEventsOpenApiTests.cs similarity index 93% rename from test/AzureOpenAIProxy.AppHost.Tests/ApiApp/Endpoints/AdminGetEventListOpenApiTests.cs rename to test/AzureOpenAIProxy.AppHost.Tests/ApiApp/Endpoints/AdminGetEventsOpenApiTests.cs index 6400eb22..7e9d0e72 100644 --- a/test/AzureOpenAIProxy.AppHost.Tests/ApiApp/Endpoints/AdminGetEventListOpenApiTests.cs +++ b/test/AzureOpenAIProxy.AppHost.Tests/ApiApp/Endpoints/AdminGetEventsOpenApiTests.cs @@ -8,7 +8,7 @@ namespace AzureOpenAIProxy.AppHost.Tests.ApiApp.Endpoints; -public class AdminGetEventListOpenApiTests(AspireAppHostFixture host) : IClassFixture +public class AdminGetEventsOpenApiTests(AspireAppHostFixture host) : IClassFixture { // TODO: [tae0y] 테스트코드 작성하기 [Fact] @@ -23,7 +23,7 @@ public async Task Given_Resource_When_Invoked_Endpoint_Then_It_Should_Return_Pat // Assert var result = openapi!.RootElement.GetProperty("paths") - .TryGetProperty("/admin/eventlist", out var property) ? property : default; + .TryGetProperty("/admin/events", out var property) ? property : default; result.ValueKind.Should().Be(JsonValueKind.Object); } @@ -39,7 +39,7 @@ public async Task Given_Resource_When_Invoked_Endpoint_Then_It_Should_Return_Ver // Assert var result = openapi!.RootElement.GetProperty("paths") - .GetProperty("/admin/eventlist") + .GetProperty("/admin/events") .TryGetProperty("get", out var property) ? property : default; result.ValueKind.Should().Be(JsonValueKind.Object); } @@ -57,7 +57,7 @@ public async Task Given_Resource_When_Invoked_Endpoint_Then_It_Should_Return_Tag // Assert var result = openapi!.RootElement.GetProperty("paths") - .GetProperty("/admin/eventlist") + .GetProperty("/admin/events") .GetProperty("get") .TryGetProperty("tags", out var property) ? property : default; result.ValueKind.Should().Be(JsonValueKind.Array); @@ -79,7 +79,7 @@ public async Task Given_Resource_When_Invoked_Endpoint_Then_It_Should_Return_Val // Assert var result = openapi!.RootElement.GetProperty("paths") - .GetProperty("/admin/eventlist") + .GetProperty("/admin/events") .GetProperty("get") .TryGetProperty(attribute, out var property) ? property : default; result.ValueKind.Should().Be(JsonValueKind.String); @@ -98,7 +98,7 @@ public async Task Given_Resource_When_Invoked_Endpoint_Then_It_Should_Return_Obj // Assert var result = openapi!.RootElement.GetProperty("paths") - .GetProperty("/admin/eventlist") + .GetProperty("/admin/events") .GetProperty("get") .TryGetProperty(attribute, out var property) ? property : default; result.ValueKind.Should().Be(JsonValueKind.Object); @@ -119,7 +119,7 @@ public async Task Given_Resource_When_Invoked_Endpoint_Then_It_Should_Return_Res // Assert var result = openapi!.RootElement.GetProperty("paths") - .GetProperty("/admin/eventlist") + .GetProperty("/admin/events") .GetProperty("get") .GetProperty("responses") .TryGetProperty(attribute, out var property) ? property : default; From 21405b2ebc775fced3ccb8500968caecb9146e1d Mon Sep 17 00:00:00 2001 From: tae0y Date: Sat, 24 Aug 2024 15:30:48 +0900 Subject: [PATCH 4/5] =?UTF-8?q?endpoint=20=EC=9D=B4=EB=A6=84=EB=B3=80?= =?UTF-8?q?=EA=B2=BD,=20404=20response=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/AzureOpenAIProxy.ApiApp/Endpoints/AdminEndpointUrls.cs | 7 +++++-- .../Endpoints/AdminEventEndpoints.cs | 5 ++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/AzureOpenAIProxy.ApiApp/Endpoints/AdminEndpointUrls.cs b/src/AzureOpenAIProxy.ApiApp/Endpoints/AdminEndpointUrls.cs index 367981f4..82f89d60 100644 --- a/src/AzureOpenAIProxy.ApiApp/Endpoints/AdminEndpointUrls.cs +++ b/src/AzureOpenAIProxy.ApiApp/Endpoints/AdminEndpointUrls.cs @@ -10,6 +10,9 @@ public static class AdminEndpointUrls /// /// Declares the admin event list endpoint. /// - //TODO: [tae0y] endpoint 이름 정하기 /admin/events or /admin/eventlist - public const string AdminEventList = "/admin/events"; + /// + /// - Get method for listing all events + /// - Post method for new event creation + /// + public const string AdminEvents = "/admin/events"; } \ No newline at end of file diff --git a/src/AzureOpenAIProxy.ApiApp/Endpoints/AdminEventEndpoints.cs b/src/AzureOpenAIProxy.ApiApp/Endpoints/AdminEventEndpoints.cs index 0f2374d4..7047ae64 100644 --- a/src/AzureOpenAIProxy.ApiApp/Endpoints/AdminEventEndpoints.cs +++ b/src/AzureOpenAIProxy.ApiApp/Endpoints/AdminEventEndpoints.cs @@ -50,16 +50,15 @@ public static RouteHandlerBuilder AddAdminEventList(this WebApplication app) { // Todo: Issue #19 https://github.com/aliencube/azure-openai-sdk-proxy/issues/19 // Need authorization by admin - //TODO: [tae0y] 파라미터 없이 이벤트를 전체 조회하는게 맞는가? - var builder = app.MapGet(AdminEndpointUrls.AdminEventList, () => + var builder = app.MapGet(AdminEndpointUrls.AdminEvents, () => { // Todo: Issue #218 https://github.com/aliencube/azure-openai-sdk-proxy/issues/218 return Results.Ok(); // Todo: Issue #218 }) - //TODO: [tae0y] 이벤트 목록 조회할때는 불필요한 필드가 많은데 어떻게 처리할까? .Produces>(statusCode: StatusCodes.Status200OK, contentType: "application/json") .Produces(statusCode: StatusCodes.Status401Unauthorized) + .Produces>(statusCode: StatusCodes.Status404NotFound) .Produces(statusCode: StatusCodes.Status500InternalServerError, contentType: "text/plain") .WithTags("admin") .WithName("GetAdminEvents") From 45a3578f7a6a73e0bfb37a6075d67179e0fa1e40 Mon Sep 17 00:00:00 2001 From: tae0y Date: Sat, 24 Aug 2024 16:04:41 +0900 Subject: [PATCH 5/5] =?UTF-8?q?endpoint=20response=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/AzureOpenAIProxy.ApiApp/Endpoints/AdminEventEndpoints.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/AzureOpenAIProxy.ApiApp/Endpoints/AdminEventEndpoints.cs b/src/AzureOpenAIProxy.ApiApp/Endpoints/AdminEventEndpoints.cs index 7047ae64..451f82ca 100644 --- a/src/AzureOpenAIProxy.ApiApp/Endpoints/AdminEventEndpoints.cs +++ b/src/AzureOpenAIProxy.ApiApp/Endpoints/AdminEventEndpoints.cs @@ -58,7 +58,6 @@ public static RouteHandlerBuilder AddAdminEventList(this WebApplication app) }) .Produces>(statusCode: StatusCodes.Status200OK, contentType: "application/json") .Produces(statusCode: StatusCodes.Status401Unauthorized) - .Produces>(statusCode: StatusCodes.Status404NotFound) .Produces(statusCode: StatusCodes.Status500InternalServerError, contentType: "text/plain") .WithTags("admin") .WithName("GetAdminEvents")