Skip to content
Merged
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/Recraft/Generated/Recraft.AutoSDKHttpResponse.g.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@

#nullable enable

namespace Recraft
{
/// <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; }
}
}
72 changes: 62 additions & 10 deletions src/libs/Recraft/Generated/Recraft.ColorsClient.OptimizeColors.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,31 @@ partial void ProcessOptimizeColorsResponseContent(
/// <exception cref="global::Recraft.ApiException"></exception>
public async global::System.Threading.Tasks.Task<global::Recraft.OptimizeColorsResponse> OptimizeColorsAsync(

global::Recraft.OptimizeColorsRequest request,
global::Recraft.BillingType? billing = default,
global::Recraft.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __response = await OptimizeColorsAsResponseAsync(

request: request,
billing: billing,
requestOptions: requestOptions,
cancellationToken: cancellationToken
).ConfigureAwait(false);

return __response.Body;
}
/// <summary>
/// Optimize colors
/// </summary>
/// <param name="billing"></param>
/// <param name="request"></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::Recraft.ApiException"></exception>
public async global::System.Threading.Tasks.Task<global::Recraft.AutoSDKHttpResponse<global::Recraft.OptimizeColorsResponse>> OptimizeColorsAsResponseAsync(

global::Recraft.OptimizeColorsRequest request,
global::Recraft.BillingType? billing = default,
global::Recraft.AutoSDKRequestOptions? requestOptions = default,
Expand Down Expand Up @@ -89,11 +114,12 @@ partial void ProcessOptimizeColorsResponseContent(

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

var __pathBuilder = new global::Recraft.PathBuilder(
path: "/v1/colors/optimize",
baseUri: HttpClient.BaseAddress);
baseUri: HttpClient.BaseAddress);
__pathBuilder
.AddOptionalParameter("billing", billing?.ToValueString())
.AddOptionalParameter("billing", billing?.ToValueString())
;
var __path = __pathBuilder.ToString();
__path = global::Recraft.AutoSDKRequestOptionsSupport.AppendQueryParameters(
Expand Down Expand Up @@ -172,6 +198,8 @@ partial void ProcessOptimizeColorsResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: false,
retryDelay: null,
retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
Expand All @@ -182,6 +210,11 @@ partial void ProcessOptimizeColorsResponseContent(
}
catch (global::System.Net.Http.HttpRequestException __exception)
{
var __retryDelay = global::Recraft.AutoSDKRequestOptionsSupport.GetRetryDelay(
clientOptions: Options,
requestOptions: requestOptions,
response: null,
attempt: __attempt);
var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
await global::Recraft.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
clientOptions: Options,
Expand All @@ -199,6 +232,8 @@ partial void ProcessOptimizeColorsResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: __willRetry,
retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
retryReason: "exception",
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
if (!__willRetry)
{
Expand All @@ -208,8 +243,7 @@ partial void ProcessOptimizeColorsResponseContent(
__httpRequest.Dispose();
__httpRequest = null;
await global::Recraft.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
clientOptions: Options,
requestOptions: requestOptions,
retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
Expand All @@ -218,6 +252,11 @@ partial void ProcessOptimizeColorsResponseContent(
__attempt < __maxAttempts &&
global::Recraft.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
var __retryDelay = global::Recraft.AutoSDKRequestOptionsSupport.GetRetryDelay(
clientOptions: Options,
requestOptions: requestOptions,
response: __response,
attempt: __attempt);
await global::Recraft.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
clientOptions: Options,
context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
Expand All @@ -234,14 +273,15 @@ partial void ProcessOptimizeColorsResponseContent(
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::Recraft.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
clientOptions: Options,
requestOptions: requestOptions,
retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
Expand Down Expand Up @@ -281,6 +321,8 @@ partial void ProcessOptimizeColorsResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
retryDelay: null,
retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
else
Expand All @@ -301,6 +343,8 @@ partial void ProcessOptimizeColorsResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
retryDelay: null,
retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}

Expand All @@ -325,9 +369,13 @@ partial void ProcessOptimizeColorsResponseContent(
{
__response.EnsureSuccessStatusCode();

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

return
await global::Recraft.OptimizeColorsResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
var __value = await global::Recraft.OptimizeColorsResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
throw new global::System.InvalidOperationException("Response deserialization failed.");
return new global::Recraft.AutoSDKHttpResponse<global::Recraft.OptimizeColorsResponse>(
statusCode: __response.StatusCode,
headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
requestUri: __response.RequestMessage?.RequestUri,
body: __value);
}
catch (global::System.Exception __ex)
{
Expand Down
8 changes: 4 additions & 4 deletions src/libs/Recraft/Generated/Recraft.ColorsClient.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ public ColorsClient(
/// <param name="options">Client-wide request defaults such as headers, query parameters, retries, and timeout.</param>
/// <param name="disposeHttpClient">Dispose the HttpClient when the instance is disposed. True by default.</param>
public ColorsClient(
global::System.Net.Http.HttpClient? httpClient = null,
global::System.Uri? baseUri = null,
global::System.Collections.Generic.List<global::Recraft.EndPointAuthorization>? authorizations = null,
global::Recraft.AutoSDKClientOptions? options = null,
global::System.Net.Http.HttpClient? httpClient,
global::System.Uri? baseUri,
global::System.Collections.Generic.List<global::Recraft.EndPointAuthorization>? authorizations,
global::Recraft.AutoSDKClientOptions? options,
bool disposeHttpClient = true)
{

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,20 @@ public partial interface IColorsClient
/// Optimize colors
/// </summary>
/// <param name="billing"></param>
/// <param name="request"></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::Recraft.ApiException"></exception>
global::System.Threading.Tasks.Task<global::Recraft.AutoSDKHttpResponse<global::Recraft.OptimizeColorsResponse>> OptimizeColorsAsResponseAsync(

global::Recraft.OptimizeColorsRequest request,
global::Recraft.BillingType? billing = default,
global::Recraft.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
/// <summary>
/// Optimize colors
/// </summary>
/// <param name="billing"></param>
/// <param name="colors"></param>
/// <param name="numColorsLimit"></param>
/// <param name="requestOptions">Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.</param>
Expand Down
Loading