Skip to content

Commit 2d4aff5

Browse files
Merge pull request #37 from tryAGI/bot/update-openapi_202411121519
feat:@coderabbitai
2 parents 032b81b + bf42ef0 commit 2d4aff5

File tree

119 files changed

+6028
-3194
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+6028
-3194
lines changed
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#nullable enable
2+
3+
namespace Ideogram
4+
{
5+
/// <summary>
6+
/// Represents an exception thrown by the API.
7+
/// </summary>
8+
[global::System.Serializable]
9+
public partial class ApiException : global::System.Exception
10+
{
11+
/// <summary>
12+
/// The HTTP status code of the response.
13+
/// </summary>
14+
public global::System.Net.HttpStatusCode StatusCode { get; }
15+
/// <summary>
16+
/// The response body.
17+
/// </summary>
18+
public string? ResponseBody { get; set; }
19+
/// <summary>
20+
/// The response headers.
21+
/// </summary>
22+
public global::System.Collections.Generic.Dictionary<string, global::System.Collections.Generic.IEnumerable<string>>? ResponseHeaders { get; set; }
23+
/// <summary>
24+
/// Initializes a new instance of the <see cref="ApiException"/> class.
25+
/// </summary>
26+
public ApiException()
27+
{
28+
}
29+
30+
/// <summary>
31+
/// Initializes a new instance of the <see cref="ApiException"/> class with a specified error message.
32+
/// </summary>
33+
/// <param name="message">The message that describes the error.</param>
34+
/// <param name="statusCode">The HTTP status code of the response.</param>
35+
public ApiException(string message, global::System.Net.HttpStatusCode statusCode) : base(message)
36+
{
37+
StatusCode = statusCode;
38+
}
39+
40+
/// <summary>
41+
/// Initializes a new instance of the <see cref="ApiException"/> class with a specified error message and a reference to the inner exception that is the cause of this exception.
42+
/// </summary>
43+
/// <param name="message">The error message that explains the reason for the exception.</param>
44+
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference if no inner exception is specified.</param>
45+
/// <param name="statusCode">The HTTP status code of the response.</param>
46+
public ApiException(string message, global::System.Exception innerException, global::System.Net.HttpStatusCode statusCode) : base(message, innerException)
47+
{
48+
StatusCode = statusCode;
49+
}
50+
}
51+
52+
/// <summary>
53+
/// Represents an exception thrown by the API.
54+
/// </summary>
55+
/// <typeparam name="T"></typeparam>
56+
[global::System.Serializable]
57+
public partial class ApiException<T> : ApiException
58+
{
59+
/// <summary>
60+
/// The response object.
61+
/// </summary>
62+
public T? ResponseObject { get; set; }
63+
64+
/// <summary>
65+
/// Initializes a new instance of the <see cref="ApiException"/> class.
66+
/// </summary>
67+
public ApiException()
68+
{
69+
}
70+
71+
/// <summary>
72+
/// Initializes a new instance of the <see cref="ApiException"/> class with a specified error message.
73+
/// </summary>
74+
/// <param name="message">The message that describes the error.</param>
75+
/// <param name="statusCode">The HTTP status code of the response.</param>
76+
public ApiException(string message, global::System.Net.HttpStatusCode statusCode) : base(message, statusCode)
77+
{
78+
}
79+
80+
/// <summary>
81+
/// Initializes a new instance of the <see cref="ApiException"/> class with a specified error message and a reference to the inner exception that is the cause of this exception.
82+
/// </summary>
83+
/// <param name="message">The error message that explains the reason for the exception.</param>
84+
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference if no inner exception is specified.</param>
85+
/// <param name="statusCode">The HTTP status code of the response.</param>
86+
public ApiException(string message, global::System.Exception innerException, global::System.Net.HttpStatusCode statusCode) : base(message, innerException, statusCode)
87+
{
88+
}
89+
}
90+
}

src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostEditImage.g.cs

