diff --git a/src/libs/Recraft/Generated/Recraft.AutoSDKHttpResponse.g.cs b/src/libs/Recraft/Generated/Recraft.AutoSDKHttpResponse.g.cs
new file mode 100644
index 0000000..e07a55f
--- /dev/null
+++ b/src/libs/Recraft/Generated/Recraft.AutoSDKHttpResponse.g.cs
@@ -0,0 +1,121 @@
+
+#nullable enable
+
+namespace Recraft
+{
+ ///
+ /// Represents a successful HTTP response with status code and headers.
+ ///
+ public partial class AutoSDKHttpResponse
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public AutoSDKHttpResponse(
+ global::System.Net.HttpStatusCode statusCode,
+ global::System.Collections.Generic.Dictionary> headers)
+ : this(
+ statusCode: statusCode,
+ headers: headers,
+ requestUri: null)
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public AutoSDKHttpResponse(
+ global::System.Net.HttpStatusCode statusCode,
+ global::System.Collections.Generic.Dictionary> headers,
+ global::System.Uri? requestUri)
+ {
+ StatusCode = statusCode;
+ Headers = headers ?? throw new global::System.ArgumentNullException(nameof(headers));
+ RequestUri = requestUri;
+ }
+
+ ///
+ /// Gets the HTTP status code.
+ ///
+ public global::System.Net.HttpStatusCode StatusCode { get; }
+ ///
+ /// Gets the response headers.
+ ///
+ public global::System.Collections.Generic.Dictionary> Headers { get; }
+ ///
+ /// Gets the final request URI associated with the response.
+ ///
+ public global::System.Uri? RequestUri { get; }
+
+ internal static global::System.Collections.Generic.Dictionary> 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)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;
+ }
+ }
+
+ ///
+ /// Represents a successful HTTP response with status code, headers, and body.
+ ///
+ public partial class AutoSDKHttpResponse : AutoSDKHttpResponse
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public AutoSDKHttpResponse(
+ global::System.Net.HttpStatusCode statusCode,
+ global::System.Collections.Generic.Dictionary> headers,
+ T body)
+ : this(
+ statusCode: statusCode,
+ headers: headers,
+ requestUri: null,
+ body: body)
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public AutoSDKHttpResponse(
+ global::System.Net.HttpStatusCode statusCode,
+ global::System.Collections.Generic.Dictionary> headers,
+ global::System.Uri? requestUri,
+ T body)
+ : base(statusCode, headers, requestUri)
+ {
+ Body = body;
+ }
+
+ ///
+ /// Gets the response body.
+ ///
+ public T Body { get; }
+ }
+}
\ No newline at end of file
diff --git a/src/libs/Recraft/Generated/Recraft.ColorsClient.OptimizeColors.g.cs b/src/libs/Recraft/Generated/Recraft.ColorsClient.OptimizeColors.g.cs
index e469346..5f9917e 100644
--- a/src/libs/Recraft/Generated/Recraft.ColorsClient.OptimizeColors.g.cs
+++ b/src/libs/Recraft/Generated/Recraft.ColorsClient.OptimizeColors.g.cs
@@ -53,6 +53,31 @@ partial void ProcessOptimizeColorsResponseContent(
///
public async global::System.Threading.Tasks.Task 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;
+ }
+ ///
+ /// Optimize colors
+ ///
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> OptimizeColorsAsResponseAsync(
+
global::Recraft.OptimizeColorsRequest request,
global::Recraft.BillingType? billing = default,
global::Recraft.AutoSDKRequestOptions? requestOptions = default,
@@ -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(
@@ -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
{
@@ -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,
@@ -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)
{
@@ -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;
}
@@ -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(
@@ -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;
}
@@ -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
@@ -301,6 +343,8 @@ partial void ProcessOptimizeColorsResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
@@ -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(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
@@ -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(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
diff --git a/src/libs/Recraft/Generated/Recraft.ColorsClient.g.cs b/src/libs/Recraft/Generated/Recraft.ColorsClient.g.cs
index 7163ced..488adaa 100644
--- a/src/libs/Recraft/Generated/Recraft.ColorsClient.g.cs
+++ b/src/libs/Recraft/Generated/Recraft.ColorsClient.g.cs
@@ -72,10 +72,10 @@ public ColorsClient(
/// Client-wide request defaults such as headers, query parameters, retries, and timeout.
/// Dispose the HttpClient when the instance is disposed. True by default.
public ColorsClient(
- global::System.Net.Http.HttpClient? httpClient = null,
- global::System.Uri? baseUri = null,
- global::System.Collections.Generic.List? authorizations = null,
- global::Recraft.AutoSDKClientOptions? options = null,
+ global::System.Net.Http.HttpClient? httpClient,
+ global::System.Uri? baseUri,
+ global::System.Collections.Generic.List? authorizations,
+ global::Recraft.AutoSDKClientOptions? options,
bool disposeHttpClient = true)
{
diff --git a/src/libs/Recraft/Generated/Recraft.IColorsClient.OptimizeColors.g.cs b/src/libs/Recraft/Generated/Recraft.IColorsClient.OptimizeColors.g.cs
index 59ab4c1..f5a3589 100644
--- a/src/libs/Recraft/Generated/Recraft.IColorsClient.OptimizeColors.g.cs
+++ b/src/libs/Recraft/Generated/Recraft.IColorsClient.OptimizeColors.g.cs
@@ -22,6 +22,20 @@ public partial interface IColorsClient
/// Optimize colors
///
///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ global::System.Threading.Tasks.Task> OptimizeColorsAsResponseAsync(
+
+ global::Recraft.OptimizeColorsRequest request,
+ global::Recraft.BillingType? billing = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default);
+ ///
+ /// Optimize colors
+ ///
+ ///
///
///
/// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
diff --git a/src/libs/Recraft/Generated/Recraft.IImageClient.CreativeUpscale.g.cs b/src/libs/Recraft/Generated/Recraft.IImageClient.CreativeUpscale.g.cs
index 2b765f1..dbe6dde 100644
--- a/src/libs/Recraft/Generated/Recraft.IImageClient.CreativeUpscale.g.cs
+++ b/src/libs/Recraft/Generated/Recraft.IImageClient.CreativeUpscale.g.cs
@@ -22,6 +22,20 @@ public partial interface IImageClient
/// Creative Upscale
///
///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ global::System.Threading.Tasks.Task> CreativeUpscaleAsResponseAsync(
+
+ global::Recraft.ProcessImageRequest request,
+ global::Recraft.BillingType? billing = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default);
+ ///
+ /// Creative Upscale
+ ///
+ ///
///
///
///
@@ -41,5 +55,56 @@ public partial interface IImageClient
global::Recraft.UpscaleMode? upscale = default,
global::Recraft.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
+
+ ///
+ /// Creative Upscale
+ ///
+ ///
+ ///
+ ///
+ /// The stream to send as the multipart 'image' file part.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ global::System.Threading.Tasks.Task CreativeUpscaleAsync(
+ global::System.IO.Stream image,
+ string imagename,
+ global::Recraft.BillingType? billing = default,
+ bool? expire = default,
+ global::Recraft.ImageFormat? imageFormat = default,
+ global::Recraft.ResponseFormat? responseFormat = default,
+ global::Recraft.UpscaleMode? upscale = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default);
+ ///
+ /// Creative Upscale
+ ///
+ ///
+ ///
+ ///
+ /// The stream to send as the multipart 'image' file part.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ global::System.Threading.Tasks.Task> CreativeUpscaleAsResponseAsync(
+ global::System.IO.Stream image,
+ string imagename,
+ global::Recraft.BillingType? billing = default,
+ bool? expire = default,
+ global::Recraft.ImageFormat? imageFormat = default,
+ global::Recraft.ResponseFormat? responseFormat = default,
+ global::Recraft.UpscaleMode? upscale = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/Recraft/Generated/Recraft.IImageClient.CrispUpscale.g.cs b/src/libs/Recraft/Generated/Recraft.IImageClient.CrispUpscale.g.cs
index 11f5761..68c5e0b 100644
--- a/src/libs/Recraft/Generated/Recraft.IImageClient.CrispUpscale.g.cs
+++ b/src/libs/Recraft/Generated/Recraft.IImageClient.CrispUpscale.g.cs
@@ -22,6 +22,20 @@ public partial interface IImageClient
/// Crisp Upscale
///
///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ global::System.Threading.Tasks.Task> CrispUpscaleAsResponseAsync(
+
+ global::Recraft.ProcessImageRequest request,
+ global::Recraft.BillingType? billing = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default);
+ ///
+ /// Crisp Upscale
+ ///
+ ///
///
///
///
@@ -41,5 +55,56 @@ public partial interface IImageClient
global::Recraft.UpscaleMode? upscale = default,
global::Recraft.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
+
+ ///
+ /// Crisp Upscale
+ ///
+ ///
+ ///
+ ///
+ /// The stream to send as the multipart 'image' file part.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ global::System.Threading.Tasks.Task CrispUpscaleAsync(
+ global::System.IO.Stream image,
+ string imagename,
+ global::Recraft.BillingType? billing = default,
+ bool? expire = default,
+ global::Recraft.ImageFormat? imageFormat = default,
+ global::Recraft.ResponseFormat? responseFormat = default,
+ global::Recraft.UpscaleMode? upscale = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default);
+ ///
+ /// Crisp Upscale
+ ///
+ ///
+ ///
+ ///
+ /// The stream to send as the multipart 'image' file part.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ global::System.Threading.Tasks.Task> CrispUpscaleAsResponseAsync(
+ global::System.IO.Stream image,
+ string imagename,
+ global::Recraft.BillingType? billing = default,
+ bool? expire = default,
+ global::Recraft.ImageFormat? imageFormat = default,
+ global::Recraft.ResponseFormat? responseFormat = default,
+ global::Recraft.UpscaleMode? upscale = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/Recraft/Generated/Recraft.IImageClient.EraseRegion.g.cs b/src/libs/Recraft/Generated/Recraft.IImageClient.EraseRegion.g.cs
index 82ad1d0..613a23c 100644
--- a/src/libs/Recraft/Generated/Recraft.IImageClient.EraseRegion.g.cs
+++ b/src/libs/Recraft/Generated/Recraft.IImageClient.EraseRegion.g.cs
@@ -22,6 +22,20 @@ public partial interface IImageClient
/// Erase Region
///
///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ global::System.Threading.Tasks.Task> EraseRegionAsResponseAsync(
+
+ global::Recraft.EraseRegionRequest request,
+ global::Recraft.BillingType? billing = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default);
+ ///
+ /// Erase Region
+ ///
+ ///
///
///
///
@@ -43,5 +57,64 @@ public partial interface IImageClient
global::Recraft.ResponseFormat? responseFormat = default,
global::Recraft.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
+
+ ///
+ /// Erase Region
+ ///
+ ///
+ ///
+ ///
+ /// The stream to send as the multipart 'image' file part.
+ ///
+ ///
+ ///
+ ///
+ /// The stream to send as the multipart 'mask' file part.
+ ///
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ global::System.Threading.Tasks.Task EraseRegionAsync(
+ global::System.IO.Stream image,
+ string imagename,
+ global::System.IO.Stream mask,
+ string maskname,
+ global::Recraft.BillingType? billing = default,
+ bool? expire = default,
+ global::Recraft.ImageFormat? imageFormat = default,
+ global::Recraft.ResponseFormat? responseFormat = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default);
+ ///
+ /// Erase Region
+ ///
+ ///
+ ///
+ ///
+ /// The stream to send as the multipart 'image' file part.
+ ///
+ ///
+ ///
+ ///
+ /// The stream to send as the multipart 'mask' file part.
+ ///
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ global::System.Threading.Tasks.Task> EraseRegionAsResponseAsync(
+ global::System.IO.Stream image,
+ string imagename,
+ global::System.IO.Stream mask,
+ string maskname,
+ global::Recraft.BillingType? billing = default,
+ bool? expire = default,
+ global::Recraft.ImageFormat? imageFormat = default,
+ global::Recraft.ResponseFormat? responseFormat = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/Recraft/Generated/Recraft.IImageClient.Explore.g.cs b/src/libs/Recraft/Generated/Recraft.IImageClient.Explore.g.cs
index 27a6248..531016b 100644
--- a/src/libs/Recraft/Generated/Recraft.IImageClient.Explore.g.cs
+++ b/src/libs/Recraft/Generated/Recraft.IImageClient.Explore.g.cs
@@ -22,6 +22,20 @@ public partial interface IImageClient
/// Exploration
///
///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ global::System.Threading.Tasks.Task> ExploreAsResponseAsync(
+
+ global::Recraft.ExploreRequest request,
+ global::Recraft.BillingType? billing = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default);
+ ///
+ /// Exploration
+ ///
+ ///
///
///
///
diff --git a/src/libs/Recraft/Generated/Recraft.IImageClient.ExploreSimilar.g.cs b/src/libs/Recraft/Generated/Recraft.IImageClient.ExploreSimilar.g.cs
index 74d621d..b8782e9 100644
--- a/src/libs/Recraft/Generated/Recraft.IImageClient.ExploreSimilar.g.cs
+++ b/src/libs/Recraft/Generated/Recraft.IImageClient.ExploreSimilar.g.cs
@@ -22,6 +22,20 @@ public partial interface IImageClient
/// Continue exploration from a source image
///
///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ global::System.Threading.Tasks.Task> ExploreSimilarAsResponseAsync(
+
+ global::Recraft.ExploreSimilarRequest request,
+ global::Recraft.BillingType? billing = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default);
+ ///
+ /// Continue exploration from a source image
+ ///
+ ///
///
///
///
diff --git a/src/libs/Recraft/Generated/Recraft.IImageClient.GenerateBackground.g.cs b/src/libs/Recraft/Generated/Recraft.IImageClient.GenerateBackground.g.cs
index 26653fc..e870818 100644
--- a/src/libs/Recraft/Generated/Recraft.IImageClient.GenerateBackground.g.cs
+++ b/src/libs/Recraft/Generated/Recraft.IImageClient.GenerateBackground.g.cs
@@ -22,6 +22,20 @@ public partial interface IImageClient
/// Generate Background
///
///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ global::System.Threading.Tasks.Task> GenerateBackgroundAsResponseAsync(
+
+ global::Recraft.TransformImageWithMaskRequest request,
+ global::Recraft.BillingType? billing = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default);
+ ///
+ /// Generate Background
+ ///
+ ///
/// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
diff --git a/src/libs/Recraft/Generated/Recraft.IImageClient.GenerateImage.g.cs b/src/libs/Recraft/Generated/Recraft.IImageClient.GenerateImage.g.cs
index a158aaf..1ff3441 100644
--- a/src/libs/Recraft/Generated/Recraft.IImageClient.GenerateImage.g.cs
+++ b/src/libs/Recraft/Generated/Recraft.IImageClient.GenerateImage.g.cs
@@ -22,6 +22,20 @@ public partial interface IImageClient
/// Generate image from prompt
///
///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ global::System.Threading.Tasks.Task> GenerateImageAsResponseAsync(
+
+ global::Recraft.GenerateImageRequest request,
+ global::Recraft.BillingType? billing = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default);
+ ///
+ /// Generate image from prompt
+ ///
+ ///
///
///
///
diff --git a/src/libs/Recraft/Generated/Recraft.IImageClient.GenerateImageRaster.g.cs b/src/libs/Recraft/Generated/Recraft.IImageClient.GenerateImageRaster.g.cs
index f575b07..12cdaa0 100644
--- a/src/libs/Recraft/Generated/Recraft.IImageClient.GenerateImageRaster.g.cs
+++ b/src/libs/Recraft/Generated/Recraft.IImageClient.GenerateImageRaster.g.cs
@@ -22,6 +22,20 @@ public partial interface IImageClient
/// Generate raster image from prompt
///
///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ global::System.Threading.Tasks.Task> GenerateImageRasterAsResponseAsync(
+
+ global::Recraft.GenerateImageRequest request,
+ global::Recraft.BillingType? billing = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default);
+ ///
+ /// Generate raster image from prompt
+ ///
+ ///
///
///
///
diff --git a/src/libs/Recraft/Generated/Recraft.IImageClient.GenerateImageVector.g.cs b/src/libs/Recraft/Generated/Recraft.IImageClient.GenerateImageVector.g.cs
index 257283a..0159af6 100644
--- a/src/libs/Recraft/Generated/Recraft.IImageClient.GenerateImageVector.g.cs
+++ b/src/libs/Recraft/Generated/Recraft.IImageClient.GenerateImageVector.g.cs
@@ -22,6 +22,20 @@ public partial interface IImageClient
/// Generate vector image from prompt
///
///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ global::System.Threading.Tasks.Task> GenerateImageVectorAsResponseAsync(
+
+ global::Recraft.GenerateImageRequest request,
+ global::Recraft.BillingType? billing = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default);
+ ///
+ /// Generate vector image from prompt
+ ///
+ ///
///
///
///
diff --git a/src/libs/Recraft/Generated/Recraft.IImageClient.ImageToImage.g.cs b/src/libs/Recraft/Generated/Recraft.IImageClient.ImageToImage.g.cs
index e023aff..fd1496d 100644
--- a/src/libs/Recraft/Generated/Recraft.IImageClient.ImageToImage.g.cs
+++ b/src/libs/Recraft/Generated/Recraft.IImageClient.ImageToImage.g.cs
@@ -22,6 +22,20 @@ public partial interface IImageClient
/// Generate image from image and prompt
///
///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ global::System.Threading.Tasks.Task> ImageToImageAsResponseAsync(
+
+ global::Recraft.ImageToImageRequest request,
+ global::Recraft.BillingType? billing = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default);
+ ///
+ /// Generate image from image and prompt
+ ///
+ ///
///
///
///
@@ -65,5 +79,104 @@ public partial interface IImageClient
global::System.Collections.Generic.IList? textLayout = default,
global::Recraft.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
+
+ ///
+ /// Generate image from image and prompt
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// The stream to send as the multipart 'image' file part.
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ global::System.Threading.Tasks.Task ImageToImageAsync(
+ global::System.IO.Stream image,
+ string imagename,
+ string prompt,
+ double strength,
+ global::Recraft.BillingType? billing = default,
+ bool? blockNsfw = default,
+ bool? calculateFeatures = default,
+ global::Recraft.UserControls? controls = default,
+ bool? expire = default,
+ global::Recraft.ImageFormat? imageFormat = default,
+ global::Recraft.TransformModel? model = default,
+ int? n = default,
+ string? negativePrompt = default,
+ int? randomSeed = default,
+ global::Recraft.ResponseFormat? responseFormat = default,
+ string? style = default,
+ global::System.Guid? styleId = default,
+ global::Recraft.ImageSubStyle? substyle = default,
+ global::System.Collections.Generic.IList? textLayout = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default);
+ ///
+ /// Generate image from image and prompt
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// The stream to send as the multipart 'image' file part.
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ global::System.Threading.Tasks.Task> ImageToImageAsResponseAsync(
+ global::System.IO.Stream image,
+ string imagename,
+ string prompt,
+ double strength,
+ global::Recraft.BillingType? billing = default,
+ bool? blockNsfw = default,
+ bool? calculateFeatures = default,
+ global::Recraft.UserControls? controls = default,
+ bool? expire = default,
+ global::Recraft.ImageFormat? imageFormat = default,
+ global::Recraft.TransformModel? model = default,
+ int? n = default,
+ string? negativePrompt = default,
+ int? randomSeed = default,
+ global::Recraft.ResponseFormat? responseFormat = default,
+ string? style = default,
+ global::System.Guid? styleId = default,
+ global::Recraft.ImageSubStyle? substyle = default,
+ global::System.Collections.Generic.IList? textLayout = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/Recraft/Generated/Recraft.IImageClient.InpaintImage.g.cs b/src/libs/Recraft/Generated/Recraft.IImageClient.InpaintImage.g.cs
index d025a4e..6f5602c 100644
--- a/src/libs/Recraft/Generated/Recraft.IImageClient.InpaintImage.g.cs
+++ b/src/libs/Recraft/Generated/Recraft.IImageClient.InpaintImage.g.cs
@@ -22,6 +22,20 @@ public partial interface IImageClient
/// Inpaint Image
///
///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ global::System.Threading.Tasks.Task> InpaintImageAsResponseAsync(
+
+ global::Recraft.TransformImageWithMaskRequest request,
+ global::Recraft.BillingType? billing = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default);
+ ///
+ /// Inpaint Image
+ ///
+ ///
/// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
diff --git a/src/libs/Recraft/Generated/Recraft.IImageClient.RemoveBackground.g.cs b/src/libs/Recraft/Generated/Recraft.IImageClient.RemoveBackground.g.cs
index d5f6a14..db079db 100644
--- a/src/libs/Recraft/Generated/Recraft.IImageClient.RemoveBackground.g.cs
+++ b/src/libs/Recraft/Generated/Recraft.IImageClient.RemoveBackground.g.cs
@@ -22,6 +22,20 @@ public partial interface IImageClient
/// Remove background
///
///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ global::System.Threading.Tasks.Task> RemoveBackgroundAsResponseAsync(
+
+ global::Recraft.ProcessImageRequest request,
+ global::Recraft.BillingType? billing = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default);
+ ///
+ /// Remove background
+ ///
+ ///
///
///
///
@@ -41,5 +55,56 @@ public partial interface IImageClient
global::Recraft.UpscaleMode? upscale = default,
global::Recraft.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
+
+ ///
+ /// Remove background
+ ///
+ ///
+ ///
+ ///
+ /// The stream to send as the multipart 'image' file part.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ global::System.Threading.Tasks.Task RemoveBackgroundAsync(
+ global::System.IO.Stream image,
+ string imagename,
+ global::Recraft.BillingType? billing = default,
+ bool? expire = default,
+ global::Recraft.ImageFormat? imageFormat = default,
+ global::Recraft.ResponseFormat? responseFormat = default,
+ global::Recraft.UpscaleMode? upscale = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default);
+ ///
+ /// Remove background
+ ///
+ ///
+ ///
+ ///
+ /// The stream to send as the multipart 'image' file part.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ global::System.Threading.Tasks.Task> RemoveBackgroundAsResponseAsync(
+ global::System.IO.Stream image,
+ string imagename,
+ global::Recraft.BillingType? billing = default,
+ bool? expire = default,
+ global::Recraft.ImageFormat? imageFormat = default,
+ global::Recraft.ResponseFormat? responseFormat = default,
+ global::Recraft.UpscaleMode? upscale = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/Recraft/Generated/Recraft.IImageClient.ReplaceBackground.g.cs b/src/libs/Recraft/Generated/Recraft.IImageClient.ReplaceBackground.g.cs
index b409f71..3d7c3da 100644
--- a/src/libs/Recraft/Generated/Recraft.IImageClient.ReplaceBackground.g.cs
+++ b/src/libs/Recraft/Generated/Recraft.IImageClient.ReplaceBackground.g.cs
@@ -22,6 +22,20 @@ public partial interface IImageClient
/// Replace Background
///
///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ global::System.Threading.Tasks.Task> ReplaceBackgroundAsResponseAsync(
+
+ global::Recraft.TransformImageRequest request,
+ global::Recraft.BillingType? billing = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default);
+ ///
+ /// Replace Background
+ ///
+ ///
///
///
///
@@ -61,5 +75,96 @@ public partial interface IImageClient
global::System.Collections.Generic.IList? textLayout = default,
global::Recraft.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
+
+ ///
+ /// Replace Background
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// The stream to send as the multipart 'image' file part.
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ global::System.Threading.Tasks.Task ReplaceBackgroundAsync(
+ global::System.IO.Stream image,
+ string imagename,
+ string prompt,
+ global::Recraft.BillingType? billing = default,
+ bool? blockNsfw = default,
+ bool? calculateFeatures = default,
+ bool? expire = default,
+ global::Recraft.ImageFormat? imageFormat = default,
+ global::Recraft.TransformModel? model = default,
+ int? n = default,
+ string? negativePrompt = default,
+ int? randomSeed = default,
+ global::Recraft.ResponseFormat? responseFormat = default,
+ string? style = default,
+ global::System.Guid? styleId = default,
+ global::Recraft.ImageSubStyle? substyle = default,
+ global::System.Collections.Generic.IList? textLayout = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default);
+ ///
+ /// Replace Background
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// The stream to send as the multipart 'image' file part.
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ global::System.Threading.Tasks.Task> ReplaceBackgroundAsResponseAsync(
+ global::System.IO.Stream image,
+ string imagename,
+ string prompt,
+ global::Recraft.BillingType? billing = default,
+ bool? blockNsfw = default,
+ bool? calculateFeatures = default,
+ bool? expire = default,
+ global::Recraft.ImageFormat? imageFormat = default,
+ global::Recraft.TransformModel? model = default,
+ int? n = default,
+ string? negativePrompt = default,
+ int? randomSeed = default,
+ global::Recraft.ResponseFormat? responseFormat = default,
+ string? style = default,
+ global::System.Guid? styleId = default,
+ global::Recraft.ImageSubStyle? substyle = default,
+ global::System.Collections.Generic.IList? textLayout = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/Recraft/Generated/Recraft.IImageClient.VariateImage.g.cs b/src/libs/Recraft/Generated/Recraft.IImageClient.VariateImage.g.cs
index 6fdabac..b505a72 100644
--- a/src/libs/Recraft/Generated/Recraft.IImageClient.VariateImage.g.cs
+++ b/src/libs/Recraft/Generated/Recraft.IImageClient.VariateImage.g.cs
@@ -22,6 +22,20 @@ public partial interface IImageClient
/// Variate Image
///
///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ global::System.Threading.Tasks.Task> VariateImageAsResponseAsync(
+
+ global::Recraft.VariateImageRequest request,
+ global::Recraft.BillingType? billing = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default);
+ ///
+ /// Variate Image
+ ///
+ ///
///
///
///
@@ -45,5 +59,64 @@ public partial interface IImageClient
global::Recraft.ResponseFormat? responseFormat = default,
global::Recraft.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
+
+ ///
+ /// Variate Image
+ ///
+ ///
+ ///
+ ///
+ /// The stream to send as the multipart 'image' file part.
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ global::System.Threading.Tasks.Task VariateImageAsync(
+ global::System.IO.Stream image,
+ string imagename,
+ global::Recraft.ImageSize size,
+ global::Recraft.BillingType? billing = default,
+ bool? expire = default,
+ global::Recraft.ImageFormat? imageFormat = default,
+ int? n = default,
+ int? randomSeed = default,
+ global::Recraft.ResponseFormat? responseFormat = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default);
+ ///
+ /// Variate Image
+ ///
+ ///
+ ///
+ ///
+ /// The stream to send as the multipart 'image' file part.
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ global::System.Threading.Tasks.Task> VariateImageAsResponseAsync(
+ global::System.IO.Stream image,
+ string imagename,
+ global::Recraft.ImageSize size,
+ global::Recraft.BillingType? billing = default,
+ bool? expire = default,
+ global::Recraft.ImageFormat? imageFormat = default,
+ int? n = default,
+ int? randomSeed = default,
+ global::Recraft.ResponseFormat? responseFormat = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/Recraft/Generated/Recraft.IImageClient.VectorizeImage.g.cs b/src/libs/Recraft/Generated/Recraft.IImageClient.VectorizeImage.g.cs
index 68bae9a..b1dc726 100644
--- a/src/libs/Recraft/Generated/Recraft.IImageClient.VectorizeImage.g.cs
+++ b/src/libs/Recraft/Generated/Recraft.IImageClient.VectorizeImage.g.cs
@@ -22,6 +22,20 @@ public partial interface IImageClient
/// Vectorize image
///
///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ global::System.Threading.Tasks.Task> VectorizeImageAsResponseAsync(
+
+ global::Recraft.VectorizeImageRequest request,
+ global::Recraft.BillingType? billing = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default);
+ ///
+ /// Vectorize image
+ ///
+ ///
/// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
diff --git a/src/libs/Recraft/Generated/Recraft.IRecraftClient.GetPing.g.cs b/src/libs/Recraft/Generated/Recraft.IRecraftClient.GetPing.g.cs
index 8b74a94..5460ef2 100644
--- a/src/libs/Recraft/Generated/Recraft.IRecraftClient.GetPing.g.cs
+++ b/src/libs/Recraft/Generated/Recraft.IRecraftClient.GetPing.g.cs
@@ -13,5 +13,14 @@ public partial interface IRecraftClient
global::System.Threading.Tasks.Task GetPingAsync(
global::Recraft.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
+ ///
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ global::System.Threading.Tasks.Task GetPingAsResponseAsync(
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/Recraft/Generated/Recraft.IRecraftClient.GetSystemStatus.g.cs b/src/libs/Recraft/Generated/Recraft.IRecraftClient.GetSystemStatus.g.cs
index a949f63..326e780 100644
--- a/src/libs/Recraft/Generated/Recraft.IRecraftClient.GetSystemStatus.g.cs
+++ b/src/libs/Recraft/Generated/Recraft.IRecraftClient.GetSystemStatus.g.cs
@@ -13,5 +13,14 @@ public partial interface IRecraftClient
global::System.Threading.Tasks.Task GetSystemStatusAsync(
global::Recraft.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
+ ///
+ /// Get System Status
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ global::System.Threading.Tasks.Task> GetSystemStatusAsResponseAsync(
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/Recraft/Generated/Recraft.IStyleClient.CreateStyle.g.cs b/src/libs/Recraft/Generated/Recraft.IStyleClient.CreateStyle.g.cs
index f125006..7ce776e 100644
--- a/src/libs/Recraft/Generated/Recraft.IStyleClient.CreateStyle.g.cs
+++ b/src/libs/Recraft/Generated/Recraft.IStyleClient.CreateStyle.g.cs
@@ -22,6 +22,20 @@ public partial interface IStyleClient
/// Create Style
///
///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ global::System.Threading.Tasks.Task> CreateStyleAsResponseAsync(
+
+ global::Recraft.CreateStyleRequest request,
+ global::Recraft.BillingType? billing = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default);
+ ///
+ /// Create Style
+ ///
+ ///
///
///
///
@@ -49,5 +63,80 @@ public partial interface IStyleClient
global::System.Collections.Generic.IList? sourceStyles = default,
global::Recraft.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
+
+ ///
+ /// Create Style
+ ///
+ ///
+ ///
+ ///
+ /// The streams to send as multipart 'images' file parts.
+ ///
+ ///
+ /// Optional file names to use for the multipart 'images' file parts.
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ global::System.Threading.Tasks.Task CreateStyleAsync(
+ global::System.Collections.Generic.IReadOnlyList images,
+ global::Recraft.ImageStyle style,
+ global::Recraft.BillingType? billing = default,
+ global::System.Collections.Generic.IList? imageWeights = default,
+ global::System.Collections.Generic.IReadOnlyList? imagesFileNames = default,
+ global::Recraft.MixPolicy? mixPolicy = default,
+ global::Recraft.TransformModel? model = default,
+ global::Recraft.PaletteSuggest? palette = default,
+ bool? @private = default,
+ string? prompt = default,
+ global::System.Collections.Generic.IList? sourceStyleWeights = default,
+ global::System.Collections.Generic.IList? sourceStyles = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default);
+ ///
+ /// Create Style
+ ///
+ ///
+ ///
+ ///
+ /// The streams to send as multipart 'images' file parts.
+ ///
+ ///
+ /// Optional file names to use for the multipart 'images' file parts.
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ global::System.Threading.Tasks.Task> CreateStyleAsResponseAsync(
+ global::System.Collections.Generic.IReadOnlyList images,
+ global::Recraft.ImageStyle style,
+ global::Recraft.BillingType? billing = default,
+ global::System.Collections.Generic.IList? imageWeights = default,
+ global::System.Collections.Generic.IReadOnlyList? imagesFileNames = default,
+ global::Recraft.MixPolicy? mixPolicy = default,
+ global::Recraft.TransformModel? model = default,
+ global::Recraft.PaletteSuggest? palette = default,
+ bool? @private = default,
+ string? prompt = default,
+ global::System.Collections.Generic.IList? sourceStyleWeights = default,
+ global::System.Collections.Generic.IList? sourceStyles = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/Recraft/Generated/Recraft.IStyleClient.DeleteStyle.g.cs b/src/libs/Recraft/Generated/Recraft.IStyleClient.DeleteStyle.g.cs
index 4648e9c..af07ec0 100644
--- a/src/libs/Recraft/Generated/Recraft.IStyleClient.DeleteStyle.g.cs
+++ b/src/libs/Recraft/Generated/Recraft.IStyleClient.DeleteStyle.g.cs
@@ -15,5 +15,16 @@ public partial interface IStyleClient
global::System.Guid styleId,
global::Recraft.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
+ ///
+ /// Delete Style
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ global::System.Threading.Tasks.Task> DeleteStyleAsResponseAsync(
+ global::System.Guid styleId,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/Recraft/Generated/Recraft.IStyleClient.GetStyle.g.cs b/src/libs/Recraft/Generated/Recraft.IStyleClient.GetStyle.g.cs
index fc0ac38..f2c912f 100644
--- a/src/libs/Recraft/Generated/Recraft.IStyleClient.GetStyle.g.cs
+++ b/src/libs/Recraft/Generated/Recraft.IStyleClient.GetStyle.g.cs
@@ -15,5 +15,16 @@ public partial interface IStyleClient
global::System.Guid styleId,
global::Recraft.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
+ ///
+ /// Get Style
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ global::System.Threading.Tasks.Task> GetStyleAsResponseAsync(
+ global::System.Guid styleId,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/Recraft/Generated/Recraft.IStyleClient.ListBasicStyles.g.cs b/src/libs/Recraft/Generated/Recraft.IStyleClient.ListBasicStyles.g.cs
index ba3411f..c708648 100644
--- a/src/libs/Recraft/Generated/Recraft.IStyleClient.ListBasicStyles.g.cs
+++ b/src/libs/Recraft/Generated/Recraft.IStyleClient.ListBasicStyles.g.cs
@@ -13,5 +13,14 @@ public partial interface IStyleClient
global::System.Threading.Tasks.Task ListBasicStylesAsync(
global::Recraft.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
+ ///
+ /// List Basic Styles
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ global::System.Threading.Tasks.Task> ListBasicStylesAsResponseAsync(
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/Recraft/Generated/Recraft.IStyleClient.ListStyles.g.cs b/src/libs/Recraft/Generated/Recraft.IStyleClient.ListStyles.g.cs
index 73a037a..108f209 100644
--- a/src/libs/Recraft/Generated/Recraft.IStyleClient.ListStyles.g.cs
+++ b/src/libs/Recraft/Generated/Recraft.IStyleClient.ListStyles.g.cs
@@ -13,5 +13,14 @@ public partial interface IStyleClient
global::System.Threading.Tasks.Task ListStylesAsync(
global::Recraft.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
+ ///
+ /// List Styles
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ global::System.Threading.Tasks.Task> ListStylesAsResponseAsync(
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/Recraft/Generated/Recraft.IUserClient.GetCurrentUser.g.cs b/src/libs/Recraft/Generated/Recraft.IUserClient.GetCurrentUser.g.cs
index 0adfd11..58f9fb2 100644
--- a/src/libs/Recraft/Generated/Recraft.IUserClient.GetCurrentUser.g.cs
+++ b/src/libs/Recraft/Generated/Recraft.IUserClient.GetCurrentUser.g.cs
@@ -15,5 +15,16 @@ public partial interface IUserClient
global::Recraft.BillingType? billing = default,
global::Recraft.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
+ ///
+ /// Get current user info
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ global::System.Threading.Tasks.Task> GetCurrentUserAsResponseAsync(
+ global::Recraft.BillingType? billing = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/Recraft/Generated/Recraft.ImageClient.CreativeUpscale.g.cs b/src/libs/Recraft/Generated/Recraft.ImageClient.CreativeUpscale.g.cs
index 4260990..e502059 100644
--- a/src/libs/Recraft/Generated/Recraft.ImageClient.CreativeUpscale.g.cs
+++ b/src/libs/Recraft/Generated/Recraft.ImageClient.CreativeUpscale.g.cs
@@ -53,6 +53,31 @@ partial void ProcessCreativeUpscaleResponseContent(
///
public async global::System.Threading.Tasks.Task CreativeUpscaleAsync(
+ global::Recraft.ProcessImageRequest request,
+ global::Recraft.BillingType? billing = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+ var __response = await CreativeUpscaleAsResponseAsync(
+
+ request: request,
+ billing: billing,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken
+ ).ConfigureAwait(false);
+
+ return __response.Body;
+ }
+ ///
+ /// Creative Upscale
+ ///
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> CreativeUpscaleAsResponseAsync(
+
global::Recraft.ProcessImageRequest request,
global::Recraft.BillingType? billing = default,
global::Recraft.AutoSDKRequestOptions? requestOptions = default,
@@ -85,15 +110,16 @@ partial void ProcessCreativeUpscaleResponseContent(
var __maxAttempts = global::Recraft.AutoSDKRequestOptionsSupport.GetMaxAttempts(
clientOptions: Options,
requestOptions: requestOptions,
- supportsRetry: true);
+ supportsRetry: false);
global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{
+
var __pathBuilder = new global::Recraft.PathBuilder(
path: "/v1/images/creativeUpscale",
- baseUri: HttpClient.BaseAddress);
+ baseUri: HttpClient.BaseAddress);
__pathBuilder
- .AddOptionalParameter("billing", billing?.ToValueString())
+ .AddOptionalParameter("billing", billing?.ToValueString())
;
var __path = __pathBuilder.ToString();
__path = global::Recraft.AutoSDKRequestOptionsSupport.AppendQueryParameters(
@@ -124,6 +150,7 @@ partial void ProcessCreativeUpscaleResponseContent(
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
}
}
+
var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
if (billing != default)
{
@@ -131,13 +158,15 @@ partial void ProcessCreativeUpscaleResponseContent(
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((billing).HasValue ? (billing).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"billing\"");
- }
+
+ }
if (request.Expire != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.Expire, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()),
name: "\"expire\"");
+
}
var __contentImage = new global::System.Net.Http.ByteArrayContent(request.Image ?? global::System.Array.Empty());
__contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
@@ -176,28 +205,34 @@ request.Imagename is null
{
__contentImage.Headers.ContentDisposition.FileNameStar = null;
}
+
if (request.ImageFormat != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.ImageFormat).HasValue ? (request.ImageFormat).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"image_format\"");
- }
+
+ }
if (request.ResponseFormat != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.ResponseFormat).HasValue ? (request.ResponseFormat).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"response_format\"");
- }
+
+ }
if (request.Upscale != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.Upscale).HasValue ? (request.Upscale).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"upscale\"");
+
}
+
__httpRequest.Content = __httpRequestContent;
+
global::Recraft.AutoSDKRequestOptionsSupport.ApplyHeaders(
request: __httpRequest,
clientHeaders: Options.Headers,
@@ -240,6 +275,8 @@ request.Imagename is null
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
@@ -250,6 +287,11 @@ request.Imagename is null
}
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,
@@ -267,6 +309,8 @@ request.Imagename is null
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
if (!__willRetry)
{
@@ -276,8 +320,7 @@ request.Imagename is null
__httpRequest.Dispose();
__httpRequest = null;
await global::Recraft.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -286,6 +329,11 @@ request.Imagename is null
__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(
@@ -302,14 +350,15 @@ request.Imagename is null
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;
}
@@ -349,6 +398,8 @@ request.Imagename is null
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
else
@@ -369,6 +420,8 @@ request.Imagename is null
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
@@ -393,9 +446,13 @@ request.Imagename is null
{
__response.EnsureSuccessStatusCode();
- return
- global::Recraft.ProcessImageResponse.FromJson(__content, JsonSerializerContext) ??
+ var __value = global::Recraft.ProcessImageResponse.FromJson(__content, JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
@@ -423,9 +480,13 @@ request.Imagename is null
#endif
).ConfigureAwait(false);
- return
- await global::Recraft.ProcessImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ var __value = await global::Recraft.ProcessImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
@@ -503,5 +564,950 @@ request.Imagename is null
requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
+
+ ///
+ /// Creative Upscale
+ ///
+ ///
+ ///
+ ///
+ /// The stream to send as the multipart 'image' file part.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task CreativeUpscaleAsync(
+ global::System.IO.Stream image,
+ string imagename,
+ global::Recraft.BillingType? billing = default,
+ bool? expire = default,
+ global::Recraft.ImageFormat? imageFormat = default,
+ global::Recraft.ResponseFormat? responseFormat = default,
+ global::Recraft.UpscaleMode? upscale = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+
+ image = image ?? throw new global::System.ArgumentNullException(nameof(image));
+ var request = new global::Recraft.ProcessImageRequest
+ {
+ Expire = expire,
+ Image = global::System.Array.Empty(),
+ Imagename = imagename,
+ ImageFormat = imageFormat,
+ ResponseFormat = responseFormat,
+ Upscale = upscale,
+ };
+ PrepareArguments(
+ client: HttpClient);
+ PrepareCreativeUpscaleArguments(
+ httpClient: HttpClient,
+ billing: ref billing,
+ request: request);
+
+
+ var __authorizations = global::Recraft.EndPointSecurityResolver.ResolveAuthorizations(
+ availableAuthorizations: Authorizations,
+ securityRequirements: s_CreativeUpscaleSecurityRequirements,
+ operationName: "CreativeUpscaleAsync");
+
+ using var __timeoutCancellationTokenSource = global::Recraft.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Recraft.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Recraft.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: false);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+
+ var __pathBuilder = new global::Recraft.PathBuilder(
+ path: "/v1/images/creativeUpscale",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("billing", billing?.ToValueString())
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::Recraft.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+#if NET6_0_OR_GREATER
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+#endif
+
+ foreach (var __authorization in __authorizations)
+ {
+ if (__authorization.Type == "Http" ||
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
+ {
+ __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
+ scheme: __authorization.Name,
+ parameter: __authorization.Value);
+ }
+ else if (__authorization.Type == "ApiKey" &&
+ __authorization.Location == "Header")
+ {
+ __httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
+ }
+ }
+
+ var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
+ if (billing != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((billing).HasValue ? (billing).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"billing\"");
+
+ }
+ if (request.Expire != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.Expire, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()),
+ name: "\"expire\"");
+
+ }
+ var __contentImage = new global::System.Net.Http.StreamContent(image);
+ __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ request.Imagename is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(request.Imagename) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentImage,
+ name: "\"image\"",
+ fileName: request.Imagename != null ? $"\"{request.Imagename}\"" : string.Empty);
+ if (__contentImage.Headers.ContentDisposition != null)
+ {
+ __contentImage.Headers.ContentDisposition.FileNameStar = null;
+ }
+
+ if (request.ImageFormat != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.ImageFormat).HasValue ? (request.ImageFormat).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"image_format\"");
+
+ }
+ if (request.ResponseFormat != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.ResponseFormat).HasValue ? (request.ResponseFormat).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"response_format\"");
+
+ }
+ if (request.Upscale != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.Upscale).HasValue ? (request.Upscale).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"upscale\"");
+
+ }
+
+ __httpRequest.Content = __httpRequestContent;
+
+ global::Recraft.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
+
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareCreativeUpscaleRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ billing: billing,
+ request: request);
+
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
+ {
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
+ {
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Recraft.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreativeUpscale",
+ methodName: "CreativeUpscaleAsync",
+ pathTemplate: "\"/v1/images/creativeUpscale\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
+ {
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ }
+ 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,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreativeUpscale",
+ methodName: "CreativeUpscaleAsync",
+ pathTemplate: "\"/v1/images/creativeUpscale\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Recraft.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __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(
+ operationId: "CreativeUpscale",
+ methodName: "CreativeUpscaleAsync",
+ pathTemplate: "\"/v1/images/creativeUpscale\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ 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(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
+ }
+
+ if (__response == null)
+ {
+ throw new global::System.InvalidOperationException("No response received.");
+ }
+
+ using (__response)
+ {
+
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessCreativeUpscaleResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Recraft.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreativeUpscale",
+ methodName: "CreativeUpscaleAsync",
+ pathTemplate: "\"/v1/images/creativeUpscale\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ else
+ {
+ await global::Recraft.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreativeUpscale",
+ methodName: "CreativeUpscaleAsync",
+ pathTemplate: "\"/v1/images/creativeUpscale\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessCreativeUpscaleResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Recraft.ProcessImageResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Recraft.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ await global::Recraft.ProcessImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Recraft.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
+ }
+ ///
+ /// Creative Upscale
+ ///
+ ///
+ ///
+ ///
+ /// The stream to send as the multipart 'image' file part.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> CreativeUpscaleAsResponseAsync(
+ global::System.IO.Stream image,
+ string imagename,
+ global::Recraft.BillingType? billing = default,
+ bool? expire = default,
+ global::Recraft.ImageFormat? imageFormat = default,
+ global::Recraft.ResponseFormat? responseFormat = default,
+ global::Recraft.UpscaleMode? upscale = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+
+ image = image ?? throw new global::System.ArgumentNullException(nameof(image));
+ var request = new global::Recraft.ProcessImageRequest
+ {
+ Expire = expire,
+ Image = global::System.Array.Empty(),
+ Imagename = imagename,
+ ImageFormat = imageFormat,
+ ResponseFormat = responseFormat,
+ Upscale = upscale,
+ };
+ PrepareArguments(
+ client: HttpClient);
+ PrepareCreativeUpscaleArguments(
+ httpClient: HttpClient,
+ billing: ref billing,
+ request: request);
+
+
+ var __authorizations = global::Recraft.EndPointSecurityResolver.ResolveAuthorizations(
+ availableAuthorizations: Authorizations,
+ securityRequirements: s_CreativeUpscaleSecurityRequirements,
+ operationName: "CreativeUpscaleAsync");
+
+ using var __timeoutCancellationTokenSource = global::Recraft.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Recraft.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Recraft.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: false);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+
+ var __pathBuilder = new global::Recraft.PathBuilder(
+ path: "/v1/images/creativeUpscale",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("billing", billing?.ToValueString())
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::Recraft.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+#if NET6_0_OR_GREATER
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+#endif
+
+ foreach (var __authorization in __authorizations)
+ {
+ if (__authorization.Type == "Http" ||
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
+ {
+ __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
+ scheme: __authorization.Name,
+ parameter: __authorization.Value);
+ }
+ else if (__authorization.Type == "ApiKey" &&
+ __authorization.Location == "Header")
+ {
+ __httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
+ }
+ }
+
+ var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
+ if (billing != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((billing).HasValue ? (billing).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"billing\"");
+
+ }
+ if (request.Expire != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.Expire, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()),
+ name: "\"expire\"");
+
+ }
+ var __contentImage = new global::System.Net.Http.StreamContent(image);
+ __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ request.Imagename is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(request.Imagename) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentImage,
+ name: "\"image\"",
+ fileName: request.Imagename != null ? $"\"{request.Imagename}\"" : string.Empty);
+ if (__contentImage.Headers.ContentDisposition != null)
+ {
+ __contentImage.Headers.ContentDisposition.FileNameStar = null;
+ }
+
+ if (request.ImageFormat != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.ImageFormat).HasValue ? (request.ImageFormat).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"image_format\"");
+
+ }
+ if (request.ResponseFormat != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.ResponseFormat).HasValue ? (request.ResponseFormat).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"response_format\"");
+
+ }
+ if (request.Upscale != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.Upscale).HasValue ? (request.Upscale).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"upscale\"");
+
+ }
+
+ __httpRequest.Content = __httpRequestContent;
+
+ global::Recraft.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
+
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareCreativeUpscaleRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ billing: billing,
+ request: request);
+
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
+ {
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
+ {
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Recraft.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreativeUpscale",
+ methodName: "CreativeUpscaleAsync",
+ pathTemplate: "\"/v1/images/creativeUpscale\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
+ {
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ }
+ 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,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreativeUpscale",
+ methodName: "CreativeUpscaleAsync",
+ pathTemplate: "\"/v1/images/creativeUpscale\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Recraft.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __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(
+ operationId: "CreativeUpscale",
+ methodName: "CreativeUpscaleAsync",
+ pathTemplate: "\"/v1/images/creativeUpscale\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ 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(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
+ }
+
+ if (__response == null)
+ {
+ throw new global::System.InvalidOperationException("No response received.");
+ }
+
+ using (__response)
+ {
+
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessCreativeUpscaleResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Recraft.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreativeUpscale",
+ methodName: "CreativeUpscaleAsync",
+ pathTemplate: "\"/v1/images/creativeUpscale\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ else
+ {
+ await global::Recraft.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreativeUpscale",
+ methodName: "CreativeUpscaleAsync",
+ pathTemplate: "\"/v1/images/creativeUpscale\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessCreativeUpscaleResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ var __value = global::Recraft.ProcessImageResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Recraft.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ var __value = await global::Recraft.ProcessImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Recraft.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
+ }
}
}
\ No newline at end of file
diff --git a/src/libs/Recraft/Generated/Recraft.ImageClient.CrispUpscale.g.cs b/src/libs/Recraft/Generated/Recraft.ImageClient.CrispUpscale.g.cs
index d1070bd..60565af 100644
--- a/src/libs/Recraft/Generated/Recraft.ImageClient.CrispUpscale.g.cs
+++ b/src/libs/Recraft/Generated/Recraft.ImageClient.CrispUpscale.g.cs
@@ -53,6 +53,31 @@ partial void ProcessCrispUpscaleResponseContent(
///
public async global::System.Threading.Tasks.Task CrispUpscaleAsync(
+ global::Recraft.ProcessImageRequest request,
+ global::Recraft.BillingType? billing = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+ var __response = await CrispUpscaleAsResponseAsync(
+
+ request: request,
+ billing: billing,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken
+ ).ConfigureAwait(false);
+
+ return __response.Body;
+ }
+ ///
+ /// Crisp Upscale
+ ///
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> CrispUpscaleAsResponseAsync(
+
global::Recraft.ProcessImageRequest request,
global::Recraft.BillingType? billing = default,
global::Recraft.AutoSDKRequestOptions? requestOptions = default,
@@ -85,15 +110,16 @@ partial void ProcessCrispUpscaleResponseContent(
var __maxAttempts = global::Recraft.AutoSDKRequestOptionsSupport.GetMaxAttempts(
clientOptions: Options,
requestOptions: requestOptions,
- supportsRetry: true);
+ supportsRetry: false);
global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{
+
var __pathBuilder = new global::Recraft.PathBuilder(
path: "/v1/images/crispUpscale",
- baseUri: HttpClient.BaseAddress);
+ baseUri: HttpClient.BaseAddress);
__pathBuilder
- .AddOptionalParameter("billing", billing?.ToValueString())
+ .AddOptionalParameter("billing", billing?.ToValueString())
;
var __path = __pathBuilder.ToString();
__path = global::Recraft.AutoSDKRequestOptionsSupport.AppendQueryParameters(
@@ -124,6 +150,7 @@ partial void ProcessCrispUpscaleResponseContent(
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
}
}
+
var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
if (billing != default)
{
@@ -131,13 +158,15 @@ partial void ProcessCrispUpscaleResponseContent(
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((billing).HasValue ? (billing).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"billing\"");
- }
+
+ }
if (request.Expire != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.Expire, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()),
name: "\"expire\"");
+
}
var __contentImage = new global::System.Net.Http.ByteArrayContent(request.Image ?? global::System.Array.Empty());
__contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
@@ -176,28 +205,34 @@ request.Imagename is null
{
__contentImage.Headers.ContentDisposition.FileNameStar = null;
}
+
if (request.ImageFormat != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.ImageFormat).HasValue ? (request.ImageFormat).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"image_format\"");
- }
+
+ }
if (request.ResponseFormat != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.ResponseFormat).HasValue ? (request.ResponseFormat).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"response_format\"");
- }
+
+ }
if (request.Upscale != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.Upscale).HasValue ? (request.Upscale).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"upscale\"");
+
}
+
__httpRequest.Content = __httpRequestContent;
+
global::Recraft.AutoSDKRequestOptionsSupport.ApplyHeaders(
request: __httpRequest,
clientHeaders: Options.Headers,
@@ -240,6 +275,8 @@ request.Imagename is null
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
@@ -250,6 +287,11 @@ request.Imagename is null
}
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,
@@ -267,6 +309,8 @@ request.Imagename is null
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
if (!__willRetry)
{
@@ -276,8 +320,7 @@ request.Imagename is null
__httpRequest.Dispose();
__httpRequest = null;
await global::Recraft.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -286,6 +329,11 @@ request.Imagename is null
__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(
@@ -302,14 +350,15 @@ request.Imagename is null
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;
}
@@ -349,6 +398,8 @@ request.Imagename is null
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
else
@@ -369,6 +420,8 @@ request.Imagename is null
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
@@ -393,9 +446,13 @@ request.Imagename is null
{
__response.EnsureSuccessStatusCode();
- return
- global::Recraft.ProcessImageResponse.FromJson(__content, JsonSerializerContext) ??
+ var __value = global::Recraft.ProcessImageResponse.FromJson(__content, JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
@@ -423,9 +480,13 @@ request.Imagename is null
#endif
).ConfigureAwait(false);
- return
- await global::Recraft.ProcessImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ var __value = await global::Recraft.ProcessImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
@@ -503,5 +564,950 @@ request.Imagename is null
requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
+
+ ///
+ /// Crisp Upscale
+ ///
+ ///
+ ///
+ ///
+ /// The stream to send as the multipart 'image' file part.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task CrispUpscaleAsync(
+ global::System.IO.Stream image,
+ string imagename,
+ global::Recraft.BillingType? billing = default,
+ bool? expire = default,
+ global::Recraft.ImageFormat? imageFormat = default,
+ global::Recraft.ResponseFormat? responseFormat = default,
+ global::Recraft.UpscaleMode? upscale = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+
+ image = image ?? throw new global::System.ArgumentNullException(nameof(image));
+ var request = new global::Recraft.ProcessImageRequest
+ {
+ Expire = expire,
+ Image = global::System.Array.Empty(),
+ Imagename = imagename,
+ ImageFormat = imageFormat,
+ ResponseFormat = responseFormat,
+ Upscale = upscale,
+ };
+ PrepareArguments(
+ client: HttpClient);
+ PrepareCrispUpscaleArguments(
+ httpClient: HttpClient,
+ billing: ref billing,
+ request: request);
+
+
+ var __authorizations = global::Recraft.EndPointSecurityResolver.ResolveAuthorizations(
+ availableAuthorizations: Authorizations,
+ securityRequirements: s_CrispUpscaleSecurityRequirements,
+ operationName: "CrispUpscaleAsync");
+
+ using var __timeoutCancellationTokenSource = global::Recraft.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Recraft.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Recraft.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: false);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+
+ var __pathBuilder = new global::Recraft.PathBuilder(
+ path: "/v1/images/crispUpscale",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("billing", billing?.ToValueString())
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::Recraft.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+#if NET6_0_OR_GREATER
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+#endif
+
+ foreach (var __authorization in __authorizations)
+ {
+ if (__authorization.Type == "Http" ||
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
+ {
+ __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
+ scheme: __authorization.Name,
+ parameter: __authorization.Value);
+ }
+ else if (__authorization.Type == "ApiKey" &&
+ __authorization.Location == "Header")
+ {
+ __httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
+ }
+ }
+
+ var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
+ if (billing != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((billing).HasValue ? (billing).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"billing\"");
+
+ }
+ if (request.Expire != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.Expire, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()),
+ name: "\"expire\"");
+
+ }
+ var __contentImage = new global::System.Net.Http.StreamContent(image);
+ __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ request.Imagename is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(request.Imagename) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentImage,
+ name: "\"image\"",
+ fileName: request.Imagename != null ? $"\"{request.Imagename}\"" : string.Empty);
+ if (__contentImage.Headers.ContentDisposition != null)
+ {
+ __contentImage.Headers.ContentDisposition.FileNameStar = null;
+ }
+
+ if (request.ImageFormat != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.ImageFormat).HasValue ? (request.ImageFormat).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"image_format\"");
+
+ }
+ if (request.ResponseFormat != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.ResponseFormat).HasValue ? (request.ResponseFormat).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"response_format\"");
+
+ }
+ if (request.Upscale != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.Upscale).HasValue ? (request.Upscale).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"upscale\"");
+
+ }
+
+ __httpRequest.Content = __httpRequestContent;
+
+ global::Recraft.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
+
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareCrispUpscaleRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ billing: billing,
+ request: request);
+
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
+ {
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
+ {
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Recraft.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CrispUpscale",
+ methodName: "CrispUpscaleAsync",
+ pathTemplate: "\"/v1/images/crispUpscale\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
+ {
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ }
+ 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,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CrispUpscale",
+ methodName: "CrispUpscaleAsync",
+ pathTemplate: "\"/v1/images/crispUpscale\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Recraft.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __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(
+ operationId: "CrispUpscale",
+ methodName: "CrispUpscaleAsync",
+ pathTemplate: "\"/v1/images/crispUpscale\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ 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(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
+ }
+
+ if (__response == null)
+ {
+ throw new global::System.InvalidOperationException("No response received.");
+ }
+
+ using (__response)
+ {
+
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessCrispUpscaleResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Recraft.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CrispUpscale",
+ methodName: "CrispUpscaleAsync",
+ pathTemplate: "\"/v1/images/crispUpscale\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ else
+ {
+ await global::Recraft.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CrispUpscale",
+ methodName: "CrispUpscaleAsync",
+ pathTemplate: "\"/v1/images/crispUpscale\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessCrispUpscaleResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Recraft.ProcessImageResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Recraft.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ await global::Recraft.ProcessImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Recraft.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
+ }
+ ///
+ /// Crisp Upscale
+ ///
+ ///
+ ///
+ ///
+ /// The stream to send as the multipart 'image' file part.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> CrispUpscaleAsResponseAsync(
+ global::System.IO.Stream image,
+ string imagename,
+ global::Recraft.BillingType? billing = default,
+ bool? expire = default,
+ global::Recraft.ImageFormat? imageFormat = default,
+ global::Recraft.ResponseFormat? responseFormat = default,
+ global::Recraft.UpscaleMode? upscale = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+
+ image = image ?? throw new global::System.ArgumentNullException(nameof(image));
+ var request = new global::Recraft.ProcessImageRequest
+ {
+ Expire = expire,
+ Image = global::System.Array.Empty(),
+ Imagename = imagename,
+ ImageFormat = imageFormat,
+ ResponseFormat = responseFormat,
+ Upscale = upscale,
+ };
+ PrepareArguments(
+ client: HttpClient);
+ PrepareCrispUpscaleArguments(
+ httpClient: HttpClient,
+ billing: ref billing,
+ request: request);
+
+
+ var __authorizations = global::Recraft.EndPointSecurityResolver.ResolveAuthorizations(
+ availableAuthorizations: Authorizations,
+ securityRequirements: s_CrispUpscaleSecurityRequirements,
+ operationName: "CrispUpscaleAsync");
+
+ using var __timeoutCancellationTokenSource = global::Recraft.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Recraft.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Recraft.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: false);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+
+ var __pathBuilder = new global::Recraft.PathBuilder(
+ path: "/v1/images/crispUpscale",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("billing", billing?.ToValueString())
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::Recraft.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+#if NET6_0_OR_GREATER
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+#endif
+
+ foreach (var __authorization in __authorizations)
+ {
+ if (__authorization.Type == "Http" ||
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
+ {
+ __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
+ scheme: __authorization.Name,
+ parameter: __authorization.Value);
+ }
+ else if (__authorization.Type == "ApiKey" &&
+ __authorization.Location == "Header")
+ {
+ __httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
+ }
+ }
+
+ var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
+ if (billing != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((billing).HasValue ? (billing).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"billing\"");
+
+ }
+ if (request.Expire != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.Expire, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()),
+ name: "\"expire\"");
+
+ }
+ var __contentImage = new global::System.Net.Http.StreamContent(image);
+ __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ request.Imagename is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(request.Imagename) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentImage,
+ name: "\"image\"",
+ fileName: request.Imagename != null ? $"\"{request.Imagename}\"" : string.Empty);
+ if (__contentImage.Headers.ContentDisposition != null)
+ {
+ __contentImage.Headers.ContentDisposition.FileNameStar = null;
+ }
+
+ if (request.ImageFormat != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.ImageFormat).HasValue ? (request.ImageFormat).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"image_format\"");
+
+ }
+ if (request.ResponseFormat != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.ResponseFormat).HasValue ? (request.ResponseFormat).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"response_format\"");
+
+ }
+ if (request.Upscale != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.Upscale).HasValue ? (request.Upscale).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"upscale\"");
+
+ }
+
+ __httpRequest.Content = __httpRequestContent;
+
+ global::Recraft.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
+
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareCrispUpscaleRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ billing: billing,
+ request: request);
+
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
+ {
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
+ {
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Recraft.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CrispUpscale",
+ methodName: "CrispUpscaleAsync",
+ pathTemplate: "\"/v1/images/crispUpscale\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
+ {
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ }
+ 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,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CrispUpscale",
+ methodName: "CrispUpscaleAsync",
+ pathTemplate: "\"/v1/images/crispUpscale\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Recraft.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __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(
+ operationId: "CrispUpscale",
+ methodName: "CrispUpscaleAsync",
+ pathTemplate: "\"/v1/images/crispUpscale\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ 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(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
+ }
+
+ if (__response == null)
+ {
+ throw new global::System.InvalidOperationException("No response received.");
+ }
+
+ using (__response)
+ {
+
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessCrispUpscaleResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Recraft.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CrispUpscale",
+ methodName: "CrispUpscaleAsync",
+ pathTemplate: "\"/v1/images/crispUpscale\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ else
+ {
+ await global::Recraft.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CrispUpscale",
+ methodName: "CrispUpscaleAsync",
+ pathTemplate: "\"/v1/images/crispUpscale\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessCrispUpscaleResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ var __value = global::Recraft.ProcessImageResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Recraft.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ var __value = await global::Recraft.ProcessImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Recraft.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
+ }
}
}
\ No newline at end of file
diff --git a/src/libs/Recraft/Generated/Recraft.ImageClient.EraseRegion.g.cs b/src/libs/Recraft/Generated/Recraft.ImageClient.EraseRegion.g.cs
index b536e9d..1288899 100644
--- a/src/libs/Recraft/Generated/Recraft.ImageClient.EraseRegion.g.cs
+++ b/src/libs/Recraft/Generated/Recraft.ImageClient.EraseRegion.g.cs
@@ -53,6 +53,31 @@ partial void ProcessEraseRegionResponseContent(
///
public async global::System.Threading.Tasks.Task EraseRegionAsync(
+ global::Recraft.EraseRegionRequest request,
+ global::Recraft.BillingType? billing = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+ var __response = await EraseRegionAsResponseAsync(
+
+ request: request,
+ billing: billing,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken
+ ).ConfigureAwait(false);
+
+ return __response.Body;
+ }
+ ///
+ /// Erase Region
+ ///
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> EraseRegionAsResponseAsync(
+
global::Recraft.EraseRegionRequest request,
global::Recraft.BillingType? billing = default,
global::Recraft.AutoSDKRequestOptions? requestOptions = default,
@@ -85,15 +110,16 @@ partial void ProcessEraseRegionResponseContent(
var __maxAttempts = global::Recraft.AutoSDKRequestOptionsSupport.GetMaxAttempts(
clientOptions: Options,
requestOptions: requestOptions,
- supportsRetry: true);
+ supportsRetry: false);
global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{
+
var __pathBuilder = new global::Recraft.PathBuilder(
path: "/v1/images/eraseRegion",
- baseUri: HttpClient.BaseAddress);
+ baseUri: HttpClient.BaseAddress);
__pathBuilder
- .AddOptionalParameter("billing", billing?.ToValueString())
+ .AddOptionalParameter("billing", billing?.ToValueString())
;
var __path = __pathBuilder.ToString();
__path = global::Recraft.AutoSDKRequestOptionsSupport.AppendQueryParameters(
@@ -124,6 +150,7 @@ partial void ProcessEraseRegionResponseContent(
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
}
}
+
var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
if (billing != default)
{
@@ -131,13 +158,15 @@ partial void ProcessEraseRegionResponseContent(
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((billing).HasValue ? (billing).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"billing\"");
- }
+
+ }
if (request.Expire != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.Expire, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()),
name: "\"expire\"");
+
}
var __contentImage = new global::System.Net.Http.ByteArrayContent(request.Image ?? global::System.Array.Empty());
__contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
@@ -176,12 +205,14 @@ request.Imagename is null
{
__contentImage.Headers.ContentDisposition.FileNameStar = null;
}
+
if (request.ImageFormat != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.ImageFormat).HasValue ? (request.ImageFormat).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"image_format\"");
+
}
var __contentMask = new global::System.Net.Http.ByteArrayContent(request.Mask ?? global::System.Array.Empty());
__contentMask.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
@@ -220,14 +251,18 @@ request.Maskname is null
{
__contentMask.Headers.ContentDisposition.FileNameStar = null;
}
+
if (request.ResponseFormat != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.ResponseFormat).HasValue ? (request.ResponseFormat).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"response_format\"");
+
}
+
__httpRequest.Content = __httpRequestContent;
+
global::Recraft.AutoSDKRequestOptionsSupport.ApplyHeaders(
request: __httpRequest,
clientHeaders: Options.Headers,
@@ -270,6 +305,8 @@ request.Maskname is null
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
@@ -280,6 +317,11 @@ request.Maskname is null
}
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,
@@ -297,6 +339,8 @@ request.Maskname is null
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
if (!__willRetry)
{
@@ -306,8 +350,7 @@ request.Maskname is null
__httpRequest.Dispose();
__httpRequest = null;
await global::Recraft.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -316,6 +359,11 @@ request.Maskname is null
__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(
@@ -332,14 +380,15 @@ request.Maskname is null
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;
}
@@ -379,6 +428,8 @@ request.Maskname is null
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
else
@@ -399,6 +450,8 @@ request.Maskname is null
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
@@ -423,9 +476,13 @@ request.Maskname is null
{
__response.EnsureSuccessStatusCode();
- return
- global::Recraft.ProcessImageResponse.FromJson(__content, JsonSerializerContext) ??
+ var __value = global::Recraft.ProcessImageResponse.FromJson(__content, JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
@@ -453,9 +510,13 @@ request.Maskname is null
#endif
).ConfigureAwait(false);
- return
- await global::Recraft.ProcessImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ var __value = await global::Recraft.ProcessImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
@@ -536,5 +597,1022 @@ request.Maskname is null
requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
+
+ ///
+ /// Erase Region
+ ///
+ ///
+ ///
+ ///
+ /// The stream to send as the multipart 'image' file part.
+ ///
+ ///
+ ///
+ ///
+ /// The stream to send as the multipart 'mask' file part.
+ ///
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task EraseRegionAsync(
+ global::System.IO.Stream image,
+ string imagename,
+ global::System.IO.Stream mask,
+ string maskname,
+ global::Recraft.BillingType? billing = default,
+ bool? expire = default,
+ global::Recraft.ImageFormat? imageFormat = default,
+ global::Recraft.ResponseFormat? responseFormat = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+
+ image = image ?? throw new global::System.ArgumentNullException(nameof(image));
+ mask = mask ?? throw new global::System.ArgumentNullException(nameof(mask));
+ var request = new global::Recraft.EraseRegionRequest
+ {
+ Expire = expire,
+ Image = global::System.Array.Empty(),
+ Imagename = imagename,
+ ImageFormat = imageFormat,
+ Mask = global::System.Array.Empty(),
+ Maskname = maskname,
+ ResponseFormat = responseFormat,
+ };
+ PrepareArguments(
+ client: HttpClient);
+ PrepareEraseRegionArguments(
+ httpClient: HttpClient,
+ billing: ref billing,
+ request: request);
+
+
+ var __authorizations = global::Recraft.EndPointSecurityResolver.ResolveAuthorizations(
+ availableAuthorizations: Authorizations,
+ securityRequirements: s_EraseRegionSecurityRequirements,
+ operationName: "EraseRegionAsync");
+
+ using var __timeoutCancellationTokenSource = global::Recraft.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Recraft.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Recraft.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: false);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+
+ var __pathBuilder = new global::Recraft.PathBuilder(
+ path: "/v1/images/eraseRegion",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("billing", billing?.ToValueString())
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::Recraft.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+#if NET6_0_OR_GREATER
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+#endif
+
+ foreach (var __authorization in __authorizations)
+ {
+ if (__authorization.Type == "Http" ||
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
+ {
+ __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
+ scheme: __authorization.Name,
+ parameter: __authorization.Value);
+ }
+ else if (__authorization.Type == "ApiKey" &&
+ __authorization.Location == "Header")
+ {
+ __httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
+ }
+ }
+
+ var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
+ if (billing != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((billing).HasValue ? (billing).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"billing\"");
+
+ }
+ if (request.Expire != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.Expire, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()),
+ name: "\"expire\"");
+
+ }
+ var __contentImage = new global::System.Net.Http.StreamContent(image);
+ __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ request.Imagename is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(request.Imagename) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentImage,
+ name: "\"image\"",
+ fileName: request.Imagename != null ? $"\"{request.Imagename}\"" : string.Empty);
+ if (__contentImage.Headers.ContentDisposition != null)
+ {
+ __contentImage.Headers.ContentDisposition.FileNameStar = null;
+ }
+
+ if (request.ImageFormat != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.ImageFormat).HasValue ? (request.ImageFormat).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"image_format\"");
+
+ }
+ var __contentMask = new global::System.Net.Http.StreamContent(mask);
+ __contentMask.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ request.Maskname is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(request.Maskname) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentMask,
+ name: "\"mask\"",
+ fileName: request.Maskname != null ? $"\"{request.Maskname}\"" : string.Empty);
+ if (__contentMask.Headers.ContentDisposition != null)
+ {
+ __contentMask.Headers.ContentDisposition.FileNameStar = null;
+ }
+
+ if (request.ResponseFormat != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.ResponseFormat).HasValue ? (request.ResponseFormat).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"response_format\"");
+
+ }
+
+ __httpRequest.Content = __httpRequestContent;
+
+ global::Recraft.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
+
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareEraseRegionRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ billing: billing,
+ request: request);
+
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
+ {
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
+ {
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Recraft.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "EraseRegion",
+ methodName: "EraseRegionAsync",
+ pathTemplate: "\"/v1/images/eraseRegion\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
+ {
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ }
+ 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,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "EraseRegion",
+ methodName: "EraseRegionAsync",
+ pathTemplate: "\"/v1/images/eraseRegion\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Recraft.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __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(
+ operationId: "EraseRegion",
+ methodName: "EraseRegionAsync",
+ pathTemplate: "\"/v1/images/eraseRegion\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ 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(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
+ }
+
+ if (__response == null)
+ {
+ throw new global::System.InvalidOperationException("No response received.");
+ }
+
+ using (__response)
+ {
+
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessEraseRegionResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Recraft.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "EraseRegion",
+ methodName: "EraseRegionAsync",
+ pathTemplate: "\"/v1/images/eraseRegion\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ else
+ {
+ await global::Recraft.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "EraseRegion",
+ methodName: "EraseRegionAsync",
+ pathTemplate: "\"/v1/images/eraseRegion\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessEraseRegionResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Recraft.ProcessImageResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Recraft.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ await global::Recraft.ProcessImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Recraft.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
+ }
+ ///
+ /// Erase Region
+ ///
+ ///
+ ///
+ ///
+ /// The stream to send as the multipart 'image' file part.
+ ///
+ ///
+ ///
+ ///
+ /// The stream to send as the multipart 'mask' file part.
+ ///
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> EraseRegionAsResponseAsync(
+ global::System.IO.Stream image,
+ string imagename,
+ global::System.IO.Stream mask,
+ string maskname,
+ global::Recraft.BillingType? billing = default,
+ bool? expire = default,
+ global::Recraft.ImageFormat? imageFormat = default,
+ global::Recraft.ResponseFormat? responseFormat = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+
+ image = image ?? throw new global::System.ArgumentNullException(nameof(image));
+ mask = mask ?? throw new global::System.ArgumentNullException(nameof(mask));
+ var request = new global::Recraft.EraseRegionRequest
+ {
+ Expire = expire,
+ Image = global::System.Array.Empty(),
+ Imagename = imagename,
+ ImageFormat = imageFormat,
+ Mask = global::System.Array.Empty(),
+ Maskname = maskname,
+ ResponseFormat = responseFormat,
+ };
+ PrepareArguments(
+ client: HttpClient);
+ PrepareEraseRegionArguments(
+ httpClient: HttpClient,
+ billing: ref billing,
+ request: request);
+
+
+ var __authorizations = global::Recraft.EndPointSecurityResolver.ResolveAuthorizations(
+ availableAuthorizations: Authorizations,
+ securityRequirements: s_EraseRegionSecurityRequirements,
+ operationName: "EraseRegionAsync");
+
+ using var __timeoutCancellationTokenSource = global::Recraft.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Recraft.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Recraft.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: false);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+
+ var __pathBuilder = new global::Recraft.PathBuilder(
+ path: "/v1/images/eraseRegion",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("billing", billing?.ToValueString())
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::Recraft.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+#if NET6_0_OR_GREATER
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+#endif
+
+ foreach (var __authorization in __authorizations)
+ {
+ if (__authorization.Type == "Http" ||
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
+ {
+ __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
+ scheme: __authorization.Name,
+ parameter: __authorization.Value);
+ }
+ else if (__authorization.Type == "ApiKey" &&
+ __authorization.Location == "Header")
+ {
+ __httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
+ }
+ }
+
+ var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
+ if (billing != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((billing).HasValue ? (billing).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"billing\"");
+
+ }
+ if (request.Expire != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.Expire, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()),
+ name: "\"expire\"");
+
+ }
+ var __contentImage = new global::System.Net.Http.StreamContent(image);
+ __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ request.Imagename is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(request.Imagename) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentImage,
+ name: "\"image\"",
+ fileName: request.Imagename != null ? $"\"{request.Imagename}\"" : string.Empty);
+ if (__contentImage.Headers.ContentDisposition != null)
+ {
+ __contentImage.Headers.ContentDisposition.FileNameStar = null;
+ }
+
+ if (request.ImageFormat != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.ImageFormat).HasValue ? (request.ImageFormat).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"image_format\"");
+
+ }
+ var __contentMask = new global::System.Net.Http.StreamContent(mask);
+ __contentMask.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ request.Maskname is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(request.Maskname) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentMask,
+ name: "\"mask\"",
+ fileName: request.Maskname != null ? $"\"{request.Maskname}\"" : string.Empty);
+ if (__contentMask.Headers.ContentDisposition != null)
+ {
+ __contentMask.Headers.ContentDisposition.FileNameStar = null;
+ }
+
+ if (request.ResponseFormat != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.ResponseFormat).HasValue ? (request.ResponseFormat).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"response_format\"");
+
+ }
+
+ __httpRequest.Content = __httpRequestContent;
+
+ global::Recraft.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
+
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareEraseRegionRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ billing: billing,
+ request: request);
+
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
+ {
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
+ {
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Recraft.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "EraseRegion",
+ methodName: "EraseRegionAsync",
+ pathTemplate: "\"/v1/images/eraseRegion\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
+ {
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ }
+ 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,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "EraseRegion",
+ methodName: "EraseRegionAsync",
+ pathTemplate: "\"/v1/images/eraseRegion\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Recraft.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __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(
+ operationId: "EraseRegion",
+ methodName: "EraseRegionAsync",
+ pathTemplate: "\"/v1/images/eraseRegion\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ 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(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
+ }
+
+ if (__response == null)
+ {
+ throw new global::System.InvalidOperationException("No response received.");
+ }
+
+ using (__response)
+ {
+
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessEraseRegionResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Recraft.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "EraseRegion",
+ methodName: "EraseRegionAsync",
+ pathTemplate: "\"/v1/images/eraseRegion\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ else
+ {
+ await global::Recraft.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "EraseRegion",
+ methodName: "EraseRegionAsync",
+ pathTemplate: "\"/v1/images/eraseRegion\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessEraseRegionResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ var __value = global::Recraft.ProcessImageResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Recraft.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ var __value = await global::Recraft.ProcessImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Recraft.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
+ }
}
}
\ No newline at end of file
diff --git a/src/libs/Recraft/Generated/Recraft.ImageClient.Explore.g.cs b/src/libs/Recraft/Generated/Recraft.ImageClient.Explore.g.cs
index 47739d5..744ed72 100644
--- a/src/libs/Recraft/Generated/Recraft.ImageClient.Explore.g.cs
+++ b/src/libs/Recraft/Generated/Recraft.ImageClient.Explore.g.cs
@@ -53,6 +53,31 @@ partial void ProcessExploreResponseContent(
///
public async global::System.Threading.Tasks.Task ExploreAsync(
+ global::Recraft.ExploreRequest request,
+ global::Recraft.BillingType? billing = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+ var __response = await ExploreAsResponseAsync(
+
+ request: request,
+ billing: billing,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken
+ ).ConfigureAwait(false);
+
+ return __response.Body;
+ }
+ ///
+ /// Exploration
+ ///
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> ExploreAsResponseAsync(
+
global::Recraft.ExploreRequest request,
global::Recraft.BillingType? billing = default,
global::Recraft.AutoSDKRequestOptions? requestOptions = default,
@@ -89,11 +114,12 @@ partial void ProcessExploreResponseContent(
global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{
+
var __pathBuilder = new global::Recraft.PathBuilder(
path: "/v1/images/explore",
- baseUri: HttpClient.BaseAddress);
+ baseUri: HttpClient.BaseAddress);
__pathBuilder
- .AddOptionalParameter("billing", billing?.ToValueString())
+ .AddOptionalParameter("billing", billing?.ToValueString())
;
var __path = __pathBuilder.ToString();
__path = global::Recraft.AutoSDKRequestOptionsSupport.AppendQueryParameters(
@@ -172,6 +198,8 @@ partial void ProcessExploreResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
@@ -182,6 +210,11 @@ partial void ProcessExploreResponseContent(
}
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,
@@ -199,6 +232,8 @@ partial void ProcessExploreResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
if (!__willRetry)
{
@@ -208,8 +243,7 @@ partial void ProcessExploreResponseContent(
__httpRequest.Dispose();
__httpRequest = null;
await global::Recraft.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -218,6 +252,11 @@ partial void ProcessExploreResponseContent(
__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(
@@ -234,14 +273,15 @@ partial void ProcessExploreResponseContent(
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;
}
@@ -281,6 +321,8 @@ partial void ProcessExploreResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
else
@@ -301,6 +343,8 @@ partial void ProcessExploreResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
@@ -325,9 +369,13 @@ partial void ProcessExploreResponseContent(
{
__response.EnsureSuccessStatusCode();
- return
- global::Recraft.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ??
+ var __value = global::Recraft.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
@@ -355,9 +403,13 @@ partial void ProcessExploreResponseContent(
#endif
).ConfigureAwait(false);
- return
- await global::Recraft.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ var __value = await global::Recraft.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
diff --git a/src/libs/Recraft/Generated/Recraft.ImageClient.ExploreSimilar.g.cs b/src/libs/Recraft/Generated/Recraft.ImageClient.ExploreSimilar.g.cs
index bd292fc..e04d53f 100644
--- a/src/libs/Recraft/Generated/Recraft.ImageClient.ExploreSimilar.g.cs
+++ b/src/libs/Recraft/Generated/Recraft.ImageClient.ExploreSimilar.g.cs
@@ -53,6 +53,31 @@ partial void ProcessExploreSimilarResponseContent(
///
public async global::System.Threading.Tasks.Task ExploreSimilarAsync(
+ global::Recraft.ExploreSimilarRequest request,
+ global::Recraft.BillingType? billing = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+ var __response = await ExploreSimilarAsResponseAsync(
+
+ request: request,
+ billing: billing,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken
+ ).ConfigureAwait(false);
+
+ return __response.Body;
+ }
+ ///
+ /// Continue exploration from a source image
+ ///
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> ExploreSimilarAsResponseAsync(
+
global::Recraft.ExploreSimilarRequest request,
global::Recraft.BillingType? billing = default,
global::Recraft.AutoSDKRequestOptions? requestOptions = default,
@@ -89,11 +114,12 @@ partial void ProcessExploreSimilarResponseContent(
global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{
+
var __pathBuilder = new global::Recraft.PathBuilder(
path: "/v1/images/explore/similar",
- baseUri: HttpClient.BaseAddress);
+ baseUri: HttpClient.BaseAddress);
__pathBuilder
- .AddOptionalParameter("billing", billing?.ToValueString())
+ .AddOptionalParameter("billing", billing?.ToValueString())
;
var __path = __pathBuilder.ToString();
__path = global::Recraft.AutoSDKRequestOptionsSupport.AppendQueryParameters(
@@ -172,6 +198,8 @@ partial void ProcessExploreSimilarResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
@@ -182,6 +210,11 @@ partial void ProcessExploreSimilarResponseContent(
}
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,
@@ -199,6 +232,8 @@ partial void ProcessExploreSimilarResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
if (!__willRetry)
{
@@ -208,8 +243,7 @@ partial void ProcessExploreSimilarResponseContent(
__httpRequest.Dispose();
__httpRequest = null;
await global::Recraft.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -218,6 +252,11 @@ partial void ProcessExploreSimilarResponseContent(
__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(
@@ -234,14 +273,15 @@ partial void ProcessExploreSimilarResponseContent(
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;
}
@@ -281,6 +321,8 @@ partial void ProcessExploreSimilarResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
else
@@ -301,6 +343,8 @@ partial void ProcessExploreSimilarResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
@@ -325,9 +369,13 @@ partial void ProcessExploreSimilarResponseContent(
{
__response.EnsureSuccessStatusCode();
- return
- global::Recraft.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ??
+ var __value = global::Recraft.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
@@ -355,9 +403,13 @@ partial void ProcessExploreSimilarResponseContent(
#endif
).ConfigureAwait(false);
- return
- await global::Recraft.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ var __value = await global::Recraft.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
diff --git a/src/libs/Recraft/Generated/Recraft.ImageClient.GenerateBackground.g.cs b/src/libs/Recraft/Generated/Recraft.ImageClient.GenerateBackground.g.cs
index 7de4c3c..f126d97 100644
--- a/src/libs/Recraft/Generated/Recraft.ImageClient.GenerateBackground.g.cs
+++ b/src/libs/Recraft/Generated/Recraft.ImageClient.GenerateBackground.g.cs
@@ -53,6 +53,31 @@ partial void ProcessGenerateBackgroundResponseContent(
///
public async global::System.Threading.Tasks.Task GenerateBackgroundAsync(
+ global::Recraft.TransformImageWithMaskRequest request,
+ global::Recraft.BillingType? billing = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+ var __response = await GenerateBackgroundAsResponseAsync(
+
+ request: request,
+ billing: billing,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken
+ ).ConfigureAwait(false);
+
+ return __response.Body;
+ }
+ ///
+ /// Generate Background
+ ///
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> GenerateBackgroundAsResponseAsync(
+
global::Recraft.TransformImageWithMaskRequest request,
global::Recraft.BillingType? billing = default,
global::Recraft.AutoSDKRequestOptions? requestOptions = default,
@@ -83,15 +108,16 @@ partial void ProcessGenerateBackgroundResponseContent(
var __maxAttempts = global::Recraft.AutoSDKRequestOptionsSupport.GetMaxAttempts(
clientOptions: Options,
requestOptions: requestOptions,
- supportsRetry: true);
+ supportsRetry: false);
global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{
+
var __pathBuilder = new global::Recraft.PathBuilder(
path: "/v1/images/generateBackground",
- baseUri: HttpClient.BaseAddress);
+ baseUri: HttpClient.BaseAddress);
__pathBuilder
- .AddOptionalParameter("billing", billing?.ToValueString())
+ .AddOptionalParameter("billing", billing?.ToValueString())
;
var __path = __pathBuilder.ToString();
__path = global::Recraft.AutoSDKRequestOptionsSupport.AppendQueryParameters(
@@ -122,6 +148,7 @@ partial void ProcessGenerateBackgroundResponseContent(
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
}
}
+
var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
if (billing != default)
{
@@ -129,8 +156,11 @@ partial void ProcessGenerateBackgroundResponseContent(
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((billing).HasValue ? (billing).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"billing\"");
+
}
+
__httpRequest.Content = __httpRequestContent;
+
global::Recraft.AutoSDKRequestOptionsSupport.ApplyHeaders(
request: __httpRequest,
clientHeaders: Options.Headers,
@@ -173,6 +203,8 @@ partial void ProcessGenerateBackgroundResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
@@ -183,6 +215,11 @@ partial void ProcessGenerateBackgroundResponseContent(
}
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,
@@ -200,6 +237,8 @@ partial void ProcessGenerateBackgroundResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
if (!__willRetry)
{
@@ -209,8 +248,7 @@ partial void ProcessGenerateBackgroundResponseContent(
__httpRequest.Dispose();
__httpRequest = null;
await global::Recraft.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -219,6 +257,11 @@ partial void ProcessGenerateBackgroundResponseContent(
__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(
@@ -235,14 +278,15 @@ partial void ProcessGenerateBackgroundResponseContent(
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;
}
@@ -282,6 +326,8 @@ partial void ProcessGenerateBackgroundResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
else
@@ -302,6 +348,8 @@ partial void ProcessGenerateBackgroundResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
@@ -326,9 +374,13 @@ partial void ProcessGenerateBackgroundResponseContent(
{
__response.EnsureSuccessStatusCode();
- return
- global::Recraft.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ??
+ var __value = global::Recraft.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
@@ -356,9 +408,13 @@ partial void ProcessGenerateBackgroundResponseContent(
#endif
).ConfigureAwait(false);
- return
- await global::Recraft.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ var __value = await global::Recraft.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
diff --git a/src/libs/Recraft/Generated/Recraft.ImageClient.GenerateImage.g.cs b/src/libs/Recraft/Generated/Recraft.ImageClient.GenerateImage.g.cs
index 3e74056..b0ee41a 100644
--- a/src/libs/Recraft/Generated/Recraft.ImageClient.GenerateImage.g.cs
+++ b/src/libs/Recraft/Generated/Recraft.ImageClient.GenerateImage.g.cs
@@ -53,6 +53,31 @@ partial void ProcessGenerateImageResponseContent(
///
public async global::System.Threading.Tasks.Task GenerateImageAsync(
+ global::Recraft.GenerateImageRequest request,
+ global::Recraft.BillingType? billing = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+ var __response = await GenerateImageAsResponseAsync(
+
+ request: request,
+ billing: billing,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken
+ ).ConfigureAwait(false);
+
+ return __response.Body;
+ }
+ ///
+ /// Generate image from prompt
+ ///
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> GenerateImageAsResponseAsync(
+
global::Recraft.GenerateImageRequest request,
global::Recraft.BillingType? billing = default,
global::Recraft.AutoSDKRequestOptions? requestOptions = default,
@@ -89,11 +114,12 @@ partial void ProcessGenerateImageResponseContent(
global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{
+
var __pathBuilder = new global::Recraft.PathBuilder(
path: "/v1/images/generations",
- baseUri: HttpClient.BaseAddress);
+ baseUri: HttpClient.BaseAddress);
__pathBuilder
- .AddOptionalParameter("billing", billing?.ToValueString())
+ .AddOptionalParameter("billing", billing?.ToValueString())
;
var __path = __pathBuilder.ToString();
__path = global::Recraft.AutoSDKRequestOptionsSupport.AppendQueryParameters(
@@ -172,6 +198,8 @@ partial void ProcessGenerateImageResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
@@ -182,6 +210,11 @@ partial void ProcessGenerateImageResponseContent(
}
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,
@@ -199,6 +232,8 @@ partial void ProcessGenerateImageResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
if (!__willRetry)
{
@@ -208,8 +243,7 @@ partial void ProcessGenerateImageResponseContent(
__httpRequest.Dispose();
__httpRequest = null;
await global::Recraft.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -218,6 +252,11 @@ partial void ProcessGenerateImageResponseContent(
__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(
@@ -234,14 +273,15 @@ partial void ProcessGenerateImageResponseContent(
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;
}
@@ -281,6 +321,8 @@ partial void ProcessGenerateImageResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
else
@@ -301,6 +343,8 @@ partial void ProcessGenerateImageResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
@@ -325,9 +369,13 @@ partial void ProcessGenerateImageResponseContent(
{
__response.EnsureSuccessStatusCode();
- return
- global::Recraft.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ??
+ var __value = global::Recraft.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
@@ -355,9 +403,13 @@ partial void ProcessGenerateImageResponseContent(
#endif
).ConfigureAwait(false);
- return
- await global::Recraft.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ var __value = await global::Recraft.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
diff --git a/src/libs/Recraft/Generated/Recraft.ImageClient.GenerateImageRaster.g.cs b/src/libs/Recraft/Generated/Recraft.ImageClient.GenerateImageRaster.g.cs
index a11e573..d74dd21 100644
--- a/src/libs/Recraft/Generated/Recraft.ImageClient.GenerateImageRaster.g.cs
+++ b/src/libs/Recraft/Generated/Recraft.ImageClient.GenerateImageRaster.g.cs
@@ -53,6 +53,31 @@ partial void ProcessGenerateImageRasterResponseContent(
///
public async global::System.Threading.Tasks.Task GenerateImageRasterAsync(
+ global::Recraft.GenerateImageRequest request,
+ global::Recraft.BillingType? billing = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+ var __response = await GenerateImageRasterAsResponseAsync(
+
+ request: request,
+ billing: billing,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken
+ ).ConfigureAwait(false);
+
+ return __response.Body;
+ }
+ ///
+ /// Generate raster image from prompt
+ ///
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> GenerateImageRasterAsResponseAsync(
+
global::Recraft.GenerateImageRequest request,
global::Recraft.BillingType? billing = default,
global::Recraft.AutoSDKRequestOptions? requestOptions = default,
@@ -89,11 +114,12 @@ partial void ProcessGenerateImageRasterResponseContent(
global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{
+
var __pathBuilder = new global::Recraft.PathBuilder(
path: "/v1/images/generations/raster",
- baseUri: HttpClient.BaseAddress);
+ baseUri: HttpClient.BaseAddress);
__pathBuilder
- .AddOptionalParameter("billing", billing?.ToValueString())
+ .AddOptionalParameter("billing", billing?.ToValueString())
;
var __path = __pathBuilder.ToString();
__path = global::Recraft.AutoSDKRequestOptionsSupport.AppendQueryParameters(
@@ -172,6 +198,8 @@ partial void ProcessGenerateImageRasterResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
@@ -182,6 +210,11 @@ partial void ProcessGenerateImageRasterResponseContent(
}
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,
@@ -199,6 +232,8 @@ partial void ProcessGenerateImageRasterResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
if (!__willRetry)
{
@@ -208,8 +243,7 @@ partial void ProcessGenerateImageRasterResponseContent(
__httpRequest.Dispose();
__httpRequest = null;
await global::Recraft.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -218,6 +252,11 @@ partial void ProcessGenerateImageRasterResponseContent(
__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(
@@ -234,14 +273,15 @@ partial void ProcessGenerateImageRasterResponseContent(
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;
}
@@ -281,6 +321,8 @@ partial void ProcessGenerateImageRasterResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
else
@@ -301,6 +343,8 @@ partial void ProcessGenerateImageRasterResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
@@ -325,9 +369,13 @@ partial void ProcessGenerateImageRasterResponseContent(
{
__response.EnsureSuccessStatusCode();
- return
- global::Recraft.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ??
+ var __value = global::Recraft.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
@@ -355,9 +403,13 @@ partial void ProcessGenerateImageRasterResponseContent(
#endif
).ConfigureAwait(false);
- return
- await global::Recraft.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ var __value = await global::Recraft.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
diff --git a/src/libs/Recraft/Generated/Recraft.ImageClient.GenerateImageVector.g.cs b/src/libs/Recraft/Generated/Recraft.ImageClient.GenerateImageVector.g.cs
index b2ffbe2..b687353 100644
--- a/src/libs/Recraft/Generated/Recraft.ImageClient.GenerateImageVector.g.cs
+++ b/src/libs/Recraft/Generated/Recraft.ImageClient.GenerateImageVector.g.cs
@@ -53,6 +53,31 @@ partial void ProcessGenerateImageVectorResponseContent(
///
public async global::System.Threading.Tasks.Task GenerateImageVectorAsync(
+ global::Recraft.GenerateImageRequest request,
+ global::Recraft.BillingType? billing = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+ var __response = await GenerateImageVectorAsResponseAsync(
+
+ request: request,
+ billing: billing,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken
+ ).ConfigureAwait(false);
+
+ return __response.Body;
+ }
+ ///
+ /// Generate vector image from prompt
+ ///
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> GenerateImageVectorAsResponseAsync(
+
global::Recraft.GenerateImageRequest request,
global::Recraft.BillingType? billing = default,
global::Recraft.AutoSDKRequestOptions? requestOptions = default,
@@ -89,11 +114,12 @@ partial void ProcessGenerateImageVectorResponseContent(
global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{
+
var __pathBuilder = new global::Recraft.PathBuilder(
path: "/v1/images/generations/vector",
- baseUri: HttpClient.BaseAddress);
+ baseUri: HttpClient.BaseAddress);
__pathBuilder
- .AddOptionalParameter("billing", billing?.ToValueString())
+ .AddOptionalParameter("billing", billing?.ToValueString())
;
var __path = __pathBuilder.ToString();
__path = global::Recraft.AutoSDKRequestOptionsSupport.AppendQueryParameters(
@@ -172,6 +198,8 @@ partial void ProcessGenerateImageVectorResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
@@ -182,6 +210,11 @@ partial void ProcessGenerateImageVectorResponseContent(
}
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,
@@ -199,6 +232,8 @@ partial void ProcessGenerateImageVectorResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
if (!__willRetry)
{
@@ -208,8 +243,7 @@ partial void ProcessGenerateImageVectorResponseContent(
__httpRequest.Dispose();
__httpRequest = null;
await global::Recraft.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -218,6 +252,11 @@ partial void ProcessGenerateImageVectorResponseContent(
__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(
@@ -234,14 +273,15 @@ partial void ProcessGenerateImageVectorResponseContent(
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;
}
@@ -281,6 +321,8 @@ partial void ProcessGenerateImageVectorResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
else
@@ -301,6 +343,8 @@ partial void ProcessGenerateImageVectorResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
@@ -325,9 +369,13 @@ partial void ProcessGenerateImageVectorResponseContent(
{
__response.EnsureSuccessStatusCode();
- return
- global::Recraft.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ??
+ var __value = global::Recraft.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
@@ -355,9 +403,13 @@ partial void ProcessGenerateImageVectorResponseContent(
#endif
).ConfigureAwait(false);
- return
- await global::Recraft.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ var __value = await global::Recraft.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
diff --git a/src/libs/Recraft/Generated/Recraft.ImageClient.ImageToImage.g.cs b/src/libs/Recraft/Generated/Recraft.ImageClient.ImageToImage.g.cs
index 5ead9bd..7a6d4f5 100644
--- a/src/libs/Recraft/Generated/Recraft.ImageClient.ImageToImage.g.cs
+++ b/src/libs/Recraft/Generated/Recraft.ImageClient.ImageToImage.g.cs
@@ -53,6 +53,31 @@ partial void ProcessImageToImageResponseContent(
///
public async global::System.Threading.Tasks.Task ImageToImageAsync(
+ global::Recraft.ImageToImageRequest request,
+ global::Recraft.BillingType? billing = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+ var __response = await ImageToImageAsResponseAsync(
+
+ request: request,
+ billing: billing,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken
+ ).ConfigureAwait(false);
+
+ return __response.Body;
+ }
+ ///
+ /// Generate image from image and prompt
+ ///
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> ImageToImageAsResponseAsync(
+
global::Recraft.ImageToImageRequest request,
global::Recraft.BillingType? billing = default,
global::Recraft.AutoSDKRequestOptions? requestOptions = default,
@@ -85,15 +110,16 @@ partial void ProcessImageToImageResponseContent(
var __maxAttempts = global::Recraft.AutoSDKRequestOptionsSupport.GetMaxAttempts(
clientOptions: Options,
requestOptions: requestOptions,
- supportsRetry: true);
+ supportsRetry: false);
global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{
+
var __pathBuilder = new global::Recraft.PathBuilder(
path: "/v1/images/imageToImage",
- baseUri: HttpClient.BaseAddress);
+ baseUri: HttpClient.BaseAddress);
__pathBuilder
- .AddOptionalParameter("billing", billing?.ToValueString())
+ .AddOptionalParameter("billing", billing?.ToValueString())
;
var __path = __pathBuilder.ToString();
__path = global::Recraft.AutoSDKRequestOptionsSupport.AppendQueryParameters(
@@ -124,6 +150,7 @@ partial void ProcessImageToImageResponseContent(
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
}
}
+
var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
if (billing != default)
{
@@ -131,34 +158,39 @@ partial void ProcessImageToImageResponseContent(
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((billing).HasValue ? (billing).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"billing\"");
- }
+
+ }
if (request.BlockNsfw != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.BlockNsfw, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()),
name: "\"block_nsfw\"");
- }
+
+ }
if (request.CalculateFeatures != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.CalculateFeatures, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()),
name: "\"calculate_features\"");
- }
+
+ }
if (request.Controls != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(request.Controls.ToJson(JsonSerializerContext)),
name: "\"controls\"");
- }
+
+ }
if (request.Expire != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.Expire, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()),
name: "\"expire\"");
+
}
var __contentImage = new global::System.Net.Http.ByteArrayContent(request.Image ?? global::System.Array.Empty());
__contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
@@ -197,83 +229,98 @@ request.Imagename is null
{
__contentImage.Headers.ContentDisposition.FileNameStar = null;
}
+
if (request.ImageFormat != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.ImageFormat).HasValue ? (request.ImageFormat).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"image_format\"");
- }
+
+ }
if (request.Model != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.Model).HasValue ? (request.Model).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"model\"");
- }
+
+ }
if (request.N != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.N, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
name: "\"n\"");
- }
+
+ }
if (request.NegativePrompt != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(request.NegativePrompt ?? string.Empty),
name: "\"negative_prompt\"");
+
}
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty),
name: "\"prompt\"");
+
if (request.RandomSeed != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.RandomSeed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
name: "\"random_seed\"");
- }
+
+ }
if (request.ResponseFormat != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.ResponseFormat).HasValue ? (request.ResponseFormat).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"response_format\"");
+
}
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Strength, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
name: "\"strength\"");
+
if (request.Style != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(request.Style ?? string.Empty),
name: "\"style\"");
- }
+
+ }
if (request.StyleId != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(request.StyleId.ToString() ?? string.Empty),
name: "\"style_id\"");
- }
+
+ }
if (request.Substyle != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.Substyle).HasValue ? (request.Substyle).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"substyle\"");
- }
+
+ }
if (request.TextLayout != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.TextLayout, x => x.ToJson(JsonSerializerContext)))}]"),
name: "\"text_layout\"");
+
}
+
__httpRequest.Content = __httpRequestContent;
+
global::Recraft.AutoSDKRequestOptionsSupport.ApplyHeaders(
request: __httpRequest,
clientHeaders: Options.Headers,
@@ -316,6 +363,8 @@ request.Imagename is null
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
@@ -326,6 +375,11 @@ request.Imagename is null
}
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,
@@ -343,6 +397,8 @@ request.Imagename is null
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
if (!__willRetry)
{
@@ -352,8 +408,7 @@ request.Imagename is null
__httpRequest.Dispose();
__httpRequest = null;
await global::Recraft.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -362,6 +417,11 @@ request.Imagename is null
__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(
@@ -378,14 +438,15 @@ request.Imagename is null
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;
}
@@ -425,6 +486,8 @@ request.Imagename is null
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
else
@@ -445,6 +508,8 @@ request.Imagename is null
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
@@ -469,9 +534,13 @@ request.Imagename is null
{
__response.EnsureSuccessStatusCode();
- return
- global::Recraft.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ??
+ var __value = global::Recraft.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
@@ -499,9 +568,13 @@ request.Imagename is null
#endif
).ConfigureAwait(false);
- return
- await global::Recraft.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ var __value = await global::Recraft.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
@@ -615,5 +688,1198 @@ request.Imagename is null
requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
+
+ ///
+ /// Generate image from image and prompt
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// The stream to send as the multipart 'image' file part.
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task ImageToImageAsync(
+ global::System.IO.Stream image,
+ string imagename,
+ string prompt,
+ double strength,
+ global::Recraft.BillingType? billing = default,
+ bool? blockNsfw = default,
+ bool? calculateFeatures = default,
+ global::Recraft.UserControls? controls = default,
+ bool? expire = default,
+ global::Recraft.ImageFormat? imageFormat = default,
+ global::Recraft.TransformModel? model = default,
+ int? n = default,
+ string? negativePrompt = default,
+ int? randomSeed = default,
+ global::Recraft.ResponseFormat? responseFormat = default,
+ string? style = default,
+ global::System.Guid? styleId = default,
+ global::Recraft.ImageSubStyle? substyle = default,
+ global::System.Collections.Generic.IList? textLayout = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+
+ image = image ?? throw new global::System.ArgumentNullException(nameof(image));
+ var request = new global::Recraft.ImageToImageRequest
+ {
+ BlockNsfw = blockNsfw,
+ CalculateFeatures = calculateFeatures,
+ Controls = controls,
+ Expire = expire,
+ Image = global::System.Array.Empty(),
+ Imagename = imagename,
+ ImageFormat = imageFormat,
+ Model = model,
+ N = n,
+ NegativePrompt = negativePrompt,
+ Prompt = prompt,
+ RandomSeed = randomSeed,
+ ResponseFormat = responseFormat,
+ Strength = strength,
+ Style = style,
+ StyleId = styleId,
+ Substyle = substyle,
+ TextLayout = textLayout,
+ };
+ PrepareArguments(
+ client: HttpClient);
+ PrepareImageToImageArguments(
+ httpClient: HttpClient,
+ billing: ref billing,
+ request: request);
+
+
+ var __authorizations = global::Recraft.EndPointSecurityResolver.ResolveAuthorizations(
+ availableAuthorizations: Authorizations,
+ securityRequirements: s_ImageToImageSecurityRequirements,
+ operationName: "ImageToImageAsync");
+
+ using var __timeoutCancellationTokenSource = global::Recraft.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Recraft.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Recraft.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: false);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+
+ var __pathBuilder = new global::Recraft.PathBuilder(
+ path: "/v1/images/imageToImage",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("billing", billing?.ToValueString())
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::Recraft.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+#if NET6_0_OR_GREATER
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+#endif
+
+ foreach (var __authorization in __authorizations)
+ {
+ if (__authorization.Type == "Http" ||
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
+ {
+ __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
+ scheme: __authorization.Name,
+ parameter: __authorization.Value);
+ }
+ else if (__authorization.Type == "ApiKey" &&
+ __authorization.Location == "Header")
+ {
+ __httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
+ }
+ }
+
+ var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
+ if (billing != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((billing).HasValue ? (billing).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"billing\"");
+
+ }
+ if (request.BlockNsfw != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.BlockNsfw, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()),
+ name: "\"block_nsfw\"");
+
+ }
+ if (request.CalculateFeatures != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.CalculateFeatures, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()),
+ name: "\"calculate_features\"");
+
+ }
+ if (request.Controls != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.Controls.ToJson(JsonSerializerContext)),
+ name: "\"controls\"");
+
+ }
+ if (request.Expire != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.Expire, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()),
+ name: "\"expire\"");
+
+ }
+ var __contentImage = new global::System.Net.Http.StreamContent(image);
+ __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ request.Imagename is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(request.Imagename) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentImage,
+ name: "\"image\"",
+ fileName: request.Imagename != null ? $"\"{request.Imagename}\"" : string.Empty);
+ if (__contentImage.Headers.ContentDisposition != null)
+ {
+ __contentImage.Headers.ContentDisposition.FileNameStar = null;
+ }
+
+ if (request.ImageFormat != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.ImageFormat).HasValue ? (request.ImageFormat).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"image_format\"");
+
+ }
+ if (request.Model != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.Model).HasValue ? (request.Model).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"model\"");
+
+ }
+ if (request.N != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.N, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
+ name: "\"n\"");
+
+ }
+ if (request.NegativePrompt != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.NegativePrompt ?? string.Empty),
+ name: "\"negative_prompt\"");
+
+ }
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty),
+ name: "\"prompt\"");
+
+ if (request.RandomSeed != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.RandomSeed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
+ name: "\"random_seed\"");
+
+ }
+ if (request.ResponseFormat != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.ResponseFormat).HasValue ? (request.ResponseFormat).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"response_format\"");
+
+ }
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Strength, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
+ name: "\"strength\"");
+
+ if (request.Style != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.Style ?? string.Empty),
+ name: "\"style\"");
+
+ }
+ if (request.StyleId != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.StyleId.ToString() ?? string.Empty),
+ name: "\"style_id\"");
+
+ }
+ if (request.Substyle != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.Substyle).HasValue ? (request.Substyle).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"substyle\"");
+
+ }
+ if (request.TextLayout != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.TextLayout, x => x.ToJson(JsonSerializerContext)))}]"),
+ name: "\"text_layout\"");
+
+ }
+
+ __httpRequest.Content = __httpRequestContent;
+
+ global::Recraft.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
+
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareImageToImageRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ billing: billing,
+ request: request);
+
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
+ {
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
+ {
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Recraft.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ImageToImage",
+ methodName: "ImageToImageAsync",
+ pathTemplate: "\"/v1/images/imageToImage\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
+ {
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ }
+ 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,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ImageToImage",
+ methodName: "ImageToImageAsync",
+ pathTemplate: "\"/v1/images/imageToImage\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Recraft.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __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(
+ operationId: "ImageToImage",
+ methodName: "ImageToImageAsync",
+ pathTemplate: "\"/v1/images/imageToImage\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ 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(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
+ }
+
+ if (__response == null)
+ {
+ throw new global::System.InvalidOperationException("No response received.");
+ }
+
+ using (__response)
+ {
+
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessImageToImageResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Recraft.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ImageToImage",
+ methodName: "ImageToImageAsync",
+ pathTemplate: "\"/v1/images/imageToImage\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ else
+ {
+ await global::Recraft.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ImageToImage",
+ methodName: "ImageToImageAsync",
+ pathTemplate: "\"/v1/images/imageToImage\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessImageToImageResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Recraft.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Recraft.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ await global::Recraft.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Recraft.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
+ }
+ ///
+ /// Generate image from image and prompt
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// The stream to send as the multipart 'image' file part.
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> ImageToImageAsResponseAsync(
+ global::System.IO.Stream image,
+ string imagename,
+ string prompt,
+ double strength,
+ global::Recraft.BillingType? billing = default,
+ bool? blockNsfw = default,
+ bool? calculateFeatures = default,
+ global::Recraft.UserControls? controls = default,
+ bool? expire = default,
+ global::Recraft.ImageFormat? imageFormat = default,
+ global::Recraft.TransformModel? model = default,
+ int? n = default,
+ string? negativePrompt = default,
+ int? randomSeed = default,
+ global::Recraft.ResponseFormat? responseFormat = default,
+ string? style = default,
+ global::System.Guid? styleId = default,
+ global::Recraft.ImageSubStyle? substyle = default,
+ global::System.Collections.Generic.IList? textLayout = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+
+ image = image ?? throw new global::System.ArgumentNullException(nameof(image));
+ var request = new global::Recraft.ImageToImageRequest
+ {
+ BlockNsfw = blockNsfw,
+ CalculateFeatures = calculateFeatures,
+ Controls = controls,
+ Expire = expire,
+ Image = global::System.Array.Empty(),
+ Imagename = imagename,
+ ImageFormat = imageFormat,
+ Model = model,
+ N = n,
+ NegativePrompt = negativePrompt,
+ Prompt = prompt,
+ RandomSeed = randomSeed,
+ ResponseFormat = responseFormat,
+ Strength = strength,
+ Style = style,
+ StyleId = styleId,
+ Substyle = substyle,
+ TextLayout = textLayout,
+ };
+ PrepareArguments(
+ client: HttpClient);
+ PrepareImageToImageArguments(
+ httpClient: HttpClient,
+ billing: ref billing,
+ request: request);
+
+
+ var __authorizations = global::Recraft.EndPointSecurityResolver.ResolveAuthorizations(
+ availableAuthorizations: Authorizations,
+ securityRequirements: s_ImageToImageSecurityRequirements,
+ operationName: "ImageToImageAsync");
+
+ using var __timeoutCancellationTokenSource = global::Recraft.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Recraft.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Recraft.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: false);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+
+ var __pathBuilder = new global::Recraft.PathBuilder(
+ path: "/v1/images/imageToImage",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("billing", billing?.ToValueString())
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::Recraft.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+#if NET6_0_OR_GREATER
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+#endif
+
+ foreach (var __authorization in __authorizations)
+ {
+ if (__authorization.Type == "Http" ||
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
+ {
+ __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
+ scheme: __authorization.Name,
+ parameter: __authorization.Value);
+ }
+ else if (__authorization.Type == "ApiKey" &&
+ __authorization.Location == "Header")
+ {
+ __httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
+ }
+ }
+
+ var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
+ if (billing != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((billing).HasValue ? (billing).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"billing\"");
+
+ }
+ if (request.BlockNsfw != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.BlockNsfw, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()),
+ name: "\"block_nsfw\"");
+
+ }
+ if (request.CalculateFeatures != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.CalculateFeatures, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()),
+ name: "\"calculate_features\"");
+
+ }
+ if (request.Controls != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.Controls.ToJson(JsonSerializerContext)),
+ name: "\"controls\"");
+
+ }
+ if (request.Expire != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.Expire, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()),
+ name: "\"expire\"");
+
+ }
+ var __contentImage = new global::System.Net.Http.StreamContent(image);
+ __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ request.Imagename is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(request.Imagename) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentImage,
+ name: "\"image\"",
+ fileName: request.Imagename != null ? $"\"{request.Imagename}\"" : string.Empty);
+ if (__contentImage.Headers.ContentDisposition != null)
+ {
+ __contentImage.Headers.ContentDisposition.FileNameStar = null;
+ }
+
+ if (request.ImageFormat != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.ImageFormat).HasValue ? (request.ImageFormat).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"image_format\"");
+
+ }
+ if (request.Model != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.Model).HasValue ? (request.Model).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"model\"");
+
+ }
+ if (request.N != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.N, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
+ name: "\"n\"");
+
+ }
+ if (request.NegativePrompt != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.NegativePrompt ?? string.Empty),
+ name: "\"negative_prompt\"");
+
+ }
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty),
+ name: "\"prompt\"");
+
+ if (request.RandomSeed != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.RandomSeed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
+ name: "\"random_seed\"");
+
+ }
+ if (request.ResponseFormat != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.ResponseFormat).HasValue ? (request.ResponseFormat).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"response_format\"");
+
+ }
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Strength, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
+ name: "\"strength\"");
+
+ if (request.Style != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.Style ?? string.Empty),
+ name: "\"style\"");
+
+ }
+ if (request.StyleId != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.StyleId.ToString() ?? string.Empty),
+ name: "\"style_id\"");
+
+ }
+ if (request.Substyle != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.Substyle).HasValue ? (request.Substyle).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"substyle\"");
+
+ }
+ if (request.TextLayout != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.TextLayout, x => x.ToJson(JsonSerializerContext)))}]"),
+ name: "\"text_layout\"");
+
+ }
+
+ __httpRequest.Content = __httpRequestContent;
+
+ global::Recraft.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
+
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareImageToImageRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ billing: billing,
+ request: request);
+
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
+ {
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
+ {
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Recraft.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ImageToImage",
+ methodName: "ImageToImageAsync",
+ pathTemplate: "\"/v1/images/imageToImage\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
+ {
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ }
+ 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,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ImageToImage",
+ methodName: "ImageToImageAsync",
+ pathTemplate: "\"/v1/images/imageToImage\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Recraft.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __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(
+ operationId: "ImageToImage",
+ methodName: "ImageToImageAsync",
+ pathTemplate: "\"/v1/images/imageToImage\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ 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(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
+ }
+
+ if (__response == null)
+ {
+ throw new global::System.InvalidOperationException("No response received.");
+ }
+
+ using (__response)
+ {
+
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessImageToImageResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Recraft.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ImageToImage",
+ methodName: "ImageToImageAsync",
+ pathTemplate: "\"/v1/images/imageToImage\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ else
+ {
+ await global::Recraft.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ImageToImage",
+ methodName: "ImageToImageAsync",
+ pathTemplate: "\"/v1/images/imageToImage\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessImageToImageResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ var __value = global::Recraft.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Recraft.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ var __value = await global::Recraft.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Recraft.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
+ }
}
}
\ No newline at end of file
diff --git a/src/libs/Recraft/Generated/Recraft.ImageClient.InpaintImage.g.cs b/src/libs/Recraft/Generated/Recraft.ImageClient.InpaintImage.g.cs
index 988d5f2..226a41f 100644
--- a/src/libs/Recraft/Generated/Recraft.ImageClient.InpaintImage.g.cs
+++ b/src/libs/Recraft/Generated/Recraft.ImageClient.InpaintImage.g.cs
@@ -53,6 +53,31 @@ partial void ProcessInpaintImageResponseContent(
///
public async global::System.Threading.Tasks.Task InpaintImageAsync(
+ global::Recraft.TransformImageWithMaskRequest request,
+ global::Recraft.BillingType? billing = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+ var __response = await InpaintImageAsResponseAsync(
+
+ request: request,
+ billing: billing,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken
+ ).ConfigureAwait(false);
+
+ return __response.Body;
+ }
+ ///
+ /// Inpaint Image
+ ///
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> InpaintImageAsResponseAsync(
+
global::Recraft.TransformImageWithMaskRequest request,
global::Recraft.BillingType? billing = default,
global::Recraft.AutoSDKRequestOptions? requestOptions = default,
@@ -83,15 +108,16 @@ partial void ProcessInpaintImageResponseContent(
var __maxAttempts = global::Recraft.AutoSDKRequestOptionsSupport.GetMaxAttempts(
clientOptions: Options,
requestOptions: requestOptions,
- supportsRetry: true);
+ supportsRetry: false);
global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{
+
var __pathBuilder = new global::Recraft.PathBuilder(
path: "/v1/images/inpaint",
- baseUri: HttpClient.BaseAddress);
+ baseUri: HttpClient.BaseAddress);
__pathBuilder
- .AddOptionalParameter("billing", billing?.ToValueString())
+ .AddOptionalParameter("billing", billing?.ToValueString())
;
var __path = __pathBuilder.ToString();
__path = global::Recraft.AutoSDKRequestOptionsSupport.AppendQueryParameters(
@@ -122,6 +148,7 @@ partial void ProcessInpaintImageResponseContent(
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
}
}
+
var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
if (billing != default)
{
@@ -129,8 +156,11 @@ partial void ProcessInpaintImageResponseContent(
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((billing).HasValue ? (billing).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"billing\"");
+
}
+
__httpRequest.Content = __httpRequestContent;
+
global::Recraft.AutoSDKRequestOptionsSupport.ApplyHeaders(
request: __httpRequest,
clientHeaders: Options.Headers,
@@ -173,6 +203,8 @@ partial void ProcessInpaintImageResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
@@ -183,6 +215,11 @@ partial void ProcessInpaintImageResponseContent(
}
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,
@@ -200,6 +237,8 @@ partial void ProcessInpaintImageResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
if (!__willRetry)
{
@@ -209,8 +248,7 @@ partial void ProcessInpaintImageResponseContent(
__httpRequest.Dispose();
__httpRequest = null;
await global::Recraft.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -219,6 +257,11 @@ partial void ProcessInpaintImageResponseContent(
__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(
@@ -235,14 +278,15 @@ partial void ProcessInpaintImageResponseContent(
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;
}
@@ -282,6 +326,8 @@ partial void ProcessInpaintImageResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
else
@@ -302,6 +348,8 @@ partial void ProcessInpaintImageResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
@@ -326,9 +374,13 @@ partial void ProcessInpaintImageResponseContent(
{
__response.EnsureSuccessStatusCode();
- return
- global::Recraft.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ??
+ var __value = global::Recraft.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
@@ -356,9 +408,13 @@ partial void ProcessInpaintImageResponseContent(
#endif
).ConfigureAwait(false);
- return
- await global::Recraft.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ var __value = await global::Recraft.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
diff --git a/src/libs/Recraft/Generated/Recraft.ImageClient.RemoveBackground.g.cs b/src/libs/Recraft/Generated/Recraft.ImageClient.RemoveBackground.g.cs
index ef484f5..71bf509 100644
--- a/src/libs/Recraft/Generated/Recraft.ImageClient.RemoveBackground.g.cs
+++ b/src/libs/Recraft/Generated/Recraft.ImageClient.RemoveBackground.g.cs
@@ -53,6 +53,31 @@ partial void ProcessRemoveBackgroundResponseContent(
///
public async global::System.Threading.Tasks.Task RemoveBackgroundAsync(
+ global::Recraft.ProcessImageRequest request,
+ global::Recraft.BillingType? billing = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+ var __response = await RemoveBackgroundAsResponseAsync(
+
+ request: request,
+ billing: billing,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken
+ ).ConfigureAwait(false);
+
+ return __response.Body;
+ }
+ ///
+ /// Remove background
+ ///
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> RemoveBackgroundAsResponseAsync(
+
global::Recraft.ProcessImageRequest request,
global::Recraft.BillingType? billing = default,
global::Recraft.AutoSDKRequestOptions? requestOptions = default,
@@ -85,15 +110,16 @@ partial void ProcessRemoveBackgroundResponseContent(
var __maxAttempts = global::Recraft.AutoSDKRequestOptionsSupport.GetMaxAttempts(
clientOptions: Options,
requestOptions: requestOptions,
- supportsRetry: true);
+ supportsRetry: false);
global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{
+
var __pathBuilder = new global::Recraft.PathBuilder(
path: "/v1/images/removeBackground",
- baseUri: HttpClient.BaseAddress);
+ baseUri: HttpClient.BaseAddress);
__pathBuilder
- .AddOptionalParameter("billing", billing?.ToValueString())
+ .AddOptionalParameter("billing", billing?.ToValueString())
;
var __path = __pathBuilder.ToString();
__path = global::Recraft.AutoSDKRequestOptionsSupport.AppendQueryParameters(
@@ -124,6 +150,7 @@ partial void ProcessRemoveBackgroundResponseContent(
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
}
}
+
var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
if (billing != default)
{
@@ -131,13 +158,15 @@ partial void ProcessRemoveBackgroundResponseContent(
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((billing).HasValue ? (billing).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"billing\"");
- }
+
+ }
if (request.Expire != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.Expire, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()),
name: "\"expire\"");
+
}
var __contentImage = new global::System.Net.Http.ByteArrayContent(request.Image ?? global::System.Array.Empty());
__contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
@@ -176,28 +205,34 @@ request.Imagename is null
{
__contentImage.Headers.ContentDisposition.FileNameStar = null;
}
+
if (request.ImageFormat != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.ImageFormat).HasValue ? (request.ImageFormat).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"image_format\"");
- }
+
+ }
if (request.ResponseFormat != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.ResponseFormat).HasValue ? (request.ResponseFormat).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"response_format\"");
- }
+
+ }
if (request.Upscale != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.Upscale).HasValue ? (request.Upscale).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"upscale\"");
+
}
+
__httpRequest.Content = __httpRequestContent;
+
global::Recraft.AutoSDKRequestOptionsSupport.ApplyHeaders(
request: __httpRequest,
clientHeaders: Options.Headers,
@@ -240,6 +275,8 @@ request.Imagename is null
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
@@ -250,6 +287,11 @@ request.Imagename is null
}
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,
@@ -267,6 +309,8 @@ request.Imagename is null
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
if (!__willRetry)
{
@@ -276,8 +320,7 @@ request.Imagename is null
__httpRequest.Dispose();
__httpRequest = null;
await global::Recraft.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -286,6 +329,11 @@ request.Imagename is null
__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(
@@ -302,14 +350,15 @@ request.Imagename is null
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;
}
@@ -349,6 +398,8 @@ request.Imagename is null
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
else
@@ -369,6 +420,8 @@ request.Imagename is null
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
@@ -393,9 +446,13 @@ request.Imagename is null
{
__response.EnsureSuccessStatusCode();
- return
- global::Recraft.ProcessImageResponse.FromJson(__content, JsonSerializerContext) ??
+ var __value = global::Recraft.ProcessImageResponse.FromJson(__content, JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
@@ -423,9 +480,13 @@ request.Imagename is null
#endif
).ConfigureAwait(false);
- return
- await global::Recraft.ProcessImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ var __value = await global::Recraft.ProcessImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
@@ -503,5 +564,950 @@ request.Imagename is null
requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
+
+ ///
+ /// Remove background
+ ///
+ ///
+ ///
+ ///
+ /// The stream to send as the multipart 'image' file part.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task RemoveBackgroundAsync(
+ global::System.IO.Stream image,
+ string imagename,
+ global::Recraft.BillingType? billing = default,
+ bool? expire = default,
+ global::Recraft.ImageFormat? imageFormat = default,
+ global::Recraft.ResponseFormat? responseFormat = default,
+ global::Recraft.UpscaleMode? upscale = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+
+ image = image ?? throw new global::System.ArgumentNullException(nameof(image));
+ var request = new global::Recraft.ProcessImageRequest
+ {
+ Expire = expire,
+ Image = global::System.Array.Empty(),
+ Imagename = imagename,
+ ImageFormat = imageFormat,
+ ResponseFormat = responseFormat,
+ Upscale = upscale,
+ };
+ PrepareArguments(
+ client: HttpClient);
+ PrepareRemoveBackgroundArguments(
+ httpClient: HttpClient,
+ billing: ref billing,
+ request: request);
+
+
+ var __authorizations = global::Recraft.EndPointSecurityResolver.ResolveAuthorizations(
+ availableAuthorizations: Authorizations,
+ securityRequirements: s_RemoveBackgroundSecurityRequirements,
+ operationName: "RemoveBackgroundAsync");
+
+ using var __timeoutCancellationTokenSource = global::Recraft.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Recraft.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Recraft.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: false);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+
+ var __pathBuilder = new global::Recraft.PathBuilder(
+ path: "/v1/images/removeBackground",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("billing", billing?.ToValueString())
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::Recraft.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+#if NET6_0_OR_GREATER
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+#endif
+
+ foreach (var __authorization in __authorizations)
+ {
+ if (__authorization.Type == "Http" ||
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
+ {
+ __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
+ scheme: __authorization.Name,
+ parameter: __authorization.Value);
+ }
+ else if (__authorization.Type == "ApiKey" &&
+ __authorization.Location == "Header")
+ {
+ __httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
+ }
+ }
+
+ var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
+ if (billing != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((billing).HasValue ? (billing).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"billing\"");
+
+ }
+ if (request.Expire != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.Expire, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()),
+ name: "\"expire\"");
+
+ }
+ var __contentImage = new global::System.Net.Http.StreamContent(image);
+ __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ request.Imagename is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(request.Imagename) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentImage,
+ name: "\"image\"",
+ fileName: request.Imagename != null ? $"\"{request.Imagename}\"" : string.Empty);
+ if (__contentImage.Headers.ContentDisposition != null)
+ {
+ __contentImage.Headers.ContentDisposition.FileNameStar = null;
+ }
+
+ if (request.ImageFormat != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.ImageFormat).HasValue ? (request.ImageFormat).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"image_format\"");
+
+ }
+ if (request.ResponseFormat != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.ResponseFormat).HasValue ? (request.ResponseFormat).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"response_format\"");
+
+ }
+ if (request.Upscale != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.Upscale).HasValue ? (request.Upscale).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"upscale\"");
+
+ }
+
+ __httpRequest.Content = __httpRequestContent;
+
+ global::Recraft.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
+
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareRemoveBackgroundRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ billing: billing,
+ request: request);
+
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
+ {
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
+ {
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Recraft.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RemoveBackground",
+ methodName: "RemoveBackgroundAsync",
+ pathTemplate: "\"/v1/images/removeBackground\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
+ {
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ }
+ 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,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RemoveBackground",
+ methodName: "RemoveBackgroundAsync",
+ pathTemplate: "\"/v1/images/removeBackground\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Recraft.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __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(
+ operationId: "RemoveBackground",
+ methodName: "RemoveBackgroundAsync",
+ pathTemplate: "\"/v1/images/removeBackground\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ 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(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
+ }
+
+ if (__response == null)
+ {
+ throw new global::System.InvalidOperationException("No response received.");
+ }
+
+ using (__response)
+ {
+
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessRemoveBackgroundResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Recraft.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RemoveBackground",
+ methodName: "RemoveBackgroundAsync",
+ pathTemplate: "\"/v1/images/removeBackground\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ else
+ {
+ await global::Recraft.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RemoveBackground",
+ methodName: "RemoveBackgroundAsync",
+ pathTemplate: "\"/v1/images/removeBackground\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessRemoveBackgroundResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Recraft.ProcessImageResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Recraft.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ await global::Recraft.ProcessImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Recraft.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
+ }
+ ///
+ /// Remove background
+ ///
+ ///
+ ///
+ ///
+ /// The stream to send as the multipart 'image' file part.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> RemoveBackgroundAsResponseAsync(
+ global::System.IO.Stream image,
+ string imagename,
+ global::Recraft.BillingType? billing = default,
+ bool? expire = default,
+ global::Recraft.ImageFormat? imageFormat = default,
+ global::Recraft.ResponseFormat? responseFormat = default,
+ global::Recraft.UpscaleMode? upscale = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+
+ image = image ?? throw new global::System.ArgumentNullException(nameof(image));
+ var request = new global::Recraft.ProcessImageRequest
+ {
+ Expire = expire,
+ Image = global::System.Array.Empty(),
+ Imagename = imagename,
+ ImageFormat = imageFormat,
+ ResponseFormat = responseFormat,
+ Upscale = upscale,
+ };
+ PrepareArguments(
+ client: HttpClient);
+ PrepareRemoveBackgroundArguments(
+ httpClient: HttpClient,
+ billing: ref billing,
+ request: request);
+
+
+ var __authorizations = global::Recraft.EndPointSecurityResolver.ResolveAuthorizations(
+ availableAuthorizations: Authorizations,
+ securityRequirements: s_RemoveBackgroundSecurityRequirements,
+ operationName: "RemoveBackgroundAsync");
+
+ using var __timeoutCancellationTokenSource = global::Recraft.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Recraft.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Recraft.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: false);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+
+ var __pathBuilder = new global::Recraft.PathBuilder(
+ path: "/v1/images/removeBackground",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("billing", billing?.ToValueString())
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::Recraft.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+#if NET6_0_OR_GREATER
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+#endif
+
+ foreach (var __authorization in __authorizations)
+ {
+ if (__authorization.Type == "Http" ||
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
+ {
+ __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
+ scheme: __authorization.Name,
+ parameter: __authorization.Value);
+ }
+ else if (__authorization.Type == "ApiKey" &&
+ __authorization.Location == "Header")
+ {
+ __httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
+ }
+ }
+
+ var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
+ if (billing != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((billing).HasValue ? (billing).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"billing\"");
+
+ }
+ if (request.Expire != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.Expire, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()),
+ name: "\"expire\"");
+
+ }
+ var __contentImage = new global::System.Net.Http.StreamContent(image);
+ __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ request.Imagename is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(request.Imagename) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentImage,
+ name: "\"image\"",
+ fileName: request.Imagename != null ? $"\"{request.Imagename}\"" : string.Empty);
+ if (__contentImage.Headers.ContentDisposition != null)
+ {
+ __contentImage.Headers.ContentDisposition.FileNameStar = null;
+ }
+
+ if (request.ImageFormat != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.ImageFormat).HasValue ? (request.ImageFormat).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"image_format\"");
+
+ }
+ if (request.ResponseFormat != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.ResponseFormat).HasValue ? (request.ResponseFormat).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"response_format\"");
+
+ }
+ if (request.Upscale != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.Upscale).HasValue ? (request.Upscale).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"upscale\"");
+
+ }
+
+ __httpRequest.Content = __httpRequestContent;
+
+ global::Recraft.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
+
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareRemoveBackgroundRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ billing: billing,
+ request: request);
+
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
+ {
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
+ {
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Recraft.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RemoveBackground",
+ methodName: "RemoveBackgroundAsync",
+ pathTemplate: "\"/v1/images/removeBackground\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
+ {
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ }
+ 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,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RemoveBackground",
+ methodName: "RemoveBackgroundAsync",
+ pathTemplate: "\"/v1/images/removeBackground\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Recraft.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __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(
+ operationId: "RemoveBackground",
+ methodName: "RemoveBackgroundAsync",
+ pathTemplate: "\"/v1/images/removeBackground\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ 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(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
+ }
+
+ if (__response == null)
+ {
+ throw new global::System.InvalidOperationException("No response received.");
+ }
+
+ using (__response)
+ {
+
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessRemoveBackgroundResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Recraft.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RemoveBackground",
+ methodName: "RemoveBackgroundAsync",
+ pathTemplate: "\"/v1/images/removeBackground\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ else
+ {
+ await global::Recraft.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RemoveBackground",
+ methodName: "RemoveBackgroundAsync",
+ pathTemplate: "\"/v1/images/removeBackground\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessRemoveBackgroundResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ var __value = global::Recraft.ProcessImageResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Recraft.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ var __value = await global::Recraft.ProcessImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Recraft.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
+ }
}
}
\ No newline at end of file
diff --git a/src/libs/Recraft/Generated/Recraft.ImageClient.ReplaceBackground.g.cs b/src/libs/Recraft/Generated/Recraft.ImageClient.ReplaceBackground.g.cs
index ff12439..a047159 100644
--- a/src/libs/Recraft/Generated/Recraft.ImageClient.ReplaceBackground.g.cs
+++ b/src/libs/Recraft/Generated/Recraft.ImageClient.ReplaceBackground.g.cs
@@ -53,6 +53,31 @@ partial void ProcessReplaceBackgroundResponseContent(
///
public async global::System.Threading.Tasks.Task ReplaceBackgroundAsync(
+ global::Recraft.TransformImageRequest request,
+ global::Recraft.BillingType? billing = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+ var __response = await ReplaceBackgroundAsResponseAsync(
+
+ request: request,
+ billing: billing,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken
+ ).ConfigureAwait(false);
+
+ return __response.Body;
+ }
+ ///
+ /// Replace Background
+ ///
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> ReplaceBackgroundAsResponseAsync(
+
global::Recraft.TransformImageRequest request,
global::Recraft.BillingType? billing = default,
global::Recraft.AutoSDKRequestOptions? requestOptions = default,
@@ -85,15 +110,16 @@ partial void ProcessReplaceBackgroundResponseContent(
var __maxAttempts = global::Recraft.AutoSDKRequestOptionsSupport.GetMaxAttempts(
clientOptions: Options,
requestOptions: requestOptions,
- supportsRetry: true);
+ supportsRetry: false);
global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{
+
var __pathBuilder = new global::Recraft.PathBuilder(
path: "/v1/images/replaceBackground",
- baseUri: HttpClient.BaseAddress);
+ baseUri: HttpClient.BaseAddress);
__pathBuilder
- .AddOptionalParameter("billing", billing?.ToValueString())
+ .AddOptionalParameter("billing", billing?.ToValueString())
;
var __path = __pathBuilder.ToString();
__path = global::Recraft.AutoSDKRequestOptionsSupport.AppendQueryParameters(
@@ -124,6 +150,7 @@ partial void ProcessReplaceBackgroundResponseContent(
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
}
}
+
var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
if (billing != default)
{
@@ -131,27 +158,31 @@ partial void ProcessReplaceBackgroundResponseContent(
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((billing).HasValue ? (billing).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"billing\"");
- }
+
+ }
if (request.BlockNsfw != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.BlockNsfw, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()),
name: "\"block_nsfw\"");
- }
+
+ }
if (request.CalculateFeatures != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.CalculateFeatures, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()),
name: "\"calculate_features\"");
- }
+
+ }
if (request.Expire != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.Expire, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()),
name: "\"expire\"");
+
}
var __contentImage = new global::System.Net.Http.ByteArrayContent(request.Image ?? global::System.Array.Empty());
__contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
@@ -190,80 +221,94 @@ request.Imagename is null
{
__contentImage.Headers.ContentDisposition.FileNameStar = null;
}
+
if (request.ImageFormat != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.ImageFormat).HasValue ? (request.ImageFormat).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"image_format\"");
- }
+
+ }
if (request.Model != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.Model).HasValue ? (request.Model).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"model\"");
- }
+
+ }
if (request.N != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.N, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
name: "\"n\"");
- }
+
+ }
if (request.NegativePrompt != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(request.NegativePrompt ?? string.Empty),
name: "\"negative_prompt\"");
+
}
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty),
name: "\"prompt\"");
+
if (request.RandomSeed != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.RandomSeed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
name: "\"random_seed\"");
- }
+
+ }
if (request.ResponseFormat != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.ResponseFormat).HasValue ? (request.ResponseFormat).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"response_format\"");
- }
+
+ }
if (request.Style != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(request.Style ?? string.Empty),
name: "\"style\"");
- }
+
+ }
if (request.StyleId != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(request.StyleId.ToString() ?? string.Empty),
name: "\"style_id\"");
- }
+
+ }
if (request.Substyle != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.Substyle).HasValue ? (request.Substyle).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"substyle\"");
- }
+
+ }
if (request.TextLayout != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.TextLayout, x => x.ToJson(JsonSerializerContext)))}]"),
name: "\"text_layout\"");
+
}
+
__httpRequest.Content = __httpRequestContent;
+
global::Recraft.AutoSDKRequestOptionsSupport.ApplyHeaders(
request: __httpRequest,
clientHeaders: Options.Headers,
@@ -306,6 +351,8 @@ request.Imagename is null
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
@@ -316,6 +363,11 @@ request.Imagename is null
}
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,
@@ -333,6 +385,8 @@ request.Imagename is null
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
if (!__willRetry)
{
@@ -342,8 +396,7 @@ request.Imagename is null
__httpRequest.Dispose();
__httpRequest = null;
await global::Recraft.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -352,6 +405,11 @@ request.Imagename is null
__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(
@@ -368,14 +426,15 @@ request.Imagename is null
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;
}
@@ -415,6 +474,8 @@ request.Imagename is null
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
else
@@ -435,6 +496,8 @@ request.Imagename is null
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
@@ -459,9 +522,13 @@ request.Imagename is null
{
__response.EnsureSuccessStatusCode();
- return
- global::Recraft.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ??
+ var __value = global::Recraft.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
@@ -489,9 +556,13 @@ request.Imagename is null
#endif
).ConfigureAwait(false);
- return
- await global::Recraft.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ var __value = await global::Recraft.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
@@ -599,5 +670,1162 @@ request.Imagename is null
requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
+
+ ///
+ /// Replace Background
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// The stream to send as the multipart 'image' file part.
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task ReplaceBackgroundAsync(
+ global::System.IO.Stream image,
+ string imagename,
+ string prompt,
+ global::Recraft.BillingType? billing = default,
+ bool? blockNsfw = default,
+ bool? calculateFeatures = default,
+ bool? expire = default,
+ global::Recraft.ImageFormat? imageFormat = default,
+ global::Recraft.TransformModel? model = default,
+ int? n = default,
+ string? negativePrompt = default,
+ int? randomSeed = default,
+ global::Recraft.ResponseFormat? responseFormat = default,
+ string? style = default,
+ global::System.Guid? styleId = default,
+ global::Recraft.ImageSubStyle? substyle = default,
+ global::System.Collections.Generic.IList? textLayout = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+
+ image = image ?? throw new global::System.ArgumentNullException(nameof(image));
+ var request = new global::Recraft.TransformImageRequest
+ {
+ BlockNsfw = blockNsfw,
+ CalculateFeatures = calculateFeatures,
+ Expire = expire,
+ Image = global::System.Array.Empty(),
+ Imagename = imagename,
+ ImageFormat = imageFormat,
+ Model = model,
+ N = n,
+ NegativePrompt = negativePrompt,
+ Prompt = prompt,
+ RandomSeed = randomSeed,
+ ResponseFormat = responseFormat,
+ Style = style,
+ StyleId = styleId,
+ Substyle = substyle,
+ TextLayout = textLayout,
+ };
+ PrepareArguments(
+ client: HttpClient);
+ PrepareReplaceBackgroundArguments(
+ httpClient: HttpClient,
+ billing: ref billing,
+ request: request);
+
+
+ var __authorizations = global::Recraft.EndPointSecurityResolver.ResolveAuthorizations(
+ availableAuthorizations: Authorizations,
+ securityRequirements: s_ReplaceBackgroundSecurityRequirements,
+ operationName: "ReplaceBackgroundAsync");
+
+ using var __timeoutCancellationTokenSource = global::Recraft.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Recraft.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Recraft.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: false);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+
+ var __pathBuilder = new global::Recraft.PathBuilder(
+ path: "/v1/images/replaceBackground",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("billing", billing?.ToValueString())
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::Recraft.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+#if NET6_0_OR_GREATER
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+#endif
+
+ foreach (var __authorization in __authorizations)
+ {
+ if (__authorization.Type == "Http" ||
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
+ {
+ __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
+ scheme: __authorization.Name,
+ parameter: __authorization.Value);
+ }
+ else if (__authorization.Type == "ApiKey" &&
+ __authorization.Location == "Header")
+ {
+ __httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
+ }
+ }
+
+ var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
+ if (billing != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((billing).HasValue ? (billing).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"billing\"");
+
+ }
+ if (request.BlockNsfw != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.BlockNsfw, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()),
+ name: "\"block_nsfw\"");
+
+ }
+ if (request.CalculateFeatures != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.CalculateFeatures, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()),
+ name: "\"calculate_features\"");
+
+ }
+ if (request.Expire != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.Expire, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()),
+ name: "\"expire\"");
+
+ }
+ var __contentImage = new global::System.Net.Http.StreamContent(image);
+ __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ request.Imagename is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(request.Imagename) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentImage,
+ name: "\"image\"",
+ fileName: request.Imagename != null ? $"\"{request.Imagename}\"" : string.Empty);
+ if (__contentImage.Headers.ContentDisposition != null)
+ {
+ __contentImage.Headers.ContentDisposition.FileNameStar = null;
+ }
+
+ if (request.ImageFormat != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.ImageFormat).HasValue ? (request.ImageFormat).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"image_format\"");
+
+ }
+ if (request.Model != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.Model).HasValue ? (request.Model).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"model\"");
+
+ }
+ if (request.N != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.N, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
+ name: "\"n\"");
+
+ }
+ if (request.NegativePrompt != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.NegativePrompt ?? string.Empty),
+ name: "\"negative_prompt\"");
+
+ }
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty),
+ name: "\"prompt\"");
+
+ if (request.RandomSeed != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.RandomSeed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
+ name: "\"random_seed\"");
+
+ }
+ if (request.ResponseFormat != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.ResponseFormat).HasValue ? (request.ResponseFormat).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"response_format\"");
+
+ }
+ if (request.Style != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.Style ?? string.Empty),
+ name: "\"style\"");
+
+ }
+ if (request.StyleId != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.StyleId.ToString() ?? string.Empty),
+ name: "\"style_id\"");
+
+ }
+ if (request.Substyle != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.Substyle).HasValue ? (request.Substyle).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"substyle\"");
+
+ }
+ if (request.TextLayout != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.TextLayout, x => x.ToJson(JsonSerializerContext)))}]"),
+ name: "\"text_layout\"");
+
+ }
+
+ __httpRequest.Content = __httpRequestContent;
+
+ global::Recraft.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
+
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareReplaceBackgroundRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ billing: billing,
+ request: request);
+
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
+ {
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
+ {
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Recraft.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ReplaceBackground",
+ methodName: "ReplaceBackgroundAsync",
+ pathTemplate: "\"/v1/images/replaceBackground\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
+ {
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ }
+ 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,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ReplaceBackground",
+ methodName: "ReplaceBackgroundAsync",
+ pathTemplate: "\"/v1/images/replaceBackground\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Recraft.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __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(
+ operationId: "ReplaceBackground",
+ methodName: "ReplaceBackgroundAsync",
+ pathTemplate: "\"/v1/images/replaceBackground\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ 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(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
+ }
+
+ if (__response == null)
+ {
+ throw new global::System.InvalidOperationException("No response received.");
+ }
+
+ using (__response)
+ {
+
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessReplaceBackgroundResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Recraft.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ReplaceBackground",
+ methodName: "ReplaceBackgroundAsync",
+ pathTemplate: "\"/v1/images/replaceBackground\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ else
+ {
+ await global::Recraft.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ReplaceBackground",
+ methodName: "ReplaceBackgroundAsync",
+ pathTemplate: "\"/v1/images/replaceBackground\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessReplaceBackgroundResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Recraft.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Recraft.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ await global::Recraft.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Recraft.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
+ }
+ ///
+ /// Replace Background
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// The stream to send as the multipart 'image' file part.
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> ReplaceBackgroundAsResponseAsync(
+ global::System.IO.Stream image,
+ string imagename,
+ string prompt,
+ global::Recraft.BillingType? billing = default,
+ bool? blockNsfw = default,
+ bool? calculateFeatures = default,
+ bool? expire = default,
+ global::Recraft.ImageFormat? imageFormat = default,
+ global::Recraft.TransformModel? model = default,
+ int? n = default,
+ string? negativePrompt = default,
+ int? randomSeed = default,
+ global::Recraft.ResponseFormat? responseFormat = default,
+ string? style = default,
+ global::System.Guid? styleId = default,
+ global::Recraft.ImageSubStyle? substyle = default,
+ global::System.Collections.Generic.IList? textLayout = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+
+ image = image ?? throw new global::System.ArgumentNullException(nameof(image));
+ var request = new global::Recraft.TransformImageRequest
+ {
+ BlockNsfw = blockNsfw,
+ CalculateFeatures = calculateFeatures,
+ Expire = expire,
+ Image = global::System.Array.Empty(),
+ Imagename = imagename,
+ ImageFormat = imageFormat,
+ Model = model,
+ N = n,
+ NegativePrompt = negativePrompt,
+ Prompt = prompt,
+ RandomSeed = randomSeed,
+ ResponseFormat = responseFormat,
+ Style = style,
+ StyleId = styleId,
+ Substyle = substyle,
+ TextLayout = textLayout,
+ };
+ PrepareArguments(
+ client: HttpClient);
+ PrepareReplaceBackgroundArguments(
+ httpClient: HttpClient,
+ billing: ref billing,
+ request: request);
+
+
+ var __authorizations = global::Recraft.EndPointSecurityResolver.ResolveAuthorizations(
+ availableAuthorizations: Authorizations,
+ securityRequirements: s_ReplaceBackgroundSecurityRequirements,
+ operationName: "ReplaceBackgroundAsync");
+
+ using var __timeoutCancellationTokenSource = global::Recraft.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Recraft.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Recraft.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: false);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+
+ var __pathBuilder = new global::Recraft.PathBuilder(
+ path: "/v1/images/replaceBackground",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("billing", billing?.ToValueString())
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::Recraft.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+#if NET6_0_OR_GREATER
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+#endif
+
+ foreach (var __authorization in __authorizations)
+ {
+ if (__authorization.Type == "Http" ||
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
+ {
+ __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
+ scheme: __authorization.Name,
+ parameter: __authorization.Value);
+ }
+ else if (__authorization.Type == "ApiKey" &&
+ __authorization.Location == "Header")
+ {
+ __httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
+ }
+ }
+
+ var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
+ if (billing != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((billing).HasValue ? (billing).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"billing\"");
+
+ }
+ if (request.BlockNsfw != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.BlockNsfw, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()),
+ name: "\"block_nsfw\"");
+
+ }
+ if (request.CalculateFeatures != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.CalculateFeatures, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()),
+ name: "\"calculate_features\"");
+
+ }
+ if (request.Expire != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.Expire, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()),
+ name: "\"expire\"");
+
+ }
+ var __contentImage = new global::System.Net.Http.StreamContent(image);
+ __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ request.Imagename is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(request.Imagename) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentImage,
+ name: "\"image\"",
+ fileName: request.Imagename != null ? $"\"{request.Imagename}\"" : string.Empty);
+ if (__contentImage.Headers.ContentDisposition != null)
+ {
+ __contentImage.Headers.ContentDisposition.FileNameStar = null;
+ }
+
+ if (request.ImageFormat != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.ImageFormat).HasValue ? (request.ImageFormat).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"image_format\"");
+
+ }
+ if (request.Model != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.Model).HasValue ? (request.Model).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"model\"");
+
+ }
+ if (request.N != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.N, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
+ name: "\"n\"");
+
+ }
+ if (request.NegativePrompt != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.NegativePrompt ?? string.Empty),
+ name: "\"negative_prompt\"");
+
+ }
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty),
+ name: "\"prompt\"");
+
+ if (request.RandomSeed != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.RandomSeed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
+ name: "\"random_seed\"");
+
+ }
+ if (request.ResponseFormat != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.ResponseFormat).HasValue ? (request.ResponseFormat).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"response_format\"");
+
+ }
+ if (request.Style != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.Style ?? string.Empty),
+ name: "\"style\"");
+
+ }
+ if (request.StyleId != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.StyleId.ToString() ?? string.Empty),
+ name: "\"style_id\"");
+
+ }
+ if (request.Substyle != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.Substyle).HasValue ? (request.Substyle).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"substyle\"");
+
+ }
+ if (request.TextLayout != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.TextLayout, x => x.ToJson(JsonSerializerContext)))}]"),
+ name: "\"text_layout\"");
+
+ }
+
+ __httpRequest.Content = __httpRequestContent;
+
+ global::Recraft.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
+
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareReplaceBackgroundRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ billing: billing,
+ request: request);
+
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
+ {
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
+ {
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Recraft.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ReplaceBackground",
+ methodName: "ReplaceBackgroundAsync",
+ pathTemplate: "\"/v1/images/replaceBackground\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
+ {
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ }
+ 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,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ReplaceBackground",
+ methodName: "ReplaceBackgroundAsync",
+ pathTemplate: "\"/v1/images/replaceBackground\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Recraft.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __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(
+ operationId: "ReplaceBackground",
+ methodName: "ReplaceBackgroundAsync",
+ pathTemplate: "\"/v1/images/replaceBackground\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ 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(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
+ }
+
+ if (__response == null)
+ {
+ throw new global::System.InvalidOperationException("No response received.");
+ }
+
+ using (__response)
+ {
+
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessReplaceBackgroundResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Recraft.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ReplaceBackground",
+ methodName: "ReplaceBackgroundAsync",
+ pathTemplate: "\"/v1/images/replaceBackground\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ else
+ {
+ await global::Recraft.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ReplaceBackground",
+ methodName: "ReplaceBackgroundAsync",
+ pathTemplate: "\"/v1/images/replaceBackground\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessReplaceBackgroundResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ var __value = global::Recraft.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Recraft.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ var __value = await global::Recraft.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Recraft.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
+ }
}
}
\ No newline at end of file
diff --git a/src/libs/Recraft/Generated/Recraft.ImageClient.VariateImage.g.cs b/src/libs/Recraft/Generated/Recraft.ImageClient.VariateImage.g.cs
index f2e7790..be9070f 100644
--- a/src/libs/Recraft/Generated/Recraft.ImageClient.VariateImage.g.cs
+++ b/src/libs/Recraft/Generated/Recraft.ImageClient.VariateImage.g.cs
@@ -53,6 +53,31 @@ partial void ProcessVariateImageResponseContent(
///
public async global::System.Threading.Tasks.Task VariateImageAsync(
+ global::Recraft.VariateImageRequest request,
+ global::Recraft.BillingType? billing = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+ var __response = await VariateImageAsResponseAsync(
+
+ request: request,
+ billing: billing,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken
+ ).ConfigureAwait(false);
+
+ return __response.Body;
+ }
+ ///
+ /// Variate Image
+ ///
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> VariateImageAsResponseAsync(
+
global::Recraft.VariateImageRequest request,
global::Recraft.BillingType? billing = default,
global::Recraft.AutoSDKRequestOptions? requestOptions = default,
@@ -85,15 +110,16 @@ partial void ProcessVariateImageResponseContent(
var __maxAttempts = global::Recraft.AutoSDKRequestOptionsSupport.GetMaxAttempts(
clientOptions: Options,
requestOptions: requestOptions,
- supportsRetry: true);
+ supportsRetry: false);
global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{
+
var __pathBuilder = new global::Recraft.PathBuilder(
path: "/v1/images/variateImage",
- baseUri: HttpClient.BaseAddress);
+ baseUri: HttpClient.BaseAddress);
__pathBuilder
- .AddOptionalParameter("billing", billing?.ToValueString())
+ .AddOptionalParameter("billing", billing?.ToValueString())
;
var __path = __pathBuilder.ToString();
__path = global::Recraft.AutoSDKRequestOptionsSupport.AppendQueryParameters(
@@ -124,6 +150,7 @@ partial void ProcessVariateImageResponseContent(
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
}
}
+
var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
if (billing != default)
{
@@ -131,13 +158,15 @@ partial void ProcessVariateImageResponseContent(
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((billing).HasValue ? (billing).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"billing\"");
- }
+
+ }
if (request.Expire != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.Expire, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()),
name: "\"expire\"");
+
}
var __contentImage = new global::System.Net.Http.ByteArrayContent(request.Image ?? global::System.Array.Empty());
__contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
@@ -176,38 +205,45 @@ request.Imagename is null
{
__contentImage.Headers.ContentDisposition.FileNameStar = null;
}
+
if (request.ImageFormat != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.ImageFormat).HasValue ? (request.ImageFormat).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"image_format\"");
- }
+
+ }
if (request.N != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.N, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
name: "\"n\"");
- }
+
+ }
if (request.RandomSeed != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.RandomSeed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
name: "\"random_seed\"");
- }
+
+ }
if (request.ResponseFormat != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.ResponseFormat).HasValue ? (request.ResponseFormat).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"response_format\"");
+
}
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(request.Size.ToValueString()),
name: "\"size\"");
+
__httpRequest.Content = __httpRequestContent;
+
global::Recraft.AutoSDKRequestOptionsSupport.ApplyHeaders(
request: __httpRequest,
clientHeaders: Options.Headers,
@@ -250,6 +286,8 @@ request.Imagename is null
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
@@ -260,6 +298,11 @@ request.Imagename is null
}
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,
@@ -277,6 +320,8 @@ request.Imagename is null
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
if (!__willRetry)
{
@@ -286,8 +331,7 @@ request.Imagename is null
__httpRequest.Dispose();
__httpRequest = null;
await global::Recraft.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -296,6 +340,11 @@ request.Imagename is null
__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(
@@ -312,14 +361,15 @@ request.Imagename is null
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;
}
@@ -359,6 +409,8 @@ request.Imagename is null
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
else
@@ -379,6 +431,8 @@ request.Imagename is null
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
@@ -403,9 +457,13 @@ request.Imagename is null
{
__response.EnsureSuccessStatusCode();
- return
- global::Recraft.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ??
+ var __value = global::Recraft.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
@@ -433,9 +491,13 @@ request.Imagename is null
#endif
).ConfigureAwait(false);
- return
- await global::Recraft.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ var __value = await global::Recraft.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
@@ -519,5 +581,984 @@ request.Imagename is null
requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
+
+ ///
+ /// Variate Image
+ ///
+ ///
+ ///
+ ///
+ /// The stream to send as the multipart 'image' file part.
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task VariateImageAsync(
+ global::System.IO.Stream image,
+ string imagename,
+ global::Recraft.ImageSize size,
+ global::Recraft.BillingType? billing = default,
+ bool? expire = default,
+ global::Recraft.ImageFormat? imageFormat = default,
+ int? n = default,
+ int? randomSeed = default,
+ global::Recraft.ResponseFormat? responseFormat = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+
+ image = image ?? throw new global::System.ArgumentNullException(nameof(image));
+ var request = new global::Recraft.VariateImageRequest
+ {
+ Expire = expire,
+ Image = global::System.Array.Empty(),
+ Imagename = imagename,
+ ImageFormat = imageFormat,
+ N = n,
+ RandomSeed = randomSeed,
+ ResponseFormat = responseFormat,
+ Size = size,
+ };
+ PrepareArguments(
+ client: HttpClient);
+ PrepareVariateImageArguments(
+ httpClient: HttpClient,
+ billing: ref billing,
+ request: request);
+
+
+ var __authorizations = global::Recraft.EndPointSecurityResolver.ResolveAuthorizations(
+ availableAuthorizations: Authorizations,
+ securityRequirements: s_VariateImageSecurityRequirements,
+ operationName: "VariateImageAsync");
+
+ using var __timeoutCancellationTokenSource = global::Recraft.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Recraft.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Recraft.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: false);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+
+ var __pathBuilder = new global::Recraft.PathBuilder(
+ path: "/v1/images/variateImage",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("billing", billing?.ToValueString())
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::Recraft.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+#if NET6_0_OR_GREATER
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+#endif
+
+ foreach (var __authorization in __authorizations)
+ {
+ if (__authorization.Type == "Http" ||
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
+ {
+ __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
+ scheme: __authorization.Name,
+ parameter: __authorization.Value);
+ }
+ else if (__authorization.Type == "ApiKey" &&
+ __authorization.Location == "Header")
+ {
+ __httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
+ }
+ }
+
+ var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
+ if (billing != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((billing).HasValue ? (billing).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"billing\"");
+
+ }
+ if (request.Expire != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.Expire, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()),
+ name: "\"expire\"");
+
+ }
+ var __contentImage = new global::System.Net.Http.StreamContent(image);
+ __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ request.Imagename is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(request.Imagename) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentImage,
+ name: "\"image\"",
+ fileName: request.Imagename != null ? $"\"{request.Imagename}\"" : string.Empty);
+ if (__contentImage.Headers.ContentDisposition != null)
+ {
+ __contentImage.Headers.ContentDisposition.FileNameStar = null;
+ }
+
+ if (request.ImageFormat != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.ImageFormat).HasValue ? (request.ImageFormat).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"image_format\"");
+
+ }
+ if (request.N != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.N, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
+ name: "\"n\"");
+
+ }
+ if (request.RandomSeed != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.RandomSeed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
+ name: "\"random_seed\"");
+
+ }
+ if (request.ResponseFormat != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.ResponseFormat).HasValue ? (request.ResponseFormat).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"response_format\"");
+
+ }
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.Size.ToValueString()),
+ name: "\"size\"");
+
+ __httpRequest.Content = __httpRequestContent;
+
+ global::Recraft.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
+
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareVariateImageRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ billing: billing,
+ request: request);
+
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
+ {
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
+ {
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Recraft.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "VariateImage",
+ methodName: "VariateImageAsync",
+ pathTemplate: "\"/v1/images/variateImage\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
+ {
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ }
+ 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,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "VariateImage",
+ methodName: "VariateImageAsync",
+ pathTemplate: "\"/v1/images/variateImage\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Recraft.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __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(
+ operationId: "VariateImage",
+ methodName: "VariateImageAsync",
+ pathTemplate: "\"/v1/images/variateImage\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ 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(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
+ }
+
+ if (__response == null)
+ {
+ throw new global::System.InvalidOperationException("No response received.");
+ }
+
+ using (__response)
+ {
+
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessVariateImageResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Recraft.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "VariateImage",
+ methodName: "VariateImageAsync",
+ pathTemplate: "\"/v1/images/variateImage\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ else
+ {
+ await global::Recraft.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "VariateImage",
+ methodName: "VariateImageAsync",
+ pathTemplate: "\"/v1/images/variateImage\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessVariateImageResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Recraft.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Recraft.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ await global::Recraft.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Recraft.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
+ }
+ ///
+ /// Variate Image
+ ///
+ ///
+ ///
+ ///
+ /// The stream to send as the multipart 'image' file part.
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> VariateImageAsResponseAsync(
+ global::System.IO.Stream image,
+ string imagename,
+ global::Recraft.ImageSize size,
+ global::Recraft.BillingType? billing = default,
+ bool? expire = default,
+ global::Recraft.ImageFormat? imageFormat = default,
+ int? n = default,
+ int? randomSeed = default,
+ global::Recraft.ResponseFormat? responseFormat = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+
+ image = image ?? throw new global::System.ArgumentNullException(nameof(image));
+ var request = new global::Recraft.VariateImageRequest
+ {
+ Expire = expire,
+ Image = global::System.Array.Empty(),
+ Imagename = imagename,
+ ImageFormat = imageFormat,
+ N = n,
+ RandomSeed = randomSeed,
+ ResponseFormat = responseFormat,
+ Size = size,
+ };
+ PrepareArguments(
+ client: HttpClient);
+ PrepareVariateImageArguments(
+ httpClient: HttpClient,
+ billing: ref billing,
+ request: request);
+
+
+ var __authorizations = global::Recraft.EndPointSecurityResolver.ResolveAuthorizations(
+ availableAuthorizations: Authorizations,
+ securityRequirements: s_VariateImageSecurityRequirements,
+ operationName: "VariateImageAsync");
+
+ using var __timeoutCancellationTokenSource = global::Recraft.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Recraft.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Recraft.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: false);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+
+ var __pathBuilder = new global::Recraft.PathBuilder(
+ path: "/v1/images/variateImage",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("billing", billing?.ToValueString())
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::Recraft.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+#if NET6_0_OR_GREATER
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+#endif
+
+ foreach (var __authorization in __authorizations)
+ {
+ if (__authorization.Type == "Http" ||
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
+ {
+ __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
+ scheme: __authorization.Name,
+ parameter: __authorization.Value);
+ }
+ else if (__authorization.Type == "ApiKey" &&
+ __authorization.Location == "Header")
+ {
+ __httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
+ }
+ }
+
+ var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
+ if (billing != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((billing).HasValue ? (billing).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"billing\"");
+
+ }
+ if (request.Expire != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.Expire, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()),
+ name: "\"expire\"");
+
+ }
+ var __contentImage = new global::System.Net.Http.StreamContent(image);
+ __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ request.Imagename is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(request.Imagename) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentImage,
+ name: "\"image\"",
+ fileName: request.Imagename != null ? $"\"{request.Imagename}\"" : string.Empty);
+ if (__contentImage.Headers.ContentDisposition != null)
+ {
+ __contentImage.Headers.ContentDisposition.FileNameStar = null;
+ }
+
+ if (request.ImageFormat != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.ImageFormat).HasValue ? (request.ImageFormat).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"image_format\"");
+
+ }
+ if (request.N != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.N, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
+ name: "\"n\"");
+
+ }
+ if (request.RandomSeed != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.RandomSeed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
+ name: "\"random_seed\"");
+
+ }
+ if (request.ResponseFormat != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.ResponseFormat).HasValue ? (request.ResponseFormat).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"response_format\"");
+
+ }
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.Size.ToValueString()),
+ name: "\"size\"");
+
+ __httpRequest.Content = __httpRequestContent;
+
+ global::Recraft.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
+
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareVariateImageRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ billing: billing,
+ request: request);
+
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
+ {
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
+ {
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Recraft.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "VariateImage",
+ methodName: "VariateImageAsync",
+ pathTemplate: "\"/v1/images/variateImage\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
+ {
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ }
+ 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,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "VariateImage",
+ methodName: "VariateImageAsync",
+ pathTemplate: "\"/v1/images/variateImage\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Recraft.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __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(
+ operationId: "VariateImage",
+ methodName: "VariateImageAsync",
+ pathTemplate: "\"/v1/images/variateImage\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ 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(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
+ }
+
+ if (__response == null)
+ {
+ throw new global::System.InvalidOperationException("No response received.");
+ }
+
+ using (__response)
+ {
+
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessVariateImageResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Recraft.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "VariateImage",
+ methodName: "VariateImageAsync",
+ pathTemplate: "\"/v1/images/variateImage\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ else
+ {
+ await global::Recraft.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "VariateImage",
+ methodName: "VariateImageAsync",
+ pathTemplate: "\"/v1/images/variateImage\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessVariateImageResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ var __value = global::Recraft.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Recraft.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ var __value = await global::Recraft.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Recraft.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
+ }
}
}
\ No newline at end of file
diff --git a/src/libs/Recraft/Generated/Recraft.ImageClient.VectorizeImage.g.cs b/src/libs/Recraft/Generated/Recraft.ImageClient.VectorizeImage.g.cs
index 78ed531..04780c5 100644
--- a/src/libs/Recraft/Generated/Recraft.ImageClient.VectorizeImage.g.cs
+++ b/src/libs/Recraft/Generated/Recraft.ImageClient.VectorizeImage.g.cs
@@ -53,6 +53,31 @@ partial void ProcessVectorizeImageResponseContent(
///
public async global::System.Threading.Tasks.Task VectorizeImageAsync(
+ global::Recraft.VectorizeImageRequest request,
+ global::Recraft.BillingType? billing = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+ var __response = await VectorizeImageAsResponseAsync(
+
+ request: request,
+ billing: billing,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken
+ ).ConfigureAwait(false);
+
+ return __response.Body;
+ }
+ ///
+ /// Vectorize image
+ ///
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> VectorizeImageAsResponseAsync(
+
global::Recraft.VectorizeImageRequest request,
global::Recraft.BillingType? billing = default,
global::Recraft.AutoSDKRequestOptions? requestOptions = default,
@@ -83,15 +108,16 @@ partial void ProcessVectorizeImageResponseContent(
var __maxAttempts = global::Recraft.AutoSDKRequestOptionsSupport.GetMaxAttempts(
clientOptions: Options,
requestOptions: requestOptions,
- supportsRetry: true);
+ supportsRetry: false);
global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{
+
var __pathBuilder = new global::Recraft.PathBuilder(
path: "/v1/images/vectorize",
- baseUri: HttpClient.BaseAddress);
+ baseUri: HttpClient.BaseAddress);
__pathBuilder
- .AddOptionalParameter("billing", billing?.ToValueString())
+ .AddOptionalParameter("billing", billing?.ToValueString())
;
var __path = __pathBuilder.ToString();
__path = global::Recraft.AutoSDKRequestOptionsSupport.AppendQueryParameters(
@@ -122,6 +148,7 @@ partial void ProcessVectorizeImageResponseContent(
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
}
}
+
var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
if (billing != default)
{
@@ -129,8 +156,11 @@ partial void ProcessVectorizeImageResponseContent(
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((billing).HasValue ? (billing).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"billing\"");
+
}
+
__httpRequest.Content = __httpRequestContent;
+
global::Recraft.AutoSDKRequestOptionsSupport.ApplyHeaders(
request: __httpRequest,
clientHeaders: Options.Headers,
@@ -173,6 +203,8 @@ partial void ProcessVectorizeImageResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
@@ -183,6 +215,11 @@ partial void ProcessVectorizeImageResponseContent(
}
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,
@@ -200,6 +237,8 @@ partial void ProcessVectorizeImageResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
if (!__willRetry)
{
@@ -209,8 +248,7 @@ partial void ProcessVectorizeImageResponseContent(
__httpRequest.Dispose();
__httpRequest = null;
await global::Recraft.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -219,6 +257,11 @@ partial void ProcessVectorizeImageResponseContent(
__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(
@@ -235,14 +278,15 @@ partial void ProcessVectorizeImageResponseContent(
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;
}
@@ -282,6 +326,8 @@ partial void ProcessVectorizeImageResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
else
@@ -302,6 +348,8 @@ partial void ProcessVectorizeImageResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
@@ -326,9 +374,13 @@ partial void ProcessVectorizeImageResponseContent(
{
__response.EnsureSuccessStatusCode();
- return
- global::Recraft.ProcessImageResponse.FromJson(__content, JsonSerializerContext) ??
+ var __value = global::Recraft.ProcessImageResponse.FromJson(__content, JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
@@ -356,9 +408,13 @@ partial void ProcessVectorizeImageResponseContent(
#endif
).ConfigureAwait(false);
- return
- await global::Recraft.ProcessImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ var __value = await global::Recraft.ProcessImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
diff --git a/src/libs/Recraft/Generated/Recraft.ImageClient.g.cs b/src/libs/Recraft/Generated/Recraft.ImageClient.g.cs
index 7efb37c..18fc884 100644
--- a/src/libs/Recraft/Generated/Recraft.ImageClient.g.cs
+++ b/src/libs/Recraft/Generated/Recraft.ImageClient.g.cs
@@ -72,10 +72,10 @@ public ImageClient(
/// Client-wide request defaults such as headers, query parameters, retries, and timeout.
/// Dispose the HttpClient when the instance is disposed. True by default.
public ImageClient(
- global::System.Net.Http.HttpClient? httpClient = null,
- global::System.Uri? baseUri = null,
- global::System.Collections.Generic.List? authorizations = null,
- global::Recraft.AutoSDKClientOptions? options = null,
+ global::System.Net.Http.HttpClient? httpClient,
+ global::System.Uri? baseUri,
+ global::System.Collections.Generic.List? authorizations,
+ global::Recraft.AutoSDKClientOptions? options,
bool disposeHttpClient = true)
{
diff --git a/src/libs/Recraft/Generated/Recraft.OptionsSupport.g.cs b/src/libs/Recraft/Generated/Recraft.OptionsSupport.g.cs
index b422453..4d65880 100644
--- a/src/libs/Recraft/Generated/Recraft.OptionsSupport.g.cs
+++ b/src/libs/Recraft/Generated/Recraft.OptionsSupport.g.cs
@@ -101,9 +101,45 @@ public sealed class AutoSDKRetryOptions
public int MaxAttempts { get; set; } = 1;
///
- /// Optional fixed delay between retry attempts.
+ /// Optional fixed delay between retry attempts. When set, this takes precedence over exponential backoff.
///
public global::System.TimeSpan? Delay { get; set; }
+
+ ///
+ /// Initial exponential backoff delay used when is not set.
+ ///
+ public global::System.TimeSpan InitialDelay { get; set; } = global::System.TimeSpan.FromSeconds(1);
+
+ ///
+ /// Maximum retry delay after applying retry headers, backoff, and jitter.
+ ///
+ public global::System.TimeSpan MaxDelay { get; set; } = global::System.TimeSpan.FromSeconds(30);
+
+ ///
+ /// Multiplier applied to exponential backoff after each failed attempt.
+ /// Values below 1 are normalized to 1.
+ ///
+ public double BackoffMultiplier { get; set; } = 2D;
+
+ ///
+ /// Randomizes computed backoff by plus or minus this ratio. Values are clamped to 0..1.
+ ///
+ public double JitterRatio { get; set; } = 0.2D;
+
+ ///
+ /// Whether Retry-After response headers should control retry delay when present.
+ ///
+ public bool UseRetryAfterHeader { get; set; } = true;
+
+ ///
+ /// Whether a rate-limit reset response header should control retry delay when present.
+ ///
+ public bool UseRateLimitResetHeader { get; set; }
+
+ ///
+ /// Optional provider-specific rate-limit reset header name. Values may be Unix seconds or an HTTP date.
+ ///
+ public string? RateLimitResetHeaderName { get; set; } = "X-RateLimit-Reset";
}
@@ -231,6 +267,16 @@ public sealed class AutoSDKHookContext
///
public bool WillRetry { get; set; }
+ ///
+ /// The computed retry delay when is true.
+ ///
+ public global::System.TimeSpan? RetryDelay { get; set; }
+
+ ///
+ /// A short retry reason such as exception or status:429.
+ ///
+ public string RetryReason { get; set; } = string.Empty;
+
///
/// The effective cancellation token for the current request attempt.
///
@@ -254,6 +300,8 @@ internal static class AutoSDKRequestOptionsSupport
int attempt,
int maxAttempts,
bool willRetry,
+ global::System.TimeSpan? retryDelay,
+ string retryReason,
global::System.Threading.CancellationToken cancellationToken)
{
return new global::Recraft.AutoSDKHookContext
@@ -271,6 +319,8 @@ internal static class AutoSDKRequestOptionsSupport
Attempt = attempt,
MaxAttempts = maxAttempts,
WillRetry = willRetry,
+ RetryDelay = retryDelay,
+ RetryReason = retryReason ?? string.Empty,
CancellationToken = cancellationToken,
};
}
@@ -338,19 +388,188 @@ internal static int GetMaxAttempts(
return maxAttempts < 1 ? 1 : maxAttempts;
}
- internal static async global::System.Threading.Tasks.Task DelayBeforeRetryAsync(
+ internal static global::System.TimeSpan GetRetryDelay(
global::Recraft.AutoSDKClientOptions clientOptions,
global::Recraft.AutoSDKRequestOptions? requestOptions,
+ global::System.Net.Http.HttpResponseMessage? response,
+ int attempt)
+ {
+ var retryOptions = requestOptions?.Retry ?? clientOptions.Retry ?? new global::Recraft.AutoSDKRetryOptions();
+
+ if (retryOptions.UseRetryAfterHeader &&
+ TryGetRetryAfterDelay(response, out var retryAfterDelay))
+ {
+ return ClampRetryDelay(retryAfterDelay, retryOptions);
+ }
+
+ if (retryOptions.UseRateLimitResetHeader &&
+ TryGetRateLimitResetDelay(response, retryOptions.RateLimitResetHeaderName, out var rateLimitResetDelay))
+ {
+ return ClampRetryDelay(rateLimitResetDelay, retryOptions);
+ }
+
+ if (retryOptions.Delay.HasValue)
+ {
+ return ClampRetryDelay(retryOptions.Delay.Value, retryOptions);
+ }
+
+ var initialDelay = retryOptions.InitialDelay;
+ if (initialDelay <= global::System.TimeSpan.Zero)
+ {
+ return global::System.TimeSpan.Zero;
+ }
+
+ var multiplier = retryOptions.BackoffMultiplier < 1D ? 1D : retryOptions.BackoffMultiplier;
+ var exponent = attempt <= 1 ? 0 : attempt - 1;
+ var delayMilliseconds = initialDelay.TotalMilliseconds * global::System.Math.Pow(multiplier, exponent);
+ if (double.IsNaN(delayMilliseconds) || double.IsInfinity(delayMilliseconds) || delayMilliseconds < 0D)
+ {
+ delayMilliseconds = 0D;
+ }
+
+ var delay = global::System.TimeSpan.FromMilliseconds(delayMilliseconds);
+ delay = ApplyJitter(delay, retryOptions.JitterRatio);
+ return ClampRetryDelay(delay, retryOptions);
+ }
+
+ internal static async global::System.Threading.Tasks.Task DelayBeforeRetryAsync(
+ global::System.TimeSpan retryDelay,
global::System.Threading.CancellationToken cancellationToken)
{
- var delay = requestOptions?.Retry?.Delay ??
- clientOptions.Retry?.Delay;
- if (!delay.HasValue || delay.Value <= global::System.TimeSpan.Zero)
+ if (retryDelay <= global::System.TimeSpan.Zero)
{
return;
}
- await global::System.Threading.Tasks.Task.Delay(delay.Value, cancellationToken).ConfigureAwait(false);
+ await global::System.Threading.Tasks.Task.Delay(retryDelay, cancellationToken).ConfigureAwait(false);
+ }
+
+ private static bool TryGetRetryAfterDelay(
+ global::System.Net.Http.HttpResponseMessage? response,
+ out global::System.TimeSpan delay)
+ {
+ delay = global::System.TimeSpan.Zero;
+ var retryAfter = response?.Headers.RetryAfter;
+ if (retryAfter == null)
+ {
+ return false;
+ }
+
+ if (retryAfter.Delta.HasValue)
+ {
+ delay = retryAfter.Delta.Value;
+ return delay > global::System.TimeSpan.Zero;
+ }
+
+ if (retryAfter.Date.HasValue)
+ {
+ delay = retryAfter.Date.Value - global::System.DateTimeOffset.UtcNow;
+ return delay > global::System.TimeSpan.Zero;
+ }
+
+ return false;
+ }
+
+ private static bool TryGetRateLimitResetDelay(
+ global::System.Net.Http.HttpResponseMessage? response,
+ string? headerName,
+ out global::System.TimeSpan delay)
+ {
+ delay = global::System.TimeSpan.Zero;
+ if (response == null || string.IsNullOrWhiteSpace(headerName))
+ {
+ return false;
+ }
+
+ if (!response.Headers.TryGetValues(headerName, out var values) &&
+ (response.Content?.Headers == null || !response.Content.Headers.TryGetValues(headerName, out values)))
+ {
+ return false;
+ }
+
+ var value = global::System.Linq.Enumerable.FirstOrDefault(values);
+ if (string.IsNullOrWhiteSpace(value))
+ {
+ return false;
+ }
+
+ value = value.Trim();
+ if (long.TryParse(
+ value,
+ global::System.Globalization.NumberStyles.Integer,
+ global::System.Globalization.CultureInfo.InvariantCulture,
+ out var unixSeconds))
+ {
+ delay = global::System.DateTimeOffset.FromUnixTimeSeconds(unixSeconds) - global::System.DateTimeOffset.UtcNow;
+ return delay > global::System.TimeSpan.Zero;
+ }
+
+ if (global::System.DateTimeOffset.TryParse(
+ value,
+ global::System.Globalization.CultureInfo.InvariantCulture,
+ global::System.Globalization.DateTimeStyles.AssumeUniversal | global::System.Globalization.DateTimeStyles.AdjustToUniversal,
+ out var resetAt))
+ {
+ delay = resetAt - global::System.DateTimeOffset.UtcNow;
+ return delay > global::System.TimeSpan.Zero;
+ }
+
+ return false;
+ }
+
+ private static global::System.TimeSpan ApplyJitter(
+ global::System.TimeSpan delay,
+ double jitterRatio)
+ {
+ if (delay <= global::System.TimeSpan.Zero || jitterRatio <= 0D)
+ {
+ return delay;
+ }
+
+ if (jitterRatio > 1D)
+ {
+ jitterRatio = 1D;
+ }
+
+ var sample = NextJitterSample();
+ var multiplier = 1D - jitterRatio + (sample * jitterRatio * 2D);
+ var milliseconds = delay.TotalMilliseconds * multiplier;
+ if (double.IsNaN(milliseconds) || double.IsInfinity(milliseconds) || milliseconds < 0D)
+ {
+ milliseconds = 0D;
+ }
+
+ return global::System.TimeSpan.FromMilliseconds(milliseconds);
+ }
+
+ private static double NextJitterSample()
+ {
+ var bytes = new byte[8];
+ using (var randomNumberGenerator = global::System.Security.Cryptography.RandomNumberGenerator.Create())
+ {
+ randomNumberGenerator.GetBytes(bytes);
+ }
+
+ var value = global::System.BitConverter.ToUInt64(bytes, 0);
+ return value / (double)ulong.MaxValue;
+ }
+
+ private static global::System.TimeSpan ClampRetryDelay(
+ global::System.TimeSpan delay,
+ global::Recraft.AutoSDKRetryOptions retryOptions)
+ {
+ if (delay <= global::System.TimeSpan.Zero)
+ {
+ return global::System.TimeSpan.Zero;
+ }
+
+ var maxDelay = retryOptions.MaxDelay;
+ if (maxDelay > global::System.TimeSpan.Zero && delay > maxDelay)
+ {
+ return maxDelay;
+ }
+
+ return delay;
}
internal static bool ShouldRetryStatusCode(
diff --git a/src/libs/Recraft/Generated/Recraft.RecraftClient.GetPing.g.cs b/src/libs/Recraft/Generated/Recraft.RecraftClient.GetPing.g.cs
index 5f02c54..60a1763 100644
--- a/src/libs/Recraft/Generated/Recraft.RecraftClient.GetPing.g.cs
+++ b/src/libs/Recraft/Generated/Recraft.RecraftClient.GetPing.g.cs
@@ -43,6 +43,21 @@ partial void ProcessGetPingResponse(
public async global::System.Threading.Tasks.Task GetPingAsync(
global::Recraft.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
+ {
+ await GetPingAsResponseAsync(
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken
+ ).ConfigureAwait(false);
+ }
+ ///
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task GetPingAsResponseAsync(
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
client: HttpClient);
@@ -71,6 +86,7 @@ partial void ProcessGetPingResponse(
global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{
+
var __pathBuilder = new global::Recraft.PathBuilder(
path: "/ping",
baseUri: HttpClient.BaseAddress);
@@ -143,6 +159,8 @@ partial void ProcessGetPingResponse(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
@@ -153,6 +171,11 @@ partial void ProcessGetPingResponse(
}
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,
@@ -170,6 +193,8 @@ partial void ProcessGetPingResponse(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
if (!__willRetry)
{
@@ -179,8 +204,7 @@ partial void ProcessGetPingResponse(
__httpRequest.Dispose();
__httpRequest = null;
await global::Recraft.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -189,6 +213,11 @@ partial void ProcessGetPingResponse(
__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(
@@ -205,14 +234,15 @@ partial void ProcessGetPingResponse(
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;
}
@@ -252,6 +282,8 @@ partial void ProcessGetPingResponse(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
else
@@ -272,6 +304,8 @@ partial void ProcessGetPingResponse(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
@@ -292,6 +326,10 @@ partial void ProcessGetPingResponse(
{
__response.EnsureSuccessStatusCode();
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri);
}
catch (global::System.Exception __ex)
{
@@ -313,6 +351,10 @@ partial void ProcessGetPingResponse(
try
{
__response.EnsureSuccessStatusCode();
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri);
}
catch (global::System.Exception __ex)
{
diff --git a/src/libs/Recraft/Generated/Recraft.RecraftClient.GetSystemStatus.g.cs b/src/libs/Recraft/Generated/Recraft.RecraftClient.GetSystemStatus.g.cs
index d4b69d2..99d5ce8 100644
--- a/src/libs/Recraft/Generated/Recraft.RecraftClient.GetSystemStatus.g.cs
+++ b/src/libs/Recraft/Generated/Recraft.RecraftClient.GetSystemStatus.g.cs
@@ -48,6 +48,23 @@ partial void ProcessGetSystemStatusResponseContent(
public async global::System.Threading.Tasks.Task GetSystemStatusAsync(
global::Recraft.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
+ {
+ var __response = await GetSystemStatusAsResponseAsync(
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken
+ ).ConfigureAwait(false);
+
+ return __response.Body;
+ }
+ ///
+ /// Get System Status
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> GetSystemStatusAsResponseAsync(
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
client: HttpClient);
@@ -76,6 +93,7 @@ partial void ProcessGetSystemStatusResponseContent(
global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{
+
var __pathBuilder = new global::Recraft.PathBuilder(
path: "/status",
baseUri: HttpClient.BaseAddress);
@@ -148,6 +166,8 @@ partial void ProcessGetSystemStatusResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
@@ -158,6 +178,11 @@ partial void ProcessGetSystemStatusResponseContent(
}
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,
@@ -175,6 +200,8 @@ partial void ProcessGetSystemStatusResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
if (!__willRetry)
{
@@ -184,8 +211,7 @@ partial void ProcessGetSystemStatusResponseContent(
__httpRequest.Dispose();
__httpRequest = null;
await global::Recraft.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -194,6 +220,11 @@ partial void ProcessGetSystemStatusResponseContent(
__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(
@@ -210,14 +241,15 @@ partial void ProcessGetSystemStatusResponseContent(
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;
}
@@ -257,6 +289,8 @@ partial void ProcessGetSystemStatusResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
else
@@ -277,6 +311,8 @@ partial void ProcessGetSystemStatusResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
@@ -301,9 +337,13 @@ partial void ProcessGetSystemStatusResponseContent(
{
__response.EnsureSuccessStatusCode();
- return
- global::Recraft.SystemStatus.FromJson(__content, JsonSerializerContext) ??
+ var __value = global::Recraft.SystemStatus.FromJson(__content, JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
@@ -331,9 +371,13 @@ partial void ProcessGetSystemStatusResponseContent(
#endif
).ConfigureAwait(false);
- return
- await global::Recraft.SystemStatus.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ var __value = await global::Recraft.SystemStatus.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
diff --git a/src/libs/Recraft/Generated/Recraft.RecraftClient.g.cs b/src/libs/Recraft/Generated/Recraft.RecraftClient.g.cs
index a22b86a..fb20ea0 100644
--- a/src/libs/Recraft/Generated/Recraft.RecraftClient.g.cs
+++ b/src/libs/Recraft/Generated/Recraft.RecraftClient.g.cs
@@ -42,7 +42,7 @@ public sealed partial class RecraftClient : global::Recraft.IRecraftClient, glob
///
///
///
- public ColorsClient Colors => new ColorsClient(HttpClient, authorizations: Authorizations, options: Options)
+ public ColorsClient Colors => new ColorsClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options)
{
ReadResponseAsString = ReadResponseAsString,
JsonSerializerContext = JsonSerializerContext,
@@ -51,7 +51,7 @@ public sealed partial class RecraftClient : global::Recraft.IRecraftClient, glob
///
///
///
- public ImageClient Image => new ImageClient(HttpClient, authorizations: Authorizations, options: Options)
+ public ImageClient Image => new ImageClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options)
{
ReadResponseAsString = ReadResponseAsString,
JsonSerializerContext = JsonSerializerContext,
@@ -60,7 +60,7 @@ public sealed partial class RecraftClient : global::Recraft.IRecraftClient, glob
///
///
///
- public StyleClient Style => new StyleClient(HttpClient, authorizations: Authorizations, options: Options)
+ public StyleClient Style => new StyleClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options)
{
ReadResponseAsString = ReadResponseAsString,
JsonSerializerContext = JsonSerializerContext,
@@ -69,7 +69,7 @@ public sealed partial class RecraftClient : global::Recraft.IRecraftClient, glob
///
///
///
- public UserClient User => new UserClient(HttpClient, authorizations: Authorizations, options: Options)
+ public UserClient User => new UserClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options)
{
ReadResponseAsString = ReadResponseAsString,
JsonSerializerContext = JsonSerializerContext,
@@ -108,10 +108,10 @@ public RecraftClient(
/// Client-wide request defaults such as headers, query parameters, retries, and timeout.
/// Dispose the HttpClient when the instance is disposed. True by default.
public RecraftClient(
- global::System.Net.Http.HttpClient? httpClient = null,
- global::System.Uri? baseUri = null,
- global::System.Collections.Generic.List? authorizations = null,
- global::Recraft.AutoSDKClientOptions? options = null,
+ global::System.Net.Http.HttpClient? httpClient,
+ global::System.Uri? baseUri,
+ global::System.Collections.Generic.List? authorizations,
+ global::Recraft.AutoSDKClientOptions? options,
bool disposeHttpClient = true)
{
diff --git a/src/libs/Recraft/Generated/Recraft.StyleClient.CreateStyle.g.cs b/src/libs/Recraft/Generated/Recraft.StyleClient.CreateStyle.g.cs
index a56af5c..e20105b 100644
--- a/src/libs/Recraft/Generated/Recraft.StyleClient.CreateStyle.g.cs
+++ b/src/libs/Recraft/Generated/Recraft.StyleClient.CreateStyle.g.cs
@@ -53,6 +53,31 @@ partial void ProcessCreateStyleResponseContent(
///
public async global::System.Threading.Tasks.Task CreateStyleAsync(
+ global::Recraft.CreateStyleRequest request,
+ global::Recraft.BillingType? billing = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+ var __response = await CreateStyleAsResponseAsync(
+
+ request: request,
+ billing: billing,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken
+ ).ConfigureAwait(false);
+
+ return __response.Body;
+ }
+ ///
+ /// Create Style
+ ///
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> CreateStyleAsResponseAsync(
+
global::Recraft.CreateStyleRequest request,
global::Recraft.BillingType? billing = default,
global::Recraft.AutoSDKRequestOptions? requestOptions = default,
@@ -85,15 +110,16 @@ partial void ProcessCreateStyleResponseContent(
var __maxAttempts = global::Recraft.AutoSDKRequestOptionsSupport.GetMaxAttempts(
clientOptions: Options,
requestOptions: requestOptions,
- supportsRetry: true);
+ supportsRetry: false);
global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{
+
var __pathBuilder = new global::Recraft.PathBuilder(
path: "/v1/styles",
- baseUri: HttpClient.BaseAddress);
+ baseUri: HttpClient.BaseAddress);
__pathBuilder
- .AddOptionalParameter("billing", billing?.ToValueString())
+ .AddOptionalParameter("billing", billing?.ToValueString())
;
var __path = __pathBuilder.ToString();
__path = global::Recraft.AutoSDKRequestOptionsSupport.AppendQueryParameters(
@@ -124,6 +150,7 @@ partial void ProcessCreateStyleResponseContent(
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
}
}
+
var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
if (billing != default)
{
@@ -131,13 +158,15 @@ partial void ProcessCreateStyleResponseContent(
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((billing).HasValue ? (billing).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"billing\"");
- }
+
+ }
if (request.ImageWeights != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.ImageWeights, x => global::System.Convert.ToString(x, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty))}]"),
name: "\"image_weights\"");
+
}
for (var __iImages = 0; __iImages < request.Images.Count; __iImages++)
{
@@ -152,59 +181,69 @@ partial void ProcessCreateStyleResponseContent(
__contentImages.Headers.ContentDisposition.FileNameStar = null;
}
}
+
if (request.MixPolicy != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.MixPolicy).HasValue ? (request.MixPolicy).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"mix_policy\"");
- }
+
+ }
if (request.Model != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.Model).HasValue ? (request.Model).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"model\"");
- }
+
+ }
if (request.Palette != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(request.Palette.ToJson(JsonSerializerContext)),
name: "\"palette\"");
- }
+
+ }
if (request.Private != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.Private, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()),
name: "\"private\"");
- }
+
+ }
if (request.Prompt != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty),
name: "\"prompt\"");
- }
+
+ }
if (request.SourceStyleWeights != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.SourceStyleWeights, x => global::System.Convert.ToString(x, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty))}]"),
name: "\"source_style_weights\"");
- }
+
+ }
if (request.SourceStyles != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.SourceStyles, x => x.ToString() ?? string.Empty))}]"),
name: "\"source_styles\"");
+
}
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(request.Style.ToValueString()),
name: "\"style\"");
+
__httpRequest.Content = __httpRequestContent;
+
global::Recraft.AutoSDKRequestOptionsSupport.ApplyHeaders(
request: __httpRequest,
clientHeaders: Options.Headers,
@@ -247,6 +286,8 @@ partial void ProcessCreateStyleResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
@@ -257,6 +298,11 @@ partial void ProcessCreateStyleResponseContent(
}
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,
@@ -274,6 +320,8 @@ partial void ProcessCreateStyleResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
if (!__willRetry)
{
@@ -283,8 +331,7 @@ partial void ProcessCreateStyleResponseContent(
__httpRequest.Dispose();
__httpRequest = null;
await global::Recraft.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -293,6 +340,11 @@ partial void ProcessCreateStyleResponseContent(
__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(
@@ -309,14 +361,15 @@ partial void ProcessCreateStyleResponseContent(
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;
}
@@ -356,6 +409,8 @@ partial void ProcessCreateStyleResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
else
@@ -376,6 +431,8 @@ partial void ProcessCreateStyleResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
@@ -400,9 +457,13 @@ partial void ProcessCreateStyleResponseContent(
{
__response.EnsureSuccessStatusCode();
- return
- global::Recraft.CreateStyleResponse.FromJson(__content, JsonSerializerContext) ??
+ var __value = global::Recraft.CreateStyleResponse.FromJson(__content, JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
@@ -430,9 +491,13 @@ partial void ProcessCreateStyleResponseContent(
#endif
).ConfigureAwait(false);
- return
- await global::Recraft.CreateStyleResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ var __value = await global::Recraft.CreateStyleResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
@@ -522,5 +587,1068 @@ partial void ProcessCreateStyleResponseContent(
requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
+
+ ///
+ /// Create Style
+ ///
+ ///
+ ///
+ ///
+ /// The streams to send as multipart 'images' file parts.
+ ///
+ ///
+ /// Optional file names to use for the multipart 'images' file parts.
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task CreateStyleAsync(
+ global::System.Collections.Generic.IReadOnlyList images,
+ global::Recraft.ImageStyle style,
+ global::Recraft.BillingType? billing = default,
+ global::System.Collections.Generic.IList? imageWeights = default,
+ global::System.Collections.Generic.IReadOnlyList? imagesFileNames = default,
+ global::Recraft.MixPolicy? mixPolicy = default,
+ global::Recraft.TransformModel? model = default,
+ global::Recraft.PaletteSuggest? palette = default,
+ bool? @private = default,
+ string? prompt = default,
+ global::System.Collections.Generic.IList? sourceStyleWeights = default,
+ global::System.Collections.Generic.IList? sourceStyles = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+
+ images = images ?? throw new global::System.ArgumentNullException(nameof(images));
+ var request = new global::Recraft.CreateStyleRequest
+ {
+ ImageWeights = imageWeights,
+ Images = new global::System.Collections.Generic.List(),
+ MixPolicy = mixPolicy,
+ Model = model,
+ Palette = palette,
+ Private = @private,
+ Prompt = prompt,
+ SourceStyleWeights = sourceStyleWeights,
+ SourceStyles = sourceStyles,
+ Style = style,
+ };
+ PrepareArguments(
+ client: HttpClient);
+ PrepareCreateStyleArguments(
+ httpClient: HttpClient,
+ billing: ref billing,
+ request: request);
+
+
+ var __authorizations = global::Recraft.EndPointSecurityResolver.ResolveAuthorizations(
+ availableAuthorizations: Authorizations,
+ securityRequirements: s_CreateStyleSecurityRequirements,
+ operationName: "CreateStyleAsync");
+
+ using var __timeoutCancellationTokenSource = global::Recraft.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Recraft.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Recraft.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: false);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+
+ var __pathBuilder = new global::Recraft.PathBuilder(
+ path: "/v1/styles",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("billing", billing?.ToValueString())
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::Recraft.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+#if NET6_0_OR_GREATER
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+#endif
+
+ foreach (var __authorization in __authorizations)
+ {
+ if (__authorization.Type == "Http" ||
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
+ {
+ __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
+ scheme: __authorization.Name,
+ parameter: __authorization.Value);
+ }
+ else if (__authorization.Type == "ApiKey" &&
+ __authorization.Location == "Header")
+ {
+ __httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
+ }
+ }
+
+ var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
+ if (billing != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((billing).HasValue ? (billing).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"billing\"");
+
+ }
+ if (request.ImageWeights != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.ImageWeights, x => global::System.Convert.ToString(x, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty))}]"),
+ name: "\"image_weights\"");
+
+ }
+ for (var __iImages = 0; __iImages < images.Count; __iImages++)
+ {
+ var __fileNameImages = imagesFileNames != null &&
+ __iImages < imagesFileNames.Count &&
+ imagesFileNames[__iImages] != null
+ ? imagesFileNames[__iImages]
+ : $"file{__iImages}.bin";
+ var __contentImages = new global::System.Net.Http.StreamContent(images[__iImages]);
+ __contentImages.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ __fileNameImages is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(__fileNameImages) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentImages,
+ name: "\"images\"",
+ fileName: $"\"{__fileNameImages}\"");
+ if (__contentImages.Headers.ContentDisposition != null)
+ {
+ __contentImages.Headers.ContentDisposition.FileNameStar = null;
+ }
+ }
+
+ if (request.MixPolicy != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.MixPolicy).HasValue ? (request.MixPolicy).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"mix_policy\"");
+
+ }
+ if (request.Model != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.Model).HasValue ? (request.Model).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"model\"");
+
+ }
+ if (request.Palette != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.Palette.ToJson(JsonSerializerContext)),
+ name: "\"palette\"");
+
+ }
+ if (request.Private != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.Private, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()),
+ name: "\"private\"");
+
+ }
+ if (request.Prompt != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty),
+ name: "\"prompt\"");
+
+ }
+ if (request.SourceStyleWeights != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.SourceStyleWeights, x => global::System.Convert.ToString(x, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty))}]"),
+ name: "\"source_style_weights\"");
+
+ }
+ if (request.SourceStyles != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.SourceStyles, x => x.ToString() ?? string.Empty))}]"),
+ name: "\"source_styles\"");
+
+ }
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.Style.ToValueString()),
+ name: "\"style\"");
+
+ __httpRequest.Content = __httpRequestContent;
+
+ global::Recraft.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
+
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareCreateStyleRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ billing: billing,
+ request: request);
+
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
+ {
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
+ {
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Recraft.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateStyle",
+ methodName: "CreateStyleAsync",
+ pathTemplate: "\"/v1/styles\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
+ {
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ }
+ 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,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateStyle",
+ methodName: "CreateStyleAsync",
+ pathTemplate: "\"/v1/styles\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Recraft.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __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(
+ operationId: "CreateStyle",
+ methodName: "CreateStyleAsync",
+ pathTemplate: "\"/v1/styles\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ 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(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
+ }
+
+ if (__response == null)
+ {
+ throw new global::System.InvalidOperationException("No response received.");
+ }
+
+ using (__response)
+ {
+
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessCreateStyleResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Recraft.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateStyle",
+ methodName: "CreateStyleAsync",
+ pathTemplate: "\"/v1/styles\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ else
+ {
+ await global::Recraft.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateStyle",
+ methodName: "CreateStyleAsync",
+ pathTemplate: "\"/v1/styles\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessCreateStyleResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Recraft.CreateStyleResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Recraft.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ await global::Recraft.CreateStyleResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Recraft.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
+ }
+ ///
+ /// Create Style
+ ///
+ ///
+ ///
+ ///
+ /// The streams to send as multipart 'images' file parts.
+ ///
+ ///
+ /// Optional file names to use for the multipart 'images' file parts.
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> CreateStyleAsResponseAsync(
+ global::System.Collections.Generic.IReadOnlyList images,
+ global::Recraft.ImageStyle style,
+ global::Recraft.BillingType? billing = default,
+ global::System.Collections.Generic.IList? imageWeights = default,
+ global::System.Collections.Generic.IReadOnlyList? imagesFileNames = default,
+ global::Recraft.MixPolicy? mixPolicy = default,
+ global::Recraft.TransformModel? model = default,
+ global::Recraft.PaletteSuggest? palette = default,
+ bool? @private = default,
+ string? prompt = default,
+ global::System.Collections.Generic.IList? sourceStyleWeights = default,
+ global::System.Collections.Generic.IList? sourceStyles = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+
+ images = images ?? throw new global::System.ArgumentNullException(nameof(images));
+ var request = new global::Recraft.CreateStyleRequest
+ {
+ ImageWeights = imageWeights,
+ Images = new global::System.Collections.Generic.List(),
+ MixPolicy = mixPolicy,
+ Model = model,
+ Palette = palette,
+ Private = @private,
+ Prompt = prompt,
+ SourceStyleWeights = sourceStyleWeights,
+ SourceStyles = sourceStyles,
+ Style = style,
+ };
+ PrepareArguments(
+ client: HttpClient);
+ PrepareCreateStyleArguments(
+ httpClient: HttpClient,
+ billing: ref billing,
+ request: request);
+
+
+ var __authorizations = global::Recraft.EndPointSecurityResolver.ResolveAuthorizations(
+ availableAuthorizations: Authorizations,
+ securityRequirements: s_CreateStyleSecurityRequirements,
+ operationName: "CreateStyleAsync");
+
+ using var __timeoutCancellationTokenSource = global::Recraft.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Recraft.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Recraft.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: false);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+
+ var __pathBuilder = new global::Recraft.PathBuilder(
+ path: "/v1/styles",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("billing", billing?.ToValueString())
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::Recraft.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+#if NET6_0_OR_GREATER
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+#endif
+
+ foreach (var __authorization in __authorizations)
+ {
+ if (__authorization.Type == "Http" ||
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
+ {
+ __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
+ scheme: __authorization.Name,
+ parameter: __authorization.Value);
+ }
+ else if (__authorization.Type == "ApiKey" &&
+ __authorization.Location == "Header")
+ {
+ __httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
+ }
+ }
+
+ var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
+ if (billing != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((billing).HasValue ? (billing).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"billing\"");
+
+ }
+ if (request.ImageWeights != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.ImageWeights, x => global::System.Convert.ToString(x, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty))}]"),
+ name: "\"image_weights\"");
+
+ }
+ for (var __iImages = 0; __iImages < images.Count; __iImages++)
+ {
+ var __fileNameImages = imagesFileNames != null &&
+ __iImages < imagesFileNames.Count &&
+ imagesFileNames[__iImages] != null
+ ? imagesFileNames[__iImages]
+ : $"file{__iImages}.bin";
+ var __contentImages = new global::System.Net.Http.StreamContent(images[__iImages]);
+ __contentImages.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ __fileNameImages is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(__fileNameImages) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentImages,
+ name: "\"images\"",
+ fileName: $"\"{__fileNameImages}\"");
+ if (__contentImages.Headers.ContentDisposition != null)
+ {
+ __contentImages.Headers.ContentDisposition.FileNameStar = null;
+ }
+ }
+
+ if (request.MixPolicy != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.MixPolicy).HasValue ? (request.MixPolicy).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"mix_policy\"");
+
+ }
+ if (request.Model != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.Model).HasValue ? (request.Model).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"model\"");
+
+ }
+ if (request.Palette != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.Palette.ToJson(JsonSerializerContext)),
+ name: "\"palette\"");
+
+ }
+ if (request.Private != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.Private, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()),
+ name: "\"private\"");
+
+ }
+ if (request.Prompt != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty),
+ name: "\"prompt\"");
+
+ }
+ if (request.SourceStyleWeights != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.SourceStyleWeights, x => global::System.Convert.ToString(x, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty))}]"),
+ name: "\"source_style_weights\"");
+
+ }
+ if (request.SourceStyles != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.SourceStyles, x => x.ToString() ?? string.Empty))}]"),
+ name: "\"source_styles\"");
+
+ }
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.Style.ToValueString()),
+ name: "\"style\"");
+
+ __httpRequest.Content = __httpRequestContent;
+
+ global::Recraft.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
+
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareCreateStyleRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ billing: billing,
+ request: request);
+
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
+ {
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
+ {
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Recraft.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateStyle",
+ methodName: "CreateStyleAsync",
+ pathTemplate: "\"/v1/styles\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
+ {
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ }
+ 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,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateStyle",
+ methodName: "CreateStyleAsync",
+ pathTemplate: "\"/v1/styles\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Recraft.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __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(
+ operationId: "CreateStyle",
+ methodName: "CreateStyleAsync",
+ pathTemplate: "\"/v1/styles\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ 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(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
+ }
+
+ if (__response == null)
+ {
+ throw new global::System.InvalidOperationException("No response received.");
+ }
+
+ using (__response)
+ {
+
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessCreateStyleResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Recraft.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateStyle",
+ methodName: "CreateStyleAsync",
+ pathTemplate: "\"/v1/styles\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ else
+ {
+ await global::Recraft.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateStyle",
+ methodName: "CreateStyleAsync",
+ pathTemplate: "\"/v1/styles\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessCreateStyleResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ var __value = global::Recraft.CreateStyleResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Recraft.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ var __value = await global::Recraft.CreateStyleResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Recraft.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
+ }
}
}
\ No newline at end of file
diff --git a/src/libs/Recraft/Generated/Recraft.StyleClient.DeleteStyle.g.cs b/src/libs/Recraft/Generated/Recraft.StyleClient.DeleteStyle.g.cs
index cdb03ef..2ac93b8 100644
--- a/src/libs/Recraft/Generated/Recraft.StyleClient.DeleteStyle.g.cs
+++ b/src/libs/Recraft/Generated/Recraft.StyleClient.DeleteStyle.g.cs
@@ -52,6 +52,26 @@ partial void ProcessDeleteStyleResponseContent(
global::System.Guid styleId,
global::Recraft.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
+ {
+ var __response = await DeleteStyleAsResponseAsync(
+ styleId: styleId,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken
+ ).ConfigureAwait(false);
+
+ return __response.Body;
+ }
+ ///
+ /// Delete Style
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> DeleteStyleAsResponseAsync(
+ global::System.Guid styleId,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
client: HttpClient);
@@ -81,6 +101,7 @@ partial void ProcessDeleteStyleResponseContent(
global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{
+
var __pathBuilder = new global::Recraft.PathBuilder(
path: $"/v1/styles/{styleId}",
baseUri: HttpClient.BaseAddress);
@@ -154,6 +175,8 @@ partial void ProcessDeleteStyleResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
@@ -164,6 +187,11 @@ partial void ProcessDeleteStyleResponseContent(
}
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,
@@ -181,6 +209,8 @@ partial void ProcessDeleteStyleResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
if (!__willRetry)
{
@@ -190,8 +220,7 @@ partial void ProcessDeleteStyleResponseContent(
__httpRequest.Dispose();
__httpRequest = null;
await global::Recraft.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -200,6 +229,11 @@ partial void ProcessDeleteStyleResponseContent(
__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(
@@ -216,14 +250,15 @@ partial void ProcessDeleteStyleResponseContent(
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;
}
@@ -263,6 +298,8 @@ partial void ProcessDeleteStyleResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
else
@@ -283,6 +320,8 @@ partial void ProcessDeleteStyleResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
@@ -307,7 +346,11 @@ partial void ProcessDeleteStyleResponseContent(
{
__response.EnsureSuccessStatusCode();
- return __content;
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __content);
}
catch (global::System.Exception __ex)
{
@@ -335,7 +378,11 @@ partial void ProcessDeleteStyleResponseContent(
#endif
).ConfigureAwait(false);
- return __content;
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __content);
}
catch (global::System.Exception __ex)
{
diff --git a/src/libs/Recraft/Generated/Recraft.StyleClient.GetStyle.g.cs b/src/libs/Recraft/Generated/Recraft.StyleClient.GetStyle.g.cs
index 68c74e3..1e9f022 100644
--- a/src/libs/Recraft/Generated/Recraft.StyleClient.GetStyle.g.cs
+++ b/src/libs/Recraft/Generated/Recraft.StyleClient.GetStyle.g.cs
@@ -52,6 +52,26 @@ partial void ProcessGetStyleResponseContent(
global::System.Guid styleId,
global::Recraft.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
+ {
+ var __response = await GetStyleAsResponseAsync(
+ styleId: styleId,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken
+ ).ConfigureAwait(false);
+
+ return __response.Body;
+ }
+ ///
+ /// Get Style
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> GetStyleAsResponseAsync(
+ global::System.Guid styleId,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
client: HttpClient);
@@ -81,6 +101,7 @@ partial void ProcessGetStyleResponseContent(
global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{
+
var __pathBuilder = new global::Recraft.PathBuilder(
path: $"/v1/styles/{styleId}",
baseUri: HttpClient.BaseAddress);
@@ -154,6 +175,8 @@ partial void ProcessGetStyleResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
@@ -164,6 +187,11 @@ partial void ProcessGetStyleResponseContent(
}
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,
@@ -181,6 +209,8 @@ partial void ProcessGetStyleResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
if (!__willRetry)
{
@@ -190,8 +220,7 @@ partial void ProcessGetStyleResponseContent(
__httpRequest.Dispose();
__httpRequest = null;
await global::Recraft.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -200,6 +229,11 @@ partial void ProcessGetStyleResponseContent(
__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(
@@ -216,14 +250,15 @@ partial void ProcessGetStyleResponseContent(
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;
}
@@ -263,6 +298,8 @@ partial void ProcessGetStyleResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
else
@@ -283,6 +320,8 @@ partial void ProcessGetStyleResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
@@ -307,9 +346,13 @@ partial void ProcessGetStyleResponseContent(
{
__response.EnsureSuccessStatusCode();
- return
- global::Recraft.Style.FromJson(__content, JsonSerializerContext) ??
+ var __value = global::Recraft.Style.FromJson(__content, JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
@@ -337,9 +380,13 @@ partial void ProcessGetStyleResponseContent(
#endif
).ConfigureAwait(false);
- return
- await global::Recraft.Style.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ var __value = await global::Recraft.Style.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
diff --git a/src/libs/Recraft/Generated/Recraft.StyleClient.ListBasicStyles.g.cs b/src/libs/Recraft/Generated/Recraft.StyleClient.ListBasicStyles.g.cs
index b6f173c..61e772a 100644
--- a/src/libs/Recraft/Generated/Recraft.StyleClient.ListBasicStyles.g.cs
+++ b/src/libs/Recraft/Generated/Recraft.StyleClient.ListBasicStyles.g.cs
@@ -48,6 +48,23 @@ partial void ProcessListBasicStylesResponseContent(
public async global::System.Threading.Tasks.Task ListBasicStylesAsync(
global::Recraft.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
+ {
+ var __response = await ListBasicStylesAsResponseAsync(
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken
+ ).ConfigureAwait(false);
+
+ return __response.Body;
+ }
+ ///
+ /// List Basic Styles
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> ListBasicStylesAsResponseAsync(
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
client: HttpClient);
@@ -76,6 +93,7 @@ partial void ProcessListBasicStylesResponseContent(
global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{
+
var __pathBuilder = new global::Recraft.PathBuilder(
path: "/v1/styles/basic",
baseUri: HttpClient.BaseAddress);
@@ -148,6 +166,8 @@ partial void ProcessListBasicStylesResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
@@ -158,6 +178,11 @@ partial void ProcessListBasicStylesResponseContent(
}
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,
@@ -175,6 +200,8 @@ partial void ProcessListBasicStylesResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
if (!__willRetry)
{
@@ -184,8 +211,7 @@ partial void ProcessListBasicStylesResponseContent(
__httpRequest.Dispose();
__httpRequest = null;
await global::Recraft.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -194,6 +220,11 @@ partial void ProcessListBasicStylesResponseContent(
__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(
@@ -210,14 +241,15 @@ partial void ProcessListBasicStylesResponseContent(
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;
}
@@ -257,6 +289,8 @@ partial void ProcessListBasicStylesResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
else
@@ -277,6 +311,8 @@ partial void ProcessListBasicStylesResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
@@ -301,9 +337,13 @@ partial void ProcessListBasicStylesResponseContent(
{
__response.EnsureSuccessStatusCode();
- return
- global::Recraft.ListBasicStylesResponse.FromJson(__content, JsonSerializerContext) ??
+ var __value = global::Recraft.ListBasicStylesResponse.FromJson(__content, JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
@@ -331,9 +371,13 @@ partial void ProcessListBasicStylesResponseContent(
#endif
).ConfigureAwait(false);
- return
- await global::Recraft.ListBasicStylesResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ var __value = await global::Recraft.ListBasicStylesResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
diff --git a/src/libs/Recraft/Generated/Recraft.StyleClient.ListStyles.g.cs b/src/libs/Recraft/Generated/Recraft.StyleClient.ListStyles.g.cs
index 00b2074..d3bb70e 100644
--- a/src/libs/Recraft/Generated/Recraft.StyleClient.ListStyles.g.cs
+++ b/src/libs/Recraft/Generated/Recraft.StyleClient.ListStyles.g.cs
@@ -48,6 +48,23 @@ partial void ProcessListStylesResponseContent(
public async global::System.Threading.Tasks.Task ListStylesAsync(
global::Recraft.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
+ {
+ var __response = await ListStylesAsResponseAsync(
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken
+ ).ConfigureAwait(false);
+
+ return __response.Body;
+ }
+ ///
+ /// List Styles
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> ListStylesAsResponseAsync(
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
client: HttpClient);
@@ -76,6 +93,7 @@ partial void ProcessListStylesResponseContent(
global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{
+
var __pathBuilder = new global::Recraft.PathBuilder(
path: "/v1/styles",
baseUri: HttpClient.BaseAddress);
@@ -148,6 +166,8 @@ partial void ProcessListStylesResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
@@ -158,6 +178,11 @@ partial void ProcessListStylesResponseContent(
}
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,
@@ -175,6 +200,8 @@ partial void ProcessListStylesResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
if (!__willRetry)
{
@@ -184,8 +211,7 @@ partial void ProcessListStylesResponseContent(
__httpRequest.Dispose();
__httpRequest = null;
await global::Recraft.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -194,6 +220,11 @@ partial void ProcessListStylesResponseContent(
__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(
@@ -210,14 +241,15 @@ partial void ProcessListStylesResponseContent(
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;
}
@@ -257,6 +289,8 @@ partial void ProcessListStylesResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
else
@@ -277,6 +311,8 @@ partial void ProcessListStylesResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
@@ -301,9 +337,13 @@ partial void ProcessListStylesResponseContent(
{
__response.EnsureSuccessStatusCode();
- return
- global::Recraft.ListStylesResponse.FromJson(__content, JsonSerializerContext) ??
+ var __value = global::Recraft.ListStylesResponse.FromJson(__content, JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
@@ -331,9 +371,13 @@ partial void ProcessListStylesResponseContent(
#endif
).ConfigureAwait(false);
- return
- await global::Recraft.ListStylesResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ var __value = await global::Recraft.ListStylesResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
diff --git a/src/libs/Recraft/Generated/Recraft.StyleClient.g.cs b/src/libs/Recraft/Generated/Recraft.StyleClient.g.cs
index 4c8807e..48c75c1 100644
--- a/src/libs/Recraft/Generated/Recraft.StyleClient.g.cs
+++ b/src/libs/Recraft/Generated/Recraft.StyleClient.g.cs
@@ -72,10 +72,10 @@ public StyleClient(
/// Client-wide request defaults such as headers, query parameters, retries, and timeout.
/// Dispose the HttpClient when the instance is disposed. True by default.
public StyleClient(
- global::System.Net.Http.HttpClient? httpClient = null,
- global::System.Uri? baseUri = null,
- global::System.Collections.Generic.List? authorizations = null,
- global::Recraft.AutoSDKClientOptions? options = null,
+ global::System.Net.Http.HttpClient? httpClient,
+ global::System.Uri? baseUri,
+ global::System.Collections.Generic.List? authorizations,
+ global::Recraft.AutoSDKClientOptions? options,
bool disposeHttpClient = true)
{
diff --git a/src/libs/Recraft/Generated/Recraft.UserClient.GetCurrentUser.g.cs b/src/libs/Recraft/Generated/Recraft.UserClient.GetCurrentUser.g.cs
index 980d96f..baf7bf1 100644
--- a/src/libs/Recraft/Generated/Recraft.UserClient.GetCurrentUser.g.cs
+++ b/src/libs/Recraft/Generated/Recraft.UserClient.GetCurrentUser.g.cs
@@ -52,6 +52,26 @@ partial void ProcessGetCurrentUserResponseContent(
global::Recraft.BillingType? billing = default,
global::Recraft.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
+ {
+ var __response = await GetCurrentUserAsResponseAsync(
+ billing: billing,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken
+ ).ConfigureAwait(false);
+
+ return __response.Body;
+ }
+ ///
+ /// Get current user info
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> GetCurrentUserAsResponseAsync(
+ global::Recraft.BillingType? billing = default,
+ global::Recraft.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
client: HttpClient);
@@ -81,11 +101,12 @@ partial void ProcessGetCurrentUserResponseContent(
global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{
+
var __pathBuilder = new global::Recraft.PathBuilder(
path: "/v1/users/me",
- baseUri: HttpClient.BaseAddress);
+ baseUri: HttpClient.BaseAddress);
__pathBuilder
- .AddOptionalParameter("billing", billing?.ToValueString())
+ .AddOptionalParameter("billing", billing?.ToValueString())
;
var __path = __pathBuilder.ToString();
__path = global::Recraft.AutoSDKRequestOptionsSupport.AppendQueryParameters(
@@ -157,6 +178,8 @@ partial void ProcessGetCurrentUserResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
@@ -167,6 +190,11 @@ partial void ProcessGetCurrentUserResponseContent(
}
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,
@@ -184,6 +212,8 @@ partial void ProcessGetCurrentUserResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
if (!__willRetry)
{
@@ -193,8 +223,7 @@ partial void ProcessGetCurrentUserResponseContent(
__httpRequest.Dispose();
__httpRequest = null;
await global::Recraft.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -203,6 +232,11 @@ partial void ProcessGetCurrentUserResponseContent(
__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(
@@ -219,14 +253,15 @@ partial void ProcessGetCurrentUserResponseContent(
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;
}
@@ -266,6 +301,8 @@ partial void ProcessGetCurrentUserResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
else
@@ -286,6 +323,8 @@ partial void ProcessGetCurrentUserResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
@@ -310,9 +349,13 @@ partial void ProcessGetCurrentUserResponseContent(
{
__response.EnsureSuccessStatusCode();
- return
- global::Recraft.User.FromJson(__content, JsonSerializerContext) ??
+ var __value = global::Recraft.User.FromJson(__content, JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
@@ -340,9 +383,13 @@ partial void ProcessGetCurrentUserResponseContent(
#endif
).ConfigureAwait(false);
- return
- await global::Recraft.User.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ var __value = await global::Recraft.User.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Recraft.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
diff --git a/src/libs/Recraft/Generated/Recraft.UserClient.g.cs b/src/libs/Recraft/Generated/Recraft.UserClient.g.cs
index a0de802..e0b97bf 100644
--- a/src/libs/Recraft/Generated/Recraft.UserClient.g.cs
+++ b/src/libs/Recraft/Generated/Recraft.UserClient.g.cs
@@ -72,10 +72,10 @@ public UserClient(
/// Client-wide request defaults such as headers, query parameters, retries, and timeout.
/// Dispose the HttpClient when the instance is disposed. True by default.
public UserClient(
- global::System.Net.Http.HttpClient? httpClient = null,
- global::System.Uri? baseUri = null,
- global::System.Collections.Generic.List? authorizations = null,
- global::Recraft.AutoSDKClientOptions? options = null,
+ global::System.Net.Http.HttpClient? httpClient,
+ global::System.Uri? baseUri,
+ global::System.Collections.Generic.List? authorizations,
+ global::Recraft.AutoSDKClientOptions? options,
bool disposeHttpClient = true)
{