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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions src/libs/Recraft/Generated/Recraft.IImageClient.VariateImage.g.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#nullable enable

namespace Recraft
{
public partial interface IImageClient
{
/// <summary>
/// Variate Image
/// </summary>
/// <param name="request"></param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::Recraft.ApiException"></exception>
global::System.Threading.Tasks.Task<global::Recraft.GenerateImageResponse> VariateImageAsync(
global::Recraft.VariateImageRequest request,
global::System.Threading.CancellationToken cancellationToken = default);

/// <summary>
/// Variate Image
/// </summary>
/// <param name="expire"></param>
/// <param name="image"></param>
/// <param name="imagename"></param>
/// <param name="imageFormat"></param>
/// <param name="n"></param>
/// <param name="randomSeed"></param>
/// <param name="responseFormat"></param>
/// <param name="size"></param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::System.InvalidOperationException"></exception>
global::System.Threading.Tasks.Task<global::Recraft.GenerateImageResponse> VariateImageAsync(
byte[] image,
string imagename,
global::Recraft.ImageSize size,
bool? expire = default,
global::Recraft.ImageFormat? imageFormat = default,
int? n = default,
int? randomSeed = default,
global::Recraft.ResponseFormat? responseFormat = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
242 changes: 242 additions & 0 deletions src/libs/Recraft/Generated/Recraft.ImageClient.VariateImage.g.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,242 @@

#nullable enable

namespace Recraft
{
public partial class ImageClient
{
partial void PrepareVariateImageArguments(
global::System.Net.Http.HttpClient httpClient,
global::Recraft.VariateImageRequest request);
partial void PrepareVariateImageRequest(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpRequestMessage httpRequestMessage,
global::Recraft.VariateImageRequest request);
partial void ProcessVariateImageResponse(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage);

partial void ProcessVariateImageResponseContent(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage,
ref string content);

/// <summary>
/// Variate Image
/// </summary>
/// <param name="request"></param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::Recraft.ApiException"></exception>
public async global::System.Threading.Tasks.Task<global::Recraft.GenerateImageResponse> VariateImageAsync(
global::Recraft.VariateImageRequest request,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));

PrepareArguments(
client: HttpClient);
PrepareVariateImageArguments(
httpClient: HttpClient,
request: request);

var __pathBuilder = new global::Recraft.PathBuilder(
path: "/v1/images/variateImage",
baseUri: HttpClient.BaseAddress);
var __path = __pathBuilder.ToString();
using 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")
{
__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);
}
}
using var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
if (request.Expire != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent($"{request.Expire}"),
name: "expire");
}
__httpRequestContent.Add(
content: new global::System.Net.Http.ByteArrayContent(request.Image ?? global::System.Array.Empty<byte>()),
name: "image",
fileName: request.Imagename ?? string.Empty);
if (request.ImageFormat != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent($"{request.ImageFormat?.ToValueString()}"),
name: "image_format");
}
if (request.N != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent($"{request.N}"),
name: "n");
}
if (request.RandomSeed != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent($"{request.RandomSeed}"),
name: "random_seed");
}
if (request.ResponseFormat != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent($"{request.ResponseFormat?.ToValueString()}"),
name: "response_format");
}
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent($"{request.Size.ToValueString()}"),
name: "size");
__httpRequest.Content = __httpRequestContent;

PrepareRequest(
client: HttpClient,
request: __httpRequest);
PrepareVariateImageRequest(
httpClient: HttpClient,
httpRequestMessage: __httpRequest,
request: request);

using var __response = await HttpClient.SendAsync(
request: __httpRequest,
completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
cancellationToken: cancellationToken).ConfigureAwait(false);

ProcessResponse(
client: HttpClient,
response: __response);
ProcessVariateImageResponse(
httpClient: HttpClient,
httpResponseMessage: __response);

if (ReadResponseAsString)
{
var __content = await __response.Content.ReadAsStringAsync(
#if NET5_0_OR_GREATER
cancellationToken
#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
cancellationToken
#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)
{
throw new global::Recraft.ApiException(
message: __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
statusCode: __response.StatusCode)
{
ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
h => h.Value),
};
}
}
}

