diff --git a/src/libs/Picsart/Generated/Picsart.IImageClassificationClient.ImageCarsClassifier.g.cs b/src/libs/Picsart/Generated/Picsart.IImageClassificationClient.ImageCarsClassifier.g.cs
index ac18bc7..05f80a9 100644
--- a/src/libs/Picsart/Generated/Picsart.IImageClassificationClient.ImageCarsClassifier.g.cs
+++ b/src/libs/Picsart/Generated/Picsart.IImageClassificationClient.ImageCarsClassifier.g.cs
@@ -57,52 +57,5 @@ 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 70e7522..4784af0 100644
--- a/src/libs/Picsart/Generated/Picsart.IImageClassificationClient.ImageDescriber.g.cs
+++ b/src/libs/Picsart/Generated/Picsart.IImageClassificationClient.ImageDescriber.g.cs
@@ -54,50 +54,5 @@ 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 d933ae2..42895f1 100644
--- a/src/libs/Picsart/Generated/Picsart.IImageClassificationClient.ImageExtractColors.g.cs
+++ b/src/libs/Picsart/Generated/Picsart.IImageClassificationClient.ImageExtractColors.g.cs
@@ -57,52 +57,5 @@ 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 4f552f6..c77022d 100644
--- a/src/libs/Picsart/Generated/Picsart.IImageClassificationClient.ImageTagging.g.cs
+++ b/src/libs/Picsart/Generated/Picsart.IImageClassificationClient.ImageTagging.g.cs
@@ -54,50 +54,5 @@ 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 494bac7..8cc668d 100644
--- a/src/libs/Picsart/Generated/Picsart.IImageConversionClient.ImageDesignImport.g.cs
+++ b/src/libs/Picsart/Generated/Picsart.IImageConversionClient.ImageDesignImport.g.cs
@@ -67,60 +67,5 @@ 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 53dda25..19a3612 100644
--- a/src/libs/Picsart/Generated/Picsart.IImageUtilitiesClient.ImageUpload.g.cs
+++ b/src/libs/Picsart/Generated/Picsart.IImageUtilitiesClient.ImageUpload.g.cs
@@ -67,60 +67,5 @@ 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 a04da94..f28bd5f 100644
--- a/src/libs/Picsart/Generated/Picsart.IVdVariableDataContentClient.VdDescribeVariableDataContent.g.cs
+++ b/src/libs/Picsart/Generated/Picsart.IVdVariableDataContentClient.VdDescribeVariableDataContent.g.cs
@@ -56,58 +56,5 @@ 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 c13b07c..3d955c7 100644
--- a/src/libs/Picsart/Generated/Picsart.IVideoUtilitiesClient.VideoUpload.g.cs
+++ b/src/libs/Picsart/Generated/Picsart.IVideoUtilitiesClient.VideoUpload.g.cs
@@ -48,42 +48,5 @@ 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 ad426ef..0efb59b 100644
--- a/src/libs/Picsart/Generated/Picsart.ImageClassificationClient.ImageCarsClassifier.g.cs
+++ b/src/libs/Picsart/Generated/Picsart.ImageClassificationClient.ImageCarsClassifier.g.cs
@@ -1028,1876 +1028,5 @@ 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 9b41a6c..cded4cc 100644
--- a/src/libs/Picsart/Generated/Picsart.ImageClassificationClient.ImageDescriber.g.cs
+++ b/src/libs/Picsart/Generated/Picsart.ImageClassificationClient.ImageDescriber.g.cs
@@ -1025,1874 +1025,5 @@ 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 d8cdf09..094124c 100644
--- a/src/libs/Picsart/Generated/Picsart.ImageClassificationClient.ImageExtractColors.g.cs
+++ b/src/libs/Picsart/Generated/Picsart.ImageClassificationClient.ImageExtractColors.g.cs
@@ -1028,1876 +1028,5 @@ 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.ImageTagging.g.cs b/src/libs/Picsart/Generated/Picsart.ImageClassificationClient.ImageTagging.g.cs
index d7a1d0c..1f24ebb 100644
--- a/src/libs/Picsart/Generated/Picsart.ImageClassificationClient.ImageTagging.g.cs
+++ b/src/libs/Picsart/Generated/Picsart.ImageClassificationClient.ImageTagging.g.cs
@@ -1025,1874 +1025,5 @@ 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.ImageConversionClient.ImageDesignImport.g.cs b/src/libs/Picsart/Generated/Picsart.ImageConversionClient.ImageDesignImport.g.cs
index 81f4897..7afde0a 100644
--- a/src/libs/Picsart/Generated/Picsart.ImageConversionClient.ImageDesignImport.g.cs
+++ b/src/libs/Picsart/Generated/Picsart.ImageConversionClient.ImageDesignImport.g.cs
@@ -1030,1868 +1030,5 @@ 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.ImageUtilitiesClient.ImageUpload.g.cs b/src/libs/Picsart/Generated/Picsart.ImageUtilitiesClient.ImageUpload.g.cs
index 3f7139c..af7dbba 100644
--- a/src/libs/Picsart/Generated/Picsart.ImageUtilitiesClient.ImageUpload.g.cs
+++ b/src/libs/Picsart/Generated/Picsart.ImageUtilitiesClient.ImageUpload.g.cs
@@ -1030,1868 +1030,5 @@ 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.OptionsSupport.g.cs b/src/libs/Picsart/Generated/Picsart.OptionsSupport.g.cs
index 83316f0..876d25a 100644
--- a/src/libs/Picsart/Generated/Picsart.OptionsSupport.g.cs
+++ b/src/libs/Picsart/Generated/Picsart.OptionsSupport.g.cs
@@ -150,6 +150,84 @@ public interface IAutoSDKAuthorizationProvider
global::Picsart.AutoSDKHookContext context);
}
+ ///
+ /// Marker keys stamped onto outgoing
+ /// instances so consumer s — and any
+ /// other transport-layer code that runs after AutoSDK's send pipeline — can observe whether
+ /// the resolved Authorization is call-scoped and opt out of overwriting it with a
+ /// rotation-aware account-level credential.
+ ///
+ public static class AutoSDKHttpRequestOptions
+ {
+ ///
+ /// Key under which records the marker. Exposed
+ /// for handlers that target frameworks older than .NET 5 and need to read the value
+ /// through the legacy HttpRequestMessage.Properties bag.
+ ///
+ public const string AuthorizationOverrideKey = "AutoSDK.AuthorizationOverride";
+
+#if NET5_0_OR_GREATER
+ ///
+ /// Strongly-typed for
+ /// the call-scoped Authorization marker on .NET 5+ targets. Consumers should prefer this
+ /// over the legacy HttpRequestMessage.Properties bag where available.
+ ///
+ public static readonly global::System.Net.Http.HttpRequestOptionsKey AuthorizationOverride =
+ new global::System.Net.Http.HttpRequestOptionsKey(AuthorizationOverrideKey);
+#endif
+
+ ///
+ /// Stamps the call-scoped Authorization marker on . AutoSDK's
+ /// built-in calls this whenever the
+ /// resolved auth came from a per-request override or a client-level
+ /// . Hand-written SDK extensions that set a
+ /// non-default Authorization header (e.g. a session-scoped bearer returned by an
+ /// upstream poll) should call this too so downstream rotation handlers know to skip the
+ /// overwrite.
+ ///
+ ///
+ public static void StampAuthorizationOverride(
+ global::System.Net.Http.HttpRequestMessage? request)
+ {
+ if (request is null)
+ {
+ return;
+ }
+
+#if NET5_0_OR_GREATER
+ request.Options.Set(AuthorizationOverride, true);
+#else
+#pragma warning disable CS0618 // HttpRequestMessage.Properties is obsolete in NET5+, but the only option below it.
+ request.Properties[AuthorizationOverrideKey] = true;
+#pragma warning restore CS0618
+#endif
+ }
+
+ ///
+ /// Returns true when previously marked the
+ /// request as carrying a call-scoped Authorization.
+ ///
+ ///
+ public static bool HasAuthorizationOverride(
+ global::System.Net.Http.HttpRequestMessage? request)
+ {
+ if (request is null)
+ {
+ return false;
+ }
+
+#if NET5_0_OR_GREATER
+ return request.Options.TryGetValue(AuthorizationOverride, out var value) && value;
+#else
+#pragma warning disable CS0618
+ return request.Properties.TryGetValue(AuthorizationOverrideKey, out var raw) &&
+ raw is bool flag &&
+ flag;
+#pragma warning restore CS0618
+#endif
+ }
+ }
+
///
/// Built-in that consults
/// before every outgoing
@@ -176,6 +254,7 @@ public sealed class AutoSDKAuthorizationProviderHook : global::Picsart.AutoSDKHo
ApplyAuthorization(context.Request, perRequest[index]);
}
+ global::Picsart.AutoSDKHttpRequestOptions.StampAuthorizationOverride(context.Request);
return;
}
@@ -195,6 +274,8 @@ public sealed class AutoSDKAuthorizationProviderHook : global::Picsart.AutoSDKHo
{
ApplyAuthorization(context.Request, resolved[index]);
}
+
+ global::Picsart.AutoSDKHttpRequestOptions.StampAuthorizationOverride(context.Request);
}
private static void ApplyAuthorization(
diff --git a/src/libs/Picsart/Generated/Picsart.VdVariableDataContentClient.VdDescribeVariableDataContent.g.cs b/src/libs/Picsart/Generated/Picsart.VdVariableDataContentClient.VdDescribeVariableDataContent.g.cs
index e107261..621e240 100644
--- a/src/libs/Picsart/Generated/Picsart.VdVariableDataContentClient.VdDescribeVariableDataContent.g.cs
+++ b/src/libs/Picsart/Generated/Picsart.VdVariableDataContentClient.VdDescribeVariableDataContent.g.cs
@@ -1028,1884 +1028,5 @@ 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.VideoUtilitiesClient.VideoUpload.g.cs b/src/libs/Picsart/Generated/Picsart.VideoUtilitiesClient.VideoUpload.g.cs
index e449684..c0ffaa3 100644
--- a/src/libs/Picsart/Generated/Picsart.VideoUtilitiesClient.VideoUpload.g.cs
+++ b/src/libs/Picsart/Generated/Picsart.VideoUtilitiesClient.VideoUpload.g.cs
@@ -926,1680 +926,5 @@ 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