1+
2+ #nullable enable
3+
4+ namespace Ideogram
5+ {
6+ public partial class BatchClient
7+ {
8+ partial void PrepareGetBatchStatusArguments (
9+ global ::System . Net . Http . HttpClient httpClient ,
10+ ref string jobId ) ;
11+ partial void PrepareGetBatchStatusRequest (
12+ global ::System . Net . Http . HttpClient httpClient ,
13+ global ::System . Net . Http . HttpRequestMessage httpRequestMessage ,
14+ string jobId ) ;
15+ partial void ProcessGetBatchStatusResponse (
16+ global ::System . Net . Http . HttpClient httpClient ,
17+ global ::System . Net . Http . HttpResponseMessage httpResponseMessage ) ;
18+
19+ partial void ProcessGetBatchStatusResponseContent (
20+ global ::System . Net . Http . HttpClient httpClient ,
21+ global ::System . Net . Http . HttpResponseMessage httpResponseMessage ,
22+ ref string content ) ;
23+
24+ /// <summary>
25+ /// Get Batch Magic Prompt Job Status and TFRecord URL if available<br/>
26+ /// Gets the status of a batch magic prompt job and the TFRecord URL if available.
27+ /// </summary>
28+ /// <param name="jobId"></param>
29+ /// <param name="cancellationToken">The token to cancel the operation with</param>
30+ /// <exception cref="global::Ideogram.ApiException"></exception>
31+ public async global ::System . Threading . Tasks . Task < global ::Ideogram . InternalBatchStatusResponse > GetBatchStatusAsync (
32+ string jobId ,
33+ global ::System . Threading . CancellationToken cancellationToken = default )
34+ {
35+ PrepareArguments (
36+ client : HttpClient ) ;
37+ PrepareGetBatchStatusArguments (
38+ httpClient : HttpClient ,
39+ jobId : ref jobId ) ;
40+
41+ var __pathBuilder = new global ::Ideogram . PathBuilder (
42+ path : $ "/internal/batch/status/{ jobId } ",
43+ baseUri : HttpClient . BaseAddress ) ;
44+ var __path = __pathBuilder . ToString ( ) ;
45+ using var __httpRequest = new global ::System . Net . Http . HttpRequestMessage (
46+ method : global ::System . Net . Http . HttpMethod . Get ,
47+ requestUri : new global ::System . Uri ( __path , global ::System . UriKind . RelativeOrAbsolute ) ) ;
48+ #if NET6_0_OR_GREATER
49+ __httpRequest . Version = global ::System . Net . HttpVersion . Version11 ;
50+ __httpRequest . VersionPolicy = global ::System . Net . Http . HttpVersionPolicy . RequestVersionOrHigher ;
51+ #endif
52+
53+ foreach ( var __authorization in Authorizations )
54+ {
55+ if ( __authorization . Type == "Http" ||
56+ __authorization . Type == "OAuth2" )
57+ {
58+ __httpRequest . Headers . Authorization = new global ::System . Net . Http . Headers . AuthenticationHeaderValue (
59+ scheme : __authorization . Name ,
60+ parameter : __authorization . Value ) ;
61+ }
62+ else if ( __authorization . Type == "ApiKey" &&
63+ __authorization . Location == "Header" )
64+ {
65+ __httpRequest . Headers . Add ( __authorization . Name , __authorization . Value ) ;
66+ }
67+ }
68+
69+ PrepareRequest (
70+ client : HttpClient ,
71+ request : __httpRequest ) ;
72+ PrepareGetBatchStatusRequest (
73+ httpClient : HttpClient ,
74+ httpRequestMessage : __httpRequest ,
75+ jobId : jobId ) ;
76+
77+ using var __response = await HttpClient . SendAsync (
78+ request : __httpRequest ,
79+ completionOption : global ::System . Net . Http . HttpCompletionOption . ResponseContentRead ,
80+ cancellationToken : cancellationToken ) . ConfigureAwait ( false ) ;
81+
82+ ProcessResponse (
83+ client : HttpClient ,
84+ response : __response ) ;
85+ ProcessGetBatchStatusResponse (
86+ httpClient : HttpClient ,
87+ httpResponseMessage : __response ) ;
88+ //
89+ if ( ( int ) __response . StatusCode == 400 )
90+ {
91+ string ? __content_400 = null ;
92+ global ::System . Exception ? __exception_400 = null ;
93+ try
94+ {
95+ if ( ReadResponseAsString )
96+ {
97+ __content_400 = await __response . Content . ReadAsStringAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
98+ }
99+ else
100+ {
101+ var __contentStream_400 = await __response . Content . ReadAsStreamAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
102+ }
103+ }
104+ catch ( global ::System . Exception __ex )
105+ {
106+ __exception_400 = __ex ;
107+ }
108+
109+ throw new global ::Ideogram . ApiException (
110+ message : __content_400 ?? __response . ReasonPhrase ?? string . Empty ,
111+ innerException : __exception_400 ,
112+ statusCode : __response . StatusCode )
113+ {
114+ ResponseBody = __content_400 ,
115+ ResponseHeaders = global ::System . Linq . Enumerable . ToDictionary (
116+ __response . Headers ,
117+ h => h . Key ,
118+ h => h . Value ) ,
119+ } ;
120+ }
121+ //
122+ if ( ( int ) __response . StatusCode == 401 )
123+ {
124+ string ? __content_401 = null ;
125+ global ::System . Exception ? __exception_401 = null ;
126+ try
127+ {
128+ if ( ReadResponseAsString )
129+ {
130+ __content_401 = await __response . Content . ReadAsStringAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
131+ }
132+ else
133+ {
134+ var __contentStream_401 = await __response . Content . ReadAsStreamAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
135+ }
136+ }
137+ catch ( global ::System . Exception __ex )
138+ {
139+ __exception_401 = __ex ;
140+ }
141+
142+ throw new global ::Ideogram . ApiException (
143+ message : __content_401 ?? __response . ReasonPhrase ?? string . Empty ,
144+ innerException : __exception_401 ,
145+ statusCode : __response . StatusCode )
146+ {
147+ ResponseBody = __content_401 ,
148+ ResponseHeaders = global ::System . Linq . Enumerable . ToDictionary (
149+ __response . Headers ,
150+ h => h . Key ,
151+ h => h . Value ) ,
152+ } ;
153+ }
154+ //
155+ if ( ( int ) __response . StatusCode == 429 )
156+ {
157+ string ? __content_429 = null ;
158+ global ::System . Exception ? __exception_429 = null ;
159+ try
160+ {
161+ if ( ReadResponseAsString )
162+ {
163+ __content_429 = await __response . Content . ReadAsStringAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
164+ }
165+ else
166+ {
167+ var __contentStream_429 = await __response . Content . ReadAsStreamAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
168+ }
169+ }
170+ catch ( global ::System . Exception __ex )
171+ {
172+ __exception_429 = __ex ;
173+ }
174+
175+ throw new global ::Ideogram . ApiException (
176+ message : __content_429 ?? __response . ReasonPhrase ?? string . Empty ,
177+ innerException : __exception_429 ,
178+ statusCode : __response . StatusCode )
179+ {
180+ ResponseBody = __content_429 ,
181+ ResponseHeaders = global ::System . Linq . Enumerable . ToDictionary (
182+ __response . Headers ,
183+ h => h . Key ,
184+ h => h . Value ) ,
185+ } ;
186+ }
187+ //
188+ if ( ( int ) __response . StatusCode == 500 )
189+ {
190+ string ? __content_500 = null ;
191+ global ::System . Exception ? __exception_500 = null ;
192+ try
193+ {
194+ if ( ReadResponseAsString )
195+ {
196+ __content_500 = await __response . Content . ReadAsStringAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
197+ }
198+ else
199+ {
200+ var __contentStream_500 = await __response . Content . ReadAsStreamAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
201+ }
202+ }
203+ catch ( global ::System . Exception __ex )
204+ {
205+ __exception_500 = __ex ;
206+ }
207+
208+ throw new global ::Ideogram . ApiException (
209+ message : __content_500 ?? __response . ReasonPhrase ?? string . Empty ,
210+ innerException : __exception_500 ,
211+ statusCode : __response . StatusCode )
212+ {
213+ ResponseBody = __content_500 ,
214+ ResponseHeaders = global ::System . Linq . Enumerable . ToDictionary (
215+ __response . Headers ,
216+ h => h . Key ,
217+ h => h . Value ) ,
218+ } ;
219+ }
220+
221+ if ( ReadResponseAsString )
222+ {
223+ var __content = await __response . Content . ReadAsStringAsync (
224+ #if NET5_0_OR_GREATER
225+ cancellationToken
226+ #endif
227+ ) . ConfigureAwait ( false ) ;
228+
229+ ProcessResponseContent (
230+ client : HttpClient ,
231+ response : __response ,
232+ content : ref __content ) ;
233+ ProcessGetBatchStatusResponseContent (
234+ httpClient : HttpClient ,
235+ httpResponseMessage : __response ,
236+ content : ref __content ) ;
237+
238+ try
239+ {
240+ __response . EnsureSuccessStatusCode ( ) ;
241+
242+ return
243+ global ::Ideogram . InternalBatchStatusResponse . FromJson ( __content , JsonSerializerContext ) ??
244+ throw new global ::System . InvalidOperationException ( $ "Response deserialization failed for \" { __content } \" ") ;
245+ }
246+ catch ( global ::System . Exception __ex )
247+ {
248+ throw new global ::Ideogram . ApiException (
249+ message : __content ?? __response . ReasonPhrase ?? string . Empty ,
250+ innerException : __ex ,
251+ statusCode : __response . StatusCode )
252+ {
253+ ResponseBody = __content ,
254+ ResponseHeaders = global ::System . Linq . Enumerable . ToDictionary (
255+ __response . Headers ,
256+ h => h . Key ,
257+ h => h . Value ) ,
258+ } ;
259+ }
260+ }
261+ else
262+ {
263+ try
264+ {
265+ __response . EnsureSuccessStatusCode ( ) ;
266+
267+ using var __content = await __response . Content . ReadAsStreamAsync (
268+ #if NET5_0_OR_GREATER
269+ cancellationToken
270+ #endif
271+ ) . ConfigureAwait ( false ) ;
272+
273+ return
274+ await global ::Ideogram . InternalBatchStatusResponse . FromJsonStreamAsync ( __content , JsonSerializerContext ) . ConfigureAwait ( false ) ??
275+ throw new global ::System . InvalidOperationException ( "Response deserialization failed." ) ;
276+ }
277+ catch ( global ::System . Exception __ex )
278+ {
279+ throw new global ::Ideogram . ApiException (
280+ message : __response . ReasonPhrase ?? string . Empty ,
281+ innerException : __ex ,
282+ statusCode : __response . StatusCode )
283+ {
284+ ResponseHeaders = global ::System . Linq . Enumerable . ToDictionary (
285+ __response . Headers ,
286+ h => h . Key ,
287+ h => h . Value ) ,
288+ } ;
289+ }
290+ }
291+ }
292+ }
293+ }
0 commit comments