diff --git a/src/libs/Picsart/Generated/Picsart.AutoSDKHttpResponse.g.cs b/src/libs/Picsart/Generated/Picsart.AutoSDKHttpResponse.g.cs index 34d2535..1c8d2b3 100644 --- a/src/libs/Picsart/Generated/Picsart.AutoSDKHttpResponse.g.cs +++ b/src/libs/Picsart/Generated/Picsart.AutoSDKHttpResponse.g.cs @@ -14,9 +14,24 @@ public partial class AutoSDKHttpResponse 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; } /// @@ -27,6 +42,10 @@ public AutoSDKHttpResponse( /// 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) @@ -73,7 +92,23 @@ public AutoSDKHttpResponse( global::System.Net.HttpStatusCode statusCode, global::System.Collections.Generic.Dictionary> headers, T body) - : base(statusCode, headers) + : 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; } diff --git a/src/libs/Picsart/Generated/Picsart.GenAIInpaintingImage2ImageClient.GenaiExpandImage.g.cs b/src/libs/Picsart/Generated/Picsart.GenAIInpaintingImage2ImageClient.GenaiExpandImage.g.cs index 20fd7ec..96fe283 100644 --- a/src/libs/Picsart/Generated/Picsart.GenAIInpaintingImage2ImageClient.GenaiExpandImage.g.cs +++ b/src/libs/Picsart/Generated/Picsart.GenAIInpaintingImage2ImageClient.GenaiExpandImage.g.cs @@ -106,10 +106,11 @@ partial void ProcessGenaiExpandImageResponseContent( var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/genai/painting/expand", baseUri: HttpClient.BaseAddress); @@ -142,8 +143,11 @@ partial void ProcessGenaiExpandImageResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + __httpRequest.Content = __httpRequestContent; + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -185,6 +189,8 @@ partial void ProcessGenaiExpandImageResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -195,6 +201,11 @@ partial void ProcessGenaiExpandImageResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -212,6 +223,8 @@ partial void ProcessGenaiExpandImageResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -221,8 +234,7 @@ partial void ProcessGenaiExpandImageResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -231,6 +243,11 @@ partial void ProcessGenaiExpandImageResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -247,14 +264,15 @@ partial void ProcessGenaiExpandImageResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -294,6 +312,8 @@ partial void ProcessGenaiExpandImageResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -314,6 +334,8 @@ partial void ProcessGenaiExpandImageResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -799,6 +821,7 @@ partial void ProcessGenaiExpandImageResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -832,6 +855,7 @@ partial void ProcessGenaiExpandImageResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.GenAIInpaintingImage2ImageClient.GenaiGenerateImageBleed.g.cs b/src/libs/Picsart/Generated/Picsart.GenAIInpaintingImage2ImageClient.GenaiGenerateImageBleed.g.cs index 470a315..7115b7c 100644 --- a/src/libs/Picsart/Generated/Picsart.GenAIInpaintingImage2ImageClient.GenaiGenerateImageBleed.g.cs +++ b/src/libs/Picsart/Generated/Picsart.GenAIInpaintingImage2ImageClient.GenaiGenerateImageBleed.g.cs @@ -104,10 +104,11 @@ partial void ProcessGenaiGenerateImageBleedResponseContent( var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/genai/painting/bleed", baseUri: HttpClient.BaseAddress); @@ -140,8 +141,11 @@ partial void ProcessGenaiGenerateImageBleedResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + __httpRequest.Content = __httpRequestContent; + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -183,6 +187,8 @@ partial void ProcessGenaiGenerateImageBleedResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -193,6 +199,11 @@ partial void ProcessGenaiGenerateImageBleedResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -210,6 +221,8 @@ partial void ProcessGenaiGenerateImageBleedResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -219,8 +232,7 @@ partial void ProcessGenaiGenerateImageBleedResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -229,6 +241,11 @@ partial void ProcessGenaiGenerateImageBleedResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -245,14 +262,15 @@ partial void ProcessGenaiGenerateImageBleedResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -292,6 +310,8 @@ partial void ProcessGenaiGenerateImageBleedResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -312,6 +332,8 @@ partial void ProcessGenaiGenerateImageBleedResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -797,6 +819,7 @@ partial void ProcessGenaiGenerateImageBleedResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -830,6 +853,7 @@ partial void ProcessGenaiGenerateImageBleedResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.GenAIInpaintingImage2ImageClient.GenaiImageInpainting.g.cs b/src/libs/Picsart/Generated/Picsart.GenAIInpaintingImage2ImageClient.GenaiImageInpainting.g.cs index 13d914d..7708e48 100644 --- a/src/libs/Picsart/Generated/Picsart.GenAIInpaintingImage2ImageClient.GenaiImageInpainting.g.cs +++ b/src/libs/Picsart/Generated/Picsart.GenAIInpaintingImage2ImageClient.GenaiImageInpainting.g.cs @@ -102,10 +102,11 @@ partial void ProcessGenaiImageInpaintingResponseContent( var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/genai/painting/inpaint", baseUri: HttpClient.BaseAddress); @@ -138,8 +139,11 @@ partial void ProcessGenaiImageInpaintingResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + __httpRequest.Content = __httpRequestContent; + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -181,6 +185,8 @@ partial void ProcessGenaiImageInpaintingResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -191,6 +197,11 @@ partial void ProcessGenaiImageInpaintingResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -208,6 +219,8 @@ partial void ProcessGenaiImageInpaintingResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -217,8 +230,7 @@ partial void ProcessGenaiImageInpaintingResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -227,6 +239,11 @@ partial void ProcessGenaiImageInpaintingResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -243,14 +260,15 @@ partial void ProcessGenaiImageInpaintingResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -290,6 +308,8 @@ partial void ProcessGenaiImageInpaintingResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -310,6 +330,8 @@ partial void ProcessGenaiImageInpaintingResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -795,6 +817,7 @@ partial void ProcessGenaiImageInpaintingResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -828,6 +851,7 @@ partial void ProcessGenaiImageInpaintingResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.GenAIInpaintingImage2ImageClient.GenaiImageInpaintingGetresult.g.cs b/src/libs/Picsart/Generated/Picsart.GenAIInpaintingImage2ImageClient.GenaiImageInpaintingGetresult.g.cs index d6f6cd1..f004c10 100644 --- a/src/libs/Picsart/Generated/Picsart.GenAIInpaintingImage2ImageClient.GenaiImageInpaintingGetresult.g.cs +++ b/src/libs/Picsart/Generated/Picsart.GenAIInpaintingImage2ImageClient.GenaiImageInpaintingGetresult.g.cs @@ -105,6 +105,7 @@ partial void ProcessGenaiImageInpaintingGetresultResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: $"/genai/painting/{inferenceId}", baseUri: HttpClient.BaseAddress); @@ -178,6 +179,8 @@ partial void ProcessGenaiImageInpaintingGetresultResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -188,6 +191,11 @@ partial void ProcessGenaiImageInpaintingGetresultResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -205,6 +213,8 @@ partial void ProcessGenaiImageInpaintingGetresultResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -214,8 +224,7 @@ partial void ProcessGenaiImageInpaintingGetresultResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -224,6 +233,11 @@ partial void ProcessGenaiImageInpaintingGetresultResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -240,14 +254,15 @@ partial void ProcessGenaiImageInpaintingGetresultResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -287,6 +302,8 @@ partial void ProcessGenaiImageInpaintingGetresultResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -307,6 +324,8 @@ partial void ProcessGenaiImageInpaintingGetresultResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -792,6 +811,7 @@ partial void ProcessGenaiImageInpaintingGetresultResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -825,6 +845,7 @@ partial void ProcessGenaiImageInpaintingGetresultResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.GenAIInpaintingImage2ImageClient.GenaiImageOutpainting.g.cs b/src/libs/Picsart/Generated/Picsart.GenAIInpaintingImage2ImageClient.GenaiImageOutpainting.g.cs index 505b0e0..8a9843e 100644 --- a/src/libs/Picsart/Generated/Picsart.GenAIInpaintingImage2ImageClient.GenaiImageOutpainting.g.cs +++ b/src/libs/Picsart/Generated/Picsart.GenAIInpaintingImage2ImageClient.GenaiImageOutpainting.g.cs @@ -108,10 +108,11 @@ partial void ProcessGenaiImageOutpaintingResponseContent( var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/genai/painting/outpaint", baseUri: HttpClient.BaseAddress); @@ -144,8 +145,11 @@ partial void ProcessGenaiImageOutpaintingResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + __httpRequest.Content = __httpRequestContent; + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -187,6 +191,8 @@ partial void ProcessGenaiImageOutpaintingResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -197,6 +203,11 @@ partial void ProcessGenaiImageOutpaintingResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -214,6 +225,8 @@ partial void ProcessGenaiImageOutpaintingResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -223,8 +236,7 @@ partial void ProcessGenaiImageOutpaintingResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -233,6 +245,11 @@ partial void ProcessGenaiImageOutpaintingResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -249,14 +266,15 @@ partial void ProcessGenaiImageOutpaintingResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -296,6 +314,8 @@ partial void ProcessGenaiImageOutpaintingResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -316,6 +336,8 @@ partial void ProcessGenaiImageOutpaintingResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -801,6 +823,7 @@ partial void ProcessGenaiImageOutpaintingResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -834,6 +857,7 @@ partial void ProcessGenaiImageOutpaintingResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.GenAIInpaintingImage2ImageClient.GenaiRemoveObject.g.cs b/src/libs/Picsart/Generated/Picsart.GenAIInpaintingImage2ImageClient.GenaiRemoveObject.g.cs index cd2bb1b..0cb7223 100644 --- a/src/libs/Picsart/Generated/Picsart.GenAIInpaintingImage2ImageClient.GenaiRemoveObject.g.cs +++ b/src/libs/Picsart/Generated/Picsart.GenAIInpaintingImage2ImageClient.GenaiRemoveObject.g.cs @@ -104,10 +104,11 @@ partial void ProcessGenaiRemoveObjectResponseContent( var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/genai/painting/remove-object", baseUri: HttpClient.BaseAddress); @@ -140,8 +141,11 @@ partial void ProcessGenaiRemoveObjectResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + __httpRequest.Content = __httpRequestContent; + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -183,6 +187,8 @@ partial void ProcessGenaiRemoveObjectResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -193,6 +199,11 @@ partial void ProcessGenaiRemoveObjectResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -210,6 +221,8 @@ partial void ProcessGenaiRemoveObjectResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -219,8 +232,7 @@ partial void ProcessGenaiRemoveObjectResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -229,6 +241,11 @@ partial void ProcessGenaiRemoveObjectResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -245,14 +262,15 @@ partial void ProcessGenaiRemoveObjectResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -292,6 +310,8 @@ partial void ProcessGenaiRemoveObjectResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -312,6 +332,8 @@ partial void ProcessGenaiRemoveObjectResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -797,6 +819,7 @@ partial void ProcessGenaiRemoveObjectResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -830,6 +853,7 @@ partial void ProcessGenaiRemoveObjectResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.GenAIInpaintingImage2ImageClient.GenaiSmartBackground.g.cs b/src/libs/Picsart/Generated/Picsart.GenAIInpaintingImage2ImageClient.GenaiSmartBackground.g.cs index c17d7a7..acb6b9c 100644 --- a/src/libs/Picsart/Generated/Picsart.GenAIInpaintingImage2ImageClient.GenaiSmartBackground.g.cs +++ b/src/libs/Picsart/Generated/Picsart.GenAIInpaintingImage2ImageClient.GenaiSmartBackground.g.cs @@ -110,10 +110,11 @@ partial void ProcessGenaiSmartBackgroundResponseContent( var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/genai/painting/replace-background", baseUri: HttpClient.BaseAddress); @@ -146,8 +147,11 @@ partial void ProcessGenaiSmartBackgroundResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + __httpRequest.Content = __httpRequestContent; + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -189,6 +193,8 @@ partial void ProcessGenaiSmartBackgroundResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -199,6 +205,11 @@ partial void ProcessGenaiSmartBackgroundResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -216,6 +227,8 @@ partial void ProcessGenaiSmartBackgroundResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -225,8 +238,7 @@ partial void ProcessGenaiSmartBackgroundResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -235,6 +247,11 @@ partial void ProcessGenaiSmartBackgroundResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -251,14 +268,15 @@ partial void ProcessGenaiSmartBackgroundResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -298,6 +316,8 @@ partial void ProcessGenaiSmartBackgroundResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -318,6 +338,8 @@ partial void ProcessGenaiSmartBackgroundResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -803,6 +825,7 @@ partial void ProcessGenaiSmartBackgroundResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -836,6 +859,7 @@ partial void ProcessGenaiSmartBackgroundResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.GenAIInpaintingImage2ImageClient.g.cs b/src/libs/Picsart/Generated/Picsart.GenAIInpaintingImage2ImageClient.g.cs index e1a7880..709c6d3 100644 --- a/src/libs/Picsart/Generated/Picsart.GenAIInpaintingImage2ImageClient.g.cs +++ b/src/libs/Picsart/Generated/Picsart.GenAIInpaintingImage2ImageClient.g.cs @@ -72,10 +72,10 @@ public GenAIInpaintingImage2ImageClient( /// Client-wide request defaults such as headers, query parameters, retries, and timeout. /// Dispose the HttpClient when the instance is disposed. True by default. public GenAIInpaintingImage2ImageClient( - global::System.Net.Http.HttpClient? httpClient = null, - global::System.Uri? baseUri = null, - global::System.Collections.Generic.List? authorizations = null, - global::Picsart.AutoSDKClientOptions? options = null, + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Picsart.AutoSDKClientOptions? options, bool disposeHttpClient = true) { diff --git a/src/libs/Picsart/Generated/Picsart.GenAIText2AudioClient.GenaiText2audioGetresult.g.cs b/src/libs/Picsart/Generated/Picsart.GenAIText2AudioClient.GenaiText2audioGetresult.g.cs index 0610c31..46fce9a 100644 --- a/src/libs/Picsart/Generated/Picsart.GenAIText2AudioClient.GenaiText2audioGetresult.g.cs +++ b/src/libs/Picsart/Generated/Picsart.GenAIText2AudioClient.GenaiText2audioGetresult.g.cs @@ -103,6 +103,7 @@ partial void ProcessGenaiText2audioGetresultResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: $"/genai/audio/{inferenceId}", baseUri: HttpClient.BaseAddress); @@ -176,6 +177,8 @@ partial void ProcessGenaiText2audioGetresultResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -186,6 +189,11 @@ partial void ProcessGenaiText2audioGetresultResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -203,6 +211,8 @@ partial void ProcessGenaiText2audioGetresultResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -212,8 +222,7 @@ partial void ProcessGenaiText2audioGetresultResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -222,6 +231,11 @@ partial void ProcessGenaiText2audioGetresultResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -238,14 +252,15 @@ partial void ProcessGenaiText2audioGetresultResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -285,6 +300,8 @@ partial void ProcessGenaiText2audioGetresultResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -305,6 +322,8 @@ partial void ProcessGenaiText2audioGetresultResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -790,6 +809,7 @@ partial void ProcessGenaiText2audioGetresultResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -823,6 +843,7 @@ partial void ProcessGenaiText2audioGetresultResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.GenAIText2AudioClient.GenaiText2sound.g.cs b/src/libs/Picsart/Generated/Picsart.GenAIText2AudioClient.GenaiText2sound.g.cs index 0e2fbe6..28912ea 100644 --- a/src/libs/Picsart/Generated/Picsart.GenAIText2AudioClient.GenaiText2sound.g.cs +++ b/src/libs/Picsart/Generated/Picsart.GenAIText2AudioClient.GenaiText2sound.g.cs @@ -106,6 +106,7 @@ partial void ProcessGenaiText2soundResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/genai/text2sound", baseUri: HttpClient.BaseAddress); @@ -185,6 +186,8 @@ partial void ProcessGenaiText2soundResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -195,6 +198,11 @@ partial void ProcessGenaiText2soundResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -212,6 +220,8 @@ partial void ProcessGenaiText2soundResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -221,8 +231,7 @@ partial void ProcessGenaiText2soundResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -231,6 +240,11 @@ partial void ProcessGenaiText2soundResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -247,14 +261,15 @@ partial void ProcessGenaiText2soundResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -294,6 +309,8 @@ partial void ProcessGenaiText2soundResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -314,6 +331,8 @@ partial void ProcessGenaiText2soundResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -799,6 +818,7 @@ partial void ProcessGenaiText2soundResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -832,6 +852,7 @@ partial void ProcessGenaiText2soundResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.GenAIText2AudioClient.GenaiText2speech.g.cs b/src/libs/Picsart/Generated/Picsart.GenAIText2AudioClient.GenaiText2speech.g.cs index 3585d15..640e999 100644 --- a/src/libs/Picsart/Generated/Picsart.GenAIText2AudioClient.GenaiText2speech.g.cs +++ b/src/libs/Picsart/Generated/Picsart.GenAIText2AudioClient.GenaiText2speech.g.cs @@ -106,6 +106,7 @@ partial void ProcessGenaiText2speechResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/genai/text2speech", baseUri: HttpClient.BaseAddress); @@ -185,6 +186,8 @@ partial void ProcessGenaiText2speechResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -195,6 +198,11 @@ partial void ProcessGenaiText2speechResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -212,6 +220,8 @@ partial void ProcessGenaiText2speechResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -221,8 +231,7 @@ partial void ProcessGenaiText2speechResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -231,6 +240,11 @@ partial void ProcessGenaiText2speechResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -247,14 +261,15 @@ partial void ProcessGenaiText2speechResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -294,6 +309,8 @@ partial void ProcessGenaiText2speechResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -314,6 +331,8 @@ partial void ProcessGenaiText2speechResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -799,6 +818,7 @@ partial void ProcessGenaiText2speechResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -832,6 +852,7 @@ partial void ProcessGenaiText2speechResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.GenAIText2AudioClient.g.cs b/src/libs/Picsart/Generated/Picsart.GenAIText2AudioClient.g.cs index f1f1fcd..efce1e7 100644 --- a/src/libs/Picsart/Generated/Picsart.GenAIText2AudioClient.g.cs +++ b/src/libs/Picsart/Generated/Picsart.GenAIText2AudioClient.g.cs @@ -72,10 +72,10 @@ public GenAIText2AudioClient( /// Client-wide request defaults such as headers, query parameters, retries, and timeout. /// Dispose the HttpClient when the instance is disposed. True by default. public GenAIText2AudioClient( - global::System.Net.Http.HttpClient? httpClient = null, - global::System.Uri? baseUri = null, - global::System.Collections.Generic.List? authorizations = null, - global::Picsart.AutoSDKClientOptions? options = null, + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Picsart.AutoSDKClientOptions? options, bool disposeHttpClient = true) { diff --git a/src/libs/Picsart/Generated/Picsart.GenAIText2ImageClient.GenaiGenerateLogo.g.cs b/src/libs/Picsart/Generated/Picsart.GenAIText2ImageClient.GenaiGenerateLogo.g.cs index 11acaa0..a10f7d6 100644 --- a/src/libs/Picsart/Generated/Picsart.GenAIText2ImageClient.GenaiGenerateLogo.g.cs +++ b/src/libs/Picsart/Generated/Picsart.GenAIText2ImageClient.GenaiGenerateLogo.g.cs @@ -102,10 +102,11 @@ partial void ProcessGenaiGenerateLogoResponseContent( var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/genai/logo", baseUri: HttpClient.BaseAddress); @@ -138,8 +139,11 @@ partial void ProcessGenaiGenerateLogoResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + __httpRequest.Content = __httpRequestContent; + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -181,6 +185,8 @@ partial void ProcessGenaiGenerateLogoResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -191,6 +197,11 @@ partial void ProcessGenaiGenerateLogoResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -208,6 +219,8 @@ partial void ProcessGenaiGenerateLogoResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -217,8 +230,7 @@ partial void ProcessGenaiGenerateLogoResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -227,6 +239,11 @@ partial void ProcessGenaiGenerateLogoResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -243,14 +260,15 @@ partial void ProcessGenaiGenerateLogoResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -290,6 +308,8 @@ partial void ProcessGenaiGenerateLogoResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -310,6 +330,8 @@ partial void ProcessGenaiGenerateLogoResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -795,6 +817,7 @@ partial void ProcessGenaiGenerateLogoResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -828,6 +851,7 @@ partial void ProcessGenaiGenerateLogoResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.GenAIText2ImageClient.GenaiGenerateLogoGetresult.g.cs b/src/libs/Picsart/Generated/Picsart.GenAIText2ImageClient.GenaiGenerateLogoGetresult.g.cs index e323c0c..b1129c2 100644 --- a/src/libs/Picsart/Generated/Picsart.GenAIText2ImageClient.GenaiGenerateLogoGetresult.g.cs +++ b/src/libs/Picsart/Generated/Picsart.GenAIText2ImageClient.GenaiGenerateLogoGetresult.g.cs @@ -103,6 +103,7 @@ partial void ProcessGenaiGenerateLogoGetresultResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: $"/genai/logo/inferences/{inferenceId}", baseUri: HttpClient.BaseAddress); @@ -176,6 +177,8 @@ partial void ProcessGenaiGenerateLogoGetresultResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -186,6 +189,11 @@ partial void ProcessGenaiGenerateLogoGetresultResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -203,6 +211,8 @@ partial void ProcessGenaiGenerateLogoGetresultResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -212,8 +222,7 @@ partial void ProcessGenaiGenerateLogoGetresultResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -222,6 +231,11 @@ partial void ProcessGenaiGenerateLogoGetresultResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -238,14 +252,15 @@ partial void ProcessGenaiGenerateLogoGetresultResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -285,6 +300,8 @@ partial void ProcessGenaiGenerateLogoGetresultResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -305,6 +322,8 @@ partial void ProcessGenaiGenerateLogoGetresultResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -790,6 +809,7 @@ partial void ProcessGenaiGenerateLogoGetresultResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -823,6 +843,7 @@ partial void ProcessGenaiGenerateLogoGetresultResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.GenAIText2ImageClient.GenaiText2image.g.cs b/src/libs/Picsart/Generated/Picsart.GenAIText2ImageClient.GenaiText2image.g.cs index 899b16a..3775020 100644 --- a/src/libs/Picsart/Generated/Picsart.GenAIText2ImageClient.GenaiText2image.g.cs +++ b/src/libs/Picsart/Generated/Picsart.GenAIText2ImageClient.GenaiText2image.g.cs @@ -108,6 +108,7 @@ partial void ProcessGenaiText2imageResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/genai/text2image", baseUri: HttpClient.BaseAddress); @@ -187,6 +188,8 @@ partial void ProcessGenaiText2imageResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -197,6 +200,11 @@ partial void ProcessGenaiText2imageResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -214,6 +222,8 @@ partial void ProcessGenaiText2imageResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -223,8 +233,7 @@ partial void ProcessGenaiText2imageResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -233,6 +242,11 @@ partial void ProcessGenaiText2imageResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -249,14 +263,15 @@ partial void ProcessGenaiText2imageResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -296,6 +311,8 @@ partial void ProcessGenaiText2imageResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -316,6 +333,8 @@ partial void ProcessGenaiText2imageResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -801,6 +820,7 @@ partial void ProcessGenaiText2imageResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -834,6 +854,7 @@ partial void ProcessGenaiText2imageResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.GenAIText2ImageClient.GenaiText2imageGetresult.g.cs b/src/libs/Picsart/Generated/Picsart.GenAIText2ImageClient.GenaiText2imageGetresult.g.cs index c288899..8687ce4 100644 --- a/src/libs/Picsart/Generated/Picsart.GenAIText2ImageClient.GenaiText2imageGetresult.g.cs +++ b/src/libs/Picsart/Generated/Picsart.GenAIText2ImageClient.GenaiText2imageGetresult.g.cs @@ -103,6 +103,7 @@ partial void ProcessGenaiText2imageGetresultResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: $"/genai/text2image/inferences/{inferenceId}", baseUri: HttpClient.BaseAddress); @@ -176,6 +177,8 @@ partial void ProcessGenaiText2imageGetresultResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -186,6 +189,11 @@ partial void ProcessGenaiText2imageGetresultResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -203,6 +211,8 @@ partial void ProcessGenaiText2imageGetresultResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -212,8 +222,7 @@ partial void ProcessGenaiText2imageGetresultResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -222,6 +231,11 @@ partial void ProcessGenaiText2imageGetresultResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -238,14 +252,15 @@ partial void ProcessGenaiText2imageGetresultResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -285,6 +300,8 @@ partial void ProcessGenaiText2imageGetresultResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -305,6 +322,8 @@ partial void ProcessGenaiText2imageGetresultResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -790,6 +809,7 @@ partial void ProcessGenaiText2imageGetresultResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -823,6 +843,7 @@ partial void ProcessGenaiText2imageGetresultResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.GenAIText2ImageClient.GenaiText2sticker.g.cs b/src/libs/Picsart/Generated/Picsart.GenAIText2ImageClient.GenaiText2sticker.g.cs index c52981c..dadeceb 100644 --- a/src/libs/Picsart/Generated/Picsart.GenAIText2ImageClient.GenaiText2sticker.g.cs +++ b/src/libs/Picsart/Generated/Picsart.GenAIText2ImageClient.GenaiText2sticker.g.cs @@ -108,6 +108,7 @@ partial void ProcessGenaiText2stickerResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/genai/text2sticker", baseUri: HttpClient.BaseAddress); @@ -187,6 +188,8 @@ partial void ProcessGenaiText2stickerResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -197,6 +200,11 @@ partial void ProcessGenaiText2stickerResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -214,6 +222,8 @@ partial void ProcessGenaiText2stickerResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -223,8 +233,7 @@ partial void ProcessGenaiText2stickerResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -233,6 +242,11 @@ partial void ProcessGenaiText2stickerResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -249,14 +263,15 @@ partial void ProcessGenaiText2stickerResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -296,6 +311,8 @@ partial void ProcessGenaiText2stickerResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -316,6 +333,8 @@ partial void ProcessGenaiText2stickerResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -801,6 +820,7 @@ partial void ProcessGenaiText2stickerResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -834,6 +854,7 @@ partial void ProcessGenaiText2stickerResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.GenAIText2ImageClient.GenaiText2stickerGetresult.g.cs b/src/libs/Picsart/Generated/Picsart.GenAIText2ImageClient.GenaiText2stickerGetresult.g.cs index fbd1c1d..7b20fb3 100644 --- a/src/libs/Picsart/Generated/Picsart.GenAIText2ImageClient.GenaiText2stickerGetresult.g.cs +++ b/src/libs/Picsart/Generated/Picsart.GenAIText2ImageClient.GenaiText2stickerGetresult.g.cs @@ -103,6 +103,7 @@ partial void ProcessGenaiText2stickerGetresultResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: $"/genai/text2sticker/inferences/{inferenceId}", baseUri: HttpClient.BaseAddress); @@ -176,6 +177,8 @@ partial void ProcessGenaiText2stickerGetresultResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -186,6 +189,11 @@ partial void ProcessGenaiText2stickerGetresultResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -203,6 +211,8 @@ partial void ProcessGenaiText2stickerGetresultResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -212,8 +222,7 @@ partial void ProcessGenaiText2stickerGetresultResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -222,6 +231,11 @@ partial void ProcessGenaiText2stickerGetresultResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -238,14 +252,15 @@ partial void ProcessGenaiText2stickerGetresultResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -285,6 +300,8 @@ partial void ProcessGenaiText2stickerGetresultResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -305,6 +322,8 @@ partial void ProcessGenaiText2stickerGetresultResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -790,6 +809,7 @@ partial void ProcessGenaiText2stickerGetresultResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -823,6 +843,7 @@ partial void ProcessGenaiText2stickerGetresultResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.GenAIText2ImageClient.GenaiText2stickerLaserEngraving.g.cs b/src/libs/Picsart/Generated/Picsart.GenAIText2ImageClient.GenaiText2stickerLaserEngraving.g.cs index 7451226..bfca5ed 100644 --- a/src/libs/Picsart/Generated/Picsart.GenAIText2ImageClient.GenaiText2stickerLaserEngraving.g.cs +++ b/src/libs/Picsart/Generated/Picsart.GenAIText2ImageClient.GenaiText2stickerLaserEngraving.g.cs @@ -108,6 +108,7 @@ partial void ProcessGenaiText2stickerLaserEngravingResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/genai/text2sticker/laserengraving", baseUri: HttpClient.BaseAddress); @@ -187,6 +188,8 @@ partial void ProcessGenaiText2stickerLaserEngravingResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -197,6 +200,11 @@ partial void ProcessGenaiText2stickerLaserEngravingResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -214,6 +222,8 @@ partial void ProcessGenaiText2stickerLaserEngravingResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -223,8 +233,7 @@ partial void ProcessGenaiText2stickerLaserEngravingResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -233,6 +242,11 @@ partial void ProcessGenaiText2stickerLaserEngravingResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -249,14 +263,15 @@ partial void ProcessGenaiText2stickerLaserEngravingResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -296,6 +311,8 @@ partial void ProcessGenaiText2stickerLaserEngravingResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -316,6 +333,8 @@ partial void ProcessGenaiText2stickerLaserEngravingResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -801,6 +820,7 @@ partial void ProcessGenaiText2stickerLaserEngravingResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -834,6 +854,7 @@ partial void ProcessGenaiText2stickerLaserEngravingResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.GenAIText2ImageClient.g.cs b/src/libs/Picsart/Generated/Picsart.GenAIText2ImageClient.g.cs index 14f264d..b070a82 100644 --- a/src/libs/Picsart/Generated/Picsart.GenAIText2ImageClient.g.cs +++ b/src/libs/Picsart/Generated/Picsart.GenAIText2ImageClient.g.cs @@ -72,10 +72,10 @@ public GenAIText2ImageClient( /// Client-wide request defaults such as headers, query parameters, retries, and timeout. /// Dispose the HttpClient when the instance is disposed. True by default. public GenAIText2ImageClient( - global::System.Net.Http.HttpClient? httpClient = null, - global::System.Uri? baseUri = null, - global::System.Collections.Generic.List? authorizations = null, - global::Picsart.AutoSDKClientOptions? options = null, + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Picsart.AutoSDKClientOptions? options, bool disposeHttpClient = true) { diff --git a/src/libs/Picsart/Generated/Picsart.GenAIText2TextClient.GenaiText2textCompletions.g.cs b/src/libs/Picsart/Generated/Picsart.GenAIText2TextClient.GenaiText2textCompletions.g.cs index ac925d2..217f518 100644 --- a/src/libs/Picsart/Generated/Picsart.GenAIText2TextClient.GenaiText2textCompletions.g.cs +++ b/src/libs/Picsart/Generated/Picsart.GenAIText2TextClient.GenaiText2textCompletions.g.cs @@ -106,6 +106,7 @@ partial void ProcessGenaiText2textCompletionsResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/genai/text2text/chat/completions", baseUri: HttpClient.BaseAddress); @@ -185,6 +186,8 @@ partial void ProcessGenaiText2textCompletionsResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -195,6 +198,11 @@ partial void ProcessGenaiText2textCompletionsResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -212,6 +220,8 @@ partial void ProcessGenaiText2textCompletionsResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -221,8 +231,7 @@ partial void ProcessGenaiText2textCompletionsResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -231,6 +240,11 @@ partial void ProcessGenaiText2textCompletionsResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -247,14 +261,15 @@ partial void ProcessGenaiText2textCompletionsResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -294,6 +309,8 @@ partial void ProcessGenaiText2textCompletionsResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -314,6 +331,8 @@ partial void ProcessGenaiText2textCompletionsResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -799,6 +818,7 @@ partial void ProcessGenaiText2textCompletionsResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -832,6 +852,7 @@ partial void ProcessGenaiText2textCompletionsResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.GenAIText2TextClient.g.cs b/src/libs/Picsart/Generated/Picsart.GenAIText2TextClient.g.cs index 54f4bd8..db3e324 100644 --- a/src/libs/Picsart/Generated/Picsart.GenAIText2TextClient.g.cs +++ b/src/libs/Picsart/Generated/Picsart.GenAIText2TextClient.g.cs @@ -72,10 +72,10 @@ public GenAIText2TextClient( /// Client-wide request defaults such as headers, query parameters, retries, and timeout. /// Dispose the HttpClient when the instance is disposed. True by default. public GenAIText2TextClient( - global::System.Net.Http.HttpClient? httpClient = null, - global::System.Uri? baseUri = null, - global::System.Collections.Generic.List? authorizations = null, - global::Picsart.AutoSDKClientOptions? options = null, + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Picsart.AutoSDKClientOptions? options, bool disposeHttpClient = true) { diff --git a/src/libs/Picsart/Generated/Picsart.GenAIText2VideoImage2VideoClient.GenaiImage2video.g.cs b/src/libs/Picsart/Generated/Picsart.GenAIText2VideoImage2VideoClient.GenaiImage2video.g.cs index e33d778..0a9c99e 100644 --- a/src/libs/Picsart/Generated/Picsart.GenAIText2VideoImage2VideoClient.GenaiImage2video.g.cs +++ b/src/libs/Picsart/Generated/Picsart.GenAIText2VideoImage2VideoClient.GenaiImage2video.g.cs @@ -110,6 +110,7 @@ partial void ProcessGenaiImage2videoResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/genai/image2video", baseUri: HttpClient.BaseAddress); @@ -189,6 +190,8 @@ partial void ProcessGenaiImage2videoResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -199,6 +202,11 @@ partial void ProcessGenaiImage2videoResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -216,6 +224,8 @@ partial void ProcessGenaiImage2videoResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -225,8 +235,7 @@ partial void ProcessGenaiImage2videoResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -235,6 +244,11 @@ partial void ProcessGenaiImage2videoResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -251,14 +265,15 @@ partial void ProcessGenaiImage2videoResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -298,6 +313,8 @@ partial void ProcessGenaiImage2videoResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -318,6 +335,8 @@ partial void ProcessGenaiImage2videoResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -803,6 +822,7 @@ partial void ProcessGenaiImage2videoResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -836,6 +856,7 @@ partial void ProcessGenaiImage2videoResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.GenAIText2VideoImage2VideoClient.GenaiText2video.g.cs b/src/libs/Picsart/Generated/Picsart.GenAIText2VideoImage2VideoClient.GenaiText2video.g.cs index 5af4f1f..80706b3 100644 --- a/src/libs/Picsart/Generated/Picsart.GenAIText2VideoImage2VideoClient.GenaiText2video.g.cs +++ b/src/libs/Picsart/Generated/Picsart.GenAIText2VideoImage2VideoClient.GenaiText2video.g.cs @@ -110,6 +110,7 @@ partial void ProcessGenaiText2videoResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/genai/text2video", baseUri: HttpClient.BaseAddress); @@ -189,6 +190,8 @@ partial void ProcessGenaiText2videoResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -199,6 +202,11 @@ partial void ProcessGenaiText2videoResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -216,6 +224,8 @@ partial void ProcessGenaiText2videoResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -225,8 +235,7 @@ partial void ProcessGenaiText2videoResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -235,6 +244,11 @@ partial void ProcessGenaiText2videoResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -251,14 +265,15 @@ partial void ProcessGenaiText2videoResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -298,6 +313,8 @@ partial void ProcessGenaiText2videoResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -318,6 +335,8 @@ partial void ProcessGenaiText2videoResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -803,6 +822,7 @@ partial void ProcessGenaiText2videoResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -836,6 +856,7 @@ partial void ProcessGenaiText2videoResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.GenAIText2VideoImage2VideoClient.GenaiText2videoGetresult.g.cs b/src/libs/Picsart/Generated/Picsart.GenAIText2VideoImage2VideoClient.GenaiText2videoGetresult.g.cs index f562ca5..474059e 100644 --- a/src/libs/Picsart/Generated/Picsart.GenAIText2VideoImage2VideoClient.GenaiText2videoGetresult.g.cs +++ b/src/libs/Picsart/Generated/Picsart.GenAIText2VideoImage2VideoClient.GenaiText2videoGetresult.g.cs @@ -103,6 +103,7 @@ partial void ProcessGenaiText2videoGetresultResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: $"/genai/video/{inferenceId}", baseUri: HttpClient.BaseAddress); @@ -176,6 +177,8 @@ partial void ProcessGenaiText2videoGetresultResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -186,6 +189,11 @@ partial void ProcessGenaiText2videoGetresultResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -203,6 +211,8 @@ partial void ProcessGenaiText2videoGetresultResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -212,8 +222,7 @@ partial void ProcessGenaiText2videoGetresultResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -222,6 +231,11 @@ partial void ProcessGenaiText2videoGetresultResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -238,14 +252,15 @@ partial void ProcessGenaiText2videoGetresultResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -285,6 +300,8 @@ partial void ProcessGenaiText2videoGetresultResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -305,6 +322,8 @@ partial void ProcessGenaiText2videoGetresultResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -790,6 +809,7 @@ partial void ProcessGenaiText2videoGetresultResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -823,6 +843,7 @@ partial void ProcessGenaiText2videoGetresultResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.GenAIText2VideoImage2VideoClient.g.cs b/src/libs/Picsart/Generated/Picsart.GenAIText2VideoImage2VideoClient.g.cs index 4c5fa34..278e7c1 100644 --- a/src/libs/Picsart/Generated/Picsart.GenAIText2VideoImage2VideoClient.g.cs +++ b/src/libs/Picsart/Generated/Picsart.GenAIText2VideoImage2VideoClient.g.cs @@ -72,10 +72,10 @@ public GenAIText2VideoImage2VideoClient( /// Client-wide request defaults such as headers, query parameters, retries, and timeout. /// Dispose the HttpClient when the instance is disposed. True by default. public GenAIText2VideoImage2VideoClient( - global::System.Net.Http.HttpClient? httpClient = null, - global::System.Uri? baseUri = null, - global::System.Collections.Generic.List? authorizations = null, - global::Picsart.AutoSDKClientOptions? options = null, + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Picsart.AutoSDKClientOptions? options, bool disposeHttpClient = true) { diff --git a/src/libs/Picsart/Generated/Picsart.GenAIUtilitiesClient.GenaiCreditsBalance.g.cs b/src/libs/Picsart/Generated/Picsart.GenAIUtilitiesClient.GenaiCreditsBalance.g.cs index 0a3a373..cf74968 100644 --- a/src/libs/Picsart/Generated/Picsart.GenAIUtilitiesClient.GenaiCreditsBalance.g.cs +++ b/src/libs/Picsart/Generated/Picsart.GenAIUtilitiesClient.GenaiCreditsBalance.g.cs @@ -99,6 +99,7 @@ partial void ProcessGenaiCreditsBalanceResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/genai/balance", baseUri: HttpClient.BaseAddress); @@ -171,6 +172,8 @@ partial void ProcessGenaiCreditsBalanceResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -181,6 +184,11 @@ partial void ProcessGenaiCreditsBalanceResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -198,6 +206,8 @@ partial void ProcessGenaiCreditsBalanceResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -207,8 +217,7 @@ partial void ProcessGenaiCreditsBalanceResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -217,6 +226,11 @@ partial void ProcessGenaiCreditsBalanceResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -233,14 +247,15 @@ partial void ProcessGenaiCreditsBalanceResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -280,6 +295,8 @@ partial void ProcessGenaiCreditsBalanceResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -300,6 +317,8 @@ partial void ProcessGenaiCreditsBalanceResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -785,6 +804,7 @@ partial void ProcessGenaiCreditsBalanceResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -818,6 +838,7 @@ partial void ProcessGenaiCreditsBalanceResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.GenAIUtilitiesClient.g.cs b/src/libs/Picsart/Generated/Picsart.GenAIUtilitiesClient.g.cs index dc9c845..795e64a 100644 --- a/src/libs/Picsart/Generated/Picsart.GenAIUtilitiesClient.g.cs +++ b/src/libs/Picsart/Generated/Picsart.GenAIUtilitiesClient.g.cs @@ -72,10 +72,10 @@ public GenAIUtilitiesClient( /// Client-wide request defaults such as headers, query parameters, retries, and timeout. /// Dispose the HttpClient when the instance is disposed. True by default. public GenAIUtilitiesClient( - global::System.Net.Http.HttpClient? httpClient = null, - global::System.Uri? baseUri = null, - global::System.Collections.Generic.List? authorizations = null, - global::Picsart.AutoSDKClientOptions? options = null, + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Picsart.AutoSDKClientOptions? options, bool disposeHttpClient = true) { diff --git a/src/libs/Picsart/Generated/Picsart.IImageClassificationClient.ImageCarsClassifier.g.cs b/src/libs/Picsart/Generated/Picsart.IImageClassificationClient.ImageCarsClassifier.g.cs index 05f80a9..ac18bc7 100644 --- a/src/libs/Picsart/Generated/Picsart.IImageClassificationClient.ImageCarsClassifier.g.cs +++ b/src/libs/Picsart/Generated/Picsart.IImageClassificationClient.ImageCarsClassifier.g.cs @@ -57,5 +57,52 @@ public partial interface IImageClassificationClient string? imageUrl = default, global::Picsart.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); + + /// + /// Classify the Car Image
+ /// The car image *Classifier* service categorizes all provided images. The supported categories are exterior, interior, engine, undercarriage, other.
+ /// It is mandatory that the provided input image is a car image. If the image is not a car image, the service will not generate an error, and the result may not be relevant. + ///
+ /// + /// Source image file (binary). (If this parameter is present, the other image source parameters must be empty.) + /// + /// + /// Source image file (binary). (If this parameter is present, the other image source parameters must be empty.) + /// + /// + /// Source image URL. (If this parameter is present, the other image source parameters must be empty.) + /// + /// 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 ImageCarsClassifierAsync( + global::System.IO.Stream? image = default, + string? imagename = default, + string? imageUrl = default, + global::Picsart.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Classify the Car Image
+ /// The car image *Classifier* service categorizes all provided images. The supported categories are exterior, interior, engine, undercarriage, other.
+ /// It is mandatory that the provided input image is a car image. If the image is not a car image, the service will not generate an error, and the result may not be relevant. + ///
+ /// + /// Source image file (binary). (If this parameter is present, the other image source parameters must be empty.) + /// + /// + /// Source image file (binary). (If this parameter is present, the other image source parameters must be empty.) + /// + /// + /// Source image URL. (If this parameter is present, the other image source parameters must be empty.) + /// + /// 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> ImageCarsClassifierAsResponseAsync( + global::System.IO.Stream? image = default, + string? imagename = default, + string? imageUrl = default, + global::Picsart.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Picsart/Generated/Picsart.IImageClassificationClient.ImageDescriber.g.cs b/src/libs/Picsart/Generated/Picsart.IImageClassificationClient.ImageDescriber.g.cs index 4784af0..70e7522 100644 --- a/src/libs/Picsart/Generated/Picsart.IImageClassificationClient.ImageDescriber.g.cs +++ b/src/libs/Picsart/Generated/Picsart.IImageClassificationClient.ImageDescriber.g.cs @@ -54,5 +54,50 @@ public partial interface IImageClassificationClient string? imageUrl = default, global::Picsart.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); + + /// + /// Describe Image
+ /// The image *Describer* service helps generate a detailed text description for the provided image (image2text). + ///
+ /// + /// Source image file (binary). (If this parameter is present, the other image source parameters must be empty.) + /// + /// + /// Source image file (binary). (If this parameter is present, the other image source parameters must be empty.) + /// + /// + /// Source image URL. (If this parameter is present, the other image source parameters must be empty.) + /// + /// 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 ImageDescriberAsync( + global::System.IO.Stream? image = default, + string? imagename = default, + string? imageUrl = default, + global::Picsart.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Describe Image
+ /// The image *Describer* service helps generate a detailed text description for the provided image (image2text). + ///
+ /// + /// Source image file (binary). (If this parameter is present, the other image source parameters must be empty.) + /// + /// + /// Source image file (binary). (If this parameter is present, the other image source parameters must be empty.) + /// + /// + /// Source image URL. (If this parameter is present, the other image source parameters must be empty.) + /// + /// 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> ImageDescriberAsResponseAsync( + global::System.IO.Stream? image = default, + string? imagename = default, + string? imageUrl = default, + global::Picsart.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Picsart/Generated/Picsart.IImageClassificationClient.ImageExtractColors.g.cs b/src/libs/Picsart/Generated/Picsart.IImageClassificationClient.ImageExtractColors.g.cs index 42895f1..d933ae2 100644 --- a/src/libs/Picsart/Generated/Picsart.IImageClassificationClient.ImageExtractColors.g.cs +++ b/src/libs/Picsart/Generated/Picsart.IImageClassificationClient.ImageExtractColors.g.cs @@ -57,5 +57,52 @@ public partial interface IImageClassificationClient string? imageUrl = default, global::Picsart.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); + + /// + /// Extract Image Colors
+ /// Extract the key colors from an image to understand its visual style and palette.
+ /// The service analyzes an image and returns up to five prominent colors, including dominant foreground and background tones. + ///
+ /// + /// Source image file (binary). (If this parameter is present, the other image source parameters must be empty.) + /// + /// + /// Source image file (binary). (If this parameter is present, the other image source parameters must be empty.) + /// + /// + /// Source image URL. (If this parameter is present, the other image source parameters must be empty.) + /// + /// 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 ImageExtractColorsAsync( + global::System.IO.Stream? image = default, + string? imagename = default, + string? imageUrl = default, + global::Picsart.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Extract Image Colors
+ /// Extract the key colors from an image to understand its visual style and palette.
+ /// The service analyzes an image and returns up to five prominent colors, including dominant foreground and background tones. + ///
+ /// + /// Source image file (binary). (If this parameter is present, the other image source parameters must be empty.) + /// + /// + /// Source image file (binary). (If this parameter is present, the other image source parameters must be empty.) + /// + /// + /// Source image URL. (If this parameter is present, the other image source parameters must be empty.) + /// + /// 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> ImageExtractColorsAsResponseAsync( + global::System.IO.Stream? image = default, + string? imagename = default, + string? imageUrl = default, + global::Picsart.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Picsart/Generated/Picsart.IImageClassificationClient.ImageTagging.g.cs b/src/libs/Picsart/Generated/Picsart.IImageClassificationClient.ImageTagging.g.cs index c77022d..4f552f6 100644 --- a/src/libs/Picsart/Generated/Picsart.IImageClassificationClient.ImageTagging.g.cs +++ b/src/libs/Picsart/Generated/Picsart.IImageClassificationClient.ImageTagging.g.cs @@ -54,5 +54,50 @@ public partial interface IImageClassificationClient string? imageUrl = default, global::Picsart.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); + + /// + /// Image Tagging
+ /// This tagging service analyzes the image and suggests hashtags that are relevant to the content. + ///
+ /// + /// Source image file (binary). (If this parameter is present, the other image source parameters must be empty.) + /// + /// + /// Source image file (binary). (If this parameter is present, the other image source parameters must be empty.) + /// + /// + /// Source image URL. (If this parameter is present, the other image source parameters must be empty.) + /// + /// 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 ImageTaggingAsync( + global::System.IO.Stream? image = default, + string? imagename = default, + string? imageUrl = default, + global::Picsart.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Image Tagging
+ /// This tagging service analyzes the image and suggests hashtags that are relevant to the content. + ///
+ /// + /// Source image file (binary). (If this parameter is present, the other image source parameters must be empty.) + /// + /// + /// Source image file (binary). (If this parameter is present, the other image source parameters must be empty.) + /// + /// + /// Source image URL. (If this parameter is present, the other image source parameters must be empty.) + /// + /// 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> ImageTaggingAsResponseAsync( + global::System.IO.Stream? image = default, + string? imagename = default, + string? imageUrl = default, + global::Picsart.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Picsart/Generated/Picsart.IImageConversionClient.ImageDesignImport.g.cs b/src/libs/Picsart/Generated/Picsart.IImageConversionClient.ImageDesignImport.g.cs index 8cc668d..494bac7 100644 --- a/src/libs/Picsart/Generated/Picsart.IImageConversionClient.ImageDesignImport.g.cs +++ b/src/libs/Picsart/Generated/Picsart.IImageConversionClient.ImageDesignImport.g.cs @@ -67,5 +67,60 @@ public partial interface IImageConversionClient string? fileUrl = default, global::Picsart.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); + + /// + /// Design Import (beta)
+ /// With the *Design Import* tool you can instantly turn your design files (AI, SVG) into a Replay file (Picsart's proprietary project file format) that can be consumed by the [Photo and Video Editor SDK](https://docs.picsart.io/docs/photo-video-editor-overview).
+ ///
+ /// Use this to import your existing designs and make them resuable in Picsart.
+ /// **Suported Formats:** Examples of where the vectorizer can be used include:
+ /// * AI (Adobe Illustrator)
+ /// * SVG (Scalable Vector Graphics) + ///
+ /// + /// Source file (binary). (If this parameter is present, the other source parameters must be empty.) + /// + /// + /// Source file (binary). (If this parameter is present, the other source parameters must be empty.) + /// + /// + /// Source file URL. (If this parameter is present, the other source parameters must be empty.) + /// + /// 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 ImageDesignImportAsync( + global::System.IO.Stream? file = default, + string? filename = default, + string? fileUrl = default, + global::Picsart.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Design Import (beta)
+ /// With the *Design Import* tool you can instantly turn your design files (AI, SVG) into a Replay file (Picsart's proprietary project file format) that can be consumed by the [Photo and Video Editor SDK](https://docs.picsart.io/docs/photo-video-editor-overview).
+ ///
+ /// Use this to import your existing designs and make them resuable in Picsart.
+ /// **Suported Formats:** Examples of where the vectorizer can be used include:
+ /// * AI (Adobe Illustrator)
+ /// * SVG (Scalable Vector Graphics) + ///
+ /// + /// Source file (binary). (If this parameter is present, the other source parameters must be empty.) + /// + /// + /// Source file (binary). (If this parameter is present, the other source parameters must be empty.) + /// + /// + /// Source file URL. (If this parameter is present, the other source parameters must be empty.) + /// + /// 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> ImageDesignImportAsResponseAsync( + global::System.IO.Stream? file = default, + string? filename = default, + string? fileUrl = default, + global::Picsart.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Picsart/Generated/Picsart.IImageUtilitiesClient.ImageUpload.g.cs b/src/libs/Picsart/Generated/Picsart.IImageUtilitiesClient.ImageUpload.g.cs index 19a3612..53dda25 100644 --- a/src/libs/Picsart/Generated/Picsart.IImageUtilitiesClient.ImageUpload.g.cs +++ b/src/libs/Picsart/Generated/Picsart.IImageUtilitiesClient.ImageUpload.g.cs @@ -67,5 +67,60 @@ public partial interface IImageUtilitiesClient string? imageUrl = default, global::Picsart.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); + + /// + /// Upload Image
+ /// The *upload* service is used to upload an image when you want to apply several transformations to it.
+ /// By uploading an image first, you'll receive a transaction_id which you can use repeatedly for transformations and thereby avoid having to upload an image for each and every one.
+ /// If you're sure you only want to do a single transformation to an image, there's no benefit to using this service. Just jump right to that service.
+ /// **Limitations:** Supported source image formats are JPG, PNG, TIFF and WEBP.
+ /// **Source Image:**
+ /// You can source the image by providing a file or a URL to an online image. + ///
+ /// + /// Source image file (binary). (If this parameter is present, the other image source parameters must be empty.) + /// + /// + /// Source image file (binary). (If this parameter is present, the other image source parameters must be empty.) + /// + /// + /// Source image URL. (If this parameter is present, the other image source parameters must be empty.) + /// + /// 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 ImageUploadAsync( + global::System.IO.Stream? image = default, + string? imagename = default, + string? imageUrl = default, + global::Picsart.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Upload Image
+ /// The *upload* service is used to upload an image when you want to apply several transformations to it.
+ /// By uploading an image first, you'll receive a transaction_id which you can use repeatedly for transformations and thereby avoid having to upload an image for each and every one.
+ /// If you're sure you only want to do a single transformation to an image, there's no benefit to using this service. Just jump right to that service.
+ /// **Limitations:** Supported source image formats are JPG, PNG, TIFF and WEBP.
+ /// **Source Image:**
+ /// You can source the image by providing a file or a URL to an online image. + ///
+ /// + /// Source image file (binary). (If this parameter is present, the other image source parameters must be empty.) + /// + /// + /// Source image file (binary). (If this parameter is present, the other image source parameters must be empty.) + /// + /// + /// Source image URL. (If this parameter is present, the other image source parameters must be empty.) + /// + /// 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> ImageUploadAsResponseAsync( + global::System.IO.Stream? image = default, + string? imagename = default, + string? imageUrl = default, + global::Picsart.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Picsart/Generated/Picsart.IVdVariableDataContentClient.VdDescribeVariableDataContent.g.cs b/src/libs/Picsart/Generated/Picsart.IVdVariableDataContentClient.VdDescribeVariableDataContent.g.cs index f28bd5f..a04da94 100644 --- a/src/libs/Picsart/Generated/Picsart.IVdVariableDataContentClient.VdDescribeVariableDataContent.g.cs +++ b/src/libs/Picsart/Generated/Picsart.IVdVariableDataContentClient.VdDescribeVariableDataContent.g.cs @@ -56,5 +56,58 @@ public partial interface IVdVariableDataContentClient string? templateUrl = default, global::Picsart.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); + + /// + /// Describe Replay's Variable Data
+ /// Describes the Replay. Lists all variable data fields and their types: image, text, etc. + ///
+ /// + /// Source template ID from Picsart Inventory. (If this parameter is present, the other template source parameters must be empty.) + /// + /// + /// Source replay file (binary). (If this parameter is present, the other template source parameters must be empty.) + /// + /// + /// Source replay file (binary). (If this parameter is present, the other template source parameters must be empty.) + /// + /// + /// Source replay URL. (If this parameter is present, the other template source parameters must be empty.) + /// + /// 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 VdDescribeVariableDataContentAsync( + string? templateId = default, + global::System.IO.Stream? template = default, + string? templatename = default, + string? templateUrl = default, + global::Picsart.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Describe Replay's Variable Data
+ /// Describes the Replay. Lists all variable data fields and their types: image, text, etc. + ///
+ /// + /// Source template ID from Picsart Inventory. (If this parameter is present, the other template source parameters must be empty.) + /// + /// + /// Source replay file (binary). (If this parameter is present, the other template source parameters must be empty.) + /// + /// + /// Source replay file (binary). (If this parameter is present, the other template source parameters must be empty.) + /// + /// + /// Source replay URL. (If this parameter is present, the other template source parameters must be empty.) + /// + /// 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> VdDescribeVariableDataContentAsResponseAsync( + string? templateId = default, + global::System.IO.Stream? template = default, + string? templatename = default, + string? templateUrl = default, + global::Picsart.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Picsart/Generated/Picsart.IVideoUtilitiesClient.VideoUpload.g.cs b/src/libs/Picsart/Generated/Picsart.IVideoUtilitiesClient.VideoUpload.g.cs index 3d955c7..c13b07c 100644 --- a/src/libs/Picsart/Generated/Picsart.IVideoUtilitiesClient.VideoUpload.g.cs +++ b/src/libs/Picsart/Generated/Picsart.IVideoUtilitiesClient.VideoUpload.g.cs @@ -48,5 +48,42 @@ public partial interface IVideoUtilitiesClient string? filename = default, global::Picsart.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); + + /// + /// Upload files
+ /// Upload resources such as videos, audios or images. The provided URL can be passed as inputs to video operation. + ///
+ /// + /// Source file (binary). + /// + /// + /// Source file (binary). + /// + /// 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 VideoUploadAsync( + global::System.IO.Stream? file = default, + string? filename = default, + global::Picsart.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Upload files
+ /// Upload resources such as videos, audios or images. The provided URL can be passed as inputs to video operation. + ///
+ /// + /// Source file (binary). + /// + /// + /// Source file (binary). + /// + /// 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> VideoUploadAsResponseAsync( + global::System.IO.Stream? file = default, + string? filename = default, + global::Picsart.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Picsart/Generated/Picsart.ImageClassificationClient.ImageCarsClassifier.g.cs b/src/libs/Picsart/Generated/Picsart.ImageClassificationClient.ImageCarsClassifier.g.cs index 1488b35..ad426ef 100644 --- a/src/libs/Picsart/Generated/Picsart.ImageClassificationClient.ImageCarsClassifier.g.cs +++ b/src/libs/Picsart/Generated/Picsart.ImageClassificationClient.ImageCarsClassifier.g.cs @@ -108,10 +108,11 @@ partial void ProcessImageCarsClassifierResponseContent( var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/image/cars/classify", baseUri: HttpClient.BaseAddress); @@ -144,6 +145,7 @@ partial void ProcessImageCarsClassifierResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); if (request.Image != default) { @@ -185,22 +187,27 @@ request.Imagename is null { __contentImage.Headers.ContentDisposition.FileNameStar = null; } - } + + } if (request.ImageUrl != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.ImageUrl ?? string.Empty), name: "\"image_url\""); - } + + } if (request.ImageId != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.ImageId ?? string.Empty), name: "\"image_id\""); + } + __httpRequest.Content = __httpRequestContent; + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -242,6 +249,8 @@ request.Imagename is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -252,6 +261,11 @@ request.Imagename is null } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -269,6 +283,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) { @@ -278,8 +294,7 @@ request.Imagename is null __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -288,6 +303,11 @@ request.Imagename is null __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -304,14 +324,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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -351,6 +372,8 @@ request.Imagename is null attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -371,6 +394,8 @@ request.Imagename is null attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -894,6 +919,7 @@ request.Imagename is null return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -927,6 +953,7 @@ request.Imagename is null return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -1001,5 +1028,1876 @@ request.Imagename is null requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } + + /// + /// Classify the Car Image
+ /// The car image *Classifier* service categorizes all provided images. The supported categories are exterior, interior, engine, undercarriage, other.
+ /// It is mandatory that the provided input image is a car image. If the image is not a car image, the service will not generate an error, and the result may not be relevant. + ///
+ /// + /// Source image file (binary). (If this parameter is present, the other image source parameters must be empty.) + /// + /// + /// Source image file (binary). (If this parameter is present, the other image source parameters must be empty.) + /// + /// + /// Source image URL. (If this parameter is present, the other image source parameters must be empty.) + /// + /// 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 ImageCarsClassifierAsync( + global::System.IO.Stream? image = default, + string? imagename = default, + string? imageUrl = default, + global::Picsart.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + var request = new global::Picsart.ImageImageParameters + { + Image = global::System.Array.Empty(), + Imagename = imagename, + ImageUrl = imageUrl, + }; + PrepareArguments( + client: HttpClient); + PrepareImageCarsClassifierArguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::Picsart.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_ImageCarsClassifierSecurityRequirements, + operationName: "ImageCarsClassifierAsync"); + + using var __timeoutCancellationTokenSource = global::Picsart.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Picsart.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Picsart.PathBuilder( + path: "/image/cars/classify", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Picsart.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 (image != default) + { + + 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.ImageUrl != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.ImageUrl ?? string.Empty), + name: "\"image_url\""); + + } + if (request.ImageId != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.ImageId ?? string.Empty), + name: "\"image_id\""); + + } + + __httpRequest.Content = __httpRequestContent; + + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareImageCarsClassifierRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + 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::Picsart.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageCarsClassifier", + methodName: "ImageCarsClassifierAsync", + pathTemplate: "\"/image/cars/classify\"", + 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::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageCarsClassifier", + methodName: "ImageCarsClassifierAsync", + pathTemplate: "\"/image/cars/classify\"", + 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageCarsClassifier", + methodName: "ImageCarsClassifierAsync", + pathTemplate: "\"/image/cars/classify\"", + 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::Picsart.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); + ProcessImageCarsClassifierResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageCarsClassifier", + methodName: "ImageCarsClassifierAsync", + pathTemplate: "\"/image/cars/classify\"", + 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::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageCarsClassifier", + methodName: "ImageCarsClassifierAsync", + pathTemplate: "\"/image/cars/classify\"", + 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); + } + // Bad Request + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + global::Picsart.ImageError? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = global::Picsart.ImageError.FromJson(__content_400, JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_400 = global::Picsart.ImageError.FromJson(__content_400, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseObject = __value_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unauthorized + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + global::Picsart.Image401Error? __value_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_401 = global::Picsart.Image401Error.FromJson(__content_401, JsonSerializerContext); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_401 = global::Picsart.Image401Error.FromJson(__content_401, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseObject = __value_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Payment Required + if ((int)__response.StatusCode == 402) + { + string? __content_402 = null; + global::System.Exception? __exception_402 = null; + global::Picsart.ImageError? __value_402 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_402 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_402 = global::Picsart.ImageError.FromJson(__content_402, JsonSerializerContext); + } + else + { + __content_402 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_402 = global::Picsart.ImageError.FromJson(__content_402, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_402 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_402 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_402, + statusCode: __response.StatusCode) + { + ResponseBody = __content_402, + ResponseObject = __value_402, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Forbidden + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + global::Picsart.ImageError? __value_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_403 = global::Picsart.ImageError.FromJson(__content_403, JsonSerializerContext); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_403 = global::Picsart.ImageError.FromJson(__content_403, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + statusCode: __response.StatusCode) + { + ResponseBody = __content_403, + ResponseObject = __value_403, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Not Found + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + global::Picsart.ImageError? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = global::Picsart.ImageError.FromJson(__content_404, JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_404 = global::Picsart.ImageError.FromJson(__content_404, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + statusCode: __response.StatusCode) + { + ResponseBody = __content_404, + ResponseObject = __value_404, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Method Not Allowed + if ((int)__response.StatusCode == 405) + { + string? __content_405 = null; + global::System.Exception? __exception_405 = null; + global::Picsart.ImageError? __value_405 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_405 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_405 = global::Picsart.ImageError.FromJson(__content_405, JsonSerializerContext); + } + else + { + __content_405 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_405 = global::Picsart.ImageError.FromJson(__content_405, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_405 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_405 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_405, + statusCode: __response.StatusCode) + { + ResponseBody = __content_405, + ResponseObject = __value_405, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Request Entity Too Large + if ((int)__response.StatusCode == 413) + { + string? __content_413 = null; + global::System.Exception? __exception_413 = null; + global::Picsart.ImageError? __value_413 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_413 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_413 = global::Picsart.ImageError.FromJson(__content_413, JsonSerializerContext); + } + else + { + __content_413 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_413 = global::Picsart.ImageError.FromJson(__content_413, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_413 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_413 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_413, + statusCode: __response.StatusCode) + { + ResponseBody = __content_413, + ResponseObject = __value_413, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unsupported Media Type + if ((int)__response.StatusCode == 415) + { + string? __content_415 = null; + global::System.Exception? __exception_415 = null; + global::Picsart.ImageError? __value_415 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_415 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_415 = global::Picsart.ImageError.FromJson(__content_415, JsonSerializerContext); + } + else + { + __content_415 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_415 = global::Picsart.ImageError.FromJson(__content_415, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_415 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_415 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_415, + statusCode: __response.StatusCode) + { + ResponseBody = __content_415, + ResponseObject = __value_415, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unprocessable Entity + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Picsart.ImageError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Picsart.ImageError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_422 = global::Picsart.ImageError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Too Many Requests + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + global::Picsart.ImageError? __value_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_429 = global::Picsart.ImageError.FromJson(__content_429, JsonSerializerContext); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_429 = global::Picsart.ImageError.FromJson(__content_429, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + statusCode: __response.StatusCode) + { + ResponseBody = __content_429, + ResponseObject = __value_429, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Request Header Fields Too Large + if ((int)__response.StatusCode == 431) + { + string? __content_431 = null; + global::System.Exception? __exception_431 = null; + global::Picsart.ImageError? __value_431 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_431 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_431 = global::Picsart.ImageError.FromJson(__content_431, JsonSerializerContext); + } + else + { + __content_431 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_431 = global::Picsart.ImageError.FromJson(__content_431, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_431 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_431 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_431, + statusCode: __response.StatusCode) + { + ResponseBody = __content_431, + ResponseObject = __value_431, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Internal Server Error + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + global::Picsart.ImageError? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = global::Picsart.ImageError.FromJson(__content_500, JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_500 = global::Picsart.ImageError.FromJson(__content_500, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Service Unavailable + if ((int)__response.StatusCode == 503) + { + string? __content_503 = null; + global::System.Exception? __exception_503 = null; + global::Picsart.ImageError? __value_503 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_503 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_503 = global::Picsart.ImageError.FromJson(__content_503, JsonSerializerContext); + } + else + { + __content_503 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_503 = global::Picsart.ImageError.FromJson(__content_503, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_503 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_503 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_503, + statusCode: __response.StatusCode) + { + ResponseBody = __content_503, + ResponseObject = __value_503, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessImageCarsClassifierResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Picsart.ImageCarsClassifierResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Picsart.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::Picsart.ImageCarsClassifierResponse.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::Picsart.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(); + } + } + /// + /// Classify the Car Image
+ /// The car image *Classifier* service categorizes all provided images. The supported categories are exterior, interior, engine, undercarriage, other.
+ /// It is mandatory that the provided input image is a car image. If the image is not a car image, the service will not generate an error, and the result may not be relevant. + ///
+ /// + /// Source image file (binary). (If this parameter is present, the other image source parameters must be empty.) + /// + /// + /// Source image file (binary). (If this parameter is present, the other image source parameters must be empty.) + /// + /// + /// Source image URL. (If this parameter is present, the other image source parameters must be empty.) + /// + /// 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> ImageCarsClassifierAsResponseAsync( + global::System.IO.Stream? image = default, + string? imagename = default, + string? imageUrl = default, + global::Picsart.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + var request = new global::Picsart.ImageImageParameters + { + Image = global::System.Array.Empty(), + Imagename = imagename, + ImageUrl = imageUrl, + }; + PrepareArguments( + client: HttpClient); + PrepareImageCarsClassifierArguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::Picsart.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_ImageCarsClassifierSecurityRequirements, + operationName: "ImageCarsClassifierAsync"); + + using var __timeoutCancellationTokenSource = global::Picsart.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Picsart.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Picsart.PathBuilder( + path: "/image/cars/classify", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Picsart.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 (image != default) + { + + 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.ImageUrl != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.ImageUrl ?? string.Empty), + name: "\"image_url\""); + + } + if (request.ImageId != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.ImageId ?? string.Empty), + name: "\"image_id\""); + + } + + __httpRequest.Content = __httpRequestContent; + + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareImageCarsClassifierRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + 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::Picsart.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageCarsClassifier", + methodName: "ImageCarsClassifierAsync", + pathTemplate: "\"/image/cars/classify\"", + 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::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageCarsClassifier", + methodName: "ImageCarsClassifierAsync", + pathTemplate: "\"/image/cars/classify\"", + 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageCarsClassifier", + methodName: "ImageCarsClassifierAsync", + pathTemplate: "\"/image/cars/classify\"", + 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::Picsart.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); + ProcessImageCarsClassifierResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageCarsClassifier", + methodName: "ImageCarsClassifierAsync", + pathTemplate: "\"/image/cars/classify\"", + 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::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageCarsClassifier", + methodName: "ImageCarsClassifierAsync", + pathTemplate: "\"/image/cars/classify\"", + 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); + } + // Bad Request + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + global::Picsart.ImageError? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = global::Picsart.ImageError.FromJson(__content_400, JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_400 = global::Picsart.ImageError.FromJson(__content_400, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseObject = __value_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unauthorized + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + global::Picsart.Image401Error? __value_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_401 = global::Picsart.Image401Error.FromJson(__content_401, JsonSerializerContext); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_401 = global::Picsart.Image401Error.FromJson(__content_401, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseObject = __value_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Payment Required + if ((int)__response.StatusCode == 402) + { + string? __content_402 = null; + global::System.Exception? __exception_402 = null; + global::Picsart.ImageError? __value_402 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_402 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_402 = global::Picsart.ImageError.FromJson(__content_402, JsonSerializerContext); + } + else + { + __content_402 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_402 = global::Picsart.ImageError.FromJson(__content_402, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_402 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_402 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_402, + statusCode: __response.StatusCode) + { + ResponseBody = __content_402, + ResponseObject = __value_402, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Forbidden + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + global::Picsart.ImageError? __value_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_403 = global::Picsart.ImageError.FromJson(__content_403, JsonSerializerContext); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_403 = global::Picsart.ImageError.FromJson(__content_403, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + statusCode: __response.StatusCode) + { + ResponseBody = __content_403, + ResponseObject = __value_403, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Not Found + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + global::Picsart.ImageError? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = global::Picsart.ImageError.FromJson(__content_404, JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_404 = global::Picsart.ImageError.FromJson(__content_404, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + statusCode: __response.StatusCode) + { + ResponseBody = __content_404, + ResponseObject = __value_404, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Method Not Allowed + if ((int)__response.StatusCode == 405) + { + string? __content_405 = null; + global::System.Exception? __exception_405 = null; + global::Picsart.ImageError? __value_405 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_405 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_405 = global::Picsart.ImageError.FromJson(__content_405, JsonSerializerContext); + } + else + { + __content_405 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_405 = global::Picsart.ImageError.FromJson(__content_405, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_405 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_405 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_405, + statusCode: __response.StatusCode) + { + ResponseBody = __content_405, + ResponseObject = __value_405, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Request Entity Too Large + if ((int)__response.StatusCode == 413) + { + string? __content_413 = null; + global::System.Exception? __exception_413 = null; + global::Picsart.ImageError? __value_413 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_413 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_413 = global::Picsart.ImageError.FromJson(__content_413, JsonSerializerContext); + } + else + { + __content_413 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_413 = global::Picsart.ImageError.FromJson(__content_413, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_413 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_413 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_413, + statusCode: __response.StatusCode) + { + ResponseBody = __content_413, + ResponseObject = __value_413, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unsupported Media Type + if ((int)__response.StatusCode == 415) + { + string? __content_415 = null; + global::System.Exception? __exception_415 = null; + global::Picsart.ImageError? __value_415 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_415 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_415 = global::Picsart.ImageError.FromJson(__content_415, JsonSerializerContext); + } + else + { + __content_415 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_415 = global::Picsart.ImageError.FromJson(__content_415, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_415 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_415 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_415, + statusCode: __response.StatusCode) + { + ResponseBody = __content_415, + ResponseObject = __value_415, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unprocessable Entity + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Picsart.ImageError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Picsart.ImageError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_422 = global::Picsart.ImageError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Too Many Requests + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + global::Picsart.ImageError? __value_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_429 = global::Picsart.ImageError.FromJson(__content_429, JsonSerializerContext); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_429 = global::Picsart.ImageError.FromJson(__content_429, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + statusCode: __response.StatusCode) + { + ResponseBody = __content_429, + ResponseObject = __value_429, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Request Header Fields Too Large + if ((int)__response.StatusCode == 431) + { + string? __content_431 = null; + global::System.Exception? __exception_431 = null; + global::Picsart.ImageError? __value_431 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_431 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_431 = global::Picsart.ImageError.FromJson(__content_431, JsonSerializerContext); + } + else + { + __content_431 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_431 = global::Picsart.ImageError.FromJson(__content_431, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_431 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_431 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_431, + statusCode: __response.StatusCode) + { + ResponseBody = __content_431, + ResponseObject = __value_431, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Internal Server Error + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + global::Picsart.ImageError? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = global::Picsart.ImageError.FromJson(__content_500, JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_500 = global::Picsart.ImageError.FromJson(__content_500, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Service Unavailable + if ((int)__response.StatusCode == 503) + { + string? __content_503 = null; + global::System.Exception? __exception_503 = null; + global::Picsart.ImageError? __value_503 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_503 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_503 = global::Picsart.ImageError.FromJson(__content_503, JsonSerializerContext); + } + else + { + __content_503 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_503 = global::Picsart.ImageError.FromJson(__content_503, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_503 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_503 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_503, + statusCode: __response.StatusCode) + { + ResponseBody = __content_503, + ResponseObject = __value_503, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessImageCarsClassifierResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Picsart.ImageCarsClassifierResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Picsart.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Picsart.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::Picsart.ImageCarsClassifierResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Picsart.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Picsart.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::Picsart.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/Picsart/Generated/Picsart.ImageClassificationClient.ImageDescriber.g.cs b/src/libs/Picsart/Generated/Picsart.ImageClassificationClient.ImageDescriber.g.cs index 6c67635..9b41a6c 100644 --- a/src/libs/Picsart/Generated/Picsart.ImageClassificationClient.ImageDescriber.g.cs +++ b/src/libs/Picsart/Generated/Picsart.ImageClassificationClient.ImageDescriber.g.cs @@ -106,10 +106,11 @@ partial void ProcessImageDescriberResponseContent( var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/image/describe", baseUri: HttpClient.BaseAddress); @@ -142,6 +143,7 @@ partial void ProcessImageDescriberResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); if (request.Image != default) { @@ -183,22 +185,27 @@ request.Imagename is null { __contentImage.Headers.ContentDisposition.FileNameStar = null; } - } + + } if (request.ImageUrl != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.ImageUrl ?? string.Empty), name: "\"image_url\""); - } + + } if (request.ImageId != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.ImageId ?? string.Empty), name: "\"image_id\""); + } + __httpRequest.Content = __httpRequestContent; + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -240,6 +247,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 +259,11 @@ request.Imagename is null } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -267,6 +281,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 +292,7 @@ request.Imagename is null __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -286,6 +301,11 @@ request.Imagename is null __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -302,14 +322,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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -349,6 +370,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 +392,8 @@ request.Imagename is null attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -892,6 +917,7 @@ request.Imagename is null return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -925,6 +951,7 @@ request.Imagename is null return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -998,5 +1025,1874 @@ request.Imagename is null requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } + + /// + /// Describe Image
+ /// The image *Describer* service helps generate a detailed text description for the provided image (image2text). + ///
+ /// + /// Source image file (binary). (If this parameter is present, the other image source parameters must be empty.) + /// + /// + /// Source image file (binary). (If this parameter is present, the other image source parameters must be empty.) + /// + /// + /// Source image URL. (If this parameter is present, the other image source parameters must be empty.) + /// + /// 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 ImageDescriberAsync( + global::System.IO.Stream? image = default, + string? imagename = default, + string? imageUrl = default, + global::Picsart.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + var request = new global::Picsart.ImageImageParameters + { + Image = global::System.Array.Empty(), + Imagename = imagename, + ImageUrl = imageUrl, + }; + PrepareArguments( + client: HttpClient); + PrepareImageDescriberArguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::Picsart.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_ImageDescriberSecurityRequirements, + operationName: "ImageDescriberAsync"); + + using var __timeoutCancellationTokenSource = global::Picsart.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Picsart.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Picsart.PathBuilder( + path: "/image/describe", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Picsart.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 (image != default) + { + + 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.ImageUrl != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.ImageUrl ?? string.Empty), + name: "\"image_url\""); + + } + if (request.ImageId != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.ImageId ?? string.Empty), + name: "\"image_id\""); + + } + + __httpRequest.Content = __httpRequestContent; + + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareImageDescriberRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + 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::Picsart.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageDescriber", + methodName: "ImageDescriberAsync", + pathTemplate: "\"/image/describe\"", + 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::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageDescriber", + methodName: "ImageDescriberAsync", + pathTemplate: "\"/image/describe\"", + 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageDescriber", + methodName: "ImageDescriberAsync", + pathTemplate: "\"/image/describe\"", + 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::Picsart.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); + ProcessImageDescriberResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageDescriber", + methodName: "ImageDescriberAsync", + pathTemplate: "\"/image/describe\"", + 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::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageDescriber", + methodName: "ImageDescriberAsync", + pathTemplate: "\"/image/describe\"", + 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); + } + // Bad Request + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + global::Picsart.ImageError? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = global::Picsart.ImageError.FromJson(__content_400, JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_400 = global::Picsart.ImageError.FromJson(__content_400, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseObject = __value_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unauthorized + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + global::Picsart.Image401Error? __value_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_401 = global::Picsart.Image401Error.FromJson(__content_401, JsonSerializerContext); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_401 = global::Picsart.Image401Error.FromJson(__content_401, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseObject = __value_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Payment Required + if ((int)__response.StatusCode == 402) + { + string? __content_402 = null; + global::System.Exception? __exception_402 = null; + global::Picsart.ImageError? __value_402 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_402 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_402 = global::Picsart.ImageError.FromJson(__content_402, JsonSerializerContext); + } + else + { + __content_402 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_402 = global::Picsart.ImageError.FromJson(__content_402, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_402 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_402 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_402, + statusCode: __response.StatusCode) + { + ResponseBody = __content_402, + ResponseObject = __value_402, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Forbidden + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + global::Picsart.ImageError? __value_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_403 = global::Picsart.ImageError.FromJson(__content_403, JsonSerializerContext); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_403 = global::Picsart.ImageError.FromJson(__content_403, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + statusCode: __response.StatusCode) + { + ResponseBody = __content_403, + ResponseObject = __value_403, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Not Found + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + global::Picsart.ImageError? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = global::Picsart.ImageError.FromJson(__content_404, JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_404 = global::Picsart.ImageError.FromJson(__content_404, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + statusCode: __response.StatusCode) + { + ResponseBody = __content_404, + ResponseObject = __value_404, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Method Not Allowed + if ((int)__response.StatusCode == 405) + { + string? __content_405 = null; + global::System.Exception? __exception_405 = null; + global::Picsart.ImageError? __value_405 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_405 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_405 = global::Picsart.ImageError.FromJson(__content_405, JsonSerializerContext); + } + else + { + __content_405 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_405 = global::Picsart.ImageError.FromJson(__content_405, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_405 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_405 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_405, + statusCode: __response.StatusCode) + { + ResponseBody = __content_405, + ResponseObject = __value_405, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Request Entity Too Large + if ((int)__response.StatusCode == 413) + { + string? __content_413 = null; + global::System.Exception? __exception_413 = null; + global::Picsart.ImageError? __value_413 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_413 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_413 = global::Picsart.ImageError.FromJson(__content_413, JsonSerializerContext); + } + else + { + __content_413 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_413 = global::Picsart.ImageError.FromJson(__content_413, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_413 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_413 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_413, + statusCode: __response.StatusCode) + { + ResponseBody = __content_413, + ResponseObject = __value_413, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unsupported Media Type + if ((int)__response.StatusCode == 415) + { + string? __content_415 = null; + global::System.Exception? __exception_415 = null; + global::Picsart.ImageError? __value_415 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_415 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_415 = global::Picsart.ImageError.FromJson(__content_415, JsonSerializerContext); + } + else + { + __content_415 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_415 = global::Picsart.ImageError.FromJson(__content_415, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_415 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_415 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_415, + statusCode: __response.StatusCode) + { + ResponseBody = __content_415, + ResponseObject = __value_415, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unprocessable Entity + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Picsart.ImageError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Picsart.ImageError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_422 = global::Picsart.ImageError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Too Many Requests + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + global::Picsart.ImageError? __value_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_429 = global::Picsart.ImageError.FromJson(__content_429, JsonSerializerContext); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_429 = global::Picsart.ImageError.FromJson(__content_429, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + statusCode: __response.StatusCode) + { + ResponseBody = __content_429, + ResponseObject = __value_429, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Request Header Fields Too Large + if ((int)__response.StatusCode == 431) + { + string? __content_431 = null; + global::System.Exception? __exception_431 = null; + global::Picsart.ImageError? __value_431 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_431 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_431 = global::Picsart.ImageError.FromJson(__content_431, JsonSerializerContext); + } + else + { + __content_431 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_431 = global::Picsart.ImageError.FromJson(__content_431, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_431 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_431 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_431, + statusCode: __response.StatusCode) + { + ResponseBody = __content_431, + ResponseObject = __value_431, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Internal Server Error + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + global::Picsart.ImageError? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = global::Picsart.ImageError.FromJson(__content_500, JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_500 = global::Picsart.ImageError.FromJson(__content_500, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Service Unavailable + if ((int)__response.StatusCode == 503) + { + string? __content_503 = null; + global::System.Exception? __exception_503 = null; + global::Picsart.ImageError? __value_503 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_503 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_503 = global::Picsart.ImageError.FromJson(__content_503, JsonSerializerContext); + } + else + { + __content_503 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_503 = global::Picsart.ImageError.FromJson(__content_503, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_503 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_503 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_503, + statusCode: __response.StatusCode) + { + ResponseBody = __content_503, + ResponseObject = __value_503, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessImageDescriberResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Picsart.ImageDescriberResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Picsart.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::Picsart.ImageDescriberResponse.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::Picsart.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(); + } + } + /// + /// Describe Image
+ /// The image *Describer* service helps generate a detailed text description for the provided image (image2text). + ///
+ /// + /// Source image file (binary). (If this parameter is present, the other image source parameters must be empty.) + /// + /// + /// Source image file (binary). (If this parameter is present, the other image source parameters must be empty.) + /// + /// + /// Source image URL. (If this parameter is present, the other image source parameters must be empty.) + /// + /// 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> ImageDescriberAsResponseAsync( + global::System.IO.Stream? image = default, + string? imagename = default, + string? imageUrl = default, + global::Picsart.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + var request = new global::Picsart.ImageImageParameters + { + Image = global::System.Array.Empty(), + Imagename = imagename, + ImageUrl = imageUrl, + }; + PrepareArguments( + client: HttpClient); + PrepareImageDescriberArguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::Picsart.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_ImageDescriberSecurityRequirements, + operationName: "ImageDescriberAsync"); + + using var __timeoutCancellationTokenSource = global::Picsart.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Picsart.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Picsart.PathBuilder( + path: "/image/describe", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Picsart.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 (image != default) + { + + 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.ImageUrl != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.ImageUrl ?? string.Empty), + name: "\"image_url\""); + + } + if (request.ImageId != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.ImageId ?? string.Empty), + name: "\"image_id\""); + + } + + __httpRequest.Content = __httpRequestContent; + + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareImageDescriberRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + 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::Picsart.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageDescriber", + methodName: "ImageDescriberAsync", + pathTemplate: "\"/image/describe\"", + 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::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageDescriber", + methodName: "ImageDescriberAsync", + pathTemplate: "\"/image/describe\"", + 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageDescriber", + methodName: "ImageDescriberAsync", + pathTemplate: "\"/image/describe\"", + 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::Picsart.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); + ProcessImageDescriberResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageDescriber", + methodName: "ImageDescriberAsync", + pathTemplate: "\"/image/describe\"", + 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::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageDescriber", + methodName: "ImageDescriberAsync", + pathTemplate: "\"/image/describe\"", + 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); + } + // Bad Request + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + global::Picsart.ImageError? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = global::Picsart.ImageError.FromJson(__content_400, JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_400 = global::Picsart.ImageError.FromJson(__content_400, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseObject = __value_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unauthorized + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + global::Picsart.Image401Error? __value_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_401 = global::Picsart.Image401Error.FromJson(__content_401, JsonSerializerContext); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_401 = global::Picsart.Image401Error.FromJson(__content_401, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseObject = __value_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Payment Required + if ((int)__response.StatusCode == 402) + { + string? __content_402 = null; + global::System.Exception? __exception_402 = null; + global::Picsart.ImageError? __value_402 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_402 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_402 = global::Picsart.ImageError.FromJson(__content_402, JsonSerializerContext); + } + else + { + __content_402 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_402 = global::Picsart.ImageError.FromJson(__content_402, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_402 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_402 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_402, + statusCode: __response.StatusCode) + { + ResponseBody = __content_402, + ResponseObject = __value_402, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Forbidden + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + global::Picsart.ImageError? __value_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_403 = global::Picsart.ImageError.FromJson(__content_403, JsonSerializerContext); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_403 = global::Picsart.ImageError.FromJson(__content_403, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + statusCode: __response.StatusCode) + { + ResponseBody = __content_403, + ResponseObject = __value_403, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Not Found + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + global::Picsart.ImageError? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = global::Picsart.ImageError.FromJson(__content_404, JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_404 = global::Picsart.ImageError.FromJson(__content_404, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + statusCode: __response.StatusCode) + { + ResponseBody = __content_404, + ResponseObject = __value_404, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Method Not Allowed + if ((int)__response.StatusCode == 405) + { + string? __content_405 = null; + global::System.Exception? __exception_405 = null; + global::Picsart.ImageError? __value_405 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_405 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_405 = global::Picsart.ImageError.FromJson(__content_405, JsonSerializerContext); + } + else + { + __content_405 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_405 = global::Picsart.ImageError.FromJson(__content_405, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_405 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_405 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_405, + statusCode: __response.StatusCode) + { + ResponseBody = __content_405, + ResponseObject = __value_405, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Request Entity Too Large + if ((int)__response.StatusCode == 413) + { + string? __content_413 = null; + global::System.Exception? __exception_413 = null; + global::Picsart.ImageError? __value_413 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_413 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_413 = global::Picsart.ImageError.FromJson(__content_413, JsonSerializerContext); + } + else + { + __content_413 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_413 = global::Picsart.ImageError.FromJson(__content_413, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_413 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_413 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_413, + statusCode: __response.StatusCode) + { + ResponseBody = __content_413, + ResponseObject = __value_413, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unsupported Media Type + if ((int)__response.StatusCode == 415) + { + string? __content_415 = null; + global::System.Exception? __exception_415 = null; + global::Picsart.ImageError? __value_415 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_415 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_415 = global::Picsart.ImageError.FromJson(__content_415, JsonSerializerContext); + } + else + { + __content_415 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_415 = global::Picsart.ImageError.FromJson(__content_415, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_415 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_415 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_415, + statusCode: __response.StatusCode) + { + ResponseBody = __content_415, + ResponseObject = __value_415, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unprocessable Entity + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Picsart.ImageError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Picsart.ImageError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_422 = global::Picsart.ImageError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Too Many Requests + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + global::Picsart.ImageError? __value_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_429 = global::Picsart.ImageError.FromJson(__content_429, JsonSerializerContext); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_429 = global::Picsart.ImageError.FromJson(__content_429, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + statusCode: __response.StatusCode) + { + ResponseBody = __content_429, + ResponseObject = __value_429, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Request Header Fields Too Large + if ((int)__response.StatusCode == 431) + { + string? __content_431 = null; + global::System.Exception? __exception_431 = null; + global::Picsart.ImageError? __value_431 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_431 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_431 = global::Picsart.ImageError.FromJson(__content_431, JsonSerializerContext); + } + else + { + __content_431 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_431 = global::Picsart.ImageError.FromJson(__content_431, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_431 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_431 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_431, + statusCode: __response.StatusCode) + { + ResponseBody = __content_431, + ResponseObject = __value_431, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Internal Server Error + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + global::Picsart.ImageError? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = global::Picsart.ImageError.FromJson(__content_500, JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_500 = global::Picsart.ImageError.FromJson(__content_500, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Service Unavailable + if ((int)__response.StatusCode == 503) + { + string? __content_503 = null; + global::System.Exception? __exception_503 = null; + global::Picsart.ImageError? __value_503 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_503 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_503 = global::Picsart.ImageError.FromJson(__content_503, JsonSerializerContext); + } + else + { + __content_503 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_503 = global::Picsart.ImageError.FromJson(__content_503, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_503 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_503 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_503, + statusCode: __response.StatusCode) + { + ResponseBody = __content_503, + ResponseObject = __value_503, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessImageDescriberResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Picsart.ImageDescriberResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Picsart.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Picsart.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::Picsart.ImageDescriberResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Picsart.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Picsart.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::Picsart.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/Picsart/Generated/Picsart.ImageClassificationClient.ImageExtractColors.g.cs b/src/libs/Picsart/Generated/Picsart.ImageClassificationClient.ImageExtractColors.g.cs index eba48ec..d8cdf09 100644 --- a/src/libs/Picsart/Generated/Picsart.ImageClassificationClient.ImageExtractColors.g.cs +++ b/src/libs/Picsart/Generated/Picsart.ImageClassificationClient.ImageExtractColors.g.cs @@ -108,10 +108,11 @@ partial void ProcessImageExtractColorsResponseContent( var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/image/extract-colors", baseUri: HttpClient.BaseAddress); @@ -144,6 +145,7 @@ partial void ProcessImageExtractColorsResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); if (request.Image != default) { @@ -185,22 +187,27 @@ request.Imagename is null { __contentImage.Headers.ContentDisposition.FileNameStar = null; } - } + + } if (request.ImageUrl != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.ImageUrl ?? string.Empty), name: "\"image_url\""); - } + + } if (request.ImageId != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.ImageId ?? string.Empty), name: "\"image_id\""); + } + __httpRequest.Content = __httpRequestContent; + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -242,6 +249,8 @@ request.Imagename is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -252,6 +261,11 @@ request.Imagename is null } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -269,6 +283,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) { @@ -278,8 +294,7 @@ request.Imagename is null __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -288,6 +303,11 @@ request.Imagename is null __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -304,14 +324,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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -351,6 +372,8 @@ request.Imagename is null attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -371,6 +394,8 @@ request.Imagename is null attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -894,6 +919,7 @@ request.Imagename is null return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -927,6 +953,7 @@ request.Imagename is null return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -1001,5 +1028,1876 @@ request.Imagename is null requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } + + /// + /// Extract Image Colors
+ /// Extract the key colors from an image to understand its visual style and palette.
+ /// The service analyzes an image and returns up to five prominent colors, including dominant foreground and background tones. + ///
+ /// + /// Source image file (binary). (If this parameter is present, the other image source parameters must be empty.) + /// + /// + /// Source image file (binary). (If this parameter is present, the other image source parameters must be empty.) + /// + /// + /// Source image URL. (If this parameter is present, the other image source parameters must be empty.) + /// + /// 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 ImageExtractColorsAsync( + global::System.IO.Stream? image = default, + string? imagename = default, + string? imageUrl = default, + global::Picsart.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + var request = new global::Picsart.ImageImageParameters + { + Image = global::System.Array.Empty(), + Imagename = imagename, + ImageUrl = imageUrl, + }; + PrepareArguments( + client: HttpClient); + PrepareImageExtractColorsArguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::Picsart.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_ImageExtractColorsSecurityRequirements, + operationName: "ImageExtractColorsAsync"); + + using var __timeoutCancellationTokenSource = global::Picsart.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Picsart.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Picsart.PathBuilder( + path: "/image/extract-colors", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Picsart.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 (image != default) + { + + 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.ImageUrl != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.ImageUrl ?? string.Empty), + name: "\"image_url\""); + + } + if (request.ImageId != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.ImageId ?? string.Empty), + name: "\"image_id\""); + + } + + __httpRequest.Content = __httpRequestContent; + + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareImageExtractColorsRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + 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::Picsart.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageExtractColors", + methodName: "ImageExtractColorsAsync", + pathTemplate: "\"/image/extract-colors\"", + 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::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageExtractColors", + methodName: "ImageExtractColorsAsync", + pathTemplate: "\"/image/extract-colors\"", + 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageExtractColors", + methodName: "ImageExtractColorsAsync", + pathTemplate: "\"/image/extract-colors\"", + 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::Picsart.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); + ProcessImageExtractColorsResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageExtractColors", + methodName: "ImageExtractColorsAsync", + pathTemplate: "\"/image/extract-colors\"", + 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::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageExtractColors", + methodName: "ImageExtractColorsAsync", + pathTemplate: "\"/image/extract-colors\"", + 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); + } + // Bad Request + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + global::Picsart.ImageError? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = global::Picsart.ImageError.FromJson(__content_400, JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_400 = global::Picsart.ImageError.FromJson(__content_400, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseObject = __value_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unauthorized + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + global::Picsart.Image401Error? __value_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_401 = global::Picsart.Image401Error.FromJson(__content_401, JsonSerializerContext); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_401 = global::Picsart.Image401Error.FromJson(__content_401, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseObject = __value_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Payment Required + if ((int)__response.StatusCode == 402) + { + string? __content_402 = null; + global::System.Exception? __exception_402 = null; + global::Picsart.ImageError? __value_402 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_402 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_402 = global::Picsart.ImageError.FromJson(__content_402, JsonSerializerContext); + } + else + { + __content_402 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_402 = global::Picsart.ImageError.FromJson(__content_402, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_402 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_402 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_402, + statusCode: __response.StatusCode) + { + ResponseBody = __content_402, + ResponseObject = __value_402, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Forbidden + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + global::Picsart.ImageError? __value_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_403 = global::Picsart.ImageError.FromJson(__content_403, JsonSerializerContext); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_403 = global::Picsart.ImageError.FromJson(__content_403, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + statusCode: __response.StatusCode) + { + ResponseBody = __content_403, + ResponseObject = __value_403, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Not Found + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + global::Picsart.ImageError? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = global::Picsart.ImageError.FromJson(__content_404, JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_404 = global::Picsart.ImageError.FromJson(__content_404, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + statusCode: __response.StatusCode) + { + ResponseBody = __content_404, + ResponseObject = __value_404, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Method Not Allowed + if ((int)__response.StatusCode == 405) + { + string? __content_405 = null; + global::System.Exception? __exception_405 = null; + global::Picsart.ImageError? __value_405 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_405 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_405 = global::Picsart.ImageError.FromJson(__content_405, JsonSerializerContext); + } + else + { + __content_405 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_405 = global::Picsart.ImageError.FromJson(__content_405, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_405 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_405 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_405, + statusCode: __response.StatusCode) + { + ResponseBody = __content_405, + ResponseObject = __value_405, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Request Entity Too Large + if ((int)__response.StatusCode == 413) + { + string? __content_413 = null; + global::System.Exception? __exception_413 = null; + global::Picsart.ImageError? __value_413 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_413 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_413 = global::Picsart.ImageError.FromJson(__content_413, JsonSerializerContext); + } + else + { + __content_413 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_413 = global::Picsart.ImageError.FromJson(__content_413, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_413 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_413 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_413, + statusCode: __response.StatusCode) + { + ResponseBody = __content_413, + ResponseObject = __value_413, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unsupported Media Type + if ((int)__response.StatusCode == 415) + { + string? __content_415 = null; + global::System.Exception? __exception_415 = null; + global::Picsart.ImageError? __value_415 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_415 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_415 = global::Picsart.ImageError.FromJson(__content_415, JsonSerializerContext); + } + else + { + __content_415 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_415 = global::Picsart.ImageError.FromJson(__content_415, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_415 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_415 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_415, + statusCode: __response.StatusCode) + { + ResponseBody = __content_415, + ResponseObject = __value_415, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unprocessable Entity + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Picsart.ImageError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Picsart.ImageError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_422 = global::Picsart.ImageError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Too Many Requests + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + global::Picsart.ImageError? __value_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_429 = global::Picsart.ImageError.FromJson(__content_429, JsonSerializerContext); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_429 = global::Picsart.ImageError.FromJson(__content_429, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + statusCode: __response.StatusCode) + { + ResponseBody = __content_429, + ResponseObject = __value_429, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Request Header Fields Too Large + if ((int)__response.StatusCode == 431) + { + string? __content_431 = null; + global::System.Exception? __exception_431 = null; + global::Picsart.ImageError? __value_431 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_431 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_431 = global::Picsart.ImageError.FromJson(__content_431, JsonSerializerContext); + } + else + { + __content_431 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_431 = global::Picsart.ImageError.FromJson(__content_431, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_431 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_431 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_431, + statusCode: __response.StatusCode) + { + ResponseBody = __content_431, + ResponseObject = __value_431, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Internal Server Error + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + global::Picsart.ImageError? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = global::Picsart.ImageError.FromJson(__content_500, JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_500 = global::Picsart.ImageError.FromJson(__content_500, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Service Unavailable + if ((int)__response.StatusCode == 503) + { + string? __content_503 = null; + global::System.Exception? __exception_503 = null; + global::Picsart.ImageError? __value_503 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_503 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_503 = global::Picsart.ImageError.FromJson(__content_503, JsonSerializerContext); + } + else + { + __content_503 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_503 = global::Picsart.ImageError.FromJson(__content_503, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_503 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_503 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_503, + statusCode: __response.StatusCode) + { + ResponseBody = __content_503, + ResponseObject = __value_503, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessImageExtractColorsResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Picsart.ImageExtractColorsResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Picsart.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::Picsart.ImageExtractColorsResponse.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::Picsart.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(); + } + } + /// + /// Extract Image Colors
+ /// Extract the key colors from an image to understand its visual style and palette.
+ /// The service analyzes an image and returns up to five prominent colors, including dominant foreground and background tones. + ///
+ /// + /// Source image file (binary). (If this parameter is present, the other image source parameters must be empty.) + /// + /// + /// Source image file (binary). (If this parameter is present, the other image source parameters must be empty.) + /// + /// + /// Source image URL. (If this parameter is present, the other image source parameters must be empty.) + /// + /// 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> ImageExtractColorsAsResponseAsync( + global::System.IO.Stream? image = default, + string? imagename = default, + string? imageUrl = default, + global::Picsart.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + var request = new global::Picsart.ImageImageParameters + { + Image = global::System.Array.Empty(), + Imagename = imagename, + ImageUrl = imageUrl, + }; + PrepareArguments( + client: HttpClient); + PrepareImageExtractColorsArguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::Picsart.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_ImageExtractColorsSecurityRequirements, + operationName: "ImageExtractColorsAsync"); + + using var __timeoutCancellationTokenSource = global::Picsart.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Picsart.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Picsart.PathBuilder( + path: "/image/extract-colors", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Picsart.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 (image != default) + { + + 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.ImageUrl != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.ImageUrl ?? string.Empty), + name: "\"image_url\""); + + } + if (request.ImageId != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.ImageId ?? string.Empty), + name: "\"image_id\""); + + } + + __httpRequest.Content = __httpRequestContent; + + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareImageExtractColorsRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + 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::Picsart.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageExtractColors", + methodName: "ImageExtractColorsAsync", + pathTemplate: "\"/image/extract-colors\"", + 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::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageExtractColors", + methodName: "ImageExtractColorsAsync", + pathTemplate: "\"/image/extract-colors\"", + 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageExtractColors", + methodName: "ImageExtractColorsAsync", + pathTemplate: "\"/image/extract-colors\"", + 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::Picsart.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); + ProcessImageExtractColorsResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageExtractColors", + methodName: "ImageExtractColorsAsync", + pathTemplate: "\"/image/extract-colors\"", + 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::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageExtractColors", + methodName: "ImageExtractColorsAsync", + pathTemplate: "\"/image/extract-colors\"", + 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); + } + // Bad Request + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + global::Picsart.ImageError? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = global::Picsart.ImageError.FromJson(__content_400, JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_400 = global::Picsart.ImageError.FromJson(__content_400, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseObject = __value_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unauthorized + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + global::Picsart.Image401Error? __value_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_401 = global::Picsart.Image401Error.FromJson(__content_401, JsonSerializerContext); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_401 = global::Picsart.Image401Error.FromJson(__content_401, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseObject = __value_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Payment Required + if ((int)__response.StatusCode == 402) + { + string? __content_402 = null; + global::System.Exception? __exception_402 = null; + global::Picsart.ImageError? __value_402 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_402 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_402 = global::Picsart.ImageError.FromJson(__content_402, JsonSerializerContext); + } + else + { + __content_402 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_402 = global::Picsart.ImageError.FromJson(__content_402, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_402 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_402 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_402, + statusCode: __response.StatusCode) + { + ResponseBody = __content_402, + ResponseObject = __value_402, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Forbidden + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + global::Picsart.ImageError? __value_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_403 = global::Picsart.ImageError.FromJson(__content_403, JsonSerializerContext); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_403 = global::Picsart.ImageError.FromJson(__content_403, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + statusCode: __response.StatusCode) + { + ResponseBody = __content_403, + ResponseObject = __value_403, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Not Found + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + global::Picsart.ImageError? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = global::Picsart.ImageError.FromJson(__content_404, JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_404 = global::Picsart.ImageError.FromJson(__content_404, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + statusCode: __response.StatusCode) + { + ResponseBody = __content_404, + ResponseObject = __value_404, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Method Not Allowed + if ((int)__response.StatusCode == 405) + { + string? __content_405 = null; + global::System.Exception? __exception_405 = null; + global::Picsart.ImageError? __value_405 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_405 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_405 = global::Picsart.ImageError.FromJson(__content_405, JsonSerializerContext); + } + else + { + __content_405 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_405 = global::Picsart.ImageError.FromJson(__content_405, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_405 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_405 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_405, + statusCode: __response.StatusCode) + { + ResponseBody = __content_405, + ResponseObject = __value_405, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Request Entity Too Large + if ((int)__response.StatusCode == 413) + { + string? __content_413 = null; + global::System.Exception? __exception_413 = null; + global::Picsart.ImageError? __value_413 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_413 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_413 = global::Picsart.ImageError.FromJson(__content_413, JsonSerializerContext); + } + else + { + __content_413 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_413 = global::Picsart.ImageError.FromJson(__content_413, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_413 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_413 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_413, + statusCode: __response.StatusCode) + { + ResponseBody = __content_413, + ResponseObject = __value_413, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unsupported Media Type + if ((int)__response.StatusCode == 415) + { + string? __content_415 = null; + global::System.Exception? __exception_415 = null; + global::Picsart.ImageError? __value_415 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_415 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_415 = global::Picsart.ImageError.FromJson(__content_415, JsonSerializerContext); + } + else + { + __content_415 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_415 = global::Picsart.ImageError.FromJson(__content_415, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_415 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_415 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_415, + statusCode: __response.StatusCode) + { + ResponseBody = __content_415, + ResponseObject = __value_415, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unprocessable Entity + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Picsart.ImageError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Picsart.ImageError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_422 = global::Picsart.ImageError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Too Many Requests + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + global::Picsart.ImageError? __value_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_429 = global::Picsart.ImageError.FromJson(__content_429, JsonSerializerContext); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_429 = global::Picsart.ImageError.FromJson(__content_429, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + statusCode: __response.StatusCode) + { + ResponseBody = __content_429, + ResponseObject = __value_429, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Request Header Fields Too Large + if ((int)__response.StatusCode == 431) + { + string? __content_431 = null; + global::System.Exception? __exception_431 = null; + global::Picsart.ImageError? __value_431 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_431 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_431 = global::Picsart.ImageError.FromJson(__content_431, JsonSerializerContext); + } + else + { + __content_431 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_431 = global::Picsart.ImageError.FromJson(__content_431, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_431 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_431 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_431, + statusCode: __response.StatusCode) + { + ResponseBody = __content_431, + ResponseObject = __value_431, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Internal Server Error + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + global::Picsart.ImageError? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = global::Picsart.ImageError.FromJson(__content_500, JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_500 = global::Picsart.ImageError.FromJson(__content_500, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Service Unavailable + if ((int)__response.StatusCode == 503) + { + string? __content_503 = null; + global::System.Exception? __exception_503 = null; + global::Picsart.ImageError? __value_503 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_503 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_503 = global::Picsart.ImageError.FromJson(__content_503, JsonSerializerContext); + } + else + { + __content_503 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_503 = global::Picsart.ImageError.FromJson(__content_503, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_503 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_503 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_503, + statusCode: __response.StatusCode) + { + ResponseBody = __content_503, + ResponseObject = __value_503, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessImageExtractColorsResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Picsart.ImageExtractColorsResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Picsart.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Picsart.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::Picsart.ImageExtractColorsResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Picsart.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Picsart.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::Picsart.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/Picsart/Generated/Picsart.ImageClassificationClient.ImageSegmentation.g.cs b/src/libs/Picsart/Generated/Picsart.ImageClassificationClient.ImageSegmentation.g.cs index 6b661a2..a976bcc 100644 --- a/src/libs/Picsart/Generated/Picsart.ImageClassificationClient.ImageSegmentation.g.cs +++ b/src/libs/Picsart/Generated/Picsart.ImageClassificationClient.ImageSegmentation.g.cs @@ -102,10 +102,11 @@ partial void ProcessImageSegmentationResponseContent( var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/image/multi-matting", baseUri: HttpClient.BaseAddress); @@ -138,8 +139,11 @@ partial void ProcessImageSegmentationResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + __httpRequest.Content = __httpRequestContent; + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -181,6 +185,8 @@ partial void ProcessImageSegmentationResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -191,6 +197,11 @@ partial void ProcessImageSegmentationResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -208,6 +219,8 @@ partial void ProcessImageSegmentationResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -217,8 +230,7 @@ partial void ProcessImageSegmentationResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -227,6 +239,11 @@ partial void ProcessImageSegmentationResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -243,14 +260,15 @@ partial void ProcessImageSegmentationResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -290,6 +308,8 @@ partial void ProcessImageSegmentationResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -310,6 +330,8 @@ partial void ProcessImageSegmentationResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -833,6 +855,7 @@ partial void ProcessImageSegmentationResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -866,6 +889,7 @@ partial void ProcessImageSegmentationResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.ImageClassificationClient.ImageTagging.g.cs b/src/libs/Picsart/Generated/Picsart.ImageClassificationClient.ImageTagging.g.cs index b23913c..d7a1d0c 100644 --- a/src/libs/Picsart/Generated/Picsart.ImageClassificationClient.ImageTagging.g.cs +++ b/src/libs/Picsart/Generated/Picsart.ImageClassificationClient.ImageTagging.g.cs @@ -106,10 +106,11 @@ partial void ProcessImageTaggingResponseContent( var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/image/tags", baseUri: HttpClient.BaseAddress); @@ -142,6 +143,7 @@ partial void ProcessImageTaggingResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); if (request.Image != default) { @@ -183,22 +185,27 @@ request.Imagename is null { __contentImage.Headers.ContentDisposition.FileNameStar = null; } - } + + } if (request.ImageUrl != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.ImageUrl ?? string.Empty), name: "\"image_url\""); - } + + } if (request.ImageId != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.ImageId ?? string.Empty), name: "\"image_id\""); + } + __httpRequest.Content = __httpRequestContent; + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -240,6 +247,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 +259,11 @@ request.Imagename is null } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -267,6 +281,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 +292,7 @@ request.Imagename is null __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -286,6 +301,11 @@ request.Imagename is null __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -302,14 +322,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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -349,6 +370,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 +392,8 @@ request.Imagename is null attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -892,6 +917,7 @@ request.Imagename is null return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -925,6 +951,7 @@ request.Imagename is null return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -998,5 +1025,1874 @@ request.Imagename is null requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } + + /// + /// Image Tagging
+ /// This tagging service analyzes the image and suggests hashtags that are relevant to the content. + ///
+ /// + /// Source image file (binary). (If this parameter is present, the other image source parameters must be empty.) + /// + /// + /// Source image file (binary). (If this parameter is present, the other image source parameters must be empty.) + /// + /// + /// Source image URL. (If this parameter is present, the other image source parameters must be empty.) + /// + /// 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 ImageTaggingAsync( + global::System.IO.Stream? image = default, + string? imagename = default, + string? imageUrl = default, + global::Picsart.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + var request = new global::Picsart.ImageImageParameters + { + Image = global::System.Array.Empty(), + Imagename = imagename, + ImageUrl = imageUrl, + }; + PrepareArguments( + client: HttpClient); + PrepareImageTaggingArguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::Picsart.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_ImageTaggingSecurityRequirements, + operationName: "ImageTaggingAsync"); + + using var __timeoutCancellationTokenSource = global::Picsart.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Picsart.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Picsart.PathBuilder( + path: "/image/tags", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Picsart.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 (image != default) + { + + 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.ImageUrl != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.ImageUrl ?? string.Empty), + name: "\"image_url\""); + + } + if (request.ImageId != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.ImageId ?? string.Empty), + name: "\"image_id\""); + + } + + __httpRequest.Content = __httpRequestContent; + + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareImageTaggingRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + 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::Picsart.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageTagging", + methodName: "ImageTaggingAsync", + pathTemplate: "\"/image/tags\"", + 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::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageTagging", + methodName: "ImageTaggingAsync", + pathTemplate: "\"/image/tags\"", + 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageTagging", + methodName: "ImageTaggingAsync", + pathTemplate: "\"/image/tags\"", + 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::Picsart.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); + ProcessImageTaggingResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageTagging", + methodName: "ImageTaggingAsync", + pathTemplate: "\"/image/tags\"", + 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::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageTagging", + methodName: "ImageTaggingAsync", + pathTemplate: "\"/image/tags\"", + 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); + } + // Bad Request + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + global::Picsart.ImageError? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = global::Picsart.ImageError.FromJson(__content_400, JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_400 = global::Picsart.ImageError.FromJson(__content_400, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseObject = __value_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unauthorized + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + global::Picsart.Image401Error? __value_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_401 = global::Picsart.Image401Error.FromJson(__content_401, JsonSerializerContext); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_401 = global::Picsart.Image401Error.FromJson(__content_401, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseObject = __value_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Payment Required + if ((int)__response.StatusCode == 402) + { + string? __content_402 = null; + global::System.Exception? __exception_402 = null; + global::Picsart.ImageError? __value_402 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_402 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_402 = global::Picsart.ImageError.FromJson(__content_402, JsonSerializerContext); + } + else + { + __content_402 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_402 = global::Picsart.ImageError.FromJson(__content_402, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_402 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_402 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_402, + statusCode: __response.StatusCode) + { + ResponseBody = __content_402, + ResponseObject = __value_402, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Forbidden + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + global::Picsart.ImageError? __value_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_403 = global::Picsart.ImageError.FromJson(__content_403, JsonSerializerContext); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_403 = global::Picsart.ImageError.FromJson(__content_403, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + statusCode: __response.StatusCode) + { + ResponseBody = __content_403, + ResponseObject = __value_403, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Not Found + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + global::Picsart.ImageError? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = global::Picsart.ImageError.FromJson(__content_404, JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_404 = global::Picsart.ImageError.FromJson(__content_404, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + statusCode: __response.StatusCode) + { + ResponseBody = __content_404, + ResponseObject = __value_404, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Method Not Allowed + if ((int)__response.StatusCode == 405) + { + string? __content_405 = null; + global::System.Exception? __exception_405 = null; + global::Picsart.ImageError? __value_405 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_405 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_405 = global::Picsart.ImageError.FromJson(__content_405, JsonSerializerContext); + } + else + { + __content_405 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_405 = global::Picsart.ImageError.FromJson(__content_405, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_405 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_405 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_405, + statusCode: __response.StatusCode) + { + ResponseBody = __content_405, + ResponseObject = __value_405, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Request Entity Too Large + if ((int)__response.StatusCode == 413) + { + string? __content_413 = null; + global::System.Exception? __exception_413 = null; + global::Picsart.ImageError? __value_413 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_413 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_413 = global::Picsart.ImageError.FromJson(__content_413, JsonSerializerContext); + } + else + { + __content_413 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_413 = global::Picsart.ImageError.FromJson(__content_413, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_413 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_413 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_413, + statusCode: __response.StatusCode) + { + ResponseBody = __content_413, + ResponseObject = __value_413, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unsupported Media Type + if ((int)__response.StatusCode == 415) + { + string? __content_415 = null; + global::System.Exception? __exception_415 = null; + global::Picsart.ImageError? __value_415 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_415 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_415 = global::Picsart.ImageError.FromJson(__content_415, JsonSerializerContext); + } + else + { + __content_415 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_415 = global::Picsart.ImageError.FromJson(__content_415, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_415 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_415 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_415, + statusCode: __response.StatusCode) + { + ResponseBody = __content_415, + ResponseObject = __value_415, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unprocessable Entity + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Picsart.ImageError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Picsart.ImageError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_422 = global::Picsart.ImageError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Too Many Requests + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + global::Picsart.ImageError? __value_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_429 = global::Picsart.ImageError.FromJson(__content_429, JsonSerializerContext); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_429 = global::Picsart.ImageError.FromJson(__content_429, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + statusCode: __response.StatusCode) + { + ResponseBody = __content_429, + ResponseObject = __value_429, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Request Header Fields Too Large + if ((int)__response.StatusCode == 431) + { + string? __content_431 = null; + global::System.Exception? __exception_431 = null; + global::Picsart.ImageError? __value_431 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_431 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_431 = global::Picsart.ImageError.FromJson(__content_431, JsonSerializerContext); + } + else + { + __content_431 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_431 = global::Picsart.ImageError.FromJson(__content_431, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_431 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_431 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_431, + statusCode: __response.StatusCode) + { + ResponseBody = __content_431, + ResponseObject = __value_431, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Internal Server Error + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + global::Picsart.ImageError? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = global::Picsart.ImageError.FromJson(__content_500, JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_500 = global::Picsart.ImageError.FromJson(__content_500, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Service Unavailable + if ((int)__response.StatusCode == 503) + { + string? __content_503 = null; + global::System.Exception? __exception_503 = null; + global::Picsart.ImageError? __value_503 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_503 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_503 = global::Picsart.ImageError.FromJson(__content_503, JsonSerializerContext); + } + else + { + __content_503 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_503 = global::Picsart.ImageError.FromJson(__content_503, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_503 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_503 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_503, + statusCode: __response.StatusCode) + { + ResponseBody = __content_503, + ResponseObject = __value_503, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessImageTaggingResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Picsart.ImageTaggingResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Picsart.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::Picsart.ImageTaggingResponse.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::Picsart.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(); + } + } + /// + /// Image Tagging
+ /// This tagging service analyzes the image and suggests hashtags that are relevant to the content. + ///
+ /// + /// Source image file (binary). (If this parameter is present, the other image source parameters must be empty.) + /// + /// + /// Source image file (binary). (If this parameter is present, the other image source parameters must be empty.) + /// + /// + /// Source image URL. (If this parameter is present, the other image source parameters must be empty.) + /// + /// 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> ImageTaggingAsResponseAsync( + global::System.IO.Stream? image = default, + string? imagename = default, + string? imageUrl = default, + global::Picsart.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + var request = new global::Picsart.ImageImageParameters + { + Image = global::System.Array.Empty(), + Imagename = imagename, + ImageUrl = imageUrl, + }; + PrepareArguments( + client: HttpClient); + PrepareImageTaggingArguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::Picsart.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_ImageTaggingSecurityRequirements, + operationName: "ImageTaggingAsync"); + + using var __timeoutCancellationTokenSource = global::Picsart.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Picsart.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Picsart.PathBuilder( + path: "/image/tags", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Picsart.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 (image != default) + { + + 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.ImageUrl != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.ImageUrl ?? string.Empty), + name: "\"image_url\""); + + } + if (request.ImageId != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.ImageId ?? string.Empty), + name: "\"image_id\""); + + } + + __httpRequest.Content = __httpRequestContent; + + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareImageTaggingRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + 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::Picsart.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageTagging", + methodName: "ImageTaggingAsync", + pathTemplate: "\"/image/tags\"", + 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::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageTagging", + methodName: "ImageTaggingAsync", + pathTemplate: "\"/image/tags\"", + 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageTagging", + methodName: "ImageTaggingAsync", + pathTemplate: "\"/image/tags\"", + 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::Picsart.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); + ProcessImageTaggingResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageTagging", + methodName: "ImageTaggingAsync", + pathTemplate: "\"/image/tags\"", + 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::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageTagging", + methodName: "ImageTaggingAsync", + pathTemplate: "\"/image/tags\"", + 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); + } + // Bad Request + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + global::Picsart.ImageError? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = global::Picsart.ImageError.FromJson(__content_400, JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_400 = global::Picsart.ImageError.FromJson(__content_400, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseObject = __value_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unauthorized + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + global::Picsart.Image401Error? __value_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_401 = global::Picsart.Image401Error.FromJson(__content_401, JsonSerializerContext); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_401 = global::Picsart.Image401Error.FromJson(__content_401, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseObject = __value_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Payment Required + if ((int)__response.StatusCode == 402) + { + string? __content_402 = null; + global::System.Exception? __exception_402 = null; + global::Picsart.ImageError? __value_402 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_402 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_402 = global::Picsart.ImageError.FromJson(__content_402, JsonSerializerContext); + } + else + { + __content_402 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_402 = global::Picsart.ImageError.FromJson(__content_402, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_402 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_402 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_402, + statusCode: __response.StatusCode) + { + ResponseBody = __content_402, + ResponseObject = __value_402, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Forbidden + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + global::Picsart.ImageError? __value_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_403 = global::Picsart.ImageError.FromJson(__content_403, JsonSerializerContext); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_403 = global::Picsart.ImageError.FromJson(__content_403, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + statusCode: __response.StatusCode) + { + ResponseBody = __content_403, + ResponseObject = __value_403, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Not Found + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + global::Picsart.ImageError? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = global::Picsart.ImageError.FromJson(__content_404, JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_404 = global::Picsart.ImageError.FromJson(__content_404, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + statusCode: __response.StatusCode) + { + ResponseBody = __content_404, + ResponseObject = __value_404, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Method Not Allowed + if ((int)__response.StatusCode == 405) + { + string? __content_405 = null; + global::System.Exception? __exception_405 = null; + global::Picsart.ImageError? __value_405 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_405 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_405 = global::Picsart.ImageError.FromJson(__content_405, JsonSerializerContext); + } + else + { + __content_405 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_405 = global::Picsart.ImageError.FromJson(__content_405, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_405 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_405 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_405, + statusCode: __response.StatusCode) + { + ResponseBody = __content_405, + ResponseObject = __value_405, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Request Entity Too Large + if ((int)__response.StatusCode == 413) + { + string? __content_413 = null; + global::System.Exception? __exception_413 = null; + global::Picsart.ImageError? __value_413 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_413 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_413 = global::Picsart.ImageError.FromJson(__content_413, JsonSerializerContext); + } + else + { + __content_413 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_413 = global::Picsart.ImageError.FromJson(__content_413, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_413 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_413 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_413, + statusCode: __response.StatusCode) + { + ResponseBody = __content_413, + ResponseObject = __value_413, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unsupported Media Type + if ((int)__response.StatusCode == 415) + { + string? __content_415 = null; + global::System.Exception? __exception_415 = null; + global::Picsart.ImageError? __value_415 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_415 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_415 = global::Picsart.ImageError.FromJson(__content_415, JsonSerializerContext); + } + else + { + __content_415 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_415 = global::Picsart.ImageError.FromJson(__content_415, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_415 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_415 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_415, + statusCode: __response.StatusCode) + { + ResponseBody = __content_415, + ResponseObject = __value_415, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unprocessable Entity + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Picsart.ImageError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Picsart.ImageError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_422 = global::Picsart.ImageError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Too Many Requests + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + global::Picsart.ImageError? __value_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_429 = global::Picsart.ImageError.FromJson(__content_429, JsonSerializerContext); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_429 = global::Picsart.ImageError.FromJson(__content_429, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + statusCode: __response.StatusCode) + { + ResponseBody = __content_429, + ResponseObject = __value_429, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Request Header Fields Too Large + if ((int)__response.StatusCode == 431) + { + string? __content_431 = null; + global::System.Exception? __exception_431 = null; + global::Picsart.ImageError? __value_431 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_431 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_431 = global::Picsart.ImageError.FromJson(__content_431, JsonSerializerContext); + } + else + { + __content_431 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_431 = global::Picsart.ImageError.FromJson(__content_431, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_431 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_431 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_431, + statusCode: __response.StatusCode) + { + ResponseBody = __content_431, + ResponseObject = __value_431, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Internal Server Error + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + global::Picsart.ImageError? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = global::Picsart.ImageError.FromJson(__content_500, JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_500 = global::Picsart.ImageError.FromJson(__content_500, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Service Unavailable + if ((int)__response.StatusCode == 503) + { + string? __content_503 = null; + global::System.Exception? __exception_503 = null; + global::Picsart.ImageError? __value_503 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_503 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_503 = global::Picsart.ImageError.FromJson(__content_503, JsonSerializerContext); + } + else + { + __content_503 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_503 = global::Picsart.ImageError.FromJson(__content_503, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_503 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_503 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_503, + statusCode: __response.StatusCode) + { + ResponseBody = __content_503, + ResponseObject = __value_503, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessImageTaggingResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Picsart.ImageTaggingResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Picsart.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Picsart.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::Picsart.ImageTaggingResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Picsart.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Picsart.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::Picsart.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/Picsart/Generated/Picsart.ImageClassificationClient.g.cs b/src/libs/Picsart/Generated/Picsart.ImageClassificationClient.g.cs index b7ba168..295f18d 100644 --- a/src/libs/Picsart/Generated/Picsart.ImageClassificationClient.g.cs +++ b/src/libs/Picsart/Generated/Picsart.ImageClassificationClient.g.cs @@ -72,10 +72,10 @@ public ImageClassificationClient( /// Client-wide request defaults such as headers, query parameters, retries, and timeout. /// Dispose the HttpClient when the instance is disposed. True by default. public ImageClassificationClient( - global::System.Net.Http.HttpClient? httpClient = null, - global::System.Uri? baseUri = null, - global::System.Collections.Generic.List? authorizations = null, - global::Picsart.AutoSDKClientOptions? options = null, + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Picsart.AutoSDKClientOptions? options, bool disposeHttpClient = true) { diff --git a/src/libs/Picsart/Generated/Picsart.ImageContentGenerationClient.ImageGeneratePattern.g.cs b/src/libs/Picsart/Generated/Picsart.ImageContentGenerationClient.ImageGeneratePattern.g.cs index 5af5cf8..cf6188b 100644 --- a/src/libs/Picsart/Generated/Picsart.ImageContentGenerationClient.ImageGeneratePattern.g.cs +++ b/src/libs/Picsart/Generated/Picsart.ImageContentGenerationClient.ImageGeneratePattern.g.cs @@ -102,10 +102,11 @@ partial void ProcessImageGeneratePatternResponseContent( var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/image/background/pattern", baseUri: HttpClient.BaseAddress); @@ -138,8 +139,11 @@ partial void ProcessImageGeneratePatternResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + __httpRequest.Content = __httpRequestContent; + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -181,6 +185,8 @@ partial void ProcessImageGeneratePatternResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -191,6 +197,11 @@ partial void ProcessImageGeneratePatternResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -208,6 +219,8 @@ partial void ProcessImageGeneratePatternResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -217,8 +230,7 @@ partial void ProcessImageGeneratePatternResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -227,6 +239,11 @@ partial void ProcessImageGeneratePatternResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -243,14 +260,15 @@ partial void ProcessImageGeneratePatternResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -290,6 +308,8 @@ partial void ProcessImageGeneratePatternResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -310,6 +330,8 @@ partial void ProcessImageGeneratePatternResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -833,6 +855,7 @@ partial void ProcessImageGeneratePatternResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -866,6 +889,7 @@ partial void ProcessImageGeneratePatternResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.ImageContentGenerationClient.g.cs b/src/libs/Picsart/Generated/Picsart.ImageContentGenerationClient.g.cs index a0100a1..4aef8d2 100644 --- a/src/libs/Picsart/Generated/Picsart.ImageContentGenerationClient.g.cs +++ b/src/libs/Picsart/Generated/Picsart.ImageContentGenerationClient.g.cs @@ -72,10 +72,10 @@ public ImageContentGenerationClient( /// Client-wide request defaults such as headers, query parameters, retries, and timeout. /// Dispose the HttpClient when the instance is disposed. True by default. public ImageContentGenerationClient( - global::System.Net.Http.HttpClient? httpClient = null, - global::System.Uri? baseUri = null, - global::System.Collections.Generic.List? authorizations = null, - global::Picsart.AutoSDKClientOptions? options = null, + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Picsart.AutoSDKClientOptions? options, bool disposeHttpClient = true) { diff --git a/src/libs/Picsart/Generated/Picsart.ImageConversionClient.ImageDesignImport.g.cs b/src/libs/Picsart/Generated/Picsart.ImageConversionClient.ImageDesignImport.g.cs index e853ab8..81f4897 100644 --- a/src/libs/Picsart/Generated/Picsart.ImageConversionClient.ImageDesignImport.g.cs +++ b/src/libs/Picsart/Generated/Picsart.ImageConversionClient.ImageDesignImport.g.cs @@ -114,10 +114,11 @@ partial void ProcessImageDesignImportResponseContent( var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/image/design2replay", baseUri: HttpClient.BaseAddress); @@ -150,6 +151,7 @@ partial void ProcessImageDesignImportResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); if (request.File != default) { @@ -191,15 +193,19 @@ request.Filename is null { __contentFile.Headers.ContentDisposition.FileNameStar = null; } - } + + } if (request.FileUrl != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.FileUrl ?? string.Empty), name: "\"file_url\""); + } + __httpRequest.Content = __httpRequestContent; + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -241,6 +247,8 @@ request.Filename is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -251,6 +259,11 @@ request.Filename is null } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -268,6 +281,8 @@ request.Filename is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -277,8 +292,7 @@ request.Filename is null __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -287,6 +301,11 @@ request.Filename is null __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -303,14 +322,15 @@ request.Filename 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -350,6 +370,8 @@ request.Filename is null attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -370,6 +392,8 @@ request.Filename is null attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -893,6 +917,7 @@ request.Filename is null return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -926,6 +951,7 @@ request.Filename is null return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -1004,5 +1030,1868 @@ request.Filename is null requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } + + /// + /// Design Import (beta)
+ /// With the *Design Import* tool you can instantly turn your design files (AI, SVG) into a Replay file (Picsart's proprietary project file format) that can be consumed by the [Photo and Video Editor SDK](https://docs.picsart.io/docs/photo-video-editor-overview).
+ ///
+ /// Use this to import your existing designs and make them resuable in Picsart.
+ /// **Suported Formats:** Examples of where the vectorizer can be used include:
+ /// * AI (Adobe Illustrator)
+ /// * SVG (Scalable Vector Graphics) + ///
+ /// + /// Source file (binary). (If this parameter is present, the other source parameters must be empty.) + /// + /// + /// Source file (binary). (If this parameter is present, the other source parameters must be empty.) + /// + /// + /// Source file URL. (If this parameter is present, the other source parameters must be empty.) + /// + /// 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 ImageDesignImportAsync( + global::System.IO.Stream? file = default, + string? filename = default, + string? fileUrl = default, + global::Picsart.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + var request = new global::Picsart.ImageFileParameters + { + File = global::System.Array.Empty(), + Filename = filename, + FileUrl = fileUrl, + }; + PrepareArguments( + client: HttpClient); + PrepareImageDesignImportArguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::Picsart.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_ImageDesignImportSecurityRequirements, + operationName: "ImageDesignImportAsync"); + + using var __timeoutCancellationTokenSource = global::Picsart.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Picsart.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Picsart.PathBuilder( + path: "/image/design2replay", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Picsart.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 (file != default) + { + + var __contentFile = new global::System.Net.Http.StreamContent(file); + __contentFile.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.Filename is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.Filename) ?? 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: __contentFile, + name: "\"file\"", + fileName: request.Filename != null ? $"\"{request.Filename}\"" : string.Empty); + if (__contentFile.Headers.ContentDisposition != null) + { + __contentFile.Headers.ContentDisposition.FileNameStar = null; + } + + } + if (request.FileUrl != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.FileUrl ?? string.Empty), + name: "\"file_url\""); + + } + + __httpRequest.Content = __httpRequestContent; + + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareImageDesignImportRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + 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::Picsart.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageDesignImport", + methodName: "ImageDesignImportAsync", + pathTemplate: "\"/image/design2replay\"", + 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::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageDesignImport", + methodName: "ImageDesignImportAsync", + pathTemplate: "\"/image/design2replay\"", + 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageDesignImport", + methodName: "ImageDesignImportAsync", + pathTemplate: "\"/image/design2replay\"", + 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::Picsart.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); + ProcessImageDesignImportResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageDesignImport", + methodName: "ImageDesignImportAsync", + pathTemplate: "\"/image/design2replay\"", + 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::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageDesignImport", + methodName: "ImageDesignImportAsync", + pathTemplate: "\"/image/design2replay\"", + 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); + } + // Bad Request + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + global::Picsart.ImageError? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = global::Picsart.ImageError.FromJson(__content_400, JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_400 = global::Picsart.ImageError.FromJson(__content_400, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseObject = __value_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unauthorized + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + global::Picsart.Image401Error? __value_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_401 = global::Picsart.Image401Error.FromJson(__content_401, JsonSerializerContext); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_401 = global::Picsart.Image401Error.FromJson(__content_401, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseObject = __value_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Payment Required + if ((int)__response.StatusCode == 402) + { + string? __content_402 = null; + global::System.Exception? __exception_402 = null; + global::Picsart.ImageError? __value_402 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_402 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_402 = global::Picsart.ImageError.FromJson(__content_402, JsonSerializerContext); + } + else + { + __content_402 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_402 = global::Picsart.ImageError.FromJson(__content_402, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_402 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_402 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_402, + statusCode: __response.StatusCode) + { + ResponseBody = __content_402, + ResponseObject = __value_402, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Forbidden + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + global::Picsart.ImageError? __value_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_403 = global::Picsart.ImageError.FromJson(__content_403, JsonSerializerContext); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_403 = global::Picsart.ImageError.FromJson(__content_403, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + statusCode: __response.StatusCode) + { + ResponseBody = __content_403, + ResponseObject = __value_403, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Not Found + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + global::Picsart.ImageError? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = global::Picsart.ImageError.FromJson(__content_404, JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_404 = global::Picsart.ImageError.FromJson(__content_404, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + statusCode: __response.StatusCode) + { + ResponseBody = __content_404, + ResponseObject = __value_404, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Method Not Allowed + if ((int)__response.StatusCode == 405) + { + string? __content_405 = null; + global::System.Exception? __exception_405 = null; + global::Picsart.ImageError? __value_405 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_405 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_405 = global::Picsart.ImageError.FromJson(__content_405, JsonSerializerContext); + } + else + { + __content_405 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_405 = global::Picsart.ImageError.FromJson(__content_405, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_405 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_405 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_405, + statusCode: __response.StatusCode) + { + ResponseBody = __content_405, + ResponseObject = __value_405, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Request Entity Too Large + if ((int)__response.StatusCode == 413) + { + string? __content_413 = null; + global::System.Exception? __exception_413 = null; + global::Picsart.ImageError? __value_413 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_413 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_413 = global::Picsart.ImageError.FromJson(__content_413, JsonSerializerContext); + } + else + { + __content_413 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_413 = global::Picsart.ImageError.FromJson(__content_413, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_413 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_413 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_413, + statusCode: __response.StatusCode) + { + ResponseBody = __content_413, + ResponseObject = __value_413, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unsupported Media Type + if ((int)__response.StatusCode == 415) + { + string? __content_415 = null; + global::System.Exception? __exception_415 = null; + global::Picsart.ImageError? __value_415 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_415 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_415 = global::Picsart.ImageError.FromJson(__content_415, JsonSerializerContext); + } + else + { + __content_415 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_415 = global::Picsart.ImageError.FromJson(__content_415, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_415 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_415 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_415, + statusCode: __response.StatusCode) + { + ResponseBody = __content_415, + ResponseObject = __value_415, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unprocessable Entity + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Picsart.ImageError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Picsart.ImageError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_422 = global::Picsart.ImageError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Too Many Requests + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + global::Picsart.ImageError? __value_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_429 = global::Picsart.ImageError.FromJson(__content_429, JsonSerializerContext); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_429 = global::Picsart.ImageError.FromJson(__content_429, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + statusCode: __response.StatusCode) + { + ResponseBody = __content_429, + ResponseObject = __value_429, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Request Header Fields Too Large + if ((int)__response.StatusCode == 431) + { + string? __content_431 = null; + global::System.Exception? __exception_431 = null; + global::Picsart.ImageError? __value_431 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_431 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_431 = global::Picsart.ImageError.FromJson(__content_431, JsonSerializerContext); + } + else + { + __content_431 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_431 = global::Picsart.ImageError.FromJson(__content_431, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_431 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_431 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_431, + statusCode: __response.StatusCode) + { + ResponseBody = __content_431, + ResponseObject = __value_431, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Internal Server Error + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + global::Picsart.ImageError? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = global::Picsart.ImageError.FromJson(__content_500, JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_500 = global::Picsart.ImageError.FromJson(__content_500, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Service Unavailable + if ((int)__response.StatusCode == 503) + { + string? __content_503 = null; + global::System.Exception? __exception_503 = null; + global::Picsart.ImageError? __value_503 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_503 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_503 = global::Picsart.ImageError.FromJson(__content_503, JsonSerializerContext); + } + else + { + __content_503 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_503 = global::Picsart.ImageError.FromJson(__content_503, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_503 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_503 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_503, + statusCode: __response.StatusCode) + { + ResponseBody = __content_503, + ResponseObject = __value_503, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessImageDesignImportResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Picsart.ImageDesignImportResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Picsart.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::Picsart.ImageDesignImportResponse.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::Picsart.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(); + } + } + /// + /// Design Import (beta)
+ /// With the *Design Import* tool you can instantly turn your design files (AI, SVG) into a Replay file (Picsart's proprietary project file format) that can be consumed by the [Photo and Video Editor SDK](https://docs.picsart.io/docs/photo-video-editor-overview).
+ ///
+ /// Use this to import your existing designs and make them resuable in Picsart.
+ /// **Suported Formats:** Examples of where the vectorizer can be used include:
+ /// * AI (Adobe Illustrator)
+ /// * SVG (Scalable Vector Graphics) + ///
+ /// + /// Source file (binary). (If this parameter is present, the other source parameters must be empty.) + /// + /// + /// Source file (binary). (If this parameter is present, the other source parameters must be empty.) + /// + /// + /// Source file URL. (If this parameter is present, the other source parameters must be empty.) + /// + /// 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> ImageDesignImportAsResponseAsync( + global::System.IO.Stream? file = default, + string? filename = default, + string? fileUrl = default, + global::Picsart.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + var request = new global::Picsart.ImageFileParameters + { + File = global::System.Array.Empty(), + Filename = filename, + FileUrl = fileUrl, + }; + PrepareArguments( + client: HttpClient); + PrepareImageDesignImportArguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::Picsart.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_ImageDesignImportSecurityRequirements, + operationName: "ImageDesignImportAsync"); + + using var __timeoutCancellationTokenSource = global::Picsart.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Picsart.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Picsart.PathBuilder( + path: "/image/design2replay", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Picsart.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 (file != default) + { + + var __contentFile = new global::System.Net.Http.StreamContent(file); + __contentFile.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.Filename is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.Filename) ?? 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: __contentFile, + name: "\"file\"", + fileName: request.Filename != null ? $"\"{request.Filename}\"" : string.Empty); + if (__contentFile.Headers.ContentDisposition != null) + { + __contentFile.Headers.ContentDisposition.FileNameStar = null; + } + + } + if (request.FileUrl != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.FileUrl ?? string.Empty), + name: "\"file_url\""); + + } + + __httpRequest.Content = __httpRequestContent; + + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareImageDesignImportRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + 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::Picsart.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageDesignImport", + methodName: "ImageDesignImportAsync", + pathTemplate: "\"/image/design2replay\"", + 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::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageDesignImport", + methodName: "ImageDesignImportAsync", + pathTemplate: "\"/image/design2replay\"", + 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageDesignImport", + methodName: "ImageDesignImportAsync", + pathTemplate: "\"/image/design2replay\"", + 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::Picsart.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); + ProcessImageDesignImportResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageDesignImport", + methodName: "ImageDesignImportAsync", + pathTemplate: "\"/image/design2replay\"", + 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::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageDesignImport", + methodName: "ImageDesignImportAsync", + pathTemplate: "\"/image/design2replay\"", + 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); + } + // Bad Request + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + global::Picsart.ImageError? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = global::Picsart.ImageError.FromJson(__content_400, JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_400 = global::Picsart.ImageError.FromJson(__content_400, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseObject = __value_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unauthorized + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + global::Picsart.Image401Error? __value_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_401 = global::Picsart.Image401Error.FromJson(__content_401, JsonSerializerContext); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_401 = global::Picsart.Image401Error.FromJson(__content_401, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseObject = __value_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Payment Required + if ((int)__response.StatusCode == 402) + { + string? __content_402 = null; + global::System.Exception? __exception_402 = null; + global::Picsart.ImageError? __value_402 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_402 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_402 = global::Picsart.ImageError.FromJson(__content_402, JsonSerializerContext); + } + else + { + __content_402 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_402 = global::Picsart.ImageError.FromJson(__content_402, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_402 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_402 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_402, + statusCode: __response.StatusCode) + { + ResponseBody = __content_402, + ResponseObject = __value_402, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Forbidden + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + global::Picsart.ImageError? __value_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_403 = global::Picsart.ImageError.FromJson(__content_403, JsonSerializerContext); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_403 = global::Picsart.ImageError.FromJson(__content_403, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + statusCode: __response.StatusCode) + { + ResponseBody = __content_403, + ResponseObject = __value_403, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Not Found + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + global::Picsart.ImageError? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = global::Picsart.ImageError.FromJson(__content_404, JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_404 = global::Picsart.ImageError.FromJson(__content_404, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + statusCode: __response.StatusCode) + { + ResponseBody = __content_404, + ResponseObject = __value_404, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Method Not Allowed + if ((int)__response.StatusCode == 405) + { + string? __content_405 = null; + global::System.Exception? __exception_405 = null; + global::Picsart.ImageError? __value_405 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_405 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_405 = global::Picsart.ImageError.FromJson(__content_405, JsonSerializerContext); + } + else + { + __content_405 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_405 = global::Picsart.ImageError.FromJson(__content_405, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_405 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_405 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_405, + statusCode: __response.StatusCode) + { + ResponseBody = __content_405, + ResponseObject = __value_405, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Request Entity Too Large + if ((int)__response.StatusCode == 413) + { + string? __content_413 = null; + global::System.Exception? __exception_413 = null; + global::Picsart.ImageError? __value_413 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_413 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_413 = global::Picsart.ImageError.FromJson(__content_413, JsonSerializerContext); + } + else + { + __content_413 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_413 = global::Picsart.ImageError.FromJson(__content_413, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_413 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_413 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_413, + statusCode: __response.StatusCode) + { + ResponseBody = __content_413, + ResponseObject = __value_413, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unsupported Media Type + if ((int)__response.StatusCode == 415) + { + string? __content_415 = null; + global::System.Exception? __exception_415 = null; + global::Picsart.ImageError? __value_415 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_415 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_415 = global::Picsart.ImageError.FromJson(__content_415, JsonSerializerContext); + } + else + { + __content_415 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_415 = global::Picsart.ImageError.FromJson(__content_415, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_415 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_415 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_415, + statusCode: __response.StatusCode) + { + ResponseBody = __content_415, + ResponseObject = __value_415, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unprocessable Entity + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Picsart.ImageError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Picsart.ImageError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_422 = global::Picsart.ImageError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Too Many Requests + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + global::Picsart.ImageError? __value_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_429 = global::Picsart.ImageError.FromJson(__content_429, JsonSerializerContext); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_429 = global::Picsart.ImageError.FromJson(__content_429, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + statusCode: __response.StatusCode) + { + ResponseBody = __content_429, + ResponseObject = __value_429, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Request Header Fields Too Large + if ((int)__response.StatusCode == 431) + { + string? __content_431 = null; + global::System.Exception? __exception_431 = null; + global::Picsart.ImageError? __value_431 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_431 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_431 = global::Picsart.ImageError.FromJson(__content_431, JsonSerializerContext); + } + else + { + __content_431 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_431 = global::Picsart.ImageError.FromJson(__content_431, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_431 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_431 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_431, + statusCode: __response.StatusCode) + { + ResponseBody = __content_431, + ResponseObject = __value_431, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Internal Server Error + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + global::Picsart.ImageError? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = global::Picsart.ImageError.FromJson(__content_500, JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_500 = global::Picsart.ImageError.FromJson(__content_500, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Service Unavailable + if ((int)__response.StatusCode == 503) + { + string? __content_503 = null; + global::System.Exception? __exception_503 = null; + global::Picsart.ImageError? __value_503 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_503 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_503 = global::Picsart.ImageError.FromJson(__content_503, JsonSerializerContext); + } + else + { + __content_503 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_503 = global::Picsart.ImageError.FromJson(__content_503, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_503 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_503 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_503, + statusCode: __response.StatusCode) + { + ResponseBody = __content_503, + ResponseObject = __value_503, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessImageDesignImportResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Picsart.ImageDesignImportResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Picsart.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Picsart.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::Picsart.ImageDesignImportResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Picsart.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Picsart.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::Picsart.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/Picsart/Generated/Picsart.ImageConversionClient.ImageDesignImportGetresult.g.cs b/src/libs/Picsart/Generated/Picsart.ImageConversionClient.ImageDesignImportGetresult.g.cs index 6c6fa31..677a5b2 100644 --- a/src/libs/Picsart/Generated/Picsart.ImageConversionClient.ImageDesignImportGetresult.g.cs +++ b/src/libs/Picsart/Generated/Picsart.ImageConversionClient.ImageDesignImportGetresult.g.cs @@ -103,6 +103,7 @@ partial void ProcessImageDesignImportGetresultResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: $"/image/design2replay/{transactionId}", baseUri: HttpClient.BaseAddress); @@ -176,6 +177,8 @@ partial void ProcessImageDesignImportGetresultResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -186,6 +189,11 @@ partial void ProcessImageDesignImportGetresultResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -203,6 +211,8 @@ partial void ProcessImageDesignImportGetresultResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -212,8 +222,7 @@ partial void ProcessImageDesignImportGetresultResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -222,6 +231,11 @@ partial void ProcessImageDesignImportGetresultResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -238,14 +252,15 @@ partial void ProcessImageDesignImportGetresultResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -285,6 +300,8 @@ partial void ProcessImageDesignImportGetresultResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -305,6 +322,8 @@ partial void ProcessImageDesignImportGetresultResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -828,6 +847,7 @@ partial void ProcessImageDesignImportGetresultResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -861,6 +881,7 @@ partial void ProcessImageDesignImportGetresultResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.ImageConversionClient.ImageVectorizeRasterToSvg.g.cs b/src/libs/Picsart/Generated/Picsart.ImageConversionClient.ImageVectorizeRasterToSvg.g.cs index 3ddf026..20d9023 100644 --- a/src/libs/Picsart/Generated/Picsart.ImageConversionClient.ImageVectorizeRasterToSvg.g.cs +++ b/src/libs/Picsart/Generated/Picsart.ImageConversionClient.ImageVectorizeRasterToSvg.g.cs @@ -102,10 +102,11 @@ partial void ProcessImageVectorizeRasterToSvgResponseContent( var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/image/vectorizer", baseUri: HttpClient.BaseAddress); @@ -138,8 +139,11 @@ partial void ProcessImageVectorizeRasterToSvgResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + __httpRequest.Content = __httpRequestContent; + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -181,6 +185,8 @@ partial void ProcessImageVectorizeRasterToSvgResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -191,6 +197,11 @@ partial void ProcessImageVectorizeRasterToSvgResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -208,6 +219,8 @@ partial void ProcessImageVectorizeRasterToSvgResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -217,8 +230,7 @@ partial void ProcessImageVectorizeRasterToSvgResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -227,6 +239,11 @@ partial void ProcessImageVectorizeRasterToSvgResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -243,14 +260,15 @@ partial void ProcessImageVectorizeRasterToSvgResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -290,6 +308,8 @@ partial void ProcessImageVectorizeRasterToSvgResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -310,6 +330,8 @@ partial void ProcessImageVectorizeRasterToSvgResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -833,6 +855,7 @@ partial void ProcessImageVectorizeRasterToSvgResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -866,6 +889,7 @@ partial void ProcessImageVectorizeRasterToSvgResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.ImageConversionClient.g.cs b/src/libs/Picsart/Generated/Picsart.ImageConversionClient.g.cs index ffb14ab..f4d1aa8 100644 --- a/src/libs/Picsart/Generated/Picsart.ImageConversionClient.g.cs +++ b/src/libs/Picsart/Generated/Picsart.ImageConversionClient.g.cs @@ -72,10 +72,10 @@ public ImageConversionClient( /// Client-wide request defaults such as headers, query parameters, retries, and timeout. /// Dispose the HttpClient when the instance is disposed. True by default. public ImageConversionClient( - global::System.Net.Http.HttpClient? httpClient = null, - global::System.Uri? baseUri = null, - global::System.Collections.Generic.List? authorizations = null, - global::Picsart.AutoSDKClientOptions? options = null, + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Picsart.AutoSDKClientOptions? options, bool disposeHttpClient = true) { diff --git a/src/libs/Picsart/Generated/Picsart.ImageEditingClient.ImageBlend.g.cs b/src/libs/Picsart/Generated/Picsart.ImageEditingClient.ImageBlend.g.cs index 87225ed..ca61484 100644 --- a/src/libs/Picsart/Generated/Picsart.ImageEditingClient.ImageBlend.g.cs +++ b/src/libs/Picsart/Generated/Picsart.ImageEditingClient.ImageBlend.g.cs @@ -106,10 +106,11 @@ partial void ProcessImageBlendResponseContent( var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/image/blend", baseUri: HttpClient.BaseAddress); @@ -142,8 +143,11 @@ partial void ProcessImageBlendResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + __httpRequest.Content = __httpRequestContent; + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -185,6 +189,8 @@ partial void ProcessImageBlendResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -195,6 +201,11 @@ partial void ProcessImageBlendResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -212,6 +223,8 @@ partial void ProcessImageBlendResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -221,8 +234,7 @@ partial void ProcessImageBlendResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -231,6 +243,11 @@ partial void ProcessImageBlendResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -247,14 +264,15 @@ partial void ProcessImageBlendResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -294,6 +312,8 @@ partial void ProcessImageBlendResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -314,6 +334,8 @@ partial void ProcessImageBlendResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -837,6 +859,7 @@ partial void ProcessImageBlendResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -870,6 +893,7 @@ partial void ProcessImageBlendResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.ImageEditingClient.ImageEdit.g.cs b/src/libs/Picsart/Generated/Picsart.ImageEditingClient.ImageEdit.g.cs index d760501..ff7b332 100644 --- a/src/libs/Picsart/Generated/Picsart.ImageEditingClient.ImageEdit.g.cs +++ b/src/libs/Picsart/Generated/Picsart.ImageEditingClient.ImageEdit.g.cs @@ -102,10 +102,11 @@ partial void ProcessImageEditResponseContent( var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/image/edit", baseUri: HttpClient.BaseAddress); @@ -138,8 +139,11 @@ partial void ProcessImageEditResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + __httpRequest.Content = __httpRequestContent; + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -181,6 +185,8 @@ partial void ProcessImageEditResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -191,6 +197,11 @@ partial void ProcessImageEditResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -208,6 +219,8 @@ partial void ProcessImageEditResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -217,8 +230,7 @@ partial void ProcessImageEditResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -227,6 +239,11 @@ partial void ProcessImageEditResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -243,14 +260,15 @@ partial void ProcessImageEditResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -290,6 +308,8 @@ partial void ProcessImageEditResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -310,6 +330,8 @@ partial void ProcessImageEditResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -833,6 +855,7 @@ partial void ProcessImageEditResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -866,6 +889,7 @@ partial void ProcessImageEditResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.ImageEditingClient.ImageSmartCrop.g.cs b/src/libs/Picsart/Generated/Picsart.ImageEditingClient.ImageSmartCrop.g.cs index 39243b4..a5058ea 100644 --- a/src/libs/Picsart/Generated/Picsart.ImageEditingClient.ImageSmartCrop.g.cs +++ b/src/libs/Picsart/Generated/Picsart.ImageEditingClient.ImageSmartCrop.g.cs @@ -102,10 +102,11 @@ partial void ProcessImageSmartCropResponseContent( var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/image/smart-crop", baseUri: HttpClient.BaseAddress); @@ -138,8 +139,11 @@ partial void ProcessImageSmartCropResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + __httpRequest.Content = __httpRequestContent; + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -181,6 +185,8 @@ partial void ProcessImageSmartCropResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -191,6 +197,11 @@ partial void ProcessImageSmartCropResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -208,6 +219,8 @@ partial void ProcessImageSmartCropResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -217,8 +230,7 @@ partial void ProcessImageSmartCropResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -227,6 +239,11 @@ partial void ProcessImageSmartCropResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -243,14 +260,15 @@ partial void ProcessImageSmartCropResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -290,6 +308,8 @@ partial void ProcessImageSmartCropResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -310,6 +330,8 @@ partial void ProcessImageSmartCropResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -833,6 +855,7 @@ partial void ProcessImageSmartCropResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -866,6 +889,7 @@ partial void ProcessImageSmartCropResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.ImageEditingClient.ImageZoom.g.cs b/src/libs/Picsart/Generated/Picsart.ImageEditingClient.ImageZoom.g.cs index b83c203..2827049 100644 --- a/src/libs/Picsart/Generated/Picsart.ImageEditingClient.ImageZoom.g.cs +++ b/src/libs/Picsart/Generated/Picsart.ImageEditingClient.ImageZoom.g.cs @@ -102,10 +102,11 @@ partial void ProcessImageZoomResponseContent( var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/image/zoom", baseUri: HttpClient.BaseAddress); @@ -138,8 +139,11 @@ partial void ProcessImageZoomResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + __httpRequest.Content = __httpRequestContent; + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -181,6 +185,8 @@ partial void ProcessImageZoomResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -191,6 +197,11 @@ partial void ProcessImageZoomResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -208,6 +219,8 @@ partial void ProcessImageZoomResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -217,8 +230,7 @@ partial void ProcessImageZoomResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -227,6 +239,11 @@ partial void ProcessImageZoomResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -243,14 +260,15 @@ partial void ProcessImageZoomResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -290,6 +308,8 @@ partial void ProcessImageZoomResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -310,6 +330,8 @@ partial void ProcessImageZoomResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -833,6 +855,7 @@ partial void ProcessImageZoomResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -866,6 +889,7 @@ partial void ProcessImageZoomResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.ImageEditingClient.g.cs b/src/libs/Picsart/Generated/Picsart.ImageEditingClient.g.cs index 4890c61..9cf5ceb 100644 --- a/src/libs/Picsart/Generated/Picsart.ImageEditingClient.g.cs +++ b/src/libs/Picsart/Generated/Picsart.ImageEditingClient.g.cs @@ -72,10 +72,10 @@ public ImageEditingClient( /// Client-wide request defaults such as headers, query parameters, retries, and timeout. /// Dispose the HttpClient when the instance is disposed. True by default. public ImageEditingClient( - global::System.Net.Http.HttpClient? httpClient = null, - global::System.Uri? baseUri = null, - global::System.Collections.Generic.List? authorizations = null, - global::Picsart.AutoSDKClientOptions? options = null, + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Picsart.AutoSDKClientOptions? options, bool disposeHttpClient = true) { diff --git a/src/libs/Picsart/Generated/Picsart.ImageEffectsClient.ImageAdjust.g.cs b/src/libs/Picsart/Generated/Picsart.ImageEffectsClient.ImageAdjust.g.cs index 7b714ba..6237d2b 100644 --- a/src/libs/Picsart/Generated/Picsart.ImageEffectsClient.ImageAdjust.g.cs +++ b/src/libs/Picsart/Generated/Picsart.ImageEffectsClient.ImageAdjust.g.cs @@ -102,10 +102,11 @@ partial void ProcessImageAdjustResponseContent( var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/image/adjust", baseUri: HttpClient.BaseAddress); @@ -138,8 +139,11 @@ partial void ProcessImageAdjustResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + __httpRequest.Content = __httpRequestContent; + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -181,6 +185,8 @@ partial void ProcessImageAdjustResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -191,6 +197,11 @@ partial void ProcessImageAdjustResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -208,6 +219,8 @@ partial void ProcessImageAdjustResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -217,8 +230,7 @@ partial void ProcessImageAdjustResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -227,6 +239,11 @@ partial void ProcessImageAdjustResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -243,14 +260,15 @@ partial void ProcessImageAdjustResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -290,6 +308,8 @@ partial void ProcessImageAdjustResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -310,6 +330,8 @@ partial void ProcessImageAdjustResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -833,6 +855,7 @@ partial void ProcessImageAdjustResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -866,6 +889,7 @@ partial void ProcessImageAdjustResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.ImageEffectsClient.ImageApplyAiEffect.g.cs b/src/libs/Picsart/Generated/Picsart.ImageEffectsClient.ImageApplyAiEffect.g.cs index 672cf79..11c5c07 100644 --- a/src/libs/Picsart/Generated/Picsart.ImageEffectsClient.ImageApplyAiEffect.g.cs +++ b/src/libs/Picsart/Generated/Picsart.ImageEffectsClient.ImageApplyAiEffect.g.cs @@ -102,10 +102,11 @@ partial void ProcessImageApplyAiEffectResponseContent( var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/image/effects/ai", baseUri: HttpClient.BaseAddress); @@ -138,8 +139,11 @@ partial void ProcessImageApplyAiEffectResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + __httpRequest.Content = __httpRequestContent; + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -181,6 +185,8 @@ partial void ProcessImageApplyAiEffectResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -191,6 +197,11 @@ partial void ProcessImageApplyAiEffectResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -208,6 +219,8 @@ partial void ProcessImageApplyAiEffectResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -217,8 +230,7 @@ partial void ProcessImageApplyAiEffectResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -227,6 +239,11 @@ partial void ProcessImageApplyAiEffectResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -243,14 +260,15 @@ partial void ProcessImageApplyAiEffectResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -290,6 +308,8 @@ partial void ProcessImageApplyAiEffectResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -310,6 +330,8 @@ partial void ProcessImageApplyAiEffectResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -833,6 +855,7 @@ partial void ProcessImageApplyAiEffectResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -866,6 +889,7 @@ partial void ProcessImageApplyAiEffectResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.ImageEffectsClient.ImageApplyEffect.g.cs b/src/libs/Picsart/Generated/Picsart.ImageEffectsClient.ImageApplyEffect.g.cs index 6545410..e69abc5 100644 --- a/src/libs/Picsart/Generated/Picsart.ImageEffectsClient.ImageApplyEffect.g.cs +++ b/src/libs/Picsart/Generated/Picsart.ImageEffectsClient.ImageApplyEffect.g.cs @@ -102,10 +102,11 @@ partial void ProcessImageApplyEffectResponseContent( var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/image/effects", baseUri: HttpClient.BaseAddress); @@ -138,8 +139,11 @@ partial void ProcessImageApplyEffectResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + __httpRequest.Content = __httpRequestContent; + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -181,6 +185,8 @@ partial void ProcessImageApplyEffectResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -191,6 +197,11 @@ partial void ProcessImageApplyEffectResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -208,6 +219,8 @@ partial void ProcessImageApplyEffectResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -217,8 +230,7 @@ partial void ProcessImageApplyEffectResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -227,6 +239,11 @@ partial void ProcessImageApplyEffectResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -243,14 +260,15 @@ partial void ProcessImageApplyEffectResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -290,6 +308,8 @@ partial void ProcessImageApplyEffectResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -310,6 +330,8 @@ partial void ProcessImageApplyEffectResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -833,6 +855,7 @@ partial void ProcessImageApplyEffectResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -866,6 +889,7 @@ partial void ProcessImageApplyEffectResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.ImageEffectsClient.ImageApplyLaserEngravingEffect.g.cs b/src/libs/Picsart/Generated/Picsart.ImageEffectsClient.ImageApplyLaserEngravingEffect.g.cs index 906b1fb..e4755fd 100644 --- a/src/libs/Picsart/Generated/Picsart.ImageEffectsClient.ImageApplyLaserEngravingEffect.g.cs +++ b/src/libs/Picsart/Generated/Picsart.ImageEffectsClient.ImageApplyLaserEngravingEffect.g.cs @@ -102,10 +102,11 @@ partial void ProcessImageApplyLaserEngravingEffectResponseContent( var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/image/effects/laserengraving", baseUri: HttpClient.BaseAddress); @@ -138,8 +139,11 @@ partial void ProcessImageApplyLaserEngravingEffectResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + __httpRequest.Content = __httpRequestContent; + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -181,6 +185,8 @@ partial void ProcessImageApplyLaserEngravingEffectResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -191,6 +197,11 @@ partial void ProcessImageApplyLaserEngravingEffectResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -208,6 +219,8 @@ partial void ProcessImageApplyLaserEngravingEffectResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -217,8 +230,7 @@ partial void ProcessImageApplyLaserEngravingEffectResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -227,6 +239,11 @@ partial void ProcessImageApplyLaserEngravingEffectResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -243,14 +260,15 @@ partial void ProcessImageApplyLaserEngravingEffectResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -290,6 +308,8 @@ partial void ProcessImageApplyLaserEngravingEffectResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -310,6 +330,8 @@ partial void ProcessImageApplyLaserEngravingEffectResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -833,6 +855,7 @@ partial void ProcessImageApplyLaserEngravingEffectResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -866,6 +889,7 @@ partial void ProcessImageApplyLaserEngravingEffectResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.ImageEffectsClient.ImageApplyMask.g.cs b/src/libs/Picsart/Generated/Picsart.ImageEffectsClient.ImageApplyMask.g.cs index daa4f2d..e4e2e61 100644 --- a/src/libs/Picsart/Generated/Picsart.ImageEffectsClient.ImageApplyMask.g.cs +++ b/src/libs/Picsart/Generated/Picsart.ImageEffectsClient.ImageApplyMask.g.cs @@ -102,10 +102,11 @@ partial void ProcessImageApplyMaskResponseContent( var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/image/masks", baseUri: HttpClient.BaseAddress); @@ -138,8 +139,11 @@ partial void ProcessImageApplyMaskResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + __httpRequest.Content = __httpRequestContent; + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -181,6 +185,8 @@ partial void ProcessImageApplyMaskResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -191,6 +197,11 @@ partial void ProcessImageApplyMaskResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -208,6 +219,8 @@ partial void ProcessImageApplyMaskResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -217,8 +230,7 @@ partial void ProcessImageApplyMaskResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -227,6 +239,11 @@ partial void ProcessImageApplyMaskResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -243,14 +260,15 @@ partial void ProcessImageApplyMaskResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -290,6 +308,8 @@ partial void ProcessImageApplyMaskResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -310,6 +330,8 @@ partial void ProcessImageApplyMaskResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -833,6 +855,7 @@ partial void ProcessImageApplyMaskResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -866,6 +889,7 @@ partial void ProcessImageApplyMaskResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.ImageEffectsClient.ImageCreateEffectPreviews.g.cs b/src/libs/Picsart/Generated/Picsart.ImageEffectsClient.ImageCreateEffectPreviews.g.cs index 278ace0..a2191ad 100644 --- a/src/libs/Picsart/Generated/Picsart.ImageEffectsClient.ImageCreateEffectPreviews.g.cs +++ b/src/libs/Picsart/Generated/Picsart.ImageEffectsClient.ImageCreateEffectPreviews.g.cs @@ -102,10 +102,11 @@ partial void ProcessImageCreateEffectPreviewsResponseContent( var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/image/effects/previews", baseUri: HttpClient.BaseAddress); @@ -138,8 +139,11 @@ partial void ProcessImageCreateEffectPreviewsResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + __httpRequest.Content = __httpRequestContent; + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -181,6 +185,8 @@ partial void ProcessImageCreateEffectPreviewsResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -191,6 +197,11 @@ partial void ProcessImageCreateEffectPreviewsResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -208,6 +219,8 @@ partial void ProcessImageCreateEffectPreviewsResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -217,8 +230,7 @@ partial void ProcessImageCreateEffectPreviewsResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -227,6 +239,11 @@ partial void ProcessImageCreateEffectPreviewsResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -243,14 +260,15 @@ partial void ProcessImageCreateEffectPreviewsResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -290,6 +308,8 @@ partial void ProcessImageCreateEffectPreviewsResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -310,6 +330,8 @@ partial void ProcessImageCreateEffectPreviewsResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -833,6 +855,7 @@ partial void ProcessImageCreateEffectPreviewsResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -866,6 +889,7 @@ partial void ProcessImageCreateEffectPreviewsResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.ImageEffectsClient.ImageCreateMaskPreviews.g.cs b/src/libs/Picsart/Generated/Picsart.ImageEffectsClient.ImageCreateMaskPreviews.g.cs index db6f046..ceeebf5 100644 --- a/src/libs/Picsart/Generated/Picsart.ImageEffectsClient.ImageCreateMaskPreviews.g.cs +++ b/src/libs/Picsart/Generated/Picsart.ImageEffectsClient.ImageCreateMaskPreviews.g.cs @@ -102,10 +102,11 @@ partial void ProcessImageCreateMaskPreviewsResponseContent( var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/image/masks/previews", baseUri: HttpClient.BaseAddress); @@ -138,8 +139,11 @@ partial void ProcessImageCreateMaskPreviewsResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + __httpRequest.Content = __httpRequestContent; + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -181,6 +185,8 @@ partial void ProcessImageCreateMaskPreviewsResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -191,6 +197,11 @@ partial void ProcessImageCreateMaskPreviewsResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -208,6 +219,8 @@ partial void ProcessImageCreateMaskPreviewsResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -217,8 +230,7 @@ partial void ProcessImageCreateMaskPreviewsResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -227,6 +239,11 @@ partial void ProcessImageCreateMaskPreviewsResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -243,14 +260,15 @@ partial void ProcessImageCreateMaskPreviewsResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -290,6 +308,8 @@ partial void ProcessImageCreateMaskPreviewsResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -310,6 +330,8 @@ partial void ProcessImageCreateMaskPreviewsResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -833,6 +855,7 @@ partial void ProcessImageCreateMaskPreviewsResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -866,6 +889,7 @@ partial void ProcessImageCreateMaskPreviewsResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.ImageEffectsClient.ImageListAiEffectNames.g.cs b/src/libs/Picsart/Generated/Picsart.ImageEffectsClient.ImageListAiEffectNames.g.cs index 38c3f61..e5adb57 100644 --- a/src/libs/Picsart/Generated/Picsart.ImageEffectsClient.ImageListAiEffectNames.g.cs +++ b/src/libs/Picsart/Generated/Picsart.ImageEffectsClient.ImageListAiEffectNames.g.cs @@ -95,6 +95,7 @@ partial void ProcessImageListAiEffectNamesResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/image/effects/ai", baseUri: HttpClient.BaseAddress); @@ -167,6 +168,8 @@ partial void ProcessImageListAiEffectNamesResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -177,6 +180,11 @@ partial void ProcessImageListAiEffectNamesResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -194,6 +202,8 @@ partial void ProcessImageListAiEffectNamesResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -203,8 +213,7 @@ partial void ProcessImageListAiEffectNamesResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -213,6 +222,11 @@ partial void ProcessImageListAiEffectNamesResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -229,14 +243,15 @@ partial void ProcessImageListAiEffectNamesResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -276,6 +291,8 @@ partial void ProcessImageListAiEffectNamesResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -296,6 +313,8 @@ partial void ProcessImageListAiEffectNamesResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -819,6 +838,7 @@ partial void ProcessImageListAiEffectNamesResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -852,6 +872,7 @@ partial void ProcessImageListAiEffectNamesResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.ImageEffectsClient.ImageListEffectNames.g.cs b/src/libs/Picsart/Generated/Picsart.ImageEffectsClient.ImageListEffectNames.g.cs index 6938b1d..d677507 100644 --- a/src/libs/Picsart/Generated/Picsart.ImageEffectsClient.ImageListEffectNames.g.cs +++ b/src/libs/Picsart/Generated/Picsart.ImageEffectsClient.ImageListEffectNames.g.cs @@ -95,6 +95,7 @@ partial void ProcessImageListEffectNamesResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/image/effects", baseUri: HttpClient.BaseAddress); @@ -167,6 +168,8 @@ partial void ProcessImageListEffectNamesResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -177,6 +180,11 @@ partial void ProcessImageListEffectNamesResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -194,6 +202,8 @@ partial void ProcessImageListEffectNamesResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -203,8 +213,7 @@ partial void ProcessImageListEffectNamesResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -213,6 +222,11 @@ partial void ProcessImageListEffectNamesResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -229,14 +243,15 @@ partial void ProcessImageListEffectNamesResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -276,6 +291,8 @@ partial void ProcessImageListEffectNamesResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -296,6 +313,8 @@ partial void ProcessImageListEffectNamesResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -819,6 +838,7 @@ partial void ProcessImageListEffectNamesResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -852,6 +872,7 @@ partial void ProcessImageListEffectNamesResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.ImageEffectsClient.ImageSelectiveBlur.g.cs b/src/libs/Picsart/Generated/Picsart.ImageEffectsClient.ImageSelectiveBlur.g.cs index 67b18fc..e541806 100644 --- a/src/libs/Picsart/Generated/Picsart.ImageEffectsClient.ImageSelectiveBlur.g.cs +++ b/src/libs/Picsart/Generated/Picsart.ImageEffectsClient.ImageSelectiveBlur.g.cs @@ -102,10 +102,11 @@ partial void ProcessImageSelectiveBlurResponseContent( var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/image/selective-blur", baseUri: HttpClient.BaseAddress); @@ -138,8 +139,11 @@ partial void ProcessImageSelectiveBlurResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + __httpRequest.Content = __httpRequestContent; + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -181,6 +185,8 @@ partial void ProcessImageSelectiveBlurResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -191,6 +197,11 @@ partial void ProcessImageSelectiveBlurResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -208,6 +219,8 @@ partial void ProcessImageSelectiveBlurResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -217,8 +230,7 @@ partial void ProcessImageSelectiveBlurResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -227,6 +239,11 @@ partial void ProcessImageSelectiveBlurResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -243,14 +260,15 @@ partial void ProcessImageSelectiveBlurResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -290,6 +308,8 @@ partial void ProcessImageSelectiveBlurResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -310,6 +330,8 @@ partial void ProcessImageSelectiveBlurResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -833,6 +855,7 @@ partial void ProcessImageSelectiveBlurResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -866,6 +889,7 @@ partial void ProcessImageSelectiveBlurResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.ImageEffectsClient.ImageTransferColor.g.cs b/src/libs/Picsart/Generated/Picsart.ImageEffectsClient.ImageTransferColor.g.cs index fc2858b..b11240f 100644 --- a/src/libs/Picsart/Generated/Picsart.ImageEffectsClient.ImageTransferColor.g.cs +++ b/src/libs/Picsart/Generated/Picsart.ImageEffectsClient.ImageTransferColor.g.cs @@ -102,10 +102,11 @@ partial void ProcessImageTransferColorResponseContent( var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/image/color-transfer", baseUri: HttpClient.BaseAddress); @@ -138,8 +139,11 @@ partial void ProcessImageTransferColorResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + __httpRequest.Content = __httpRequestContent; + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -181,6 +185,8 @@ partial void ProcessImageTransferColorResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -191,6 +197,11 @@ partial void ProcessImageTransferColorResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -208,6 +219,8 @@ partial void ProcessImageTransferColorResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -217,8 +230,7 @@ partial void ProcessImageTransferColorResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -227,6 +239,11 @@ partial void ProcessImageTransferColorResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -243,14 +260,15 @@ partial void ProcessImageTransferColorResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -290,6 +308,8 @@ partial void ProcessImageTransferColorResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -310,6 +330,8 @@ partial void ProcessImageTransferColorResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -833,6 +855,7 @@ partial void ProcessImageTransferColorResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -866,6 +889,7 @@ partial void ProcessImageTransferColorResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.ImageEffectsClient.ImageTransferStyle.g.cs b/src/libs/Picsart/Generated/Picsart.ImageEffectsClient.ImageTransferStyle.g.cs index e49810f..8d41b34 100644 --- a/src/libs/Picsart/Generated/Picsart.ImageEffectsClient.ImageTransferStyle.g.cs +++ b/src/libs/Picsart/Generated/Picsart.ImageEffectsClient.ImageTransferStyle.g.cs @@ -102,10 +102,11 @@ partial void ProcessImageTransferStyleResponseContent( var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/image/styletransfer", baseUri: HttpClient.BaseAddress); @@ -138,8 +139,11 @@ partial void ProcessImageTransferStyleResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + __httpRequest.Content = __httpRequestContent; + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -181,6 +185,8 @@ partial void ProcessImageTransferStyleResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -191,6 +197,11 @@ partial void ProcessImageTransferStyleResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -208,6 +219,8 @@ partial void ProcessImageTransferStyleResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -217,8 +230,7 @@ partial void ProcessImageTransferStyleResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -227,6 +239,11 @@ partial void ProcessImageTransferStyleResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -243,14 +260,15 @@ partial void ProcessImageTransferStyleResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -290,6 +308,8 @@ partial void ProcessImageTransferStyleResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -310,6 +330,8 @@ partial void ProcessImageTransferStyleResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -833,6 +855,7 @@ partial void ProcessImageTransferStyleResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -866,6 +889,7 @@ partial void ProcessImageTransferStyleResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.ImageEffectsClient.g.cs b/src/libs/Picsart/Generated/Picsart.ImageEffectsClient.g.cs index d80e277..1d02b9e 100644 --- a/src/libs/Picsart/Generated/Picsart.ImageEffectsClient.g.cs +++ b/src/libs/Picsart/Generated/Picsart.ImageEffectsClient.g.cs @@ -72,10 +72,10 @@ public ImageEffectsClient( /// Client-wide request defaults such as headers, query parameters, retries, and timeout. /// Dispose the HttpClient when the instance is disposed. True by default. public ImageEffectsClient( - global::System.Net.Http.HttpClient? httpClient = null, - global::System.Uri? baseUri = null, - global::System.Collections.Generic.List? authorizations = null, - global::Picsart.AutoSDKClientOptions? options = null, + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Picsart.AutoSDKClientOptions? options, bool disposeHttpClient = true) { diff --git a/src/libs/Picsart/Generated/Picsart.ImagePhotoEnhancementClient.ImageFaceEnhance.g.cs b/src/libs/Picsart/Generated/Picsart.ImagePhotoEnhancementClient.ImageFaceEnhance.g.cs index aeb841c..3e0a459 100644 --- a/src/libs/Picsart/Generated/Picsart.ImagePhotoEnhancementClient.ImageFaceEnhance.g.cs +++ b/src/libs/Picsart/Generated/Picsart.ImagePhotoEnhancementClient.ImageFaceEnhance.g.cs @@ -102,10 +102,11 @@ partial void ProcessImageFaceEnhanceResponseContent( var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/image/enhance/face", baseUri: HttpClient.BaseAddress); @@ -138,8 +139,11 @@ partial void ProcessImageFaceEnhanceResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + __httpRequest.Content = __httpRequestContent; + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -181,6 +185,8 @@ partial void ProcessImageFaceEnhanceResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -191,6 +197,11 @@ partial void ProcessImageFaceEnhanceResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -208,6 +219,8 @@ partial void ProcessImageFaceEnhanceResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -217,8 +230,7 @@ partial void ProcessImageFaceEnhanceResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -227,6 +239,11 @@ partial void ProcessImageFaceEnhanceResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -243,14 +260,15 @@ partial void ProcessImageFaceEnhanceResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -290,6 +308,8 @@ partial void ProcessImageFaceEnhanceResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -310,6 +330,8 @@ partial void ProcessImageFaceEnhanceResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -833,6 +855,7 @@ partial void ProcessImageFaceEnhanceResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -866,6 +889,7 @@ partial void ProcessImageFaceEnhanceResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.ImagePhotoEnhancementClient.ImageUltraEnhance.g.cs b/src/libs/Picsart/Generated/Picsart.ImagePhotoEnhancementClient.ImageUltraEnhance.g.cs index 2da009d..3844a62 100644 --- a/src/libs/Picsart/Generated/Picsart.ImagePhotoEnhancementClient.ImageUltraEnhance.g.cs +++ b/src/libs/Picsart/Generated/Picsart.ImagePhotoEnhancementClient.ImageUltraEnhance.g.cs @@ -124,10 +124,11 @@ partial void ProcessImageUltraEnhanceResponseContent( var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/image/upscale/enhance", baseUri: HttpClient.BaseAddress); @@ -160,8 +161,11 @@ partial void ProcessImageUltraEnhanceResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + __httpRequest.Content = __httpRequestContent; + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -203,6 +207,8 @@ partial void ProcessImageUltraEnhanceResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -213,6 +219,11 @@ partial void ProcessImageUltraEnhanceResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -230,6 +241,8 @@ partial void ProcessImageUltraEnhanceResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -239,8 +252,7 @@ partial void ProcessImageUltraEnhanceResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -249,6 +261,11 @@ partial void ProcessImageUltraEnhanceResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -265,14 +282,15 @@ partial void ProcessImageUltraEnhanceResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -312,6 +330,8 @@ partial void ProcessImageUltraEnhanceResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -332,6 +352,8 @@ partial void ProcessImageUltraEnhanceResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -855,6 +877,7 @@ partial void ProcessImageUltraEnhanceResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -888,6 +911,7 @@ partial void ProcessImageUltraEnhanceResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.ImagePhotoEnhancementClient.ImageUltraUpscale.g.cs b/src/libs/Picsart/Generated/Picsart.ImagePhotoEnhancementClient.ImageUltraUpscale.g.cs index e729f53..2659b34 100644 --- a/src/libs/Picsart/Generated/Picsart.ImagePhotoEnhancementClient.ImageUltraUpscale.g.cs +++ b/src/libs/Picsart/Generated/Picsart.ImagePhotoEnhancementClient.ImageUltraUpscale.g.cs @@ -102,10 +102,11 @@ partial void ProcessImageUltraUpscaleResponseContent( var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/image/upscale/ultra", baseUri: HttpClient.BaseAddress); @@ -138,8 +139,11 @@ partial void ProcessImageUltraUpscaleResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + __httpRequest.Content = __httpRequestContent; + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -181,6 +185,8 @@ partial void ProcessImageUltraUpscaleResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -191,6 +197,11 @@ partial void ProcessImageUltraUpscaleResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -208,6 +219,8 @@ partial void ProcessImageUltraUpscaleResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -217,8 +230,7 @@ partial void ProcessImageUltraUpscaleResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -227,6 +239,11 @@ partial void ProcessImageUltraUpscaleResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -243,14 +260,15 @@ partial void ProcessImageUltraUpscaleResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -290,6 +308,8 @@ partial void ProcessImageUltraUpscaleResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -310,6 +330,8 @@ partial void ProcessImageUltraUpscaleResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -833,6 +855,7 @@ partial void ProcessImageUltraUpscaleResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -866,6 +889,7 @@ partial void ProcessImageUltraUpscaleResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.ImagePhotoEnhancementClient.ImageUltraUpscaleGetresult.g.cs b/src/libs/Picsart/Generated/Picsart.ImagePhotoEnhancementClient.ImageUltraUpscaleGetresult.g.cs index 212c0b7..9122e36 100644 --- a/src/libs/Picsart/Generated/Picsart.ImagePhotoEnhancementClient.ImageUltraUpscaleGetresult.g.cs +++ b/src/libs/Picsart/Generated/Picsart.ImagePhotoEnhancementClient.ImageUltraUpscaleGetresult.g.cs @@ -103,6 +103,7 @@ partial void ProcessImageUltraUpscaleGetresultResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: $"/image/upscale/ultra/{transactionId}", baseUri: HttpClient.BaseAddress); @@ -176,6 +177,8 @@ partial void ProcessImageUltraUpscaleGetresultResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -186,6 +189,11 @@ partial void ProcessImageUltraUpscaleGetresultResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -203,6 +211,8 @@ partial void ProcessImageUltraUpscaleGetresultResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -212,8 +222,7 @@ partial void ProcessImageUltraUpscaleGetresultResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -222,6 +231,11 @@ partial void ProcessImageUltraUpscaleGetresultResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -238,14 +252,15 @@ partial void ProcessImageUltraUpscaleGetresultResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -285,6 +300,8 @@ partial void ProcessImageUltraUpscaleGetresultResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -305,6 +322,8 @@ partial void ProcessImageUltraUpscaleGetresultResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -828,6 +847,7 @@ partial void ProcessImageUltraUpscaleGetresultResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -861,6 +881,7 @@ partial void ProcessImageUltraUpscaleGetresultResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.ImagePhotoEnhancementClient.ImageUpscale.g.cs b/src/libs/Picsart/Generated/Picsart.ImagePhotoEnhancementClient.ImageUpscale.g.cs index 1e0b5ff..164caa7 100644 --- a/src/libs/Picsart/Generated/Picsart.ImagePhotoEnhancementClient.ImageUpscale.g.cs +++ b/src/libs/Picsart/Generated/Picsart.ImagePhotoEnhancementClient.ImageUpscale.g.cs @@ -102,10 +102,11 @@ partial void ProcessImageUpscaleResponseContent( var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/image/upscale", baseUri: HttpClient.BaseAddress); @@ -138,8 +139,11 @@ partial void ProcessImageUpscaleResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + __httpRequest.Content = __httpRequestContent; + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -181,6 +185,8 @@ partial void ProcessImageUpscaleResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -191,6 +197,11 @@ partial void ProcessImageUpscaleResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -208,6 +219,8 @@ partial void ProcessImageUpscaleResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -217,8 +230,7 @@ partial void ProcessImageUpscaleResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -227,6 +239,11 @@ partial void ProcessImageUpscaleResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -243,14 +260,15 @@ partial void ProcessImageUpscaleResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -290,6 +308,8 @@ partial void ProcessImageUpscaleResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -310,6 +330,8 @@ partial void ProcessImageUpscaleResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -833,6 +855,7 @@ partial void ProcessImageUpscaleResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -866,6 +889,7 @@ partial void ProcessImageUpscaleResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.ImagePhotoEnhancementClient.g.cs b/src/libs/Picsart/Generated/Picsart.ImagePhotoEnhancementClient.g.cs index a9979b9..c4488e7 100644 --- a/src/libs/Picsart/Generated/Picsart.ImagePhotoEnhancementClient.g.cs +++ b/src/libs/Picsart/Generated/Picsart.ImagePhotoEnhancementClient.g.cs @@ -72,10 +72,10 @@ public ImagePhotoEnhancementClient( /// Client-wide request defaults such as headers, query parameters, retries, and timeout. /// Dispose the HttpClient when the instance is disposed. True by default. public ImagePhotoEnhancementClient( - global::System.Net.Http.HttpClient? httpClient = null, - global::System.Uri? baseUri = null, - global::System.Collections.Generic.List? authorizations = null, - global::Picsart.AutoSDKClientOptions? options = null, + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Picsart.AutoSDKClientOptions? options, bool disposeHttpClient = true) { diff --git a/src/libs/Picsart/Generated/Picsart.ImageRemoveBackgroundClient.ImageRemoveBackground.g.cs b/src/libs/Picsart/Generated/Picsart.ImageRemoveBackgroundClient.ImageRemoveBackground.g.cs index 8a2cf91..f1d6ed1 100644 --- a/src/libs/Picsart/Generated/Picsart.ImageRemoveBackgroundClient.ImageRemoveBackground.g.cs +++ b/src/libs/Picsart/Generated/Picsart.ImageRemoveBackgroundClient.ImageRemoveBackground.g.cs @@ -102,10 +102,11 @@ partial void ProcessImageRemoveBackgroundResponseContent( var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/image/removebg", baseUri: HttpClient.BaseAddress); @@ -138,8 +139,11 @@ partial void ProcessImageRemoveBackgroundResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + __httpRequest.Content = __httpRequestContent; + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -181,6 +185,8 @@ partial void ProcessImageRemoveBackgroundResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -191,6 +197,11 @@ partial void ProcessImageRemoveBackgroundResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -208,6 +219,8 @@ partial void ProcessImageRemoveBackgroundResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -217,8 +230,7 @@ partial void ProcessImageRemoveBackgroundResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -227,6 +239,11 @@ partial void ProcessImageRemoveBackgroundResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -243,14 +260,15 @@ partial void ProcessImageRemoveBackgroundResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -290,6 +308,8 @@ partial void ProcessImageRemoveBackgroundResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -310,6 +330,8 @@ partial void ProcessImageRemoveBackgroundResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -833,6 +855,7 @@ partial void ProcessImageRemoveBackgroundResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -866,6 +889,7 @@ partial void ProcessImageRemoveBackgroundResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.ImageRemoveBackgroundClient.g.cs b/src/libs/Picsart/Generated/Picsart.ImageRemoveBackgroundClient.g.cs index fb1ebf9..1898b12 100644 --- a/src/libs/Picsart/Generated/Picsart.ImageRemoveBackgroundClient.g.cs +++ b/src/libs/Picsart/Generated/Picsart.ImageRemoveBackgroundClient.g.cs @@ -72,10 +72,10 @@ public ImageRemoveBackgroundClient( /// Client-wide request defaults such as headers, query parameters, retries, and timeout. /// Dispose the HttpClient when the instance is disposed. True by default. public ImageRemoveBackgroundClient( - global::System.Net.Http.HttpClient? httpClient = null, - global::System.Uri? baseUri = null, - global::System.Collections.Generic.List? authorizations = null, - global::Picsart.AutoSDKClientOptions? options = null, + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Picsart.AutoSDKClientOptions? options, bool disposeHttpClient = true) { diff --git a/src/libs/Picsart/Generated/Picsart.ImageSurfacemapClient.ImageSurfacemap.g.cs b/src/libs/Picsart/Generated/Picsart.ImageSurfacemapClient.ImageSurfacemap.g.cs index 736c120..0653589 100644 --- a/src/libs/Picsart/Generated/Picsart.ImageSurfacemapClient.ImageSurfacemap.g.cs +++ b/src/libs/Picsart/Generated/Picsart.ImageSurfacemapClient.ImageSurfacemap.g.cs @@ -102,10 +102,11 @@ partial void ProcessImageSurfacemapResponseContent( var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/image/surfacemap", baseUri: HttpClient.BaseAddress); @@ -138,8 +139,11 @@ partial void ProcessImageSurfacemapResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + __httpRequest.Content = __httpRequestContent; + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -181,6 +185,8 @@ partial void ProcessImageSurfacemapResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -191,6 +197,11 @@ partial void ProcessImageSurfacemapResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -208,6 +219,8 @@ partial void ProcessImageSurfacemapResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -217,8 +230,7 @@ partial void ProcessImageSurfacemapResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -227,6 +239,11 @@ partial void ProcessImageSurfacemapResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -243,14 +260,15 @@ partial void ProcessImageSurfacemapResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -290,6 +308,8 @@ partial void ProcessImageSurfacemapResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -310,6 +330,8 @@ partial void ProcessImageSurfacemapResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -833,6 +855,7 @@ partial void ProcessImageSurfacemapResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -866,6 +889,7 @@ partial void ProcessImageSurfacemapResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.ImageSurfacemapClient.g.cs b/src/libs/Picsart/Generated/Picsart.ImageSurfacemapClient.g.cs index e22eaeb..516e538 100644 --- a/src/libs/Picsart/Generated/Picsart.ImageSurfacemapClient.g.cs +++ b/src/libs/Picsart/Generated/Picsart.ImageSurfacemapClient.g.cs @@ -72,10 +72,10 @@ public ImageSurfacemapClient( /// Client-wide request defaults such as headers, query parameters, retries, and timeout. /// Dispose the HttpClient when the instance is disposed. True by default. public ImageSurfacemapClient( - global::System.Net.Http.HttpClient? httpClient = null, - global::System.Uri? baseUri = null, - global::System.Collections.Generic.List? authorizations = null, - global::Picsart.AutoSDKClientOptions? options = null, + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Picsart.AutoSDKClientOptions? options, bool disposeHttpClient = true) { diff --git a/src/libs/Picsart/Generated/Picsart.ImageUtilitiesClient.ImageCreditsBalance.g.cs b/src/libs/Picsart/Generated/Picsart.ImageUtilitiesClient.ImageCreditsBalance.g.cs index ae260c7..afc2a56 100644 --- a/src/libs/Picsart/Generated/Picsart.ImageUtilitiesClient.ImageCreditsBalance.g.cs +++ b/src/libs/Picsart/Generated/Picsart.ImageUtilitiesClient.ImageCreditsBalance.g.cs @@ -95,6 +95,7 @@ partial void ProcessImageCreditsBalanceResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/image/balance", baseUri: HttpClient.BaseAddress); @@ -167,6 +168,8 @@ partial void ProcessImageCreditsBalanceResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -177,6 +180,11 @@ partial void ProcessImageCreditsBalanceResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -194,6 +202,8 @@ partial void ProcessImageCreditsBalanceResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -203,8 +213,7 @@ partial void ProcessImageCreditsBalanceResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -213,6 +222,11 @@ partial void ProcessImageCreditsBalanceResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -229,14 +243,15 @@ partial void ProcessImageCreditsBalanceResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -276,6 +291,8 @@ partial void ProcessImageCreditsBalanceResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -296,6 +313,8 @@ partial void ProcessImageCreditsBalanceResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -819,6 +838,7 @@ partial void ProcessImageCreditsBalanceResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -852,6 +872,7 @@ partial void ProcessImageCreditsBalanceResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.ImageUtilitiesClient.ImageUpload.g.cs b/src/libs/Picsart/Generated/Picsart.ImageUtilitiesClient.ImageUpload.g.cs index 2fd63d1..3f7139c 100644 --- a/src/libs/Picsart/Generated/Picsart.ImageUtilitiesClient.ImageUpload.g.cs +++ b/src/libs/Picsart/Generated/Picsart.ImageUtilitiesClient.ImageUpload.g.cs @@ -114,10 +114,11 @@ partial void ProcessImageUploadResponseContent( var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/image/upload", baseUri: HttpClient.BaseAddress); @@ -150,6 +151,7 @@ partial void ProcessImageUploadResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); if (request.Image != default) { @@ -191,15 +193,19 @@ request.Imagename is null { __contentImage.Headers.ContentDisposition.FileNameStar = null; } - } + + } if (request.ImageUrl != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.ImageUrl ?? string.Empty), name: "\"image_url\""); + } + __httpRequest.Content = __httpRequestContent; + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -241,6 +247,8 @@ request.Imagename is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -251,6 +259,11 @@ request.Imagename is null } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -268,6 +281,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) { @@ -277,8 +292,7 @@ request.Imagename is null __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -287,6 +301,11 @@ request.Imagename is null __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -303,14 +322,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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -350,6 +370,8 @@ request.Imagename is null attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -370,6 +392,8 @@ request.Imagename is null attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -893,6 +917,7 @@ request.Imagename is null return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -926,6 +951,7 @@ request.Imagename is null return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -1004,5 +1030,1868 @@ request.Imagename is null requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } + + /// + /// Upload Image
+ /// The *upload* service is used to upload an image when you want to apply several transformations to it.
+ /// By uploading an image first, you'll receive a transaction_id which you can use repeatedly for transformations and thereby avoid having to upload an image for each and every one.
+ /// If you're sure you only want to do a single transformation to an image, there's no benefit to using this service. Just jump right to that service.
+ /// **Limitations:** Supported source image formats are JPG, PNG, TIFF and WEBP.
+ /// **Source Image:**
+ /// You can source the image by providing a file or a URL to an online image. + ///
+ /// + /// Source image file (binary). (If this parameter is present, the other image source parameters must be empty.) + /// + /// + /// Source image file (binary). (If this parameter is present, the other image source parameters must be empty.) + /// + /// + /// Source image URL. (If this parameter is present, the other image source parameters must be empty.) + /// + /// 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 ImageUploadAsync( + global::System.IO.Stream? image = default, + string? imagename = default, + string? imageUrl = default, + global::Picsart.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + var request = new global::Picsart.ImageUploadParameters + { + Image = global::System.Array.Empty(), + Imagename = imagename, + ImageUrl = imageUrl, + }; + PrepareArguments( + client: HttpClient); + PrepareImageUploadArguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::Picsart.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_ImageUploadSecurityRequirements, + operationName: "ImageUploadAsync"); + + using var __timeoutCancellationTokenSource = global::Picsart.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Picsart.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Picsart.PathBuilder( + path: "/image/upload", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Picsart.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 (image != default) + { + + 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.ImageUrl != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.ImageUrl ?? string.Empty), + name: "\"image_url\""); + + } + + __httpRequest.Content = __httpRequestContent; + + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareImageUploadRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + 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::Picsart.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageUpload", + methodName: "ImageUploadAsync", + pathTemplate: "\"/image/upload\"", + 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::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageUpload", + methodName: "ImageUploadAsync", + pathTemplate: "\"/image/upload\"", + 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageUpload", + methodName: "ImageUploadAsync", + pathTemplate: "\"/image/upload\"", + 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::Picsart.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); + ProcessImageUploadResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageUpload", + methodName: "ImageUploadAsync", + pathTemplate: "\"/image/upload\"", + 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::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageUpload", + methodName: "ImageUploadAsync", + pathTemplate: "\"/image/upload\"", + 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); + } + // Bad Request + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + global::Picsart.ImageError? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = global::Picsart.ImageError.FromJson(__content_400, JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_400 = global::Picsart.ImageError.FromJson(__content_400, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseObject = __value_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unauthorized + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + global::Picsart.Image401Error? __value_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_401 = global::Picsart.Image401Error.FromJson(__content_401, JsonSerializerContext); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_401 = global::Picsart.Image401Error.FromJson(__content_401, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseObject = __value_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Payment Required + if ((int)__response.StatusCode == 402) + { + string? __content_402 = null; + global::System.Exception? __exception_402 = null; + global::Picsart.ImageError? __value_402 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_402 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_402 = global::Picsart.ImageError.FromJson(__content_402, JsonSerializerContext); + } + else + { + __content_402 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_402 = global::Picsart.ImageError.FromJson(__content_402, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_402 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_402 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_402, + statusCode: __response.StatusCode) + { + ResponseBody = __content_402, + ResponseObject = __value_402, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Forbidden + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + global::Picsart.ImageError? __value_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_403 = global::Picsart.ImageError.FromJson(__content_403, JsonSerializerContext); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_403 = global::Picsart.ImageError.FromJson(__content_403, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + statusCode: __response.StatusCode) + { + ResponseBody = __content_403, + ResponseObject = __value_403, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Not Found + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + global::Picsart.ImageError? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = global::Picsart.ImageError.FromJson(__content_404, JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_404 = global::Picsart.ImageError.FromJson(__content_404, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + statusCode: __response.StatusCode) + { + ResponseBody = __content_404, + ResponseObject = __value_404, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Method Not Allowed + if ((int)__response.StatusCode == 405) + { + string? __content_405 = null; + global::System.Exception? __exception_405 = null; + global::Picsart.ImageError? __value_405 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_405 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_405 = global::Picsart.ImageError.FromJson(__content_405, JsonSerializerContext); + } + else + { + __content_405 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_405 = global::Picsart.ImageError.FromJson(__content_405, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_405 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_405 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_405, + statusCode: __response.StatusCode) + { + ResponseBody = __content_405, + ResponseObject = __value_405, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Request Entity Too Large + if ((int)__response.StatusCode == 413) + { + string? __content_413 = null; + global::System.Exception? __exception_413 = null; + global::Picsart.ImageError? __value_413 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_413 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_413 = global::Picsart.ImageError.FromJson(__content_413, JsonSerializerContext); + } + else + { + __content_413 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_413 = global::Picsart.ImageError.FromJson(__content_413, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_413 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_413 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_413, + statusCode: __response.StatusCode) + { + ResponseBody = __content_413, + ResponseObject = __value_413, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unsupported Media Type + if ((int)__response.StatusCode == 415) + { + string? __content_415 = null; + global::System.Exception? __exception_415 = null; + global::Picsart.ImageError? __value_415 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_415 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_415 = global::Picsart.ImageError.FromJson(__content_415, JsonSerializerContext); + } + else + { + __content_415 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_415 = global::Picsart.ImageError.FromJson(__content_415, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_415 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_415 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_415, + statusCode: __response.StatusCode) + { + ResponseBody = __content_415, + ResponseObject = __value_415, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unprocessable Entity + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Picsart.ImageError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Picsart.ImageError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_422 = global::Picsart.ImageError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Too Many Requests + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + global::Picsart.ImageError? __value_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_429 = global::Picsart.ImageError.FromJson(__content_429, JsonSerializerContext); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_429 = global::Picsart.ImageError.FromJson(__content_429, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + statusCode: __response.StatusCode) + { + ResponseBody = __content_429, + ResponseObject = __value_429, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Request Header Fields Too Large + if ((int)__response.StatusCode == 431) + { + string? __content_431 = null; + global::System.Exception? __exception_431 = null; + global::Picsart.ImageError? __value_431 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_431 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_431 = global::Picsart.ImageError.FromJson(__content_431, JsonSerializerContext); + } + else + { + __content_431 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_431 = global::Picsart.ImageError.FromJson(__content_431, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_431 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_431 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_431, + statusCode: __response.StatusCode) + { + ResponseBody = __content_431, + ResponseObject = __value_431, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Internal Server Error + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + global::Picsart.ImageError? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = global::Picsart.ImageError.FromJson(__content_500, JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_500 = global::Picsart.ImageError.FromJson(__content_500, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Service Unavailable + if ((int)__response.StatusCode == 503) + { + string? __content_503 = null; + global::System.Exception? __exception_503 = null; + global::Picsart.ImageError? __value_503 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_503 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_503 = global::Picsart.ImageError.FromJson(__content_503, JsonSerializerContext); + } + else + { + __content_503 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_503 = global::Picsart.ImageError.FromJson(__content_503, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_503 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_503 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_503, + statusCode: __response.StatusCode) + { + ResponseBody = __content_503, + ResponseObject = __value_503, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessImageUploadResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Picsart.ImageUploadResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Picsart.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::Picsart.ImageUploadResponse.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::Picsart.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(); + } + } + /// + /// Upload Image
+ /// The *upload* service is used to upload an image when you want to apply several transformations to it.
+ /// By uploading an image first, you'll receive a transaction_id which you can use repeatedly for transformations and thereby avoid having to upload an image for each and every one.
+ /// If you're sure you only want to do a single transformation to an image, there's no benefit to using this service. Just jump right to that service.
+ /// **Limitations:** Supported source image formats are JPG, PNG, TIFF and WEBP.
+ /// **Source Image:**
+ /// You can source the image by providing a file or a URL to an online image. + ///
+ /// + /// Source image file (binary). (If this parameter is present, the other image source parameters must be empty.) + /// + /// + /// Source image file (binary). (If this parameter is present, the other image source parameters must be empty.) + /// + /// + /// Source image URL. (If this parameter is present, the other image source parameters must be empty.) + /// + /// 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> ImageUploadAsResponseAsync( + global::System.IO.Stream? image = default, + string? imagename = default, + string? imageUrl = default, + global::Picsart.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + var request = new global::Picsart.ImageUploadParameters + { + Image = global::System.Array.Empty(), + Imagename = imagename, + ImageUrl = imageUrl, + }; + PrepareArguments( + client: HttpClient); + PrepareImageUploadArguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::Picsart.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_ImageUploadSecurityRequirements, + operationName: "ImageUploadAsync"); + + using var __timeoutCancellationTokenSource = global::Picsart.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Picsart.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Picsart.PathBuilder( + path: "/image/upload", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Picsart.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 (image != default) + { + + 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.ImageUrl != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.ImageUrl ?? string.Empty), + name: "\"image_url\""); + + } + + __httpRequest.Content = __httpRequestContent; + + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareImageUploadRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + 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::Picsart.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageUpload", + methodName: "ImageUploadAsync", + pathTemplate: "\"/image/upload\"", + 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::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageUpload", + methodName: "ImageUploadAsync", + pathTemplate: "\"/image/upload\"", + 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageUpload", + methodName: "ImageUploadAsync", + pathTemplate: "\"/image/upload\"", + 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::Picsart.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); + ProcessImageUploadResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageUpload", + methodName: "ImageUploadAsync", + pathTemplate: "\"/image/upload\"", + 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::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImageUpload", + methodName: "ImageUploadAsync", + pathTemplate: "\"/image/upload\"", + 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); + } + // Bad Request + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + global::Picsart.ImageError? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = global::Picsart.ImageError.FromJson(__content_400, JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_400 = global::Picsart.ImageError.FromJson(__content_400, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseObject = __value_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unauthorized + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + global::Picsart.Image401Error? __value_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_401 = global::Picsart.Image401Error.FromJson(__content_401, JsonSerializerContext); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_401 = global::Picsart.Image401Error.FromJson(__content_401, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseObject = __value_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Payment Required + if ((int)__response.StatusCode == 402) + { + string? __content_402 = null; + global::System.Exception? __exception_402 = null; + global::Picsart.ImageError? __value_402 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_402 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_402 = global::Picsart.ImageError.FromJson(__content_402, JsonSerializerContext); + } + else + { + __content_402 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_402 = global::Picsart.ImageError.FromJson(__content_402, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_402 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_402 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_402, + statusCode: __response.StatusCode) + { + ResponseBody = __content_402, + ResponseObject = __value_402, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Forbidden + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + global::Picsart.ImageError? __value_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_403 = global::Picsart.ImageError.FromJson(__content_403, JsonSerializerContext); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_403 = global::Picsart.ImageError.FromJson(__content_403, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + statusCode: __response.StatusCode) + { + ResponseBody = __content_403, + ResponseObject = __value_403, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Not Found + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + global::Picsart.ImageError? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = global::Picsart.ImageError.FromJson(__content_404, JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_404 = global::Picsart.ImageError.FromJson(__content_404, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + statusCode: __response.StatusCode) + { + ResponseBody = __content_404, + ResponseObject = __value_404, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Method Not Allowed + if ((int)__response.StatusCode == 405) + { + string? __content_405 = null; + global::System.Exception? __exception_405 = null; + global::Picsart.ImageError? __value_405 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_405 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_405 = global::Picsart.ImageError.FromJson(__content_405, JsonSerializerContext); + } + else + { + __content_405 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_405 = global::Picsart.ImageError.FromJson(__content_405, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_405 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_405 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_405, + statusCode: __response.StatusCode) + { + ResponseBody = __content_405, + ResponseObject = __value_405, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Request Entity Too Large + if ((int)__response.StatusCode == 413) + { + string? __content_413 = null; + global::System.Exception? __exception_413 = null; + global::Picsart.ImageError? __value_413 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_413 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_413 = global::Picsart.ImageError.FromJson(__content_413, JsonSerializerContext); + } + else + { + __content_413 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_413 = global::Picsart.ImageError.FromJson(__content_413, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_413 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_413 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_413, + statusCode: __response.StatusCode) + { + ResponseBody = __content_413, + ResponseObject = __value_413, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unsupported Media Type + if ((int)__response.StatusCode == 415) + { + string? __content_415 = null; + global::System.Exception? __exception_415 = null; + global::Picsart.ImageError? __value_415 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_415 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_415 = global::Picsart.ImageError.FromJson(__content_415, JsonSerializerContext); + } + else + { + __content_415 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_415 = global::Picsart.ImageError.FromJson(__content_415, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_415 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_415 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_415, + statusCode: __response.StatusCode) + { + ResponseBody = __content_415, + ResponseObject = __value_415, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unprocessable Entity + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Picsart.ImageError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Picsart.ImageError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_422 = global::Picsart.ImageError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Too Many Requests + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + global::Picsart.ImageError? __value_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_429 = global::Picsart.ImageError.FromJson(__content_429, JsonSerializerContext); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_429 = global::Picsart.ImageError.FromJson(__content_429, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + statusCode: __response.StatusCode) + { + ResponseBody = __content_429, + ResponseObject = __value_429, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Request Header Fields Too Large + if ((int)__response.StatusCode == 431) + { + string? __content_431 = null; + global::System.Exception? __exception_431 = null; + global::Picsart.ImageError? __value_431 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_431 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_431 = global::Picsart.ImageError.FromJson(__content_431, JsonSerializerContext); + } + else + { + __content_431 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_431 = global::Picsart.ImageError.FromJson(__content_431, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_431 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_431 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_431, + statusCode: __response.StatusCode) + { + ResponseBody = __content_431, + ResponseObject = __value_431, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Internal Server Error + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + global::Picsart.ImageError? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = global::Picsart.ImageError.FromJson(__content_500, JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_500 = global::Picsart.ImageError.FromJson(__content_500, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Service Unavailable + if ((int)__response.StatusCode == 503) + { + string? __content_503 = null; + global::System.Exception? __exception_503 = null; + global::Picsart.ImageError? __value_503 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_503 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_503 = global::Picsart.ImageError.FromJson(__content_503, JsonSerializerContext); + } + else + { + __content_503 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_503 = global::Picsart.ImageError.FromJson(__content_503, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_503 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_503 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_503, + statusCode: __response.StatusCode) + { + ResponseBody = __content_503, + ResponseObject = __value_503, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessImageUploadResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Picsart.ImageUploadResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Picsart.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Picsart.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::Picsart.ImageUploadResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Picsart.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Picsart.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::Picsart.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/Picsart/Generated/Picsart.ImageUtilitiesClient.g.cs b/src/libs/Picsart/Generated/Picsart.ImageUtilitiesClient.g.cs index 07de8d5..62d0ef0 100644 --- a/src/libs/Picsart/Generated/Picsart.ImageUtilitiesClient.g.cs +++ b/src/libs/Picsart/Generated/Picsart.ImageUtilitiesClient.g.cs @@ -72,10 +72,10 @@ public ImageUtilitiesClient( /// Client-wide request defaults such as headers, query parameters, retries, and timeout. /// Dispose the HttpClient when the instance is disposed. True by default. public ImageUtilitiesClient( - global::System.Net.Http.HttpClient? httpClient = null, - global::System.Uri? baseUri = null, - global::System.Collections.Generic.List? authorizations = null, - global::Picsart.AutoSDKClientOptions? options = null, + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Picsart.AutoSDKClientOptions? options, bool disposeHttpClient = true) { diff --git a/src/libs/Picsart/Generated/Picsart.ImageWatermarkClient.ImageAddWatermark.g.cs b/src/libs/Picsart/Generated/Picsart.ImageWatermarkClient.ImageAddWatermark.g.cs index c22d3af..524363c 100644 --- a/src/libs/Picsart/Generated/Picsart.ImageWatermarkClient.ImageAddWatermark.g.cs +++ b/src/libs/Picsart/Generated/Picsart.ImageWatermarkClient.ImageAddWatermark.g.cs @@ -102,10 +102,11 @@ partial void ProcessImageAddWatermarkResponseContent( var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/image/watermark", baseUri: HttpClient.BaseAddress); @@ -138,8 +139,11 @@ partial void ProcessImageAddWatermarkResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + __httpRequest.Content = __httpRequestContent; + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -181,6 +185,8 @@ partial void ProcessImageAddWatermarkResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -191,6 +197,11 @@ partial void ProcessImageAddWatermarkResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -208,6 +219,8 @@ partial void ProcessImageAddWatermarkResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -217,8 +230,7 @@ partial void ProcessImageAddWatermarkResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -227,6 +239,11 @@ partial void ProcessImageAddWatermarkResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -243,14 +260,15 @@ partial void ProcessImageAddWatermarkResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -290,6 +308,8 @@ partial void ProcessImageAddWatermarkResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -310,6 +330,8 @@ partial void ProcessImageAddWatermarkResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -795,6 +817,7 @@ partial void ProcessImageAddWatermarkResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -828,6 +851,7 @@ partial void ProcessImageAddWatermarkResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.ImageWatermarkClient.g.cs b/src/libs/Picsart/Generated/Picsart.ImageWatermarkClient.g.cs index 44c8e64..9abe2d7 100644 --- a/src/libs/Picsart/Generated/Picsart.ImageWatermarkClient.g.cs +++ b/src/libs/Picsart/Generated/Picsart.ImageWatermarkClient.g.cs @@ -72,10 +72,10 @@ public ImageWatermarkClient( /// Client-wide request defaults such as headers, query parameters, retries, and timeout. /// Dispose the HttpClient when the instance is disposed. True by default. public ImageWatermarkClient( - global::System.Net.Http.HttpClient? httpClient = null, - global::System.Uri? baseUri = null, - global::System.Collections.Generic.List? authorizations = null, - global::Picsart.AutoSDKClientOptions? options = null, + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Picsart.AutoSDKClientOptions? options, bool disposeHttpClient = true) { diff --git a/src/libs/Picsart/Generated/Picsart.OptionsSupport.g.cs b/src/libs/Picsart/Generated/Picsart.OptionsSupport.g.cs index 855b27d..4bfbeee 100644 --- a/src/libs/Picsart/Generated/Picsart.OptionsSupport.g.cs +++ b/src/libs/Picsart/Generated/Picsart.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::Picsart.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::Picsart.AutoSDKClientOptions clientOptions, global::Picsart.AutoSDKRequestOptions? requestOptions, + global::System.Net.Http.HttpResponseMessage? response, + int attempt) + { + var retryOptions = requestOptions?.Retry ?? clientOptions.Retry ?? new global::Picsart.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::Picsart.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/Picsart/Generated/Picsart.PicsartClient.g.cs b/src/libs/Picsart/Generated/Picsart.PicsartClient.g.cs index 75f91e4..e293514 100644 --- a/src/libs/Picsart/Generated/Picsart.PicsartClient.g.cs +++ b/src/libs/Picsart/Generated/Picsart.PicsartClient.g.cs @@ -45,7 +45,7 @@ public sealed partial class PicsartClient : global::Picsart.IPicsartClient, glob /// /// /// - public GenAIInpaintingImage2ImageClient GenAIInpaintingImage2Image => new GenAIInpaintingImage2ImageClient(HttpClient, authorizations: Authorizations, options: Options) + public GenAIInpaintingImage2ImageClient GenAIInpaintingImage2Image => new GenAIInpaintingImage2ImageClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -54,7 +54,7 @@ public sealed partial class PicsartClient : global::Picsart.IPicsartClient, glob /// /// /// - public GenAIText2AudioClient GenAIText2Audio => new GenAIText2AudioClient(HttpClient, authorizations: Authorizations, options: Options) + public GenAIText2AudioClient GenAIText2Audio => new GenAIText2AudioClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -63,7 +63,7 @@ public sealed partial class PicsartClient : global::Picsart.IPicsartClient, glob /// /// /// - public GenAIText2ImageClient GenAIText2Image => new GenAIText2ImageClient(HttpClient, authorizations: Authorizations, options: Options) + public GenAIText2ImageClient GenAIText2Image => new GenAIText2ImageClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -72,7 +72,7 @@ public sealed partial class PicsartClient : global::Picsart.IPicsartClient, glob /// /// /// - public GenAIText2TextClient GenAIText2Text => new GenAIText2TextClient(HttpClient, authorizations: Authorizations, options: Options) + public GenAIText2TextClient GenAIText2Text => new GenAIText2TextClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -81,7 +81,7 @@ public sealed partial class PicsartClient : global::Picsart.IPicsartClient, glob /// /// /// - public GenAIText2VideoImage2VideoClient GenAIText2VideoImage2Video => new GenAIText2VideoImage2VideoClient(HttpClient, authorizations: Authorizations, options: Options) + public GenAIText2VideoImage2VideoClient GenAIText2VideoImage2Video => new GenAIText2VideoImage2VideoClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -90,7 +90,7 @@ public sealed partial class PicsartClient : global::Picsart.IPicsartClient, glob /// /// /// - public GenAIUtilitiesClient GenAIUtilities => new GenAIUtilitiesClient(HttpClient, authorizations: Authorizations, options: Options) + public GenAIUtilitiesClient GenAIUtilities => new GenAIUtilitiesClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -99,7 +99,7 @@ public sealed partial class PicsartClient : global::Picsart.IPicsartClient, glob /// /// /// - public ImageClassificationClient ImageClassification => new ImageClassificationClient(HttpClient, authorizations: Authorizations, options: Options) + public ImageClassificationClient ImageClassification => new ImageClassificationClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -108,7 +108,7 @@ public sealed partial class PicsartClient : global::Picsart.IPicsartClient, glob /// /// /// - public ImageContentGenerationClient ImageContentGeneration => new ImageContentGenerationClient(HttpClient, authorizations: Authorizations, options: Options) + public ImageContentGenerationClient ImageContentGeneration => new ImageContentGenerationClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -117,7 +117,7 @@ public sealed partial class PicsartClient : global::Picsart.IPicsartClient, glob /// /// /// - public ImageConversionClient ImageConversion => new ImageConversionClient(HttpClient, authorizations: Authorizations, options: Options) + public ImageConversionClient ImageConversion => new ImageConversionClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -126,7 +126,7 @@ public sealed partial class PicsartClient : global::Picsart.IPicsartClient, glob /// /// /// - public ImageEditingClient ImageEditing => new ImageEditingClient(HttpClient, authorizations: Authorizations, options: Options) + public ImageEditingClient ImageEditing => new ImageEditingClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -135,7 +135,7 @@ public sealed partial class PicsartClient : global::Picsart.IPicsartClient, glob /// /// /// - public ImageEffectsClient ImageEffects => new ImageEffectsClient(HttpClient, authorizations: Authorizations, options: Options) + public ImageEffectsClient ImageEffects => new ImageEffectsClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -144,7 +144,7 @@ public sealed partial class PicsartClient : global::Picsart.IPicsartClient, glob /// /// /// - public ImagePhotoEnhancementClient ImagePhotoEnhancement => new ImagePhotoEnhancementClient(HttpClient, authorizations: Authorizations, options: Options) + public ImagePhotoEnhancementClient ImagePhotoEnhancement => new ImagePhotoEnhancementClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -153,7 +153,7 @@ public sealed partial class PicsartClient : global::Picsart.IPicsartClient, glob /// /// /// - public ImageRemoveBackgroundClient ImageRemoveBackground => new ImageRemoveBackgroundClient(HttpClient, authorizations: Authorizations, options: Options) + public ImageRemoveBackgroundClient ImageRemoveBackground => new ImageRemoveBackgroundClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -162,7 +162,7 @@ public sealed partial class PicsartClient : global::Picsart.IPicsartClient, glob /// /// /// - public ImageSurfacemapClient ImageSurfacemap => new ImageSurfacemapClient(HttpClient, authorizations: Authorizations, options: Options) + public ImageSurfacemapClient ImageSurfacemap => new ImageSurfacemapClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -171,7 +171,7 @@ public sealed partial class PicsartClient : global::Picsart.IPicsartClient, glob /// /// /// - public ImageUtilitiesClient ImageUtilities => new ImageUtilitiesClient(HttpClient, authorizations: Authorizations, options: Options) + public ImageUtilitiesClient ImageUtilities => new ImageUtilitiesClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -180,7 +180,7 @@ public sealed partial class PicsartClient : global::Picsart.IPicsartClient, glob /// /// /// - public ImageWatermarkClient ImageWatermark => new ImageWatermarkClient(HttpClient, authorizations: Authorizations, options: Options) + public ImageWatermarkClient ImageWatermark => new ImageWatermarkClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -189,7 +189,7 @@ public sealed partial class PicsartClient : global::Picsart.IPicsartClient, glob /// /// /// - public VdReplayClient VdReplay => new VdReplayClient(HttpClient, authorizations: Authorizations, options: Options) + public VdReplayClient VdReplay => new VdReplayClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -198,7 +198,7 @@ public sealed partial class PicsartClient : global::Picsart.IPicsartClient, glob /// /// /// - public VdUtilitiesClient VdUtilities => new VdUtilitiesClient(HttpClient, authorizations: Authorizations, options: Options) + public VdUtilitiesClient VdUtilities => new VdUtilitiesClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -207,7 +207,7 @@ public sealed partial class PicsartClient : global::Picsart.IPicsartClient, glob /// /// /// - public VdVariableDataContentClient VdVariableDataContent => new VdVariableDataContentClient(HttpClient, authorizations: Authorizations, options: Options) + public VdVariableDataContentClient VdVariableDataContent => new VdVariableDataContentClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -216,7 +216,7 @@ public sealed partial class PicsartClient : global::Picsart.IPicsartClient, glob /// /// /// - public VideoAdsClient VideoAds => new VideoAdsClient(HttpClient, authorizations: Authorizations, options: Options) + public VideoAdsClient VideoAds => new VideoAdsClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -225,7 +225,7 @@ public sealed partial class PicsartClient : global::Picsart.IPicsartClient, glob /// /// /// - public VideoAudioClient VideoAudio => new VideoAudioClient(HttpClient, authorizations: Authorizations, options: Options) + public VideoAudioClient VideoAudio => new VideoAudioClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -234,7 +234,7 @@ public sealed partial class PicsartClient : global::Picsart.IPicsartClient, glob /// /// /// - public VideoEditClient VideoEdit => new VideoEditClient(HttpClient, authorizations: Authorizations, options: Options) + public VideoEditClient VideoEdit => new VideoEditClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -243,7 +243,7 @@ public sealed partial class PicsartClient : global::Picsart.IPicsartClient, glob /// /// /// - public VideoEffectsClient VideoEffects => new VideoEffectsClient(HttpClient, authorizations: Authorizations, options: Options) + public VideoEffectsClient VideoEffects => new VideoEffectsClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -252,7 +252,7 @@ public sealed partial class PicsartClient : global::Picsart.IPicsartClient, glob /// /// /// - public VideoMetadataClient VideoMetadata => new VideoMetadataClient(HttpClient, authorizations: Authorizations, options: Options) + public VideoMetadataClient VideoMetadata => new VideoMetadataClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -261,7 +261,7 @@ public sealed partial class PicsartClient : global::Picsart.IPicsartClient, glob /// /// /// - public VideoRemoveBackgroundClient VideoRemoveBackground => new VideoRemoveBackgroundClient(HttpClient, authorizations: Authorizations, options: Options) + public VideoRemoveBackgroundClient VideoRemoveBackground => new VideoRemoveBackgroundClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -270,7 +270,7 @@ public sealed partial class PicsartClient : global::Picsart.IPicsartClient, glob /// /// /// - public VideoTranscriptionsClient VideoTranscriptions => new VideoTranscriptionsClient(HttpClient, authorizations: Authorizations, options: Options) + public VideoTranscriptionsClient VideoTranscriptions => new VideoTranscriptionsClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -279,7 +279,7 @@ public sealed partial class PicsartClient : global::Picsart.IPicsartClient, glob /// /// /// - public VideoUtilitiesClient VideoUtilities => new VideoUtilitiesClient(HttpClient, authorizations: Authorizations, options: Options) + public VideoUtilitiesClient VideoUtilities => new VideoUtilitiesClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -288,7 +288,7 @@ public sealed partial class PicsartClient : global::Picsart.IPicsartClient, glob /// /// /// - public VideoVideoEnhancementClient VideoVideoEnhancement => new VideoVideoEnhancementClient(HttpClient, authorizations: Authorizations, options: Options) + public VideoVideoEnhancementClient VideoVideoEnhancement => new VideoVideoEnhancementClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -297,7 +297,7 @@ public sealed partial class PicsartClient : global::Picsart.IPicsartClient, glob /// /// /// - public VideoWatermarkClient VideoWatermark => new VideoWatermarkClient(HttpClient, authorizations: Authorizations, options: Options) + public VideoWatermarkClient VideoWatermark => new VideoWatermarkClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -336,10 +336,10 @@ public PicsartClient( /// Client-wide request defaults such as headers, query parameters, retries, and timeout. /// Dispose the HttpClient when the instance is disposed. True by default. public PicsartClient( - global::System.Net.Http.HttpClient? httpClient = null, - global::System.Uri? baseUri = null, - global::System.Collections.Generic.List? authorizations = null, - global::Picsart.AutoSDKClientOptions? options = null, + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Picsart.AutoSDKClientOptions? options, bool disposeHttpClient = true) { diff --git a/src/libs/Picsart/Generated/Picsart.VdReplayClient.VdExportReplay.g.cs b/src/libs/Picsart/Generated/Picsart.VdReplayClient.VdExportReplay.g.cs index 5a31e82..5036ae2 100644 --- a/src/libs/Picsart/Generated/Picsart.VdReplayClient.VdExportReplay.g.cs +++ b/src/libs/Picsart/Generated/Picsart.VdReplayClient.VdExportReplay.g.cs @@ -102,10 +102,11 @@ partial void ProcessVdExportReplayResponseContent( var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/vd/export/replay", baseUri: HttpClient.BaseAddress); @@ -138,8 +139,11 @@ partial void ProcessVdExportReplayResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + __httpRequest.Content = __httpRequestContent; + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -181,6 +185,8 @@ partial void ProcessVdExportReplayResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -191,6 +197,11 @@ partial void ProcessVdExportReplayResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -208,6 +219,8 @@ partial void ProcessVdExportReplayResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -217,8 +230,7 @@ partial void ProcessVdExportReplayResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -227,6 +239,11 @@ partial void ProcessVdExportReplayResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -243,14 +260,15 @@ partial void ProcessVdExportReplayResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -290,6 +308,8 @@ partial void ProcessVdExportReplayResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -310,6 +330,8 @@ partial void ProcessVdExportReplayResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -833,6 +855,7 @@ partial void ProcessVdExportReplayResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -866,6 +889,7 @@ partial void ProcessVdExportReplayResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.VdReplayClient.VdExportReplayGetresult.g.cs b/src/libs/Picsart/Generated/Picsart.VdReplayClient.VdExportReplayGetresult.g.cs index 2fba8c6..f80aef1 100644 --- a/src/libs/Picsart/Generated/Picsart.VdReplayClient.VdExportReplayGetresult.g.cs +++ b/src/libs/Picsart/Generated/Picsart.VdReplayClient.VdExportReplayGetresult.g.cs @@ -103,6 +103,7 @@ partial void ProcessVdExportReplayGetresultResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: $"/vd/export/replay/{transactionId}", baseUri: HttpClient.BaseAddress); @@ -176,6 +177,8 @@ partial void ProcessVdExportReplayGetresultResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -186,6 +189,11 @@ partial void ProcessVdExportReplayGetresultResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -203,6 +211,8 @@ partial void ProcessVdExportReplayGetresultResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -212,8 +222,7 @@ partial void ProcessVdExportReplayGetresultResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -222,6 +231,11 @@ partial void ProcessVdExportReplayGetresultResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -238,14 +252,15 @@ partial void ProcessVdExportReplayGetresultResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -285,6 +300,8 @@ partial void ProcessVdExportReplayGetresultResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -305,6 +322,8 @@ partial void ProcessVdExportReplayGetresultResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -828,6 +847,7 @@ partial void ProcessVdExportReplayGetresultResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -861,6 +881,7 @@ partial void ProcessVdExportReplayGetresultResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.VdReplayClient.g.cs b/src/libs/Picsart/Generated/Picsart.VdReplayClient.g.cs index 31eaa15..53b5b45 100644 --- a/src/libs/Picsart/Generated/Picsart.VdReplayClient.g.cs +++ b/src/libs/Picsart/Generated/Picsart.VdReplayClient.g.cs @@ -72,10 +72,10 @@ public VdReplayClient( /// Client-wide request defaults such as headers, query parameters, retries, and timeout. /// Dispose the HttpClient when the instance is disposed. True by default. public VdReplayClient( - global::System.Net.Http.HttpClient? httpClient = null, - global::System.Uri? baseUri = null, - global::System.Collections.Generic.List? authorizations = null, - global::Picsart.AutoSDKClientOptions? options = null, + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Picsart.AutoSDKClientOptions? options, bool disposeHttpClient = true) { diff --git a/src/libs/Picsart/Generated/Picsart.VdUtilitiesClient.VdCreditsBalance.g.cs b/src/libs/Picsart/Generated/Picsart.VdUtilitiesClient.VdCreditsBalance.g.cs index 2c78ebd..e78ce3a 100644 --- a/src/libs/Picsart/Generated/Picsart.VdUtilitiesClient.VdCreditsBalance.g.cs +++ b/src/libs/Picsart/Generated/Picsart.VdUtilitiesClient.VdCreditsBalance.g.cs @@ -95,6 +95,7 @@ partial void ProcessVdCreditsBalanceResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/vd/balance", baseUri: HttpClient.BaseAddress); @@ -167,6 +168,8 @@ partial void ProcessVdCreditsBalanceResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -177,6 +180,11 @@ partial void ProcessVdCreditsBalanceResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -194,6 +202,8 @@ partial void ProcessVdCreditsBalanceResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -203,8 +213,7 @@ partial void ProcessVdCreditsBalanceResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -213,6 +222,11 @@ partial void ProcessVdCreditsBalanceResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -229,14 +243,15 @@ partial void ProcessVdCreditsBalanceResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -276,6 +291,8 @@ partial void ProcessVdCreditsBalanceResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -296,6 +313,8 @@ partial void ProcessVdCreditsBalanceResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -819,6 +838,7 @@ partial void ProcessVdCreditsBalanceResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -852,6 +872,7 @@ partial void ProcessVdCreditsBalanceResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.VdUtilitiesClient.g.cs b/src/libs/Picsart/Generated/Picsart.VdUtilitiesClient.g.cs index d567c8c..26a1d89 100644 --- a/src/libs/Picsart/Generated/Picsart.VdUtilitiesClient.g.cs +++ b/src/libs/Picsart/Generated/Picsart.VdUtilitiesClient.g.cs @@ -72,10 +72,10 @@ public VdUtilitiesClient( /// Client-wide request defaults such as headers, query parameters, retries, and timeout. /// Dispose the HttpClient when the instance is disposed. True by default. public VdUtilitiesClient( - global::System.Net.Http.HttpClient? httpClient = null, - global::System.Uri? baseUri = null, - global::System.Collections.Generic.List? authorizations = null, - global::Picsart.AutoSDKClientOptions? options = null, + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Picsart.AutoSDKClientOptions? options, bool disposeHttpClient = true) { diff --git a/src/libs/Picsart/Generated/Picsart.VdVariableDataContentClient.VdDescribeVariableDataContent.g.cs b/src/libs/Picsart/Generated/Picsart.VdVariableDataContentClient.VdDescribeVariableDataContent.g.cs index a927672..e107261 100644 --- a/src/libs/Picsart/Generated/Picsart.VdVariableDataContentClient.VdDescribeVariableDataContent.g.cs +++ b/src/libs/Picsart/Generated/Picsart.VdVariableDataContentClient.VdDescribeVariableDataContent.g.cs @@ -104,10 +104,11 @@ partial void ProcessVdDescribeVariableDataContentResponseContent( var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/vd/variable-data-content/describe", baseUri: HttpClient.BaseAddress); @@ -140,6 +141,7 @@ partial void ProcessVdDescribeVariableDataContentResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); if (request.TemplateId != default) { @@ -147,7 +149,8 @@ partial void ProcessVdDescribeVariableDataContentResponseContent( __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.TemplateId ?? string.Empty), name: "\"template_id\""); - } + + } if (request.Template != default) { @@ -188,15 +191,19 @@ request.Templatename is null { __contentTemplate.Headers.ContentDisposition.FileNameStar = null; } - } + + } if (request.TemplateUrl != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.TemplateUrl ?? string.Empty), name: "\"template_url\""); + } + __httpRequest.Content = __httpRequestContent; + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -238,6 +245,8 @@ request.Templatename is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -248,6 +257,11 @@ request.Templatename is null } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -265,6 +279,8 @@ request.Templatename is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -274,8 +290,7 @@ request.Templatename is null __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -284,6 +299,11 @@ request.Templatename is null __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -300,14 +320,15 @@ request.Templatename 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -347,6 +368,8 @@ request.Templatename is null attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -367,6 +390,8 @@ request.Templatename is null attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -890,6 +915,7 @@ request.Templatename is null return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -923,6 +949,7 @@ request.Templatename is null return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -1001,5 +1028,1884 @@ request.Templatename is null requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } + + /// + /// Describe Replay's Variable Data
+ /// Describes the Replay. Lists all variable data fields and their types: image, text, etc. + ///
+ /// + /// Source template ID from Picsart Inventory. (If this parameter is present, the other template source parameters must be empty.) + /// + /// + /// Source replay file (binary). (If this parameter is present, the other template source parameters must be empty.) + /// + /// + /// Source replay file (binary). (If this parameter is present, the other template source parameters must be empty.) + /// + /// + /// Source replay URL. (If this parameter is present, the other template source parameters must be empty.) + /// + /// 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 VdDescribeVariableDataContentAsync( + string? templateId = default, + global::System.IO.Stream? template = default, + string? templatename = default, + string? templateUrl = default, + global::Picsart.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + var request = new global::Picsart.VDTemplateParameters + { + TemplateId = templateId, + Template = global::System.Array.Empty(), + Templatename = templatename, + TemplateUrl = templateUrl, + }; + PrepareArguments( + client: HttpClient); + PrepareVdDescribeVariableDataContentArguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::Picsart.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_VdDescribeVariableDataContentSecurityRequirements, + operationName: "VdDescribeVariableDataContentAsync"); + + using var __timeoutCancellationTokenSource = global::Picsart.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Picsart.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Picsart.PathBuilder( + path: "/vd/variable-data-content/describe", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Picsart.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 (request.TemplateId != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.TemplateId ?? string.Empty), + name: "\"template_id\""); + + } + if (template != default) + { + + var __contentTemplate = new global::System.Net.Http.StreamContent(template); + __contentTemplate.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.Templatename is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.Templatename) ?? 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: __contentTemplate, + name: "\"template\"", + fileName: request.Templatename != null ? $"\"{request.Templatename}\"" : string.Empty); + if (__contentTemplate.Headers.ContentDisposition != null) + { + __contentTemplate.Headers.ContentDisposition.FileNameStar = null; + } + + } + if (request.TemplateUrl != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.TemplateUrl ?? string.Empty), + name: "\"template_url\""); + + } + + __httpRequest.Content = __httpRequestContent; + + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareVdDescribeVariableDataContentRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + 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::Picsart.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "VdDescribeVariableDataContent", + methodName: "VdDescribeVariableDataContentAsync", + pathTemplate: "\"/vd/variable-data-content/describe\"", + 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::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "VdDescribeVariableDataContent", + methodName: "VdDescribeVariableDataContentAsync", + pathTemplate: "\"/vd/variable-data-content/describe\"", + 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "VdDescribeVariableDataContent", + methodName: "VdDescribeVariableDataContentAsync", + pathTemplate: "\"/vd/variable-data-content/describe\"", + 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::Picsart.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); + ProcessVdDescribeVariableDataContentResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "VdDescribeVariableDataContent", + methodName: "VdDescribeVariableDataContentAsync", + pathTemplate: "\"/vd/variable-data-content/describe\"", + 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::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "VdDescribeVariableDataContent", + methodName: "VdDescribeVariableDataContentAsync", + pathTemplate: "\"/vd/variable-data-content/describe\"", + 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); + } + // Bad Request + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + global::Picsart.VDError? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = global::Picsart.VDError.FromJson(__content_400, JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_400 = global::Picsart.VDError.FromJson(__content_400, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseObject = __value_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unauthorized + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + global::Picsart.Vd401Error? __value_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_401 = global::Picsart.Vd401Error.FromJson(__content_401, JsonSerializerContext); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_401 = global::Picsart.Vd401Error.FromJson(__content_401, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseObject = __value_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Payment Required + if ((int)__response.StatusCode == 402) + { + string? __content_402 = null; + global::System.Exception? __exception_402 = null; + global::Picsart.VDError? __value_402 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_402 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_402 = global::Picsart.VDError.FromJson(__content_402, JsonSerializerContext); + } + else + { + __content_402 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_402 = global::Picsart.VDError.FromJson(__content_402, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_402 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_402 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_402, + statusCode: __response.StatusCode) + { + ResponseBody = __content_402, + ResponseObject = __value_402, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Forbidden + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + global::Picsart.VDError? __value_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_403 = global::Picsart.VDError.FromJson(__content_403, JsonSerializerContext); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_403 = global::Picsart.VDError.FromJson(__content_403, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + statusCode: __response.StatusCode) + { + ResponseBody = __content_403, + ResponseObject = __value_403, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Not Found + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + global::Picsart.VDError? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = global::Picsart.VDError.FromJson(__content_404, JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_404 = global::Picsart.VDError.FromJson(__content_404, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + statusCode: __response.StatusCode) + { + ResponseBody = __content_404, + ResponseObject = __value_404, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Method Not Allowed + if ((int)__response.StatusCode == 405) + { + string? __content_405 = null; + global::System.Exception? __exception_405 = null; + global::Picsart.VDError? __value_405 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_405 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_405 = global::Picsart.VDError.FromJson(__content_405, JsonSerializerContext); + } + else + { + __content_405 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_405 = global::Picsart.VDError.FromJson(__content_405, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_405 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_405 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_405, + statusCode: __response.StatusCode) + { + ResponseBody = __content_405, + ResponseObject = __value_405, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Request Entity Too Large + if ((int)__response.StatusCode == 413) + { + string? __content_413 = null; + global::System.Exception? __exception_413 = null; + global::Picsart.VDError? __value_413 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_413 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_413 = global::Picsart.VDError.FromJson(__content_413, JsonSerializerContext); + } + else + { + __content_413 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_413 = global::Picsart.VDError.FromJson(__content_413, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_413 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_413 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_413, + statusCode: __response.StatusCode) + { + ResponseBody = __content_413, + ResponseObject = __value_413, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unsupported Media Type + if ((int)__response.StatusCode == 415) + { + string? __content_415 = null; + global::System.Exception? __exception_415 = null; + global::Picsart.VDError? __value_415 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_415 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_415 = global::Picsart.VDError.FromJson(__content_415, JsonSerializerContext); + } + else + { + __content_415 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_415 = global::Picsart.VDError.FromJson(__content_415, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_415 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_415 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_415, + statusCode: __response.StatusCode) + { + ResponseBody = __content_415, + ResponseObject = __value_415, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unprocessable Entity + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Picsart.VDError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Picsart.VDError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_422 = global::Picsart.VDError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Too Many Requests + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + global::Picsart.VDError? __value_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_429 = global::Picsart.VDError.FromJson(__content_429, JsonSerializerContext); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_429 = global::Picsart.VDError.FromJson(__content_429, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + statusCode: __response.StatusCode) + { + ResponseBody = __content_429, + ResponseObject = __value_429, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Request Header Fields Too Large + if ((int)__response.StatusCode == 431) + { + string? __content_431 = null; + global::System.Exception? __exception_431 = null; + global::Picsart.VDError? __value_431 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_431 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_431 = global::Picsart.VDError.FromJson(__content_431, JsonSerializerContext); + } + else + { + __content_431 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_431 = global::Picsart.VDError.FromJson(__content_431, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_431 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_431 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_431, + statusCode: __response.StatusCode) + { + ResponseBody = __content_431, + ResponseObject = __value_431, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Internal Server Error + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + global::Picsart.VDError? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = global::Picsart.VDError.FromJson(__content_500, JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_500 = global::Picsart.VDError.FromJson(__content_500, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Service Unavailable + if ((int)__response.StatusCode == 503) + { + string? __content_503 = null; + global::System.Exception? __exception_503 = null; + global::Picsart.VDError? __value_503 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_503 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_503 = global::Picsart.VDError.FromJson(__content_503, JsonSerializerContext); + } + else + { + __content_503 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_503 = global::Picsart.VDError.FromJson(__content_503, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_503 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_503 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_503, + statusCode: __response.StatusCode) + { + ResponseBody = __content_503, + ResponseObject = __value_503, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessVdDescribeVariableDataContentResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Picsart.VdDescribeVariableDataContentResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Picsart.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::Picsart.VdDescribeVariableDataContentResponse.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::Picsart.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(); + } + } + /// + /// Describe Replay's Variable Data
+ /// Describes the Replay. Lists all variable data fields and their types: image, text, etc. + ///
+ /// + /// Source template ID from Picsart Inventory. (If this parameter is present, the other template source parameters must be empty.) + /// + /// + /// Source replay file (binary). (If this parameter is present, the other template source parameters must be empty.) + /// + /// + /// Source replay file (binary). (If this parameter is present, the other template source parameters must be empty.) + /// + /// + /// Source replay URL. (If this parameter is present, the other template source parameters must be empty.) + /// + /// 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> VdDescribeVariableDataContentAsResponseAsync( + string? templateId = default, + global::System.IO.Stream? template = default, + string? templatename = default, + string? templateUrl = default, + global::Picsart.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + var request = new global::Picsart.VDTemplateParameters + { + TemplateId = templateId, + Template = global::System.Array.Empty(), + Templatename = templatename, + TemplateUrl = templateUrl, + }; + PrepareArguments( + client: HttpClient); + PrepareVdDescribeVariableDataContentArguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::Picsart.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_VdDescribeVariableDataContentSecurityRequirements, + operationName: "VdDescribeVariableDataContentAsync"); + + using var __timeoutCancellationTokenSource = global::Picsart.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Picsart.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Picsart.PathBuilder( + path: "/vd/variable-data-content/describe", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Picsart.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 (request.TemplateId != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.TemplateId ?? string.Empty), + name: "\"template_id\""); + + } + if (template != default) + { + + var __contentTemplate = new global::System.Net.Http.StreamContent(template); + __contentTemplate.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.Templatename is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.Templatename) ?? 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: __contentTemplate, + name: "\"template\"", + fileName: request.Templatename != null ? $"\"{request.Templatename}\"" : string.Empty); + if (__contentTemplate.Headers.ContentDisposition != null) + { + __contentTemplate.Headers.ContentDisposition.FileNameStar = null; + } + + } + if (request.TemplateUrl != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.TemplateUrl ?? string.Empty), + name: "\"template_url\""); + + } + + __httpRequest.Content = __httpRequestContent; + + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareVdDescribeVariableDataContentRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + 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::Picsart.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "VdDescribeVariableDataContent", + methodName: "VdDescribeVariableDataContentAsync", + pathTemplate: "\"/vd/variable-data-content/describe\"", + 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::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "VdDescribeVariableDataContent", + methodName: "VdDescribeVariableDataContentAsync", + pathTemplate: "\"/vd/variable-data-content/describe\"", + 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "VdDescribeVariableDataContent", + methodName: "VdDescribeVariableDataContentAsync", + pathTemplate: "\"/vd/variable-data-content/describe\"", + 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::Picsart.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); + ProcessVdDescribeVariableDataContentResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "VdDescribeVariableDataContent", + methodName: "VdDescribeVariableDataContentAsync", + pathTemplate: "\"/vd/variable-data-content/describe\"", + 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::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "VdDescribeVariableDataContent", + methodName: "VdDescribeVariableDataContentAsync", + pathTemplate: "\"/vd/variable-data-content/describe\"", + 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); + } + // Bad Request + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + global::Picsart.VDError? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = global::Picsart.VDError.FromJson(__content_400, JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_400 = global::Picsart.VDError.FromJson(__content_400, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseObject = __value_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unauthorized + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + global::Picsart.Vd401Error? __value_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_401 = global::Picsart.Vd401Error.FromJson(__content_401, JsonSerializerContext); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_401 = global::Picsart.Vd401Error.FromJson(__content_401, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseObject = __value_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Payment Required + if ((int)__response.StatusCode == 402) + { + string? __content_402 = null; + global::System.Exception? __exception_402 = null; + global::Picsart.VDError? __value_402 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_402 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_402 = global::Picsart.VDError.FromJson(__content_402, JsonSerializerContext); + } + else + { + __content_402 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_402 = global::Picsart.VDError.FromJson(__content_402, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_402 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_402 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_402, + statusCode: __response.StatusCode) + { + ResponseBody = __content_402, + ResponseObject = __value_402, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Forbidden + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + global::Picsart.VDError? __value_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_403 = global::Picsart.VDError.FromJson(__content_403, JsonSerializerContext); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_403 = global::Picsart.VDError.FromJson(__content_403, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + statusCode: __response.StatusCode) + { + ResponseBody = __content_403, + ResponseObject = __value_403, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Not Found + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + global::Picsart.VDError? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = global::Picsart.VDError.FromJson(__content_404, JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_404 = global::Picsart.VDError.FromJson(__content_404, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + statusCode: __response.StatusCode) + { + ResponseBody = __content_404, + ResponseObject = __value_404, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Method Not Allowed + if ((int)__response.StatusCode == 405) + { + string? __content_405 = null; + global::System.Exception? __exception_405 = null; + global::Picsart.VDError? __value_405 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_405 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_405 = global::Picsart.VDError.FromJson(__content_405, JsonSerializerContext); + } + else + { + __content_405 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_405 = global::Picsart.VDError.FromJson(__content_405, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_405 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_405 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_405, + statusCode: __response.StatusCode) + { + ResponseBody = __content_405, + ResponseObject = __value_405, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Request Entity Too Large + if ((int)__response.StatusCode == 413) + { + string? __content_413 = null; + global::System.Exception? __exception_413 = null; + global::Picsart.VDError? __value_413 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_413 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_413 = global::Picsart.VDError.FromJson(__content_413, JsonSerializerContext); + } + else + { + __content_413 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_413 = global::Picsart.VDError.FromJson(__content_413, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_413 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_413 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_413, + statusCode: __response.StatusCode) + { + ResponseBody = __content_413, + ResponseObject = __value_413, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unsupported Media Type + if ((int)__response.StatusCode == 415) + { + string? __content_415 = null; + global::System.Exception? __exception_415 = null; + global::Picsart.VDError? __value_415 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_415 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_415 = global::Picsart.VDError.FromJson(__content_415, JsonSerializerContext); + } + else + { + __content_415 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_415 = global::Picsart.VDError.FromJson(__content_415, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_415 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_415 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_415, + statusCode: __response.StatusCode) + { + ResponseBody = __content_415, + ResponseObject = __value_415, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unprocessable Entity + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Picsart.VDError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Picsart.VDError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_422 = global::Picsart.VDError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Too Many Requests + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + global::Picsart.VDError? __value_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_429 = global::Picsart.VDError.FromJson(__content_429, JsonSerializerContext); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_429 = global::Picsart.VDError.FromJson(__content_429, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + statusCode: __response.StatusCode) + { + ResponseBody = __content_429, + ResponseObject = __value_429, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Request Header Fields Too Large + if ((int)__response.StatusCode == 431) + { + string? __content_431 = null; + global::System.Exception? __exception_431 = null; + global::Picsart.VDError? __value_431 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_431 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_431 = global::Picsart.VDError.FromJson(__content_431, JsonSerializerContext); + } + else + { + __content_431 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_431 = global::Picsart.VDError.FromJson(__content_431, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_431 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_431 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_431, + statusCode: __response.StatusCode) + { + ResponseBody = __content_431, + ResponseObject = __value_431, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Internal Server Error + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + global::Picsart.VDError? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = global::Picsart.VDError.FromJson(__content_500, JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_500 = global::Picsart.VDError.FromJson(__content_500, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Service Unavailable + if ((int)__response.StatusCode == 503) + { + string? __content_503 = null; + global::System.Exception? __exception_503 = null; + global::Picsart.VDError? __value_503 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_503 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_503 = global::Picsart.VDError.FromJson(__content_503, JsonSerializerContext); + } + else + { + __content_503 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_503 = global::Picsart.VDError.FromJson(__content_503, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_503 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_503 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_503, + statusCode: __response.StatusCode) + { + ResponseBody = __content_503, + ResponseObject = __value_503, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessVdDescribeVariableDataContentResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Picsart.VdDescribeVariableDataContentResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Picsart.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Picsart.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::Picsart.VdDescribeVariableDataContentResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Picsart.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Picsart.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::Picsart.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/Picsart/Generated/Picsart.VdVariableDataContentClient.VdExportVariableDataContent.g.cs b/src/libs/Picsart/Generated/Picsart.VdVariableDataContentClient.VdExportVariableDataContent.g.cs index 8c04bc3..14b0b76 100644 --- a/src/libs/Picsart/Generated/Picsart.VdVariableDataContentClient.VdExportVariableDataContent.g.cs +++ b/src/libs/Picsart/Generated/Picsart.VdVariableDataContentClient.VdExportVariableDataContent.g.cs @@ -104,10 +104,11 @@ partial void ProcessVdExportVariableDataContentResponseContent( var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/vd/export/variable-data-content", baseUri: HttpClient.BaseAddress); @@ -140,8 +141,11 @@ partial void ProcessVdExportVariableDataContentResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + __httpRequest.Content = __httpRequestContent; + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -183,6 +187,8 @@ partial void ProcessVdExportVariableDataContentResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -193,6 +199,11 @@ partial void ProcessVdExportVariableDataContentResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -210,6 +221,8 @@ partial void ProcessVdExportVariableDataContentResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -219,8 +232,7 @@ partial void ProcessVdExportVariableDataContentResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -229,6 +241,11 @@ partial void ProcessVdExportVariableDataContentResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -245,14 +262,15 @@ partial void ProcessVdExportVariableDataContentResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -292,6 +310,8 @@ partial void ProcessVdExportVariableDataContentResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -312,6 +332,8 @@ partial void ProcessVdExportVariableDataContentResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -835,6 +857,7 @@ partial void ProcessVdExportVariableDataContentResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -868,6 +891,7 @@ partial void ProcessVdExportVariableDataContentResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.VdVariableDataContentClient.VdExportVariableDataContentGetresult.g.cs b/src/libs/Picsart/Generated/Picsart.VdVariableDataContentClient.VdExportVariableDataContentGetresult.g.cs index b62ee91..574e85a 100644 --- a/src/libs/Picsart/Generated/Picsart.VdVariableDataContentClient.VdExportVariableDataContentGetresult.g.cs +++ b/src/libs/Picsart/Generated/Picsart.VdVariableDataContentClient.VdExportVariableDataContentGetresult.g.cs @@ -103,6 +103,7 @@ partial void ProcessVdExportVariableDataContentGetresultResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: $"/vd/export/variable-data-content/{transactionId}", baseUri: HttpClient.BaseAddress); @@ -176,6 +177,8 @@ partial void ProcessVdExportVariableDataContentGetresultResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -186,6 +189,11 @@ partial void ProcessVdExportVariableDataContentGetresultResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -203,6 +211,8 @@ partial void ProcessVdExportVariableDataContentGetresultResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -212,8 +222,7 @@ partial void ProcessVdExportVariableDataContentGetresultResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -222,6 +231,11 @@ partial void ProcessVdExportVariableDataContentGetresultResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -238,14 +252,15 @@ partial void ProcessVdExportVariableDataContentGetresultResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -285,6 +300,8 @@ partial void ProcessVdExportVariableDataContentGetresultResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -305,6 +322,8 @@ partial void ProcessVdExportVariableDataContentGetresultResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -828,6 +847,7 @@ partial void ProcessVdExportVariableDataContentGetresultResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -861,6 +881,7 @@ partial void ProcessVdExportVariableDataContentGetresultResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.VdVariableDataContentClient.g.cs b/src/libs/Picsart/Generated/Picsart.VdVariableDataContentClient.g.cs index 2a146fe..a8c9bd8 100644 --- a/src/libs/Picsart/Generated/Picsart.VdVariableDataContentClient.g.cs +++ b/src/libs/Picsart/Generated/Picsart.VdVariableDataContentClient.g.cs @@ -72,10 +72,10 @@ public VdVariableDataContentClient( /// Client-wide request defaults such as headers, query parameters, retries, and timeout. /// Dispose the HttpClient when the instance is disposed. True by default. public VdVariableDataContentClient( - global::System.Net.Http.HttpClient? httpClient = null, - global::System.Uri? baseUri = null, - global::System.Collections.Generic.List? authorizations = null, - global::Picsart.AutoSDKClientOptions? options = null, + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Picsart.AutoSDKClientOptions? options, bool disposeHttpClient = true) { diff --git a/src/libs/Picsart/Generated/Picsart.VideoAdsClient.VideoEncodeCtv.g.cs b/src/libs/Picsart/Generated/Picsart.VideoAdsClient.VideoEncodeCtv.g.cs index c930f02..206c137 100644 --- a/src/libs/Picsart/Generated/Picsart.VideoAdsClient.VideoEncodeCtv.g.cs +++ b/src/libs/Picsart/Generated/Picsart.VideoAdsClient.VideoEncodeCtv.g.cs @@ -108,6 +108,7 @@ partial void ProcessVideoEncodeCtvResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/video/encode/ctv", baseUri: HttpClient.BaseAddress); @@ -187,6 +188,8 @@ partial void ProcessVideoEncodeCtvResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -197,6 +200,11 @@ partial void ProcessVideoEncodeCtvResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -214,6 +222,8 @@ partial void ProcessVideoEncodeCtvResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -223,8 +233,7 @@ partial void ProcessVideoEncodeCtvResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -233,6 +242,11 @@ partial void ProcessVideoEncodeCtvResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -249,14 +263,15 @@ partial void ProcessVideoEncodeCtvResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -296,6 +311,8 @@ partial void ProcessVideoEncodeCtvResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -316,6 +333,8 @@ partial void ProcessVideoEncodeCtvResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -801,6 +820,7 @@ partial void ProcessVideoEncodeCtvResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -834,6 +854,7 @@ partial void ProcessVideoEncodeCtvResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.VideoAdsClient.g.cs b/src/libs/Picsart/Generated/Picsart.VideoAdsClient.g.cs index d37144f..bd66950 100644 --- a/src/libs/Picsart/Generated/Picsart.VideoAdsClient.g.cs +++ b/src/libs/Picsart/Generated/Picsart.VideoAdsClient.g.cs @@ -72,10 +72,10 @@ public VideoAdsClient( /// Client-wide request defaults such as headers, query parameters, retries, and timeout. /// Dispose the HttpClient when the instance is disposed. True by default. public VideoAdsClient( - global::System.Net.Http.HttpClient? httpClient = null, - global::System.Uri? baseUri = null, - global::System.Collections.Generic.List? authorizations = null, - global::Picsart.AutoSDKClientOptions? options = null, + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Picsart.AutoSDKClientOptions? options, bool disposeHttpClient = true) { diff --git a/src/libs/Picsart/Generated/Picsart.VideoAudioClient.VideoAdjustAudio.g.cs b/src/libs/Picsart/Generated/Picsart.VideoAudioClient.VideoAdjustAudio.g.cs index bcd44c3..aaac240 100644 --- a/src/libs/Picsart/Generated/Picsart.VideoAudioClient.VideoAdjustAudio.g.cs +++ b/src/libs/Picsart/Generated/Picsart.VideoAudioClient.VideoAdjustAudio.g.cs @@ -106,6 +106,7 @@ partial void ProcessVideoAdjustAudioResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/video/audio/adjust", baseUri: HttpClient.BaseAddress); @@ -185,6 +186,8 @@ partial void ProcessVideoAdjustAudioResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -195,6 +198,11 @@ partial void ProcessVideoAdjustAudioResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -212,6 +220,8 @@ partial void ProcessVideoAdjustAudioResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -221,8 +231,7 @@ partial void ProcessVideoAdjustAudioResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -231,6 +240,11 @@ partial void ProcessVideoAdjustAudioResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -247,14 +261,15 @@ partial void ProcessVideoAdjustAudioResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -294,6 +309,8 @@ partial void ProcessVideoAdjustAudioResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -314,6 +331,8 @@ partial void ProcessVideoAdjustAudioResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -799,6 +818,7 @@ partial void ProcessVideoAdjustAudioResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -832,6 +852,7 @@ partial void ProcessVideoAdjustAudioResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.VideoAudioClient.VideoExtractAudio.g.cs b/src/libs/Picsart/Generated/Picsart.VideoAudioClient.VideoExtractAudio.g.cs index d47d5ed..671806b 100644 --- a/src/libs/Picsart/Generated/Picsart.VideoAudioClient.VideoExtractAudio.g.cs +++ b/src/libs/Picsart/Generated/Picsart.VideoAudioClient.VideoExtractAudio.g.cs @@ -106,6 +106,7 @@ partial void ProcessVideoExtractAudioResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/video/export/audio", baseUri: HttpClient.BaseAddress); @@ -185,6 +186,8 @@ partial void ProcessVideoExtractAudioResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -195,6 +198,11 @@ partial void ProcessVideoExtractAudioResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -212,6 +220,8 @@ partial void ProcessVideoExtractAudioResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -221,8 +231,7 @@ partial void ProcessVideoExtractAudioResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -231,6 +240,11 @@ partial void ProcessVideoExtractAudioResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -247,14 +261,15 @@ partial void ProcessVideoExtractAudioResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -294,6 +309,8 @@ partial void ProcessVideoExtractAudioResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -314,6 +331,8 @@ partial void ProcessVideoExtractAudioResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -799,6 +818,7 @@ partial void ProcessVideoExtractAudioResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -832,6 +852,7 @@ partial void ProcessVideoExtractAudioResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.VideoAudioClient.g.cs b/src/libs/Picsart/Generated/Picsart.VideoAudioClient.g.cs index ae82b43..3d7316e 100644 --- a/src/libs/Picsart/Generated/Picsart.VideoAudioClient.g.cs +++ b/src/libs/Picsart/Generated/Picsart.VideoAudioClient.g.cs @@ -72,10 +72,10 @@ public VideoAudioClient( /// Client-wide request defaults such as headers, query parameters, retries, and timeout. /// Dispose the HttpClient when the instance is disposed. True by default. public VideoAudioClient( - global::System.Net.Http.HttpClient? httpClient = null, - global::System.Uri? baseUri = null, - global::System.Collections.Generic.List? authorizations = null, - global::Picsart.AutoSDKClientOptions? options = null, + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Picsart.AutoSDKClientOptions? options, bool disposeHttpClient = true) { diff --git a/src/libs/Picsart/Generated/Picsart.VideoEditClient.VideoConcat.g.cs b/src/libs/Picsart/Generated/Picsart.VideoEditClient.VideoConcat.g.cs index 9605d6d..330647b 100644 --- a/src/libs/Picsart/Generated/Picsart.VideoEditClient.VideoConcat.g.cs +++ b/src/libs/Picsart/Generated/Picsart.VideoEditClient.VideoConcat.g.cs @@ -106,6 +106,7 @@ partial void ProcessVideoConcatResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/video/concat", baseUri: HttpClient.BaseAddress); @@ -185,6 +186,8 @@ partial void ProcessVideoConcatResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -195,6 +198,11 @@ partial void ProcessVideoConcatResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -212,6 +220,8 @@ partial void ProcessVideoConcatResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -221,8 +231,7 @@ partial void ProcessVideoConcatResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -231,6 +240,11 @@ partial void ProcessVideoConcatResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -247,14 +261,15 @@ partial void ProcessVideoConcatResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -294,6 +309,8 @@ partial void ProcessVideoConcatResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -314,6 +331,8 @@ partial void ProcessVideoConcatResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -799,6 +818,7 @@ partial void ProcessVideoConcatResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -832,6 +852,7 @@ partial void ProcessVideoConcatResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.VideoEditClient.VideoConcatHighlights.g.cs b/src/libs/Picsart/Generated/Picsart.VideoEditClient.VideoConcatHighlights.g.cs index d872c73..78d0241 100644 --- a/src/libs/Picsart/Generated/Picsart.VideoEditClient.VideoConcatHighlights.g.cs +++ b/src/libs/Picsart/Generated/Picsart.VideoEditClient.VideoConcatHighlights.g.cs @@ -104,6 +104,7 @@ partial void ProcessVideoConcatHighlightsResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/video/concat/highlights", baseUri: HttpClient.BaseAddress); @@ -183,6 +184,8 @@ partial void ProcessVideoConcatHighlightsResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -193,6 +196,11 @@ partial void ProcessVideoConcatHighlightsResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -210,6 +218,8 @@ partial void ProcessVideoConcatHighlightsResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -219,8 +229,7 @@ partial void ProcessVideoConcatHighlightsResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -229,6 +238,11 @@ partial void ProcessVideoConcatHighlightsResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -245,14 +259,15 @@ partial void ProcessVideoConcatHighlightsResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -292,6 +307,8 @@ partial void ProcessVideoConcatHighlightsResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -312,6 +329,8 @@ partial void ProcessVideoConcatHighlightsResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -797,6 +816,7 @@ partial void ProcessVideoConcatHighlightsResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -830,6 +850,7 @@ partial void ProcessVideoConcatHighlightsResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.VideoEditClient.VideoCrop.g.cs b/src/libs/Picsart/Generated/Picsart.VideoEditClient.VideoCrop.g.cs index 8dc3f98..1964d03 100644 --- a/src/libs/Picsart/Generated/Picsart.VideoEditClient.VideoCrop.g.cs +++ b/src/libs/Picsart/Generated/Picsart.VideoEditClient.VideoCrop.g.cs @@ -106,6 +106,7 @@ partial void ProcessVideoCropResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/video/crop", baseUri: HttpClient.BaseAddress); @@ -185,6 +186,8 @@ partial void ProcessVideoCropResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -195,6 +198,11 @@ partial void ProcessVideoCropResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -212,6 +220,8 @@ partial void ProcessVideoCropResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -221,8 +231,7 @@ partial void ProcessVideoCropResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -231,6 +240,11 @@ partial void ProcessVideoCropResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -247,14 +261,15 @@ partial void ProcessVideoCropResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -294,6 +309,8 @@ partial void ProcessVideoCropResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -314,6 +331,8 @@ partial void ProcessVideoCropResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -799,6 +818,7 @@ partial void ProcessVideoCropResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -832,6 +852,7 @@ partial void ProcessVideoCropResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.VideoEditClient.VideoEdit.g.cs b/src/libs/Picsart/Generated/Picsart.VideoEditClient.VideoEdit.g.cs index f490bf3..acc9306 100644 --- a/src/libs/Picsart/Generated/Picsart.VideoEditClient.VideoEdit.g.cs +++ b/src/libs/Picsart/Generated/Picsart.VideoEditClient.VideoEdit.g.cs @@ -106,6 +106,7 @@ partial void ProcessVideoEditResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/video/edit", baseUri: HttpClient.BaseAddress); @@ -185,6 +186,8 @@ partial void ProcessVideoEditResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -195,6 +198,11 @@ partial void ProcessVideoEditResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -212,6 +220,8 @@ partial void ProcessVideoEditResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -221,8 +231,7 @@ partial void ProcessVideoEditResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -231,6 +240,11 @@ partial void ProcessVideoEditResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -247,14 +261,15 @@ partial void ProcessVideoEditResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -294,6 +309,8 @@ partial void ProcessVideoEditResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -314,6 +331,8 @@ partial void ProcessVideoEditResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -799,6 +818,7 @@ partial void ProcessVideoEditResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -832,6 +852,7 @@ partial void ProcessVideoEditResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.VideoEditClient.VideoFit.g.cs b/src/libs/Picsart/Generated/Picsart.VideoEditClient.VideoFit.g.cs index f8ac298..d747acf 100644 --- a/src/libs/Picsart/Generated/Picsart.VideoEditClient.VideoFit.g.cs +++ b/src/libs/Picsart/Generated/Picsart.VideoEditClient.VideoFit.g.cs @@ -106,6 +106,7 @@ partial void ProcessVideoFitResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/video/fit", baseUri: HttpClient.BaseAddress); @@ -185,6 +186,8 @@ partial void ProcessVideoFitResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -195,6 +198,11 @@ partial void ProcessVideoFitResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -212,6 +220,8 @@ partial void ProcessVideoFitResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -221,8 +231,7 @@ partial void ProcessVideoFitResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -231,6 +240,11 @@ partial void ProcessVideoFitResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -247,14 +261,15 @@ partial void ProcessVideoFitResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -294,6 +309,8 @@ partial void ProcessVideoFitResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -314,6 +331,8 @@ partial void ProcessVideoFitResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -799,6 +818,7 @@ partial void ProcessVideoFitResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -832,6 +852,7 @@ partial void ProcessVideoFitResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.VideoEditClient.VideoTrim.g.cs b/src/libs/Picsart/Generated/Picsart.VideoEditClient.VideoTrim.g.cs index 7608413..0d9cedf 100644 --- a/src/libs/Picsart/Generated/Picsart.VideoEditClient.VideoTrim.g.cs +++ b/src/libs/Picsart/Generated/Picsart.VideoEditClient.VideoTrim.g.cs @@ -106,6 +106,7 @@ partial void ProcessVideoTrimResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/video/trim", baseUri: HttpClient.BaseAddress); @@ -185,6 +186,8 @@ partial void ProcessVideoTrimResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -195,6 +198,11 @@ partial void ProcessVideoTrimResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -212,6 +220,8 @@ partial void ProcessVideoTrimResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -221,8 +231,7 @@ partial void ProcessVideoTrimResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -231,6 +240,11 @@ partial void ProcessVideoTrimResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -247,14 +261,15 @@ partial void ProcessVideoTrimResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -294,6 +309,8 @@ partial void ProcessVideoTrimResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -314,6 +331,8 @@ partial void ProcessVideoTrimResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -799,6 +818,7 @@ partial void ProcessVideoTrimResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -832,6 +852,7 @@ partial void ProcessVideoTrimResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.VideoEditClient.g.cs b/src/libs/Picsart/Generated/Picsart.VideoEditClient.g.cs index 34402c4..f47df6f 100644 --- a/src/libs/Picsart/Generated/Picsart.VideoEditClient.g.cs +++ b/src/libs/Picsart/Generated/Picsart.VideoEditClient.g.cs @@ -72,10 +72,10 @@ public VideoEditClient( /// Client-wide request defaults such as headers, query parameters, retries, and timeout. /// Dispose the HttpClient when the instance is disposed. True by default. public VideoEditClient( - global::System.Net.Http.HttpClient? httpClient = null, - global::System.Uri? baseUri = null, - global::System.Collections.Generic.List? authorizations = null, - global::Picsart.AutoSDKClientOptions? options = null, + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Picsart.AutoSDKClientOptions? options, bool disposeHttpClient = true) { diff --git a/src/libs/Picsart/Generated/Picsart.VideoEffectsClient.VideoAdjust.g.cs b/src/libs/Picsart/Generated/Picsart.VideoEffectsClient.VideoAdjust.g.cs index 079b6d7..f6c0091 100644 --- a/src/libs/Picsart/Generated/Picsart.VideoEffectsClient.VideoAdjust.g.cs +++ b/src/libs/Picsart/Generated/Picsart.VideoEffectsClient.VideoAdjust.g.cs @@ -128,6 +128,7 @@ partial void ProcessVideoAdjustResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/video/adjust", baseUri: HttpClient.BaseAddress); @@ -207,6 +208,8 @@ partial void ProcessVideoAdjustResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -217,6 +220,11 @@ partial void ProcessVideoAdjustResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -234,6 +242,8 @@ partial void ProcessVideoAdjustResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -243,8 +253,7 @@ partial void ProcessVideoAdjustResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -253,6 +262,11 @@ partial void ProcessVideoAdjustResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -269,14 +283,15 @@ partial void ProcessVideoAdjustResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -316,6 +331,8 @@ partial void ProcessVideoAdjustResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -336,6 +353,8 @@ partial void ProcessVideoAdjustResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -821,6 +840,7 @@ partial void ProcessVideoAdjustResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -854,6 +874,7 @@ partial void ProcessVideoAdjustResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.VideoEffectsClient.VideoApplyEffect.g.cs b/src/libs/Picsart/Generated/Picsart.VideoEffectsClient.VideoApplyEffect.g.cs index 0e49397..50262cd 100644 --- a/src/libs/Picsart/Generated/Picsart.VideoEffectsClient.VideoApplyEffect.g.cs +++ b/src/libs/Picsart/Generated/Picsart.VideoEffectsClient.VideoApplyEffect.g.cs @@ -106,6 +106,7 @@ partial void ProcessVideoApplyEffectResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/video/effects", baseUri: HttpClient.BaseAddress); @@ -185,6 +186,8 @@ partial void ProcessVideoApplyEffectResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -195,6 +198,11 @@ partial void ProcessVideoApplyEffectResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -212,6 +220,8 @@ partial void ProcessVideoApplyEffectResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -221,8 +231,7 @@ partial void ProcessVideoApplyEffectResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -231,6 +240,11 @@ partial void ProcessVideoApplyEffectResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -247,14 +261,15 @@ partial void ProcessVideoApplyEffectResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -294,6 +309,8 @@ partial void ProcessVideoApplyEffectResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -314,6 +331,8 @@ partial void ProcessVideoApplyEffectResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -799,6 +818,7 @@ partial void ProcessVideoApplyEffectResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -832,6 +852,7 @@ partial void ProcessVideoApplyEffectResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.VideoEffectsClient.g.cs b/src/libs/Picsart/Generated/Picsart.VideoEffectsClient.g.cs index f64d404..38db35c 100644 --- a/src/libs/Picsart/Generated/Picsart.VideoEffectsClient.g.cs +++ b/src/libs/Picsart/Generated/Picsart.VideoEffectsClient.g.cs @@ -72,10 +72,10 @@ public VideoEffectsClient( /// Client-wide request defaults such as headers, query parameters, retries, and timeout. /// Dispose the HttpClient when the instance is disposed. True by default. public VideoEffectsClient( - global::System.Net.Http.HttpClient? httpClient = null, - global::System.Uri? baseUri = null, - global::System.Collections.Generic.List? authorizations = null, - global::Picsart.AutoSDKClientOptions? options = null, + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Picsart.AutoSDKClientOptions? options, bool disposeHttpClient = true) { diff --git a/src/libs/Picsart/Generated/Picsart.VideoMetadataClient.VideoGetThumbnail.g.cs b/src/libs/Picsart/Generated/Picsart.VideoMetadataClient.VideoGetThumbnail.g.cs index 0b83d7a..9b8dfae 100644 --- a/src/libs/Picsart/Generated/Picsart.VideoMetadataClient.VideoGetThumbnail.g.cs +++ b/src/libs/Picsart/Generated/Picsart.VideoMetadataClient.VideoGetThumbnail.g.cs @@ -106,6 +106,7 @@ partial void ProcessVideoGetThumbnailResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/video/metadata/thumbnail/extract", baseUri: HttpClient.BaseAddress); @@ -185,6 +186,8 @@ partial void ProcessVideoGetThumbnailResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -195,6 +198,11 @@ partial void ProcessVideoGetThumbnailResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -212,6 +220,8 @@ partial void ProcessVideoGetThumbnailResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -221,8 +231,7 @@ partial void ProcessVideoGetThumbnailResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -231,6 +240,11 @@ partial void ProcessVideoGetThumbnailResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -247,14 +261,15 @@ partial void ProcessVideoGetThumbnailResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -294,6 +309,8 @@ partial void ProcessVideoGetThumbnailResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -314,6 +331,8 @@ partial void ProcessVideoGetThumbnailResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -799,6 +818,7 @@ partial void ProcessVideoGetThumbnailResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -832,6 +852,7 @@ partial void ProcessVideoGetThumbnailResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.VideoMetadataClient.VideoMetadata.g.cs b/src/libs/Picsart/Generated/Picsart.VideoMetadataClient.VideoMetadata.g.cs index aba7307..33873bd 100644 --- a/src/libs/Picsart/Generated/Picsart.VideoMetadataClient.VideoMetadata.g.cs +++ b/src/libs/Picsart/Generated/Picsart.VideoMetadataClient.VideoMetadata.g.cs @@ -108,6 +108,7 @@ partial void ProcessVideoMetadataResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/video/metadata", baseUri: HttpClient.BaseAddress); @@ -187,6 +188,8 @@ partial void ProcessVideoMetadataResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -197,6 +200,11 @@ partial void ProcessVideoMetadataResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -214,6 +222,8 @@ partial void ProcessVideoMetadataResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -223,8 +233,7 @@ partial void ProcessVideoMetadataResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -233,6 +242,11 @@ partial void ProcessVideoMetadataResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -249,14 +263,15 @@ partial void ProcessVideoMetadataResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -296,6 +311,8 @@ partial void ProcessVideoMetadataResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -316,6 +333,8 @@ partial void ProcessVideoMetadataResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -801,6 +820,7 @@ partial void ProcessVideoMetadataResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -834,6 +854,7 @@ partial void ProcessVideoMetadataResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.VideoMetadataClient.VideoSetThumbnail.g.cs b/src/libs/Picsart/Generated/Picsart.VideoMetadataClient.VideoSetThumbnail.g.cs index 6d94905..0271981 100644 --- a/src/libs/Picsart/Generated/Picsart.VideoMetadataClient.VideoSetThumbnail.g.cs +++ b/src/libs/Picsart/Generated/Picsart.VideoMetadataClient.VideoSetThumbnail.g.cs @@ -106,6 +106,7 @@ partial void ProcessVideoSetThumbnailResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/video/metadata/thumbnail", baseUri: HttpClient.BaseAddress); @@ -185,6 +186,8 @@ partial void ProcessVideoSetThumbnailResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -195,6 +198,11 @@ partial void ProcessVideoSetThumbnailResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -212,6 +220,8 @@ partial void ProcessVideoSetThumbnailResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -221,8 +231,7 @@ partial void ProcessVideoSetThumbnailResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -231,6 +240,11 @@ partial void ProcessVideoSetThumbnailResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -247,14 +261,15 @@ partial void ProcessVideoSetThumbnailResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -294,6 +309,8 @@ partial void ProcessVideoSetThumbnailResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -314,6 +331,8 @@ partial void ProcessVideoSetThumbnailResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -799,6 +818,7 @@ partial void ProcessVideoSetThumbnailResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -832,6 +852,7 @@ partial void ProcessVideoSetThumbnailResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.VideoMetadataClient.VideoSetThumbnailGetresult.g.cs b/src/libs/Picsart/Generated/Picsart.VideoMetadataClient.VideoSetThumbnailGetresult.g.cs index 267da22..25508f5 100644 --- a/src/libs/Picsart/Generated/Picsart.VideoMetadataClient.VideoSetThumbnailGetresult.g.cs +++ b/src/libs/Picsart/Generated/Picsart.VideoMetadataClient.VideoSetThumbnailGetresult.g.cs @@ -103,6 +103,7 @@ partial void ProcessVideoSetThumbnailGetresultResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: $"/video/metadata/thumbnail/{transactionId}", baseUri: HttpClient.BaseAddress); @@ -176,6 +177,8 @@ partial void ProcessVideoSetThumbnailGetresultResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -186,6 +189,11 @@ partial void ProcessVideoSetThumbnailGetresultResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -203,6 +211,8 @@ partial void ProcessVideoSetThumbnailGetresultResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -212,8 +222,7 @@ partial void ProcessVideoSetThumbnailGetresultResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -222,6 +231,11 @@ partial void ProcessVideoSetThumbnailGetresultResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -238,14 +252,15 @@ partial void ProcessVideoSetThumbnailGetresultResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -285,6 +300,8 @@ partial void ProcessVideoSetThumbnailGetresultResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -305,6 +322,8 @@ partial void ProcessVideoSetThumbnailGetresultResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -790,6 +809,7 @@ partial void ProcessVideoSetThumbnailGetresultResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -823,6 +843,7 @@ partial void ProcessVideoSetThumbnailGetresultResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.VideoMetadataClient.g.cs b/src/libs/Picsart/Generated/Picsart.VideoMetadataClient.g.cs index fa342ba..f5fe84e 100644 --- a/src/libs/Picsart/Generated/Picsart.VideoMetadataClient.g.cs +++ b/src/libs/Picsart/Generated/Picsart.VideoMetadataClient.g.cs @@ -72,10 +72,10 @@ public VideoMetadataClient( /// Client-wide request defaults such as headers, query parameters, retries, and timeout. /// Dispose the HttpClient when the instance is disposed. True by default. public VideoMetadataClient( - global::System.Net.Http.HttpClient? httpClient = null, - global::System.Uri? baseUri = null, - global::System.Collections.Generic.List? authorizations = null, - global::Picsart.AutoSDKClientOptions? options = null, + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Picsart.AutoSDKClientOptions? options, bool disposeHttpClient = true) { diff --git a/src/libs/Picsart/Generated/Picsart.VideoRemoveBackgroundClient.VideoRemoveBackground.g.cs b/src/libs/Picsart/Generated/Picsart.VideoRemoveBackgroundClient.VideoRemoveBackground.g.cs index 21acf6d..b80d2a4 100644 --- a/src/libs/Picsart/Generated/Picsart.VideoRemoveBackgroundClient.VideoRemoveBackground.g.cs +++ b/src/libs/Picsart/Generated/Picsart.VideoRemoveBackgroundClient.VideoRemoveBackground.g.cs @@ -102,10 +102,11 @@ partial void ProcessVideoRemoveBackgroundResponseContent( var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/video/remove-background", baseUri: HttpClient.BaseAddress); @@ -138,8 +139,11 @@ partial void ProcessVideoRemoveBackgroundResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + __httpRequest.Content = __httpRequestContent; + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -181,6 +185,8 @@ partial void ProcessVideoRemoveBackgroundResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -191,6 +197,11 @@ partial void ProcessVideoRemoveBackgroundResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -208,6 +219,8 @@ partial void ProcessVideoRemoveBackgroundResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -217,8 +230,7 @@ partial void ProcessVideoRemoveBackgroundResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -227,6 +239,11 @@ partial void ProcessVideoRemoveBackgroundResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -243,14 +260,15 @@ partial void ProcessVideoRemoveBackgroundResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -290,6 +308,8 @@ partial void ProcessVideoRemoveBackgroundResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -310,6 +330,8 @@ partial void ProcessVideoRemoveBackgroundResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -757,6 +779,7 @@ partial void ProcessVideoRemoveBackgroundResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -790,6 +813,7 @@ partial void ProcessVideoRemoveBackgroundResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.VideoRemoveBackgroundClient.g.cs b/src/libs/Picsart/Generated/Picsart.VideoRemoveBackgroundClient.g.cs index d11d37c..f1ae2d4 100644 --- a/src/libs/Picsart/Generated/Picsart.VideoRemoveBackgroundClient.g.cs +++ b/src/libs/Picsart/Generated/Picsart.VideoRemoveBackgroundClient.g.cs @@ -72,10 +72,10 @@ public VideoRemoveBackgroundClient( /// Client-wide request defaults such as headers, query parameters, retries, and timeout. /// Dispose the HttpClient when the instance is disposed. True by default. public VideoRemoveBackgroundClient( - global::System.Net.Http.HttpClient? httpClient = null, - global::System.Uri? baseUri = null, - global::System.Collections.Generic.List? authorizations = null, - global::Picsart.AutoSDKClientOptions? options = null, + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Picsart.AutoSDKClientOptions? options, bool disposeHttpClient = true) { diff --git a/src/libs/Picsart/Generated/Picsart.VideoTranscriptionsClient.VideoTranscribeAudio.g.cs b/src/libs/Picsart/Generated/Picsart.VideoTranscriptionsClient.VideoTranscribeAudio.g.cs index ddcbe6c..69590fe 100644 --- a/src/libs/Picsart/Generated/Picsart.VideoTranscriptionsClient.VideoTranscribeAudio.g.cs +++ b/src/libs/Picsart/Generated/Picsart.VideoTranscriptionsClient.VideoTranscribeAudio.g.cs @@ -124,6 +124,7 @@ partial void ProcessVideoTranscribeAudioResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/video/audio/transcribe", baseUri: HttpClient.BaseAddress); @@ -203,6 +204,8 @@ partial void ProcessVideoTranscribeAudioResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -213,6 +216,11 @@ partial void ProcessVideoTranscribeAudioResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -230,6 +238,8 @@ partial void ProcessVideoTranscribeAudioResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -239,8 +249,7 @@ partial void ProcessVideoTranscribeAudioResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -249,6 +258,11 @@ partial void ProcessVideoTranscribeAudioResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -265,14 +279,15 @@ partial void ProcessVideoTranscribeAudioResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -312,6 +327,8 @@ partial void ProcessVideoTranscribeAudioResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -332,6 +349,8 @@ partial void ProcessVideoTranscribeAudioResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -817,6 +836,7 @@ partial void ProcessVideoTranscribeAudioResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -850,6 +870,7 @@ partial void ProcessVideoTranscribeAudioResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.VideoTranscriptionsClient.VideoTranscribeAudioGetresult.g.cs b/src/libs/Picsart/Generated/Picsart.VideoTranscriptionsClient.VideoTranscribeAudioGetresult.g.cs index c8e1d56..6b60d53 100644 --- a/src/libs/Picsart/Generated/Picsart.VideoTranscriptionsClient.VideoTranscribeAudioGetresult.g.cs +++ b/src/libs/Picsart/Generated/Picsart.VideoTranscriptionsClient.VideoTranscribeAudioGetresult.g.cs @@ -103,6 +103,7 @@ partial void ProcessVideoTranscribeAudioGetresultResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: $"/video/audio/transcribe/{transactionId}", baseUri: HttpClient.BaseAddress); @@ -176,6 +177,8 @@ partial void ProcessVideoTranscribeAudioGetresultResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -186,6 +189,11 @@ partial void ProcessVideoTranscribeAudioGetresultResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -203,6 +211,8 @@ partial void ProcessVideoTranscribeAudioGetresultResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -212,8 +222,7 @@ partial void ProcessVideoTranscribeAudioGetresultResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -222,6 +231,11 @@ partial void ProcessVideoTranscribeAudioGetresultResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -238,14 +252,15 @@ partial void ProcessVideoTranscribeAudioGetresultResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -285,6 +300,8 @@ partial void ProcessVideoTranscribeAudioGetresultResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -305,6 +322,8 @@ partial void ProcessVideoTranscribeAudioGetresultResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -828,6 +847,7 @@ partial void ProcessVideoTranscribeAudioGetresultResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -861,6 +881,7 @@ partial void ProcessVideoTranscribeAudioGetresultResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.VideoTranscriptionsClient.g.cs b/src/libs/Picsart/Generated/Picsart.VideoTranscriptionsClient.g.cs index c4629bd..23758d2 100644 --- a/src/libs/Picsart/Generated/Picsart.VideoTranscriptionsClient.g.cs +++ b/src/libs/Picsart/Generated/Picsart.VideoTranscriptionsClient.g.cs @@ -72,10 +72,10 @@ public VideoTranscriptionsClient( /// Client-wide request defaults such as headers, query parameters, retries, and timeout. /// Dispose the HttpClient when the instance is disposed. True by default. public VideoTranscriptionsClient( - global::System.Net.Http.HttpClient? httpClient = null, - global::System.Uri? baseUri = null, - global::System.Collections.Generic.List? authorizations = null, - global::Picsart.AutoSDKClientOptions? options = null, + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Picsart.AutoSDKClientOptions? options, bool disposeHttpClient = true) { diff --git a/src/libs/Picsart/Generated/Picsart.VideoUtilitiesClient.VideoCreditsBalance.g.cs b/src/libs/Picsart/Generated/Picsart.VideoUtilitiesClient.VideoCreditsBalance.g.cs index 167f2e9..95636eb 100644 --- a/src/libs/Picsart/Generated/Picsart.VideoUtilitiesClient.VideoCreditsBalance.g.cs +++ b/src/libs/Picsart/Generated/Picsart.VideoUtilitiesClient.VideoCreditsBalance.g.cs @@ -95,6 +95,7 @@ partial void ProcessVideoCreditsBalanceResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/video/balance", baseUri: HttpClient.BaseAddress); @@ -167,6 +168,8 @@ partial void ProcessVideoCreditsBalanceResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -177,6 +180,11 @@ partial void ProcessVideoCreditsBalanceResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -194,6 +202,8 @@ partial void ProcessVideoCreditsBalanceResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -203,8 +213,7 @@ partial void ProcessVideoCreditsBalanceResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -213,6 +222,11 @@ partial void ProcessVideoCreditsBalanceResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -229,14 +243,15 @@ partial void ProcessVideoCreditsBalanceResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -276,6 +291,8 @@ partial void ProcessVideoCreditsBalanceResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -296,6 +313,8 @@ partial void ProcessVideoCreditsBalanceResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -819,6 +838,7 @@ partial void ProcessVideoCreditsBalanceResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -852,6 +872,7 @@ partial void ProcessVideoCreditsBalanceResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.VideoUtilitiesClient.VideoGetaudioresult.g.cs b/src/libs/Picsart/Generated/Picsart.VideoUtilitiesClient.VideoGetaudioresult.g.cs index 22a37e0..b851edd 100644 --- a/src/libs/Picsart/Generated/Picsart.VideoUtilitiesClient.VideoGetaudioresult.g.cs +++ b/src/libs/Picsart/Generated/Picsart.VideoUtilitiesClient.VideoGetaudioresult.g.cs @@ -103,6 +103,7 @@ partial void ProcessVideoGetaudioresultResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: $"/video/audio/{transactionId}", baseUri: HttpClient.BaseAddress); @@ -176,6 +177,8 @@ partial void ProcessVideoGetaudioresultResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -186,6 +189,11 @@ partial void ProcessVideoGetaudioresultResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -203,6 +211,8 @@ partial void ProcessVideoGetaudioresultResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -212,8 +222,7 @@ partial void ProcessVideoGetaudioresultResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -222,6 +231,11 @@ partial void ProcessVideoGetaudioresultResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -238,14 +252,15 @@ partial void ProcessVideoGetaudioresultResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -285,6 +300,8 @@ partial void ProcessVideoGetaudioresultResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -305,6 +322,8 @@ partial void ProcessVideoGetaudioresultResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -752,6 +771,7 @@ partial void ProcessVideoGetaudioresultResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -785,6 +805,7 @@ partial void ProcessVideoGetaudioresultResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.VideoUtilitiesClient.VideoGetresult.g.cs b/src/libs/Picsart/Generated/Picsart.VideoUtilitiesClient.VideoGetresult.g.cs index 4607ebc..3401741 100644 --- a/src/libs/Picsart/Generated/Picsart.VideoUtilitiesClient.VideoGetresult.g.cs +++ b/src/libs/Picsart/Generated/Picsart.VideoUtilitiesClient.VideoGetresult.g.cs @@ -103,6 +103,7 @@ partial void ProcessVideoGetresultResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: $"/video/video/{transactionId}", baseUri: HttpClient.BaseAddress); @@ -176,6 +177,8 @@ partial void ProcessVideoGetresultResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -186,6 +189,11 @@ partial void ProcessVideoGetresultResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -203,6 +211,8 @@ partial void ProcessVideoGetresultResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -212,8 +222,7 @@ partial void ProcessVideoGetresultResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -222,6 +231,11 @@ partial void ProcessVideoGetresultResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -238,14 +252,15 @@ partial void ProcessVideoGetresultResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -285,6 +300,8 @@ partial void ProcessVideoGetresultResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -305,6 +322,8 @@ partial void ProcessVideoGetresultResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -752,6 +771,7 @@ partial void ProcessVideoGetresultResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -785,6 +805,7 @@ partial void ProcessVideoGetresultResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.VideoUtilitiesClient.VideoUpload.g.cs b/src/libs/Picsart/Generated/Picsart.VideoUtilitiesClient.VideoUpload.g.cs index 54735a6..e449684 100644 --- a/src/libs/Picsart/Generated/Picsart.VideoUtilitiesClient.VideoUpload.g.cs +++ b/src/libs/Picsart/Generated/Picsart.VideoUtilitiesClient.VideoUpload.g.cs @@ -104,10 +104,11 @@ partial void ProcessVideoUploadResponseContent( var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/video/upload", baseUri: HttpClient.BaseAddress); @@ -140,6 +141,7 @@ partial void ProcessVideoUploadResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); if (request.File != default) { @@ -181,8 +183,11 @@ request.Filename is null { __contentFile.Headers.ContentDisposition.FileNameStar = null; } + } + __httpRequest.Content = __httpRequestContent; + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -224,6 +229,8 @@ request.Filename is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -234,6 +241,11 @@ request.Filename is null } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -251,6 +263,8 @@ request.Filename is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -260,8 +274,7 @@ request.Filename is null __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -270,6 +283,11 @@ request.Filename is null __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -286,14 +304,15 @@ request.Filename 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -333,6 +352,8 @@ request.Filename is null attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -353,6 +374,8 @@ request.Filename is null attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -800,6 +823,7 @@ request.Filename is null return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -833,6 +857,7 @@ request.Filename is null return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -901,5 +926,1680 @@ request.Filename is null requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } + + /// + /// Upload files
+ /// Upload resources such as videos, audios or images. The provided URL can be passed as inputs to video operation. + ///
+ /// + /// Source file (binary). + /// + /// + /// Source file (binary). + /// + /// 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 VideoUploadAsync( + global::System.IO.Stream? file = default, + string? filename = default, + global::Picsart.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + var request = new global::Picsart.VideoUploadParameters + { + File = global::System.Array.Empty(), + Filename = filename, + }; + PrepareArguments( + client: HttpClient); + PrepareVideoUploadArguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::Picsart.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_VideoUploadSecurityRequirements, + operationName: "VideoUploadAsync"); + + using var __timeoutCancellationTokenSource = global::Picsart.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Picsart.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Picsart.PathBuilder( + path: "/video/upload", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Picsart.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 (file != default) + { + + var __contentFile = new global::System.Net.Http.StreamContent(file); + __contentFile.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.Filename is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.Filename) ?? 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: __contentFile, + name: "\"file\"", + fileName: request.Filename != null ? $"\"{request.Filename}\"" : string.Empty); + if (__contentFile.Headers.ContentDisposition != null) + { + __contentFile.Headers.ContentDisposition.FileNameStar = null; + } + + } + + __httpRequest.Content = __httpRequestContent; + + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareVideoUploadRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + 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::Picsart.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "VideoUpload", + methodName: "VideoUploadAsync", + pathTemplate: "\"/video/upload\"", + 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::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "VideoUpload", + methodName: "VideoUploadAsync", + pathTemplate: "\"/video/upload\"", + 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "VideoUpload", + methodName: "VideoUploadAsync", + pathTemplate: "\"/video/upload\"", + 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::Picsart.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); + ProcessVideoUploadResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "VideoUpload", + methodName: "VideoUploadAsync", + pathTemplate: "\"/video/upload\"", + 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::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "VideoUpload", + methodName: "VideoUploadAsync", + pathTemplate: "\"/video/upload\"", + 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); + } + // Bad Request + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + global::Picsart.VideoError? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = global::Picsart.VideoError.FromJson(__content_400, JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_400 = global::Picsart.VideoError.FromJson(__content_400, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseObject = __value_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unauthorized + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + global::Picsart.Video401Error? __value_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_401 = global::Picsart.Video401Error.FromJson(__content_401, JsonSerializerContext); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_401 = global::Picsart.Video401Error.FromJson(__content_401, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseObject = __value_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Forbidden + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + global::Picsart.VideoError? __value_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_403 = global::Picsart.VideoError.FromJson(__content_403, JsonSerializerContext); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_403 = global::Picsart.VideoError.FromJson(__content_403, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + statusCode: __response.StatusCode) + { + ResponseBody = __content_403, + ResponseObject = __value_403, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Not Found + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + global::Picsart.VideoError? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = global::Picsart.VideoError.FromJson(__content_404, JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_404 = global::Picsart.VideoError.FromJson(__content_404, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + statusCode: __response.StatusCode) + { + ResponseBody = __content_404, + ResponseObject = __value_404, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Method Not Allowed + if ((int)__response.StatusCode == 405) + { + string? __content_405 = null; + global::System.Exception? __exception_405 = null; + global::Picsart.VideoError? __value_405 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_405 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_405 = global::Picsart.VideoError.FromJson(__content_405, JsonSerializerContext); + } + else + { + __content_405 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_405 = global::Picsart.VideoError.FromJson(__content_405, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_405 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_405 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_405, + statusCode: __response.StatusCode) + { + ResponseBody = __content_405, + ResponseObject = __value_405, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Request Entity Too Large + if ((int)__response.StatusCode == 413) + { + string? __content_413 = null; + global::System.Exception? __exception_413 = null; + global::Picsart.VideoError? __value_413 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_413 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_413 = global::Picsart.VideoError.FromJson(__content_413, JsonSerializerContext); + } + else + { + __content_413 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_413 = global::Picsart.VideoError.FromJson(__content_413, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_413 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_413 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_413, + statusCode: __response.StatusCode) + { + ResponseBody = __content_413, + ResponseObject = __value_413, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unsupported Media Type + if ((int)__response.StatusCode == 415) + { + string? __content_415 = null; + global::System.Exception? __exception_415 = null; + global::Picsart.VideoError? __value_415 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_415 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_415 = global::Picsart.VideoError.FromJson(__content_415, JsonSerializerContext); + } + else + { + __content_415 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_415 = global::Picsart.VideoError.FromJson(__content_415, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_415 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_415 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_415, + statusCode: __response.StatusCode) + { + ResponseBody = __content_415, + ResponseObject = __value_415, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Too Many Requests + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + global::Picsart.VideoError? __value_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_429 = global::Picsart.VideoError.FromJson(__content_429, JsonSerializerContext); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_429 = global::Picsart.VideoError.FromJson(__content_429, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + statusCode: __response.StatusCode) + { + ResponseBody = __content_429, + ResponseObject = __value_429, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Request Header Fields Too Large + if ((int)__response.StatusCode == 431) + { + string? __content_431 = null; + global::System.Exception? __exception_431 = null; + global::Picsart.VideoError? __value_431 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_431 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_431 = global::Picsart.VideoError.FromJson(__content_431, JsonSerializerContext); + } + else + { + __content_431 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_431 = global::Picsart.VideoError.FromJson(__content_431, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_431 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_431 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_431, + statusCode: __response.StatusCode) + { + ResponseBody = __content_431, + ResponseObject = __value_431, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Internal Server Error + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + global::Picsart.VideoError? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = global::Picsart.VideoError.FromJson(__content_500, JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_500 = global::Picsart.VideoError.FromJson(__content_500, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Service Unavailable + if ((int)__response.StatusCode == 503) + { + string? __content_503 = null; + global::System.Exception? __exception_503 = null; + global::Picsart.VideoError? __value_503 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_503 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_503 = global::Picsart.VideoError.FromJson(__content_503, JsonSerializerContext); + } + else + { + __content_503 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_503 = global::Picsart.VideoError.FromJson(__content_503, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_503 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_503 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_503, + statusCode: __response.StatusCode) + { + ResponseBody = __content_503, + ResponseObject = __value_503, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessVideoUploadResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Picsart.VideoUploadResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Picsart.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::Picsart.VideoUploadResponse.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::Picsart.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(); + } + } + /// + /// Upload files
+ /// Upload resources such as videos, audios or images. The provided URL can be passed as inputs to video operation. + ///
+ /// + /// Source file (binary). + /// + /// + /// Source file (binary). + /// + /// 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> VideoUploadAsResponseAsync( + global::System.IO.Stream? file = default, + string? filename = default, + global::Picsart.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + var request = new global::Picsart.VideoUploadParameters + { + File = global::System.Array.Empty(), + Filename = filename, + }; + PrepareArguments( + client: HttpClient); + PrepareVideoUploadArguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::Picsart.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_VideoUploadSecurityRequirements, + operationName: "VideoUploadAsync"); + + using var __timeoutCancellationTokenSource = global::Picsart.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Picsart.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Picsart.PathBuilder( + path: "/video/upload", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Picsart.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 (file != default) + { + + var __contentFile = new global::System.Net.Http.StreamContent(file); + __contentFile.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.Filename is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.Filename) ?? 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: __contentFile, + name: "\"file\"", + fileName: request.Filename != null ? $"\"{request.Filename}\"" : string.Empty); + if (__contentFile.Headers.ContentDisposition != null) + { + __contentFile.Headers.ContentDisposition.FileNameStar = null; + } + + } + + __httpRequest.Content = __httpRequestContent; + + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareVideoUploadRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + 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::Picsart.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "VideoUpload", + methodName: "VideoUploadAsync", + pathTemplate: "\"/video/upload\"", + 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::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "VideoUpload", + methodName: "VideoUploadAsync", + pathTemplate: "\"/video/upload\"", + 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "VideoUpload", + methodName: "VideoUploadAsync", + pathTemplate: "\"/video/upload\"", + 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::Picsart.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); + ProcessVideoUploadResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "VideoUpload", + methodName: "VideoUploadAsync", + pathTemplate: "\"/video/upload\"", + 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::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "VideoUpload", + methodName: "VideoUploadAsync", + pathTemplate: "\"/video/upload\"", + 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); + } + // Bad Request + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + global::Picsart.VideoError? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = global::Picsart.VideoError.FromJson(__content_400, JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_400 = global::Picsart.VideoError.FromJson(__content_400, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseObject = __value_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unauthorized + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + global::Picsart.Video401Error? __value_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_401 = global::Picsart.Video401Error.FromJson(__content_401, JsonSerializerContext); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_401 = global::Picsart.Video401Error.FromJson(__content_401, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseObject = __value_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Forbidden + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + global::Picsart.VideoError? __value_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_403 = global::Picsart.VideoError.FromJson(__content_403, JsonSerializerContext); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_403 = global::Picsart.VideoError.FromJson(__content_403, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + statusCode: __response.StatusCode) + { + ResponseBody = __content_403, + ResponseObject = __value_403, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Not Found + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + global::Picsart.VideoError? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = global::Picsart.VideoError.FromJson(__content_404, JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_404 = global::Picsart.VideoError.FromJson(__content_404, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + statusCode: __response.StatusCode) + { + ResponseBody = __content_404, + ResponseObject = __value_404, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Method Not Allowed + if ((int)__response.StatusCode == 405) + { + string? __content_405 = null; + global::System.Exception? __exception_405 = null; + global::Picsart.VideoError? __value_405 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_405 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_405 = global::Picsart.VideoError.FromJson(__content_405, JsonSerializerContext); + } + else + { + __content_405 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_405 = global::Picsart.VideoError.FromJson(__content_405, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_405 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_405 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_405, + statusCode: __response.StatusCode) + { + ResponseBody = __content_405, + ResponseObject = __value_405, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Request Entity Too Large + if ((int)__response.StatusCode == 413) + { + string? __content_413 = null; + global::System.Exception? __exception_413 = null; + global::Picsart.VideoError? __value_413 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_413 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_413 = global::Picsart.VideoError.FromJson(__content_413, JsonSerializerContext); + } + else + { + __content_413 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_413 = global::Picsart.VideoError.FromJson(__content_413, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_413 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_413 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_413, + statusCode: __response.StatusCode) + { + ResponseBody = __content_413, + ResponseObject = __value_413, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unsupported Media Type + if ((int)__response.StatusCode == 415) + { + string? __content_415 = null; + global::System.Exception? __exception_415 = null; + global::Picsart.VideoError? __value_415 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_415 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_415 = global::Picsart.VideoError.FromJson(__content_415, JsonSerializerContext); + } + else + { + __content_415 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_415 = global::Picsart.VideoError.FromJson(__content_415, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_415 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_415 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_415, + statusCode: __response.StatusCode) + { + ResponseBody = __content_415, + ResponseObject = __value_415, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Too Many Requests + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + global::Picsart.VideoError? __value_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_429 = global::Picsart.VideoError.FromJson(__content_429, JsonSerializerContext); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_429 = global::Picsart.VideoError.FromJson(__content_429, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + statusCode: __response.StatusCode) + { + ResponseBody = __content_429, + ResponseObject = __value_429, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Request Header Fields Too Large + if ((int)__response.StatusCode == 431) + { + string? __content_431 = null; + global::System.Exception? __exception_431 = null; + global::Picsart.VideoError? __value_431 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_431 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_431 = global::Picsart.VideoError.FromJson(__content_431, JsonSerializerContext); + } + else + { + __content_431 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_431 = global::Picsart.VideoError.FromJson(__content_431, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_431 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_431 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_431, + statusCode: __response.StatusCode) + { + ResponseBody = __content_431, + ResponseObject = __value_431, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Internal Server Error + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + global::Picsart.VideoError? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = global::Picsart.VideoError.FromJson(__content_500, JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_500 = global::Picsart.VideoError.FromJson(__content_500, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Service Unavailable + if ((int)__response.StatusCode == 503) + { + string? __content_503 = null; + global::System.Exception? __exception_503 = null; + global::Picsart.VideoError? __value_503 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_503 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_503 = global::Picsart.VideoError.FromJson(__content_503, JsonSerializerContext); + } + else + { + __content_503 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_503 = global::Picsart.VideoError.FromJson(__content_503, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_503 = __ex; + } + + throw new global::Picsart.ApiException( + message: __content_503 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_503, + statusCode: __response.StatusCode) + { + ResponseBody = __content_503, + ResponseObject = __value_503, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessVideoUploadResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Picsart.VideoUploadResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Picsart.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Picsart.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::Picsart.VideoUploadResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Picsart.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Picsart.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::Picsart.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/Picsart/Generated/Picsart.VideoUtilitiesClient.g.cs b/src/libs/Picsart/Generated/Picsart.VideoUtilitiesClient.g.cs index cda2234..7346791 100644 --- a/src/libs/Picsart/Generated/Picsart.VideoUtilitiesClient.g.cs +++ b/src/libs/Picsart/Generated/Picsart.VideoUtilitiesClient.g.cs @@ -72,10 +72,10 @@ public VideoUtilitiesClient( /// Client-wide request defaults such as headers, query parameters, retries, and timeout. /// Dispose the HttpClient when the instance is disposed. True by default. public VideoUtilitiesClient( - global::System.Net.Http.HttpClient? httpClient = null, - global::System.Uri? baseUri = null, - global::System.Collections.Generic.List? authorizations = null, - global::Picsart.AutoSDKClientOptions? options = null, + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Picsart.AutoSDKClientOptions? options, bool disposeHttpClient = true) { diff --git a/src/libs/Picsart/Generated/Picsart.VideoVideoEnhancementClient.VideoUpscaleFps.g.cs b/src/libs/Picsart/Generated/Picsart.VideoVideoEnhancementClient.VideoUpscaleFps.g.cs index a232ec8..08cfe7c 100644 --- a/src/libs/Picsart/Generated/Picsart.VideoVideoEnhancementClient.VideoUpscaleFps.g.cs +++ b/src/libs/Picsart/Generated/Picsart.VideoVideoEnhancementClient.VideoUpscaleFps.g.cs @@ -104,10 +104,11 @@ partial void ProcessVideoUpscaleFpsResponseContent( var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/video/upscale/fps", baseUri: HttpClient.BaseAddress); @@ -140,6 +141,7 @@ partial void ProcessVideoUpscaleFpsResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); if (request.VideoUrl != default) { @@ -147,8 +149,11 @@ partial void ProcessVideoUpscaleFpsResponseContent( __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.VideoUrl ?? string.Empty), name: "\"video_url\""); + } + __httpRequest.Content = __httpRequestContent; + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -190,6 +195,8 @@ partial void ProcessVideoUpscaleFpsResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -200,6 +207,11 @@ partial void ProcessVideoUpscaleFpsResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -217,6 +229,8 @@ partial void ProcessVideoUpscaleFpsResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -226,8 +240,7 @@ partial void ProcessVideoUpscaleFpsResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -236,6 +249,11 @@ partial void ProcessVideoUpscaleFpsResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -252,14 +270,15 @@ partial void ProcessVideoUpscaleFpsResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -299,6 +318,8 @@ partial void ProcessVideoUpscaleFpsResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -319,6 +340,8 @@ partial void ProcessVideoUpscaleFpsResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -842,6 +865,7 @@ partial void ProcessVideoUpscaleFpsResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -875,6 +899,7 @@ partial void ProcessVideoUpscaleFpsResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.VideoVideoEnhancementClient.VideoUpscaleFpsGetresult.g.cs b/src/libs/Picsart/Generated/Picsart.VideoVideoEnhancementClient.VideoUpscaleFpsGetresult.g.cs index 6062ae6..f44961e 100644 --- a/src/libs/Picsart/Generated/Picsart.VideoVideoEnhancementClient.VideoUpscaleFpsGetresult.g.cs +++ b/src/libs/Picsart/Generated/Picsart.VideoVideoEnhancementClient.VideoUpscaleFpsGetresult.g.cs @@ -103,6 +103,7 @@ partial void ProcessVideoUpscaleFpsGetresultResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: $"/video/upscale/fps/{transactionId}", baseUri: HttpClient.BaseAddress); @@ -176,6 +177,8 @@ partial void ProcessVideoUpscaleFpsGetresultResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -186,6 +189,11 @@ partial void ProcessVideoUpscaleFpsGetresultResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -203,6 +211,8 @@ partial void ProcessVideoUpscaleFpsGetresultResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -212,8 +222,7 @@ partial void ProcessVideoUpscaleFpsGetresultResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -222,6 +231,11 @@ partial void ProcessVideoUpscaleFpsGetresultResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -238,14 +252,15 @@ partial void ProcessVideoUpscaleFpsGetresultResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -285,6 +300,8 @@ partial void ProcessVideoUpscaleFpsGetresultResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -305,6 +322,8 @@ partial void ProcessVideoUpscaleFpsGetresultResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -790,6 +809,7 @@ partial void ProcessVideoUpscaleFpsGetresultResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -823,6 +843,7 @@ partial void ProcessVideoUpscaleFpsGetresultResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.VideoVideoEnhancementClient.g.cs b/src/libs/Picsart/Generated/Picsart.VideoVideoEnhancementClient.g.cs index 851711d..b5a8075 100644 --- a/src/libs/Picsart/Generated/Picsart.VideoVideoEnhancementClient.g.cs +++ b/src/libs/Picsart/Generated/Picsart.VideoVideoEnhancementClient.g.cs @@ -72,10 +72,10 @@ public VideoVideoEnhancementClient( /// Client-wide request defaults such as headers, query parameters, retries, and timeout. /// Dispose the HttpClient when the instance is disposed. True by default. public VideoVideoEnhancementClient( - global::System.Net.Http.HttpClient? httpClient = null, - global::System.Uri? baseUri = null, - global::System.Collections.Generic.List? authorizations = null, - global::Picsart.AutoSDKClientOptions? options = null, + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Picsart.AutoSDKClientOptions? options, bool disposeHttpClient = true) { diff --git a/src/libs/Picsart/Generated/Picsart.VideoWatermarkClient.VideoAddWatermark.g.cs b/src/libs/Picsart/Generated/Picsart.VideoWatermarkClient.VideoAddWatermark.g.cs index 86c9fed..71a6ffc 100644 --- a/src/libs/Picsart/Generated/Picsart.VideoWatermarkClient.VideoAddWatermark.g.cs +++ b/src/libs/Picsart/Generated/Picsart.VideoWatermarkClient.VideoAddWatermark.g.cs @@ -102,10 +102,11 @@ partial void ProcessVideoAddWatermarkResponseContent( var __maxAttempts = global::Picsart.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Picsart.PathBuilder( path: "/video/watermark", baseUri: HttpClient.BaseAddress); @@ -138,8 +139,11 @@ partial void ProcessVideoAddWatermarkResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + __httpRequest.Content = __httpRequestContent; + global::Picsart.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -181,6 +185,8 @@ partial void ProcessVideoAddWatermarkResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -191,6 +197,11 @@ partial void ProcessVideoAddWatermarkResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -208,6 +219,8 @@ partial void ProcessVideoAddWatermarkResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -217,8 +230,7 @@ partial void ProcessVideoAddWatermarkResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -227,6 +239,11 @@ partial void ProcessVideoAddWatermarkResponseContent( __attempt < __maxAttempts && global::Picsart.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Picsart.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Picsart.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Picsart.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -243,14 +260,15 @@ partial void ProcessVideoAddWatermarkResponseContent( 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::Picsart.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -290,6 +308,8 @@ partial void ProcessVideoAddWatermarkResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -310,6 +330,8 @@ partial void ProcessVideoAddWatermarkResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad Request @@ -795,6 +817,7 @@ partial void ProcessVideoAddWatermarkResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) @@ -828,6 +851,7 @@ partial void ProcessVideoAddWatermarkResponseContent( return new global::Picsart.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Picsart.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, body: __value); } catch (global::System.Exception __ex) diff --git a/src/libs/Picsart/Generated/Picsart.VideoWatermarkClient.g.cs b/src/libs/Picsart/Generated/Picsart.VideoWatermarkClient.g.cs index 5331c02..93623d8 100644 --- a/src/libs/Picsart/Generated/Picsart.VideoWatermarkClient.g.cs +++ b/src/libs/Picsart/Generated/Picsart.VideoWatermarkClient.g.cs @@ -72,10 +72,10 @@ public VideoWatermarkClient( /// Client-wide request defaults such as headers, query parameters, retries, and timeout. /// Dispose the HttpClient when the instance is disposed. True by default. public VideoWatermarkClient( - global::System.Net.Http.HttpClient? httpClient = null, - global::System.Uri? baseUri = null, - global::System.Collections.Generic.List? authorizations = null, - global::Picsart.AutoSDKClientOptions? options = null, + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Picsart.AutoSDKClientOptions? options, bool disposeHttpClient = true) {