Skip to content

Commit b56d198

Browse files
authored
Merge branch 'aliencube:main' into feature/22-response-payload-definition
2 parents c7fc5e4 + 1988498 commit b56d198

19 files changed

+472
-49
lines changed

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<ImplicitUsings>enable</ImplicitUsings>
88
<Nullable>enable</Nullable>
99

10-
<AspireVersion>8.*</AspireVersion>
10+
<AspireVersion>8.2.0</AspireVersion>
1111
<AzureOpenAIVersion>2.*-*</AzureOpenAIVersion>
1212
<AspNetCoreVersion>8.*</AspNetCoreVersion>
1313
<MicrosoftExtensionsVersion>8.*</MicrosoftExtensionsVersion>

src/AzureOpenAIProxy.ApiApp/Endpoints/AdminEventEndpoints.cs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,4 +105,37 @@ public static RouteHandlerBuilder AddUpdateAdminEvents(this WebApplication app)
105105

106106
return builder;
107107
}
108+
109+
/// <summary>
110+
/// Adds the admin event endpoint
111+
/// </summary>
112+
/// <param name="app"><see cref="WebApplication"/> instance.</param>
113+
/// <returns>Returns <see cref="RouteHandlerBuilder"/> instance.</returns>
114+
public static RouteHandlerBuilder CreateAdminEvent(this WebApplication app)
115+
{
116+
var builder = app.MapPost(AdminEndpointUrls.AdminEvents, async (
117+
[FromBody] AdminEventDetails payload,
118+
HttpRequest request) =>
119+
{
120+
return await Task.FromResult(Results.Ok());
121+
})
122+
// TODO: Check both request/response payloads
123+
.Accepts<AdminEventDetails>(contentType: "application/json")
124+
.Produces<AdminEventDetails>(statusCode: StatusCodes.Status200OK, contentType: "application/json")
125+
// TODO: Check both request/response payloads
126+
.Produces(statusCode: StatusCodes.Status400BadRequest)
127+
.Produces(statusCode: StatusCodes.Status401Unauthorized)
128+
.Produces<string>(statusCode: StatusCodes.Status500InternalServerError, contentType: "text/plain")
129+
.WithTags("admin")
130+
.WithName("CreateAdminEvent")
131+
.WithOpenApi(operation =>
132+
{
133+
operation.Summary = "Create admin event";
134+
operation.Description = "Create admin event";
135+
136+
return operation;
137+
});
138+
139+
return builder;
140+
}
108141
}

src/AzureOpenAIProxy.ApiApp/Endpoints/EndpointUrls.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace AzureOpenAIProxy.ApiApp.Endpoints;
1+
namespace AzureOpenAIProxy.ApiApp.Endpoints;
22

33
/// <summary>
44
/// This represents the collection of the endpoint URLs.
@@ -14,4 +14,9 @@ public static class EndpointUrls
1414
/// Declares the chat completions endpoint.
1515
/// </summary>
1616
public const string ChatCompletions = "/openai/deployments/{deploymentName}/chat/completions";
17-
}
17+
18+
/// <summary>
19+
/// Declares the event endpoint.
20+
/// </summary>
21+
public const string Events = "/events";
22+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using System.Text.Json;
2+
3+
using AzureOpenAIProxy.ApiApp.Models;
4+
5+
namespace AzureOpenAIProxy.ApiApp.Endpoints;
6+
7+
/// <summary>
8+
/// This represents the endpoint entity for events that the logged user joined.
9+
/// </summary>
10+
public static class EventEndpoint
11+
{
12+
/// <summary>
13+
/// Adds the event endpoint.
14+
/// </summary>
15+
/// <param name="app"><see cref="WebApplication"/> instance.</param>
16+
/// <returns>Returns <see cref="RouteHandlerBuilder"/> instance.</returns>
17+
public static RouteHandlerBuilder AddEventList(this WebApplication app)
18+
{
19+
var builder = app.MapGet(EndpointUrls.Events, () =>
20+
{
21+
// TODO: Issue #179 https://github.com/aliencube/azure-openai-sdk-proxy/issues/179
22+
return Results.Ok();
23+
})
24+
.Produces<List<EventDetails>>(statusCode: StatusCodes.Status200OK, contentType: "application/json")
25+
.Produces(statusCode: StatusCodes.Status401Unauthorized)
26+
.Produces<string>(statusCode: StatusCodes.Status500InternalServerError, contentType: "text/plain")
27+
.WithTags("events")
28+
.WithName("GetEvents")
29+
.WithOpenApi(operation =>
30+
{
31+
operation.Description = "Gets all events' details that the user joined.";
32+
operation.Summary = "This endpoint gets all events' details that the user joined.";
33+
34+
return operation;
35+
});
36+
37+
return builder;
38+
}
39+
}