/// <summary>
/// Variate Image
/// </summary>
/// <param name="expire"></param>
/// <param name="image"></param>
/// <param name="imagename"></param>
/// <param name="imageFormat"></param>
/// <param name="n"></param>
/// <param name="randomSeed"></param>
/// <param name="responseFormat"></param>
/// <param name="size"></param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::System.InvalidOperationException"></exception>
public async global::System.Threading.Tasks.Task<global::Recraft.GenerateImageResponse> VariateImageAsync(
byte[] image,
string imagename,
global::Recraft.ImageSize size,
bool? expire = default,
global::Recraft.ImageFormat? imageFormat = default,
int? n = default,
int? randomSeed = default,
global::Recraft.ResponseFormat? responseFormat = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::Recraft.VariateImageRequest
{
Expire = expire,
Image = image,
Imagename = imagename,
ImageFormat = imageFormat,
N = n,
RandomSeed = randomSeed,
ResponseFormat = responseFormat,
Size = size,
};

return await VariateImageAsync(
request: __request,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,10 @@ public sealed partial class JsonSerializerContextTypes
/// <summary>
///
/// </summary>
public object? Type45 { get; set; }
public global::Recraft.VariateImageRequest? Type45 { get; set; }
/// <summary>
///
/// </summary>
public object? Type46 { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#nullable enable

namespace Recraft
{
public sealed partial class VariateImageRequest
{
/// <summary>
/// Serializes the current instance to a JSON string using the provided JsonSerializerContext.
/// </summary>
public string ToJson(
global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext)
{
return global::System.Text.Json.JsonSerializer.Serialize(
this,
this.GetType(),
jsonSerializerContext);
}

/// <summary>
/// Serializes the current instance to a JSON string using the provided JsonSerializerOptions.
/// </summary>
#if NET8_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")]
[global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")]
#endif
public string ToJson(
global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null)
{
return global::System.Text.Json.JsonSerializer.Serialize(
this,
jsonSerializerOptions);
}

/// <summary>
/// Deserializes a JSON string using the provided JsonSerializerContext.
/// </summary>
public static global::Recraft.VariateImageRequest? FromJson(
string json,
global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext)
{
return global::System.Text.Json.JsonSerializer.Deserialize(
json,
typeof(global::Recraft.VariateImageRequest),
jsonSerializerContext) as global::Recraft.VariateImageRequest;
}

/// <summary>
/// Deserializes a JSON string using the provided JsonSerializerOptions.
/// </summary>
#if NET8_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")]
[global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")]
#endif
public static global::Recraft.VariateImageRequest? FromJson(
string json,
global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null)
{
return global::System.Text.Json.JsonSerializer.Deserialize<global::Recraft.VariateImageRequest>(
json,
jsonSerializerOptions);
}

/// <summary>
/// Deserializes a JSON stream using the provided JsonSerializerContext.
/// </summary>
public static async global::System.Threading.Tasks.ValueTask<global::Recraft.VariateImageRequest?> FromJsonStreamAsync(
global::System.IO.Stream jsonStream,
global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext)
{
return (await global::System.Text.Json.JsonSerializer.DeserializeAsync(
jsonStream,
typeof(global::Recraft.VariateImageRequest),
jsonSerializerContext).ConfigureAwait(false)) as global::Recraft.VariateImageRequest;
}

/// <summary>
/// Deserializes a JSON stream using the provided JsonSerializerOptions.
/// </summary>
#if NET8_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")]
[global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")]
#endif
public static global::System.Threading.Tasks.ValueTask<global::Recraft.VariateImageRequest?> FromJsonStreamAsync(
global::System.IO.Stream jsonStream,
global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null)
{
return global::System.Text.Json.JsonSerializer.DeserializeAsync<global::Recraft.VariateImageRequest?>(
jsonStream,
jsonSerializerOptions);
}
}
}
Loading
Loading