Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 121 additions & 0 deletions src/libs/Ideogram/Generated/Ideogram.AutoSDKHttpResponse.g.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@

#nullable enable

namespace Ideogram
{
/// <summary>
/// Represents a successful HTTP response with status code and headers.
/// </summary>
public partial class AutoSDKHttpResponse
{
/// <summary>
/// Initializes a new instance of the <see cref="AutoSDKHttpResponse"/> class.
/// </summary>
public AutoSDKHttpResponse(
global::System.Net.HttpStatusCode statusCode,
global::System.Collections.Generic.Dictionary<string, global::System.Collections.Generic.IEnumerable<string>> headers)
: this(
statusCode: statusCode,
headers: headers,
requestUri: null)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="AutoSDKHttpResponse"/> class.
/// </summary>
public AutoSDKHttpResponse(
global::System.Net.HttpStatusCode statusCode,
global::System.Collections.Generic.Dictionary<string, global::System.Collections.Generic.IEnumerable<string>> headers,
global::System.Uri? requestUri)
{
StatusCode = statusCode;
Headers = headers ?? throw new global::System.ArgumentNullException(nameof(headers));
RequestUri = requestUri;
}

/// <summary>
/// Gets the HTTP status code.
/// </summary>
public global::System.Net.HttpStatusCode StatusCode { get; }
/// <summary>
/// Gets the response headers.
/// </summary>
public global::System.Collections.Generic.Dictionary<string, global::System.Collections.Generic.IEnumerable<string>> Headers { get; }
/// <summary>
/// Gets the final request URI associated with the response.
/// </summary>
public global::System.Uri? RequestUri { get; }

internal static global::System.Collections.Generic.Dictionary<string, global::System.Collections.Generic.IEnumerable<string>> CreateHeaders(
global::System.Net.Http.HttpResponseMessage response)
{
response = response ?? throw new global::System.ArgumentNullException(nameof(response));

var headers = global::System.Linq.Enumerable.ToDictionary(
response.Headers,
static header => header.Key,
static header => (global::System.Collections.Generic.IEnumerable<string>)global::System.Linq.Enumerable.ToArray(header.Value),
global::System.StringComparer.OrdinalIgnoreCase);

if (response.Content?.Headers == null)
{
return headers;
}

foreach (var header in response.Content.Headers)
{
if (headers.TryGetValue(header.Key, out var existingValues))
{
headers[header.Key] = global::System.Linq.Enumerable.ToArray(
global::System.Linq.Enumerable.Concat(existingValues, header.Value));
}
else
{
headers[header.Key] = global::System.Linq.Enumerable.ToArray(header.Value);
}
}

return headers;
}
}

/// <summary>
/// Represents a successful HTTP response with status code, headers, and body.
/// </summary>
public partial class AutoSDKHttpResponse<T> : AutoSDKHttpResponse
{
/// <summary>
/// Initializes a new instance of the <see cref="AutoSDKHttpResponse{T}"/> class.
/// </summary>
public AutoSDKHttpResponse(
global::System.Net.HttpStatusCode statusCode,
global::System.Collections.Generic.Dictionary<string, global::System.Collections.Generic.IEnumerable<string>> headers,
T body)
: this(
statusCode: statusCode,
headers: headers,
requestUri: null,
body: body)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="AutoSDKHttpResponse{T}"/> class.
/// </summary>
public AutoSDKHttpResponse(
global::System.Net.HttpStatusCode statusCode,
global::System.Collections.Generic.Dictionary<string, global::System.Collections.Generic.IEnumerable<string>> headers,
global::System.Uri? requestUri,
T body)
: base(statusCode, headers, requestUri)
{
Body = body;
}

/// <summary>
/// Gets the response body.
/// </summary>
public T Body { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,27 @@ partial void ProcessGetMaybeBatchResultsResponseContent(
string jobId,
global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __response = await GetMaybeBatchResultsAsResponseAsync(
jobId: jobId,
requestOptions: requestOptions,
cancellationToken: cancellationToken
).ConfigureAwait(false);

return __response.Body;
}
/// <summary>
/// Get Batch Magic Prompt Job Results if available.<br/>
/// Gets the results of a batch magic prompt job if available.
/// </summary>
/// <param name="jobId"></param>
/// <param name="requestOptions">Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.</param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::Ideogram.ApiException"></exception>
public async global::System.Threading.Tasks.Task<global::Ideogram.AutoSDKHttpResponse<global::Ideogram.InternalBatchResultsResponse>> GetMaybeBatchResultsAsResponseAsync(
string jobId,
global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
client: HttpClient);
Expand Down Expand Up @@ -82,6 +103,7 @@ partial void ProcessGetMaybeBatchResultsResponseContent(

global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{

var __pathBuilder = new global::Ideogram.PathBuilder(
path: $"/internal/batch/get-maybe-batch-results/{jobId}",
baseUri: HttpClient.BaseAddress);
Expand Down Expand Up @@ -155,6 +177,8 @@ partial void ProcessGetMaybeBatchResultsResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: false,
retryDelay: null,
retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
Expand All @@ -165,6 +189,11 @@ partial void ProcessGetMaybeBatchResultsResponseContent(
}
catch (global::System.Net.Http.HttpRequestException __exception)
{
var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
clientOptions: Options,
requestOptions: requestOptions,
response: null,
attempt: __attempt);
var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
clientOptions: Options,
Expand All @@ -182,6 +211,8 @@ partial void ProcessGetMaybeBatchResultsResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: __willRetry,
retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
retryReason: "exception",
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
if (!__willRetry)
{
Expand All @@ -191,8 +222,7 @@ partial void ProcessGetMaybeBatchResultsResponseContent(
__httpRequest.Dispose();
__httpRequest = null;
await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
clientOptions: Options,
requestOptions: requestOptions,
retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
Expand All @@ -201,6 +231,11 @@ partial void ProcessGetMaybeBatchResultsResponseContent(
__attempt < __maxAttempts &&
global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
clientOptions: Options,
requestOptions: requestOptions,
response: __response,
attempt: __attempt);
await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
clientOptions: Options,
context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
Expand All @@ -217,14 +252,15 @@ partial void ProcessGetMaybeBatchResultsResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: true,
retryDelay: __retryDelay,
retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture),
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
__response.Dispose();
__response = null;
__httpRequest.Dispose();
__httpRequest = null;
await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
clientOptions: Options,
requestOptions: requestOptions,
retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
Expand Down Expand Up @@ -264,6 +300,8 @@ partial void ProcessGetMaybeBatchResultsResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
retryDelay: null,
retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
else
Expand All @@ -284,6 +322,8 @@ partial void ProcessGetMaybeBatchResultsResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
retryDelay: null,
retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
//
Expand Down Expand Up @@ -440,9 +480,13 @@ partial void ProcessGetMaybeBatchResultsResponseContent(
{
__response.EnsureSuccessStatusCode();

return
global::Ideogram.InternalBatchResultsResponse.FromJson(__content, JsonSerializerContext) ??
var __value = global::Ideogram.InternalBatchResultsResponse.FromJson(__content, JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
return new global::Ideogram.AutoSDKHttpResponse<global::Ideogram.InternalBatchResultsResponse>(
statusCode: __response.StatusCode,
headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
requestUri: __response.RequestMessage?.RequestUri,
body: __value);
}
catch (global::System.Exception __ex)
{
Expand Down Expand Up @@ -470,9 +514,13 @@ partial void ProcessGetMaybeBatchResultsResponseContent(
#endif
).ConfigureAwait(false);

return
await global::Ideogram.InternalBatchResultsResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
var __value = await global::Ideogram.InternalBatchResultsResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
throw new global::System.InvalidOperationException("Response deserialization failed.");
return new global::Ideogram.AutoSDKHttpResponse<global::Ideogram.InternalBatchResultsResponse>(
statusCode: __response.StatusCode,
headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
requestUri: __response.RequestMessage?.RequestUri,
body: __value);
}
catch (global::System.Exception __ex)
{
Expand Down
Loading