Lines changed: 158 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ partial void ProcessPostEditImageResponseContent(
3030
/// </summary>
3131
/// <param name="request"></param>
3232
/// <param name="cancellationToken">The token to cancel the operation with</param>
33-
/// <exception cref="global::System.InvalidOperationException"></exception>
33+
/// <exception cref="global::Ideogram.ApiException"></exception>
3434
public async global::System.Threading.Tasks.Task<global::Ideogram.GenerateImageResponse> PostEditImageAsync(
3535
global::Ideogram.EditImageRequest request,
3636
global::System.Threading.CancellationToken cancellationToken = default)
@@ -120,30 +120,171 @@ partial void ProcessPostEditImageResponseContent(
120120
ProcessPostEditImageResponse(
121121
httpClient: HttpClient,
122122
httpResponseMessage: __response);
123+
//
124+
if ((int)__response.StatusCode == 400)
125+
{
126+
string? __content_400 = null;
127+
if (ReadResponseAsString)
128+
{
129+
__content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
130+
}
131+
else
132+
{
133+
var __contentStream_400 = await __response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
134+
}
123135

124-
var __content = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
136+
throw new global::Ideogram.ApiException(
137+
message: __response.ReasonPhrase ?? string.Empty,
138+
statusCode: __response.StatusCode)
139+
{
140+
ResponseBody = __content_400,
141+
ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
142+
__response.Headers,
143+
h => h.Key,
144+
h => h.Value),
145+
};
146+
}
147+
//
148+
if ((int)__response.StatusCode == 401)
149+
{
150+
string? __content_401 = null;
151+
if (ReadResponseAsString)
152+
{
153+
__content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
154+
}
155+
else
156+
{
157+
var __contentStream_401 = await __response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
158+
}
125159

126-
ProcessResponseContent(
127-
client: HttpClient,
128-
response: __response,
129-
content: ref __content);
130-
ProcessPostEditImageResponseContent(
131-
httpClient: HttpClient,
132-
httpResponseMessage: __response,
133-
content: ref __content);
160+
throw new global::Ideogram.ApiException(
161+
message: __response.ReasonPhrase ?? string.Empty,
162+
statusCode: __response.StatusCode)
163+
{
164+
ResponseBody = __content_401,
165+
ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
166+
__response.Headers,
167+
h => h.Key,
168+
h => h.Value),
169+
};
170+
}
171+
// Prompt or Initial Image failed the safety checks.
172+
if ((int)__response.StatusCode == 422)
173+
{
174+
string? __content_422 = null;
175+
global::Ideogram.GenerateImageSafetyError? __value_422 = null;
176+
if (ReadResponseAsString)
177+
{
178+
__content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
179+
__value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext);
180+
}
181+
else
182+
{
183+
var __contentStream_422 = await __response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
184+
__value_422 = await global::Ideogram.GenerateImageSafetyError.FromJsonStreamAsync(__contentStream_422, JsonSerializerContext).ConfigureAwait(false);
185+
}
134186

135-
try
187+
throw new global::Ideogram.ApiException<global::Ideogram.GenerateImageSafetyError>(
188+
message: __response.ReasonPhrase ?? string.Empty,
189+
statusCode: __response.StatusCode)
190+
{
191+
ResponseBody = __content_422,
192+
ResponseObject = __value_422,
193+
ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
194+
__response.Headers,
195+
h => h.Key,
196+
h => h.Value),
197+
};
198+
}
199+
//
200+
if ((int)__response.StatusCode == 429)
136201
{
137-
__response.EnsureSuccessStatusCode();
202+
string? __content_429 = null;
203+
if (ReadResponseAsString)
204+
{
205+
__content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
206+
}
207+
else
208+
{
209+
var __contentStream_429 = await __response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
210+
}
211+
212+
throw new global::Ideogram.ApiException(
213+
message: __response.ReasonPhrase ?? string.Empty,
214+
statusCode: __response.StatusCode)
215+
{
216+
ResponseBody = __content_429,
217+
ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
218+
__response.Headers,
219+
h => h.Key,
220+
h => h.Value),
221+
};
138222
}
139-
catch (global::System.Net.Http.HttpRequestException __ex)
223+
224+
if (ReadResponseAsString)
140225
{
141-
throw new global::System.InvalidOperationException(__content, __ex);
226+
var __content = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
227+
228+
ProcessResponseContent(
229+
client: HttpClient,
230+
response: __response,
231+
content: ref __content);
232+
ProcessPostEditImageResponseContent(
233+
httpClient: HttpClient,
234+
httpResponseMessage: __response,
235+
content: ref __content);
236+
237+
try
238+
{
239+
__response.EnsureSuccessStatusCode();
240+
}
241+
catch (global::System.Net.Http.HttpRequestException __ex)
242+
{
243+
throw new global::Ideogram.ApiException(
244+
message: __content ?? __response.ReasonPhrase ?? string.Empty,
245+
innerException: __ex,
246+
statusCode: __response.StatusCode)
247+
{
248+
ResponseBody = __content,
249+
ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
250+
__response.Headers,
251+
h => h.Key,
252+
h => h.Value),
253+
};
254+
}
255+
256+
return
257+
global::Ideogram.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ??
258+
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
142259
}
260+
else
261+
{
262+
try
263+
{
264+
__response.EnsureSuccessStatusCode();
265+
}
266+
catch (global::System.Net.Http.HttpRequestException __ex)
267+
{
268+
throw new global::Ideogram.ApiException(
269+
message: __response.ReasonPhrase ?? string.Empty,
270+
innerException: __ex,
271+
statusCode: __response.StatusCode)
272+
{
273+
ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
274+
__response.Headers,
275+
h => h.Key,
276+
h => h.Value),
277+
};
278+
}
279+
280+
using var __responseStream = await __response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
143281

144-
return
145-
global::Ideogram.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ??
146-
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
282+
var __responseValue = await global::Ideogram.GenerateImageResponse.FromJsonStreamAsync(__responseStream, JsonSerializerContext).ConfigureAwait(false);
283+
284+
return
285+
__responseValue ??
286+
throw new global::System.InvalidOperationException("Response deserialization failed.");
287+
}
147288
}
148289

149290
/// <summary>

0 commit comments

Comments
 (0)