src/AzureOpenAIProxy.ApiApp/Extensions/ServiceCollectionExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Azure.Identity;
1+
using Azure.Identity;
22
using Azure.Security.KeyVault.Secrets;
33

44
using AzureOpenAIProxy.ApiApp.Builders;
@@ -132,4 +132,4 @@ public static IServiceCollection AddOpenApiService(this IServiceCollection servi
132132

133133
return services;
134134
}
135-
}
135+
}

src/AzureOpenAIProxy.ApiApp/Filters/OpenApiTagFilter.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ public void Apply(OpenApiDocument swaggerDoc, DocumentFilterContext context)
1616
[
1717
new OpenApiTag { Name = "weather", Description = "Weather forecast operations" },
1818
new OpenApiTag { Name = "openai", Description = "Azure OpenAI operations" },
19-
new OpenApiTag { Name = "admin", Description = "Admin for organizing events" }
19+
new OpenApiTag { Name = "admin", Description = "Admin for organizing events" },
20+
new OpenApiTag { Name = "events", Description = "User events" }
2021
];
2122
}
2223
}

src/AzureOpenAIProxy.ApiApp/Models/AdminEventDetails.cs

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,15 @@
33
/// <summary>
44
/// This represent the event detail data for response by admin event endpoint.
55
/// </summary>
6-
public class AdminEventDetails
6+
public class AdminEventDetails : EventDetails
77
{
88
/// <summary>
9-
/// Gets or sets the event id.
10-
/// </summary>
11-
public required string? EventId { get; set; }
12-
13-
/// <summary>
14-
/// Gets or sets the event title name.
15-
/// </summary>
16-
public required string? Title { get; set; }
17-
18-
/// <summary>
19-
/// Gets or sets the event summary.
20-
/// </summary>
21-
public required string? Summary { get; set; }
22-
23-
/// <summary>
24-
/// Gets or sets the event description.
9+
/// Gets or sets the event description.
2510
/// </summary>
2611
public string? Description { get; set; }
2712

2813
/// <summary>
29-
/// Gets or sets the event start date.
14+
/// Gets or sets the event start date.
3015
/// </summary>
3116
public required DateTimeOffset? DateStart { get; set; }
3217

@@ -46,7 +31,7 @@ public class AdminEventDetails
4631
public required bool? IsActive { get; set; }
4732

4833
/// <summary>
49-
/// Gets or sets the event organizer name.
34+
/// Gets or sets the event organizer name.
5035
/// </summary>
5136
public required string? OrganizerName { get; set; }
5237

@@ -64,14 +49,4 @@ public class AdminEventDetails
6449
/// Gets or sets the event coorganizer email.
6550
/// </summary>
6651
public string? CoorganizerEmail { get; set; }
67-
68-
/// <summary>
69-
/// Gets or sets the Azure OpenAI Service request max token capacity.
70-
/// </summary>
71-
public required int? MaxTokenCap { get; set; }
72-
73-
/// <summary>
74-
/// Gets or sets the Azure OpenAI Service daily request capacity.
75-
/// </summary>
76-
public required int? DailyRequestCap { get; set; }
7752
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System.ComponentModel.DataAnnotations;
2+
using System.Text.Json.Serialization;
3+
4+
using AzureOpenAIProxy.ApiApp.Models;
5+
6+
/// <summary>
7+
/// This represents the event's detailed data for response by EventEndpoint.
8+
/// </summary>
9+
public class EventDetails
10+
{
11+
/// <summary>
12+
/// Gets or sets the event id.
13+
/// </summary>
14+
public required string? EventId { get; set; }
15+
16+
/// <summary>
17+
/// Gets or sets the event title name.
18+
/// </summary>
19+
public required string? Title { get; set; }
20+
21+
/// <summary>
22+
/// Gets or sets the event summary.
23+
/// </summary>
24+
public required string? Summary { get; set; }
25+
26+
/// <summary>
27+
/// Gets or sets the Azure OpenAI Service request max token capacity.
28+
/// </summary>
29+
public required int? MaxTokenCap { get; set; }
30+
31+
/// <summary>
32+
/// Gets or sets the Azure OpenAI Service daily request capacity.
33+
/// </summary>
34+
public required int? DailyRequestCap { get; set; }
35+
}

src/AzureOpenAIProxy.ApiApp/Program.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,13 @@
3939
app.AddWeatherForecast();
4040
app.AddChatCompletions();
4141

42+
// Event Endpoints
43+
app.AddEventList();
44+
4245
// Admin Endpoints
4346
app.AddAdminEvents();
4447
app.AddAdminEventList();
4548
app.AddUpdateAdminEvents();
49+
app.CreateAdminEvent();
4650

4751
await app.RunAsync();

0 commit comments

Comments
 (0)