diff --git a/src/libs/HammingAI/Generated/HammingAI.DatasetsClient.CreateDataset.g.cs b/src/libs/HammingAI/Generated/HammingAI.DatasetsClient.CreateDataset.g.cs index 1db6363..3734524 100644 --- a/src/libs/HammingAI/Generated/HammingAI.DatasetsClient.CreateDataset.g.cs +++ b/src/libs/HammingAI/Generated/HammingAI.DatasetsClient.CreateDataset.g.cs @@ -140,7 +140,6 @@ partial void ProcessCreateDatasetResponseContent( try { __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( #if NET5_0_OR_GREATER cancellationToken diff --git a/src/libs/HammingAI/Generated/HammingAI.DatasetsClient.GetDataset.g.cs b/src/libs/HammingAI/Generated/HammingAI.DatasetsClient.GetDataset.g.cs index 977d2cd..1bda3e4 100644 --- a/src/libs/HammingAI/Generated/HammingAI.DatasetsClient.GetDataset.g.cs +++ b/src/libs/HammingAI/Generated/HammingAI.DatasetsClient.GetDataset.g.cs @@ -131,7 +131,6 @@ partial void ProcessGetDatasetResponseContent( try { __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( #if NET5_0_OR_GREATER cancellationToken diff --git a/src/libs/HammingAI/Generated/HammingAI.DatasetsClient.ListDatasets.g.cs b/src/libs/HammingAI/Generated/HammingAI.DatasetsClient.ListDatasets.g.cs index a2d1cb2..8401153 100644 --- a/src/libs/HammingAI/Generated/HammingAI.DatasetsClient.ListDatasets.g.cs +++ b/src/libs/HammingAI/Generated/HammingAI.DatasetsClient.ListDatasets.g.cs @@ -125,7 +125,6 @@ partial void ProcessListDatasetsResponseContent( try { __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( #if NET5_0_OR_GREATER cancellationToken diff --git a/src/libs/HammingAI/Generated/HammingAI.ExperimentsClient.CreateExperiment.g.cs b/src/libs/HammingAI/Generated/HammingAI.ExperimentsClient.CreateExperiment.g.cs index 23c6b41..80f7ca5 100644 --- a/src/libs/HammingAI/Generated/HammingAI.ExperimentsClient.CreateExperiment.g.cs +++ b/src/libs/HammingAI/Generated/HammingAI.ExperimentsClient.CreateExperiment.g.cs @@ -140,7 +140,6 @@ partial void ProcessCreateExperimentResponseContent( try { __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( #if NET5_0_OR_GREATER cancellationToken diff --git a/src/libs/HammingAI/Generated/HammingAI.ExperimentsClient.CreateExperimentItem.g.cs b/src/libs/HammingAI/Generated/HammingAI.ExperimentsClient.CreateExperimentItem.g.cs index 008eb1d..f469304 100644 --- a/src/libs/HammingAI/Generated/HammingAI.ExperimentsClient.CreateExperimentItem.g.cs +++ b/src/libs/HammingAI/Generated/HammingAI.ExperimentsClient.CreateExperimentItem.g.cs @@ -146,7 +146,6 @@ partial void ProcessCreateExperimentItemResponseContent( try { __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( #if NET5_0_OR_GREATER cancellationToken diff --git a/src/libs/HammingAI/Generated/HammingAI.ExperimentsClient.UpdateExperiment.g.cs b/src/libs/HammingAI/Generated/HammingAI.ExperimentsClient.UpdateExperiment.g.cs index f4f57d9..f4502de 100644 --- a/src/libs/HammingAI/Generated/HammingAI.ExperimentsClient.UpdateExperiment.g.cs +++ b/src/libs/HammingAI/Generated/HammingAI.ExperimentsClient.UpdateExperiment.g.cs @@ -134,13 +134,6 @@ partial void ProcessUpdateExperimentResponse( try { __response.EnsureSuccessStatusCode(); - - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } catch (global::System.Exception __ex) { diff --git a/src/libs/HammingAI/Generated/HammingAI.ExperimentsClient.UpdateExperimentItem.g.cs b/src/libs/HammingAI/Generated/HammingAI.ExperimentsClient.UpdateExperimentItem.g.cs index 76537c5..9546d2f 100644 --- a/src/libs/HammingAI/Generated/HammingAI.ExperimentsClient.UpdateExperimentItem.g.cs +++ b/src/libs/HammingAI/Generated/HammingAI.ExperimentsClient.UpdateExperimentItem.g.cs @@ -140,13 +140,6 @@ partial void ProcessUpdateExperimentItemResponse( try { __response.EnsureSuccessStatusCode(); - - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } catch (global::System.Exception __ex) { diff --git a/src/libs/HammingAI/Generated/HammingAI.MonitoringClient.CreateCallLog.g.cs b/src/libs/HammingAI/Generated/HammingAI.MonitoringClient.CreateCallLog.g.cs index a20775a..b98eae1 100644 --- a/src/libs/HammingAI/Generated/HammingAI.MonitoringClient.CreateCallLog.g.cs +++ b/src/libs/HammingAI/Generated/HammingAI.MonitoringClient.CreateCallLog.g.cs @@ -128,13 +128,6 @@ partial void ProcessCreateCallLogResponse( try { __response.EnsureSuccessStatusCode(); - - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } catch (global::System.Exception __ex) { diff --git a/src/libs/HammingAI/Generated/HammingAI.MonitoringClient.CreateSession.g.cs b/src/libs/HammingAI/Generated/HammingAI.MonitoringClient.CreateSession.g.cs index 18c6b13..9d138c2 100644 --- a/src/libs/HammingAI/Generated/HammingAI.MonitoringClient.CreateSession.g.cs +++ b/src/libs/HammingAI/Generated/HammingAI.MonitoringClient.CreateSession.g.cs @@ -140,7 +140,6 @@ partial void ProcessCreateSessionResponseContent( try { __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( #if NET5_0_OR_GREATER cancellationToken diff --git a/src/libs/HammingAI/Generated/HammingAI.Polyfills.g.cs b/src/libs/HammingAI/Generated/HammingAI.Polyfills.g.cs index 4021f44..1fa9bc1 100644 --- a/src/libs/HammingAI/Generated/HammingAI.Polyfills.g.cs +++ b/src/libs/HammingAI/Generated/HammingAI.Polyfills.g.cs @@ -1,5 +1,4 @@ -#if !NET6_0_OR_GREATER #nullable enable namespace HammingAI @@ -9,6 +8,7 @@ namespace HammingAI /// public static partial class AutoSdkPolyfills { +#if !NET6_0_OR_GREATER /// /// /// @@ -48,6 +48,128 @@ public static partial class AutoSdkPolyfills content = content ?? throw new global::System.ArgumentNullException(nameof(content)); return content.ReadAsByteArrayAsync(); } +#endif + + /// + /// Creates a JSON request content instance. + /// + public static global::System.Net.Http.HttpContent CreateJsonContent( + T inputValue, + string mediaType, + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions) + { + if (string.IsNullOrWhiteSpace(mediaType)) + { + throw new global::System.ArgumentException("Media type is required.", nameof(mediaType)); + } + +#if NET5_0_OR_GREATER + return global::System.Net.Http.Json.JsonContent.Create( + inputValue: inputValue, + mediaType: new global::System.Net.Http.Headers.MediaTypeHeaderValue(mediaType), + options: jsonSerializerOptions); +#else + var json = global::System.Text.Json.JsonSerializer.Serialize(inputValue, jsonSerializerOptions); + var stringContent = new global::System.Net.Http.StringContent( + content: json, + encoding: global::System.Text.Encoding.UTF8); + stringContent.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(mediaType) + { + CharSet = global::System.Text.Encoding.UTF8.WebName, + }; + return stringContent; +#endif + } + + /// + /// Creates a JSON request content instance using a source-generated serializer context. + /// + public static global::System.Net.Http.HttpContent CreateJsonContent( + object? inputValue, + global::System.Type inputType, + string mediaType, + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + inputType = inputType ?? throw new global::System.ArgumentNullException(nameof(inputType)); + jsonSerializerContext = jsonSerializerContext ?? throw new global::System.ArgumentNullException(nameof(jsonSerializerContext)); + + if (string.IsNullOrWhiteSpace(mediaType)) + { + throw new global::System.ArgumentException("Media type is required.", nameof(mediaType)); + } + +#if NET5_0_OR_GREATER + var jsonTypeInfo = jsonSerializerContext.GetTypeInfo(inputType) ?? + throw new global::System.InvalidOperationException($"No JsonTypeInfo registered for '{inputType}'."); + return global::System.Net.Http.Json.JsonContent.Create( + inputValue: inputValue, + jsonTypeInfo: jsonTypeInfo, + mediaType: new global::System.Net.Http.Headers.MediaTypeHeaderValue(mediaType)); +#else + var json = global::System.Text.Json.JsonSerializer.Serialize( + value: inputValue, + inputType: inputType, + jsonSerializerContext); + var stringContent = new global::System.Net.Http.StringContent( + content: json, + encoding: global::System.Text.Encoding.UTF8); + stringContent.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(mediaType) + { + CharSet = global::System.Text.Encoding.UTF8.WebName, + }; + return stringContent; +#endif + } + + /// + /// Reads JSON content into the specified type using serializer options. + /// + public static async global::System.Threading.Tasks.Task ReadFromJsonAsync( + this global::System.Net.Http.HttpContent content, + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions, + global::System.Threading.CancellationToken cancellationToken) + { + content = content ?? throw new global::System.ArgumentNullException(nameof(content)); + +#if NET5_0_OR_GREATER + return await global::System.Net.Http.Json.HttpContentJsonExtensions.ReadFromJsonAsync( + content, + jsonSerializerOptions, + cancellationToken).ConfigureAwait(false); +#else + using var stream = await AutoSdkPolyfills.ReadAsStreamAsync(content, cancellationToken).ConfigureAwait(false); + return await global::System.Text.Json.JsonSerializer.DeserializeAsync( + utf8Json: stream, + options: jsonSerializerOptions, + cancellationToken: cancellationToken).ConfigureAwait(false); +#endif + } + + /// + /// Reads JSON content into the specified type using a source-generated serializer context. + /// + public static async global::System.Threading.Tasks.Task ReadFromJsonAsync( + this global::System.Net.Http.HttpContent content, + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext, + global::System.Threading.CancellationToken cancellationToken) + { + content = content ?? throw new global::System.ArgumentNullException(nameof(content)); + jsonSerializerContext = jsonSerializerContext ?? throw new global::System.ArgumentNullException(nameof(jsonSerializerContext)); + +#if NET5_0_OR_GREATER + return (T?)await global::System.Net.Http.Json.HttpContentJsonExtensions.ReadFromJsonAsync( + content, + typeof(T), + jsonSerializerContext, + cancellationToken).ConfigureAwait(false); +#else + using var stream = await AutoSdkPolyfills.ReadAsStreamAsync(content, cancellationToken).ConfigureAwait(false); + return (T?)await global::System.Text.Json.JsonSerializer.DeserializeAsync( + utf8Json: stream, + returnType: typeof(T), + jsonSerializerContext, + cancellationToken: cancellationToken).ConfigureAwait(false); +#endif + } } } -#endif \ No newline at end of file diff --git a/src/libs/HammingAI/Generated/HammingAI.PromptsClient.GetPrompt.g.cs b/src/libs/HammingAI/Generated/HammingAI.PromptsClient.GetPrompt.g.cs index 1d84c62..a8e2aa2 100644 --- a/src/libs/HammingAI/Generated/HammingAI.PromptsClient.GetPrompt.g.cs +++ b/src/libs/HammingAI/Generated/HammingAI.PromptsClient.GetPrompt.g.cs @@ -147,7 +147,6 @@ partial void ProcessGetPromptResponseContent( try { __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( #if NET5_0_OR_GREATER cancellationToken diff --git a/src/libs/HammingAI/Generated/HammingAI.PromptsClient.ListPrompts.g.cs b/src/libs/HammingAI/Generated/HammingAI.PromptsClient.ListPrompts.g.cs index 145cc0c..eba6083 100644 --- a/src/libs/HammingAI/Generated/HammingAI.PromptsClient.ListPrompts.g.cs +++ b/src/libs/HammingAI/Generated/HammingAI.PromptsClient.ListPrompts.g.cs @@ -134,7 +134,6 @@ partial void ProcessListPromptsResponseContent( try { __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( #if NET5_0_OR_GREATER cancellationToken diff --git a/src/libs/HammingAI/Generated/HammingAI.ScoringClient.RegisterScoringFunctions.g.cs b/src/libs/HammingAI/Generated/HammingAI.ScoringClient.RegisterScoringFunctions.g.cs index 30db815..317e4fe 100644 --- a/src/libs/HammingAI/Generated/HammingAI.ScoringClient.RegisterScoringFunctions.g.cs +++ b/src/libs/HammingAI/Generated/HammingAI.ScoringClient.RegisterScoringFunctions.g.cs @@ -140,7 +140,6 @@ partial void ProcessRegisterScoringFunctionsResponseContent( try { __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( #if NET5_0_OR_GREATER cancellationToken diff --git a/src/libs/HammingAI/Generated/HammingAI.TracingClient.CreateTraces.g.cs b/src/libs/HammingAI/Generated/HammingAI.TracingClient.CreateTraces.g.cs index 8afb58c..e6e09d4 100644 --- a/src/libs/HammingAI/Generated/HammingAI.TracingClient.CreateTraces.g.cs +++ b/src/libs/HammingAI/Generated/HammingAI.TracingClient.CreateTraces.g.cs @@ -128,13 +128,6 @@ partial void ProcessCreateTracesResponse( try { __response.EnsureSuccessStatusCode(); - - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } catch (global::System.Exception __ex) { diff --git a/src/libs/HammingAI/Generated/HammingAI.VoiceAgentsClient.CreateLiveKitRooms.g.cs b/src/libs/HammingAI/Generated/HammingAI.VoiceAgentsClient.CreateLiveKitRooms.g.cs index a1c6102..1fd15f6 100644 --- a/src/libs/HammingAI/Generated/HammingAI.VoiceAgentsClient.CreateLiveKitRooms.g.cs +++ b/src/libs/HammingAI/Generated/HammingAI.VoiceAgentsClient.CreateLiveKitRooms.g.cs @@ -140,7 +140,6 @@ partial void ProcessCreateLiveKitRoomsResponseContent( try { __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( #if NET5_0_OR_GREATER cancellationToken diff --git a/src/libs/HammingAI/Generated/HammingAI.VoiceAgentsClient.GetVoiceExperiment.g.cs b/src/libs/HammingAI/Generated/HammingAI.VoiceAgentsClient.GetVoiceExperiment.g.cs index 948f4fd..7f98fbd 100644 --- a/src/libs/HammingAI/Generated/HammingAI.VoiceAgentsClient.GetVoiceExperiment.g.cs +++ b/src/libs/HammingAI/Generated/HammingAI.VoiceAgentsClient.GetVoiceExperiment.g.cs @@ -131,7 +131,6 @@ partial void ProcessGetVoiceExperimentResponseContent( try { __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( #if NET5_0_OR_GREATER cancellationToken diff --git a/src/libs/HammingAI/Generated/HammingAI.VoiceAgentsClient.GetVoiceExperimentCalls.g.cs b/src/libs/HammingAI/Generated/HammingAI.VoiceAgentsClient.GetVoiceExperimentCalls.g.cs index d1abe23..fdf78e3 100644 --- a/src/libs/HammingAI/Generated/HammingAI.VoiceAgentsClient.GetVoiceExperimentCalls.g.cs +++ b/src/libs/HammingAI/Generated/HammingAI.VoiceAgentsClient.GetVoiceExperimentCalls.g.cs @@ -131,7 +131,6 @@ partial void ProcessGetVoiceExperimentCallsResponseContent( try { __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( #if NET5_0_OR_GREATER cancellationToken diff --git a/src/libs/HammingAI/Generated/HammingAI.VoiceAgentsClient.RunVoiceAgent.g.cs b/src/libs/HammingAI/Generated/HammingAI.VoiceAgentsClient.RunVoiceAgent.g.cs index f7ba982..382bf12 100644 --- a/src/libs/HammingAI/Generated/HammingAI.VoiceAgentsClient.RunVoiceAgent.g.cs +++ b/src/libs/HammingAI/Generated/HammingAI.VoiceAgentsClient.RunVoiceAgent.g.cs @@ -146,7 +146,6 @@ partial void ProcessRunVoiceAgentResponseContent( try { __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( #if NET5_0_OR_GREATER cancellationToken