diff --git a/src/libs/Sightengine/Generated/Sightengine.ISightengineClient.CheckVideoAsync.g.cs b/src/libs/Sightengine/Generated/Sightengine.ISightengineClient.CheckVideoAsync.g.cs index 0a06ec9..a2057b1 100644 --- a/src/libs/Sightengine/Generated/Sightengine.ISightengineClient.CheckVideoAsync.g.cs +++ b/src/libs/Sightengine/Generated/Sightengine.ISightengineClient.CheckVideoAsync.g.cs @@ -71,76 +71,5 @@ public partial interface ISightengineClient string? callbackUrl = default, global::Sightengine.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); - - /// - /// Check Video (Asynchronous)
- /// Start asynchronous video or live stream moderation.
- /// Results are delivered via the callback URL.
- /// Supports videos longer than 60 seconds and live streams
- /// (HLS, RTMP, RTMPS, RTSP, RTP, MPEG-DASH). - ///
- /// - /// The video file to analyze (use this OR stream_url). - /// - /// - /// The video file to analyze (use this OR stream_url). - /// - /// - /// Public URL of the video or live stream. - /// - /// - /// Webhook URL to receive moderation results. - /// - /// - /// Comma-separated list of detection models.
- /// Available: nudity-2.1, gore-2.0, weapon, drugs, violence,
- /// alcohol, offensive, self-harm, scam. - /// - /// 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 CheckVideoAsyncAsync( - string models, - global::System.IO.Stream? media = default, - string? medianame = default, - string? streamUrl = default, - string? callbackUrl = default, - global::Sightengine.AutoSDKRequestOptions? requestOptions = default, - global::System.Threading.CancellationToken cancellationToken = default); - /// - /// Check Video (Asynchronous)
- /// Start asynchronous video or live stream moderation.
- /// Results are delivered via the callback URL.
- /// Supports videos longer than 60 seconds and live streams
- /// (HLS, RTMP, RTMPS, RTSP, RTP, MPEG-DASH). - ///
- /// - /// The video file to analyze (use this OR stream_url). - /// - /// - /// The video file to analyze (use this OR stream_url). - /// - /// - /// Public URL of the video or live stream. - /// - /// - /// Webhook URL to receive moderation results. - /// - /// - /// Comma-separated list of detection models.
- /// Available: nudity-2.1, gore-2.0, weapon, drugs, violence,
- /// alcohol, offensive, self-harm, scam. - /// - /// 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> CheckVideoAsyncAsResponseAsync( - string models, - global::System.IO.Stream? media = default, - string? medianame = default, - string? streamUrl = default, - string? callbackUrl = default, - global::Sightengine.AutoSDKRequestOptions? requestOptions = default, - global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Sightengine/Generated/Sightengine.ISightengineClient.CheckVideoSync.g.cs b/src/libs/Sightengine/Generated/Sightengine.ISightengineClient.CheckVideoSync.g.cs index 082f6e1..71d483b 100644 --- a/src/libs/Sightengine/Generated/Sightengine.ISightengineClient.CheckVideoSync.g.cs +++ b/src/libs/Sightengine/Generated/Sightengine.ISightengineClient.CheckVideoSync.g.cs @@ -61,64 +61,5 @@ public partial interface ISightengineClient string? streamUrl = default, global::Sightengine.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); - - /// - /// Check Video (Synchronous)
- /// Moderate a video synchronously (must be under 60 seconds).
- /// Submit either a raw video file or a public URL. - ///
- /// - /// The video file to analyze (use this OR stream_url). - /// - /// - /// The video file to analyze (use this OR stream_url). - /// - /// - /// Public URL of the video (use this OR media). - /// - /// - /// Comma-separated list of detection models.
- /// Available: nudity-2.1, gore-2.0, weapon, drugs, violence,
- /// alcohol, offensive, self-harm, scam. - /// - /// 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 CheckVideoSyncAsync( - string models, - global::System.IO.Stream? media = default, - string? medianame = default, - string? streamUrl = default, - global::Sightengine.AutoSDKRequestOptions? requestOptions = default, - global::System.Threading.CancellationToken cancellationToken = default); - /// - /// Check Video (Synchronous)
- /// Moderate a video synchronously (must be under 60 seconds).
- /// Submit either a raw video file or a public URL. - ///
- /// - /// The video file to analyze (use this OR stream_url). - /// - /// - /// The video file to analyze (use this OR stream_url). - /// - /// - /// Public URL of the video (use this OR media). - /// - /// - /// Comma-separated list of detection models.
- /// Available: nudity-2.1, gore-2.0, weapon, drugs, violence,
- /// alcohol, offensive, self-harm, scam. - /// - /// 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> CheckVideoSyncAsResponseAsync( - string models, - global::System.IO.Stream? media = default, - string? medianame = default, - string? streamUrl = default, - global::Sightengine.AutoSDKRequestOptions? requestOptions = default, - global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Sightengine/Generated/Sightengine.ISightengineClient.SubmitFeedback.g.cs b/src/libs/Sightengine/Generated/Sightengine.ISightengineClient.SubmitFeedback.g.cs index 53b1a12..ceeee1c 100644 --- a/src/libs/Sightengine/Generated/Sightengine.ISightengineClient.SubmitFeedback.g.cs +++ b/src/libs/Sightengine/Generated/Sightengine.ISightengineClient.SubmitFeedback.g.cs @@ -68,74 +68,5 @@ public partial interface ISightengineClient string? medianame = default, global::Sightengine.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); - - /// - /// Submit Feedback
- /// Submit moderation feedback to improve model accuracy.
- /// Feedback submissions are free and do not count as operations.
- /// The image is used to continuously improve the specified model. - ///
- /// - /// Public URL to the image (use this OR media). - /// - /// - /// The image file (use this OR url). - /// - /// - /// The image file (use this OR url). - /// - /// - /// The model that classified the image.
- /// Available: nudity, gore, weapon, drugs, violence,
- /// alcohol, offensive, self-harm, scam, genai. - /// - /// - /// The expected/correct classification result. - /// - /// 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 SubmitFeedbackAsync( - string model, - string @class, - string? url = default, - global::System.IO.Stream? media = default, - string? medianame = default, - global::Sightengine.AutoSDKRequestOptions? requestOptions = default, - global::System.Threading.CancellationToken cancellationToken = default); - /// - /// Submit Feedback
- /// Submit moderation feedback to improve model accuracy.
- /// Feedback submissions are free and do not count as operations.
- /// The image is used to continuously improve the specified model. - ///
- /// - /// Public URL to the image (use this OR media). - /// - /// - /// The image file (use this OR url). - /// - /// - /// The image file (use this OR url). - /// - /// - /// The model that classified the image.
- /// Available: nudity, gore, weapon, drugs, violence,
- /// alcohol, offensive, self-harm, scam, genai. - /// - /// - /// The expected/correct classification result. - /// - /// 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> SubmitFeedbackAsResponseAsync( - string model, - string @class, - string? url = default, - global::System.IO.Stream? media = default, - string? medianame = default, - global::Sightengine.AutoSDKRequestOptions? requestOptions = default, - global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Sightengine/Generated/Sightengine.OptionsSupport.g.cs b/src/libs/Sightengine/Generated/Sightengine.OptionsSupport.g.cs index 8d7c4a6..4bb66fd 100644 --- a/src/libs/Sightengine/Generated/Sightengine.OptionsSupport.g.cs +++ b/src/libs/Sightengine/Generated/Sightengine.OptionsSupport.g.cs @@ -150,6 +150,84 @@ public interface IAutoSDKAuthorizationProvider global::Sightengine.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::Sightengine.AutoS ApplyAuthorization(context.Request, perRequest[index]); } + global::Sightengine.AutoSDKHttpRequestOptions.StampAuthorizationOverride(context.Request); return; } @@ -195,6 +274,8 @@ public sealed class AutoSDKAuthorizationProviderHook : global::Sightengine.AutoS { ApplyAuthorization(context.Request, resolved[index]); } + + global::Sightengine.AutoSDKHttpRequestOptions.StampAuthorizationOverride(context.Request); } private static void ApplyAuthorization( diff --git a/src/libs/Sightengine/Generated/Sightengine.SightengineClient.CheckVideoAsync.g.cs b/src/libs/Sightengine/Generated/Sightengine.SightengineClient.CheckVideoAsync.g.cs index e8b67f9..b2be5ec 100644 --- a/src/libs/Sightengine/Generated/Sightengine.SightengineClient.CheckVideoAsync.g.cs +++ b/src/libs/Sightengine/Generated/Sightengine.SightengineClient.CheckVideoAsync.g.cs @@ -629,1074 +629,5 @@ request.Medianame is null requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } - - /// - /// Check Video (Asynchronous)
- /// Start asynchronous video or live stream moderation.
- /// Results are delivered via the callback URL.
- /// Supports videos longer than 60 seconds and live streams
- /// (HLS, RTMP, RTMPS, RTSP, RTP, MPEG-DASH). - ///
- /// - /// The video file to analyze (use this OR stream_url). - /// - /// - /// The video file to analyze (use this OR stream_url). - /// - /// - /// Public URL of the video or live stream. - /// - /// - /// Webhook URL to receive moderation results. - /// - /// - /// Comma-separated list of detection models.
- /// Available: nudity-2.1, gore-2.0, weapon, drugs, violence,
- /// alcohol, offensive, self-harm, scam. - /// - /// 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 CheckVideoAsyncAsync( - string models, - global::System.IO.Stream? media = default, - string? medianame = default, - string? streamUrl = default, - string? callbackUrl = default, - global::Sightengine.AutoSDKRequestOptions? requestOptions = default, - global::System.Threading.CancellationToken cancellationToken = default) - { - - var request = new global::Sightengine.CheckVideoAsyncRequest - { - Media = global::System.Array.Empty(), - Medianame = medianame, - StreamUrl = streamUrl, - CallbackUrl = callbackUrl, - Models = models, - }; - PrepareArguments( - client: HttpClient); - PrepareCheckVideoAsyncArguments( - httpClient: HttpClient, - request: request); - - - var __authorizations = global::Sightengine.EndPointSecurityResolver.ResolveAuthorizations( - availableAuthorizations: Authorizations, - securityRequirements: s_CheckVideoAsyncSecurityRequirements, - operationName: "CheckVideoAsyncAsync"); - - using var __timeoutCancellationTokenSource = global::Sightengine.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( - clientOptions: Options, - requestOptions: requestOptions, - cancellationToken: cancellationToken); - var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; - var __effectiveReadResponseAsString = global::Sightengine.AutoSDKRequestOptionsSupport.GetReadResponseAsString( - clientOptions: Options, - requestOptions: requestOptions, - fallbackValue: ReadResponseAsString); - var __maxAttempts = global::Sightengine.AutoSDKRequestOptionsSupport.GetMaxAttempts( - clientOptions: Options, - requestOptions: requestOptions, - supportsRetry: false); - - global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() - { - - var __pathBuilder = new global::Sightengine.PathBuilder( - path: "/video/check.json", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - __path = global::Sightengine.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 (media != default) - { - - var __contentMedia = new global::System.Net.Http.StreamContent(media); - __contentMedia.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( - request.Medianame is null - ? "application/octet-stream" - : (global::System.IO.Path.GetExtension(request.Medianame) ?? 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: __contentMedia, - name: "\"media\"", - fileName: request.Medianame != null ? $"\"{request.Medianame}\"" : string.Empty); - if (__contentMedia.Headers.ContentDisposition != null) - { - __contentMedia.Headers.ContentDisposition.FileNameStar = null; - } - - } - if (request.StreamUrl != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.StreamUrl ?? string.Empty), - name: "\"stream_url\""); - - } - if (request.CallbackUrl != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.CallbackUrl ?? string.Empty), - name: "\"callback_url\""); - - } - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.Models ?? string.Empty), - name: "\"models\""); - - __httpRequest.Content = __httpRequestContent; - - global::Sightengine.AutoSDKRequestOptionsSupport.ApplyHeaders( - request: __httpRequest, - clientHeaders: Options.Headers, - requestHeaders: requestOptions?.Headers); - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCheckVideoAsyncRequest( - 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::Sightengine.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( - clientOptions: Options, - context: global::Sightengine.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "CheckVideoAsync", - methodName: "CheckVideoAsyncAsync", - pathTemplate: "\"/video/check.json\"", - 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::Sightengine.AutoSDKRequestOptionsSupport.GetRetryDelay( - clientOptions: Options, - requestOptions: requestOptions, - response: null, - attempt: __attempt); - var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; - await global::Sightengine.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( - clientOptions: Options, - context: global::Sightengine.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "CheckVideoAsync", - methodName: "CheckVideoAsyncAsync", - pathTemplate: "\"/video/check.json\"", - 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::Sightengine.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - retryDelay: __retryDelay, - cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); - continue; - } - - if (__response != null && - __attempt < __maxAttempts && - global::Sightengine.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) - { - var __retryDelay = global::Sightengine.AutoSDKRequestOptionsSupport.GetRetryDelay( - clientOptions: Options, - requestOptions: requestOptions, - response: __response, - attempt: __attempt); - await global::Sightengine.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( - clientOptions: Options, - context: global::Sightengine.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "CheckVideoAsync", - methodName: "CheckVideoAsyncAsync", - pathTemplate: "\"/video/check.json\"", - 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::Sightengine.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); - ProcessCheckVideoAsyncResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - if (__response.IsSuccessStatusCode) - { - await global::Sightengine.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( - clientOptions: Options, - context: global::Sightengine.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "CheckVideoAsync", - methodName: "CheckVideoAsyncAsync", - pathTemplate: "\"/video/check.json\"", - 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::Sightengine.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( - clientOptions: Options, - context: global::Sightengine.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "CheckVideoAsync", - methodName: "CheckVideoAsyncAsync", - pathTemplate: "\"/video/check.json\"", - 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::Sightengine.ErrorResponse? __value_400 = null; - try - { - if (__effectiveReadResponseAsString) - { - __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - __value_400 = global::Sightengine.ErrorResponse.FromJson(__content_400, JsonSerializerContext); - } - else - { - __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - - __value_400 = global::Sightengine.ErrorResponse.FromJson(__content_400, JsonSerializerContext); - } - } - catch (global::System.Exception __ex) - { - __exception_400 = __ex; - } - - throw new global::Sightengine.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::Sightengine.ErrorResponse? __value_401 = null; - try - { - if (__effectiveReadResponseAsString) - { - __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - __value_401 = global::Sightengine.ErrorResponse.FromJson(__content_401, JsonSerializerContext); - } - else - { - __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - - __value_401 = global::Sightengine.ErrorResponse.FromJson(__content_401, JsonSerializerContext); - } - } - catch (global::System.Exception __ex) - { - __exception_401 = __ex; - } - - throw new global::Sightengine.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), - }; - } - - 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); - ProcessCheckVideoAsyncResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try - { - __response.EnsureSuccessStatusCode(); - - return - global::Sightengine.VideoCheckAsyncResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); - } - catch (global::System.Exception __ex) - { - throw new global::Sightengine.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::Sightengine.VideoCheckAsyncResponse.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::Sightengine.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(); - } - } - /// - /// Check Video (Asynchronous)
- /// Start asynchronous video or live stream moderation.
- /// Results are delivered via the callback URL.
- /// Supports videos longer than 60 seconds and live streams
- /// (HLS, RTMP, RTMPS, RTSP, RTP, MPEG-DASH). - ///
- /// - /// The video file to analyze (use this OR stream_url). - /// - /// - /// The video file to analyze (use this OR stream_url). - /// - /// - /// Public URL of the video or live stream. - /// - /// - /// Webhook URL to receive moderation results. - /// - /// - /// Comma-separated list of detection models.
- /// Available: nudity-2.1, gore-2.0, weapon, drugs, violence,
- /// alcohol, offensive, self-harm, scam. - /// - /// 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> CheckVideoAsyncAsResponseAsync( - string models, - global::System.IO.Stream? media = default, - string? medianame = default, - string? streamUrl = default, - string? callbackUrl = default, - global::Sightengine.AutoSDKRequestOptions? requestOptions = default, - global::System.Threading.CancellationToken cancellationToken = default) - { - - var request = new global::Sightengine.CheckVideoAsyncRequest - { - Media = global::System.Array.Empty(), - Medianame = medianame, - StreamUrl = streamUrl, - CallbackUrl = callbackUrl, - Models = models, - }; - PrepareArguments( - client: HttpClient); - PrepareCheckVideoAsyncArguments( - httpClient: HttpClient, - request: request); - - - var __authorizations = global::Sightengine.EndPointSecurityResolver.ResolveAuthorizations( - availableAuthorizations: Authorizations, - securityRequirements: s_CheckVideoAsyncSecurityRequirements, - operationName: "CheckVideoAsyncAsync"); - - using var __timeoutCancellationTokenSource = global::Sightengine.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( - clientOptions: Options, - requestOptions: requestOptions, - cancellationToken: cancellationToken); - var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; - var __effectiveReadResponseAsString = global::Sightengine.AutoSDKRequestOptionsSupport.GetReadResponseAsString( - clientOptions: Options, - requestOptions: requestOptions, - fallbackValue: ReadResponseAsString); - var __maxAttempts = global::Sightengine.AutoSDKRequestOptionsSupport.GetMaxAttempts( - clientOptions: Options, - requestOptions: requestOptions, - supportsRetry: false); - - global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() - { - - var __pathBuilder = new global::Sightengine.PathBuilder( - path: "/video/check.json", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - __path = global::Sightengine.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 (media != default) - { - - var __contentMedia = new global::System.Net.Http.StreamContent(media); - __contentMedia.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( - request.Medianame is null - ? "application/octet-stream" - : (global::System.IO.Path.GetExtension(request.Medianame) ?? 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: __contentMedia, - name: "\"media\"", - fileName: request.Medianame != null ? $"\"{request.Medianame}\"" : string.Empty); - if (__contentMedia.Headers.ContentDisposition != null) - { - __contentMedia.Headers.ContentDisposition.FileNameStar = null; - } - - } - if (request.StreamUrl != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.StreamUrl ?? string.Empty), - name: "\"stream_url\""); - - } - if (request.CallbackUrl != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.CallbackUrl ?? string.Empty), - name: "\"callback_url\""); - - } - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.Models ?? string.Empty), - name: "\"models\""); - - __httpRequest.Content = __httpRequestContent; - - global::Sightengine.AutoSDKRequestOptionsSupport.ApplyHeaders( - request: __httpRequest, - clientHeaders: Options.Headers, - requestHeaders: requestOptions?.Headers); - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCheckVideoAsyncRequest( - 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::Sightengine.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( - clientOptions: Options, - context: global::Sightengine.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "CheckVideoAsync", - methodName: "CheckVideoAsyncAsync", - pathTemplate: "\"/video/check.json\"", - 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::Sightengine.AutoSDKRequestOptionsSupport.GetRetryDelay( - clientOptions: Options, - requestOptions: requestOptions, - response: null, - attempt: __attempt); - var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; - await global::Sightengine.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( - clientOptions: Options, - context: global::Sightengine.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "CheckVideoAsync", - methodName: "CheckVideoAsyncAsync", - pathTemplate: "\"/video/check.json\"", - 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::Sightengine.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - retryDelay: __retryDelay, - cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); - continue; - } - - if (__response != null && - __attempt < __maxAttempts && - global::Sightengine.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) - { - var __retryDelay = global::Sightengine.AutoSDKRequestOptionsSupport.GetRetryDelay( - clientOptions: Options, - requestOptions: requestOptions, - response: __response, - attempt: __attempt); - await global::Sightengine.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( - clientOptions: Options, - context: global::Sightengine.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "CheckVideoAsync", - methodName: "CheckVideoAsyncAsync", - pathTemplate: "\"/video/check.json\"", - 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::Sightengine.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); - ProcessCheckVideoAsyncResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - if (__response.IsSuccessStatusCode) - { - await global::Sightengine.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( - clientOptions: Options, - context: global::Sightengine.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "CheckVideoAsync", - methodName: "CheckVideoAsyncAsync", - pathTemplate: "\"/video/check.json\"", - 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::Sightengine.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( - clientOptions: Options, - context: global::Sightengine.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "CheckVideoAsync", - methodName: "CheckVideoAsyncAsync", - pathTemplate: "\"/video/check.json\"", - 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::Sightengine.ErrorResponse? __value_400 = null; - try - { - if (__effectiveReadResponseAsString) - { - __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - __value_400 = global::Sightengine.ErrorResponse.FromJson(__content_400, JsonSerializerContext); - } - else - { - __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - - __value_400 = global::Sightengine.ErrorResponse.FromJson(__content_400, JsonSerializerContext); - } - } - catch (global::System.Exception __ex) - { - __exception_400 = __ex; - } - - throw new global::Sightengine.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::Sightengine.ErrorResponse? __value_401 = null; - try - { - if (__effectiveReadResponseAsString) - { - __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - __value_401 = global::Sightengine.ErrorResponse.FromJson(__content_401, JsonSerializerContext); - } - else - { - __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - - __value_401 = global::Sightengine.ErrorResponse.FromJson(__content_401, JsonSerializerContext); - } - } - catch (global::System.Exception __ex) - { - __exception_401 = __ex; - } - - throw new global::Sightengine.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), - }; - } - - 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); - ProcessCheckVideoAsyncResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try - { - __response.EnsureSuccessStatusCode(); - - var __value = global::Sightengine.VideoCheckAsyncResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); - return new global::Sightengine.AutoSDKHttpResponse( - statusCode: __response.StatusCode, - headers: global::Sightengine.AutoSDKHttpResponse.CreateHeaders(__response), - requestUri: __response.RequestMessage?.RequestUri, - body: __value); - } - catch (global::System.Exception __ex) - { - throw new global::Sightengine.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::Sightengine.VideoCheckAsyncResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - return new global::Sightengine.AutoSDKHttpResponse( - statusCode: __response.StatusCode, - headers: global::Sightengine.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::Sightengine.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/Sightengine/Generated/Sightengine.SightengineClient.CheckVideoSync.g.cs b/src/libs/Sightengine/Generated/Sightengine.SightengineClient.CheckVideoSync.g.cs index 14dd231..aa16f31 100644 --- a/src/libs/Sightengine/Generated/Sightengine.SightengineClient.CheckVideoSync.g.cs +++ b/src/libs/Sightengine/Generated/Sightengine.SightengineClient.CheckVideoSync.g.cs @@ -610,1044 +610,5 @@ request.Medianame is null requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } - - /// - /// Check Video (Synchronous)
- /// Moderate a video synchronously (must be under 60 seconds).
- /// Submit either a raw video file or a public URL. - ///
- /// - /// The video file to analyze (use this OR stream_url). - /// - /// - /// The video file to analyze (use this OR stream_url). - /// - /// - /// Public URL of the video (use this OR media). - /// - /// - /// Comma-separated list of detection models.
- /// Available: nudity-2.1, gore-2.0, weapon, drugs, violence,
- /// alcohol, offensive, self-harm, scam. - /// - /// 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 CheckVideoSyncAsync( - string models, - global::System.IO.Stream? media = default, - string? medianame = default, - string? streamUrl = default, - global::Sightengine.AutoSDKRequestOptions? requestOptions = default, - global::System.Threading.CancellationToken cancellationToken = default) - { - - var request = new global::Sightengine.CheckVideoSyncRequest - { - Media = global::System.Array.Empty(), - Medianame = medianame, - StreamUrl = streamUrl, - Models = models, - }; - PrepareArguments( - client: HttpClient); - PrepareCheckVideoSyncArguments( - httpClient: HttpClient, - request: request); - - - var __authorizations = global::Sightengine.EndPointSecurityResolver.ResolveAuthorizations( - availableAuthorizations: Authorizations, - securityRequirements: s_CheckVideoSyncSecurityRequirements, - operationName: "CheckVideoSyncAsync"); - - using var __timeoutCancellationTokenSource = global::Sightengine.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( - clientOptions: Options, - requestOptions: requestOptions, - cancellationToken: cancellationToken); - var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; - var __effectiveReadResponseAsString = global::Sightengine.AutoSDKRequestOptionsSupport.GetReadResponseAsString( - clientOptions: Options, - requestOptions: requestOptions, - fallbackValue: ReadResponseAsString); - var __maxAttempts = global::Sightengine.AutoSDKRequestOptionsSupport.GetMaxAttempts( - clientOptions: Options, - requestOptions: requestOptions, - supportsRetry: false); - - global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() - { - - var __pathBuilder = new global::Sightengine.PathBuilder( - path: "/video/check-sync.json", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - __path = global::Sightengine.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 (media != default) - { - - var __contentMedia = new global::System.Net.Http.StreamContent(media); - __contentMedia.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( - request.Medianame is null - ? "application/octet-stream" - : (global::System.IO.Path.GetExtension(request.Medianame) ?? 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: __contentMedia, - name: "\"media\"", - fileName: request.Medianame != null ? $"\"{request.Medianame}\"" : string.Empty); - if (__contentMedia.Headers.ContentDisposition != null) - { - __contentMedia.Headers.ContentDisposition.FileNameStar = null; - } - - } - if (request.StreamUrl != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.StreamUrl ?? string.Empty), - name: "\"stream_url\""); - - } - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.Models ?? string.Empty), - name: "\"models\""); - - __httpRequest.Content = __httpRequestContent; - - global::Sightengine.AutoSDKRequestOptionsSupport.ApplyHeaders( - request: __httpRequest, - clientHeaders: Options.Headers, - requestHeaders: requestOptions?.Headers); - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCheckVideoSyncRequest( - 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::Sightengine.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( - clientOptions: Options, - context: global::Sightengine.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "CheckVideoSync", - methodName: "CheckVideoSyncAsync", - pathTemplate: "\"/video/check-sync.json\"", - 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::Sightengine.AutoSDKRequestOptionsSupport.GetRetryDelay( - clientOptions: Options, - requestOptions: requestOptions, - response: null, - attempt: __attempt); - var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; - await global::Sightengine.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( - clientOptions: Options, - context: global::Sightengine.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "CheckVideoSync", - methodName: "CheckVideoSyncAsync", - pathTemplate: "\"/video/check-sync.json\"", - 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::Sightengine.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - retryDelay: __retryDelay, - cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); - continue; - } - - if (__response != null && - __attempt < __maxAttempts && - global::Sightengine.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) - { - var __retryDelay = global::Sightengine.AutoSDKRequestOptionsSupport.GetRetryDelay( - clientOptions: Options, - requestOptions: requestOptions, - response: __response, - attempt: __attempt); - await global::Sightengine.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( - clientOptions: Options, - context: global::Sightengine.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "CheckVideoSync", - methodName: "CheckVideoSyncAsync", - pathTemplate: "\"/video/check-sync.json\"", - 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::Sightengine.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); - ProcessCheckVideoSyncResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - if (__response.IsSuccessStatusCode) - { - await global::Sightengine.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( - clientOptions: Options, - context: global::Sightengine.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "CheckVideoSync", - methodName: "CheckVideoSyncAsync", - pathTemplate: "\"/video/check-sync.json\"", - 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::Sightengine.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( - clientOptions: Options, - context: global::Sightengine.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "CheckVideoSync", - methodName: "CheckVideoSyncAsync", - pathTemplate: "\"/video/check-sync.json\"", - 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::Sightengine.ErrorResponse? __value_400 = null; - try - { - if (__effectiveReadResponseAsString) - { - __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - __value_400 = global::Sightengine.ErrorResponse.FromJson(__content_400, JsonSerializerContext); - } - else - { - __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - - __value_400 = global::Sightengine.ErrorResponse.FromJson(__content_400, JsonSerializerContext); - } - } - catch (global::System.Exception __ex) - { - __exception_400 = __ex; - } - - throw new global::Sightengine.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::Sightengine.ErrorResponse? __value_401 = null; - try - { - if (__effectiveReadResponseAsString) - { - __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - __value_401 = global::Sightengine.ErrorResponse.FromJson(__content_401, JsonSerializerContext); - } - else - { - __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - - __value_401 = global::Sightengine.ErrorResponse.FromJson(__content_401, JsonSerializerContext); - } - } - catch (global::System.Exception __ex) - { - __exception_401 = __ex; - } - - throw new global::Sightengine.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), - }; - } - - 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); - ProcessCheckVideoSyncResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try - { - __response.EnsureSuccessStatusCode(); - - return - global::Sightengine.VideoCheckSyncResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); - } - catch (global::System.Exception __ex) - { - throw new global::Sightengine.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::Sightengine.VideoCheckSyncResponse.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::Sightengine.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(); - } - } - /// - /// Check Video (Synchronous)
- /// Moderate a video synchronously (must be under 60 seconds).
- /// Submit either a raw video file or a public URL. - ///
- /// - /// The video file to analyze (use this OR stream_url). - /// - /// - /// The video file to analyze (use this OR stream_url). - /// - /// - /// Public URL of the video (use this OR media). - /// - /// - /// Comma-separated list of detection models.
- /// Available: nudity-2.1, gore-2.0, weapon, drugs, violence,
- /// alcohol, offensive, self-harm, scam. - /// - /// 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> CheckVideoSyncAsResponseAsync( - string models, - global::System.IO.Stream? media = default, - string? medianame = default, - string? streamUrl = default, - global::Sightengine.AutoSDKRequestOptions? requestOptions = default, - global::System.Threading.CancellationToken cancellationToken = default) - { - - var request = new global::Sightengine.CheckVideoSyncRequest - { - Media = global::System.Array.Empty(), - Medianame = medianame, - StreamUrl = streamUrl, - Models = models, - }; - PrepareArguments( - client: HttpClient); - PrepareCheckVideoSyncArguments( - httpClient: HttpClient, - request: request); - - - var __authorizations = global::Sightengine.EndPointSecurityResolver.ResolveAuthorizations( - availableAuthorizations: Authorizations, - securityRequirements: s_CheckVideoSyncSecurityRequirements, - operationName: "CheckVideoSyncAsync"); - - using var __timeoutCancellationTokenSource = global::Sightengine.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( - clientOptions: Options, - requestOptions: requestOptions, - cancellationToken: cancellationToken); - var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; - var __effectiveReadResponseAsString = global::Sightengine.AutoSDKRequestOptionsSupport.GetReadResponseAsString( - clientOptions: Options, - requestOptions: requestOptions, - fallbackValue: ReadResponseAsString); - var __maxAttempts = global::Sightengine.AutoSDKRequestOptionsSupport.GetMaxAttempts( - clientOptions: Options, - requestOptions: requestOptions, - supportsRetry: false); - - global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() - { - - var __pathBuilder = new global::Sightengine.PathBuilder( - path: "/video/check-sync.json", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - __path = global::Sightengine.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 (media != default) - { - - var __contentMedia = new global::System.Net.Http.StreamContent(media); - __contentMedia.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( - request.Medianame is null - ? "application/octet-stream" - : (global::System.IO.Path.GetExtension(request.Medianame) ?? 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: __contentMedia, - name: "\"media\"", - fileName: request.Medianame != null ? $"\"{request.Medianame}\"" : string.Empty); - if (__contentMedia.Headers.ContentDisposition != null) - { - __contentMedia.Headers.ContentDisposition.FileNameStar = null; - } - - } - if (request.StreamUrl != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.StreamUrl ?? string.Empty), - name: "\"stream_url\""); - - } - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.Models ?? string.Empty), - name: "\"models\""); - - __httpRequest.Content = __httpRequestContent; - - global::Sightengine.AutoSDKRequestOptionsSupport.ApplyHeaders( - request: __httpRequest, - clientHeaders: Options.Headers, - requestHeaders: requestOptions?.Headers); - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCheckVideoSyncRequest( - 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::Sightengine.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( - clientOptions: Options, - context: global::Sightengine.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "CheckVideoSync", - methodName: "CheckVideoSyncAsync", - pathTemplate: "\"/video/check-sync.json\"", - 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::Sightengine.AutoSDKRequestOptionsSupport.GetRetryDelay( - clientOptions: Options, - requestOptions: requestOptions, - response: null, - attempt: __attempt); - var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; - await global::Sightengine.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( - clientOptions: Options, - context: global::Sightengine.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "CheckVideoSync", - methodName: "CheckVideoSyncAsync", - pathTemplate: "\"/video/check-sync.json\"", - 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::Sightengine.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - retryDelay: __retryDelay, - cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); - continue; - } - - if (__response != null && - __attempt < __maxAttempts && - global::Sightengine.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) - { - var __retryDelay = global::Sightengine.AutoSDKRequestOptionsSupport.GetRetryDelay( - clientOptions: Options, - requestOptions: requestOptions, - response: __response, - attempt: __attempt); - await global::Sightengine.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( - clientOptions: Options, - context: global::Sightengine.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "CheckVideoSync", - methodName: "CheckVideoSyncAsync", - pathTemplate: "\"/video/check-sync.json\"", - 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::Sightengine.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); - ProcessCheckVideoSyncResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - if (__response.IsSuccessStatusCode) - { - await global::Sightengine.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( - clientOptions: Options, - context: global::Sightengine.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "CheckVideoSync", - methodName: "CheckVideoSyncAsync", - pathTemplate: "\"/video/check-sync.json\"", - 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::Sightengine.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( - clientOptions: Options, - context: global::Sightengine.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "CheckVideoSync", - methodName: "CheckVideoSyncAsync", - pathTemplate: "\"/video/check-sync.json\"", - 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::Sightengine.ErrorResponse? __value_400 = null; - try - { - if (__effectiveReadResponseAsString) - { - __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - __value_400 = global::Sightengine.ErrorResponse.FromJson(__content_400, JsonSerializerContext); - } - else - { - __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - - __value_400 = global::Sightengine.ErrorResponse.FromJson(__content_400, JsonSerializerContext); - } - } - catch (global::System.Exception __ex) - { - __exception_400 = __ex; - } - - throw new global::Sightengine.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::Sightengine.ErrorResponse? __value_401 = null; - try - { - if (__effectiveReadResponseAsString) - { - __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - __value_401 = global::Sightengine.ErrorResponse.FromJson(__content_401, JsonSerializerContext); - } - else - { - __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - - __value_401 = global::Sightengine.ErrorResponse.FromJson(__content_401, JsonSerializerContext); - } - } - catch (global::System.Exception __ex) - { - __exception_401 = __ex; - } - - throw new global::Sightengine.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), - }; - } - - 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); - ProcessCheckVideoSyncResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try - { - __response.EnsureSuccessStatusCode(); - - var __value = global::Sightengine.VideoCheckSyncResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); - return new global::Sightengine.AutoSDKHttpResponse( - statusCode: __response.StatusCode, - headers: global::Sightengine.AutoSDKHttpResponse.CreateHeaders(__response), - requestUri: __response.RequestMessage?.RequestUri, - body: __value); - } - catch (global::System.Exception __ex) - { - throw new global::Sightengine.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::Sightengine.VideoCheckSyncResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - return new global::Sightengine.AutoSDKHttpResponse( - statusCode: __response.StatusCode, - headers: global::Sightengine.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::Sightengine.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/Sightengine/Generated/Sightengine.SightengineClient.SubmitFeedback.g.cs b/src/libs/Sightengine/Generated/Sightengine.SightengineClient.SubmitFeedback.g.cs index 522e5a1..fb5d0ed 100644 --- a/src/libs/Sightengine/Generated/Sightengine.SightengineClient.SubmitFeedback.g.cs +++ b/src/libs/Sightengine/Generated/Sightengine.SightengineClient.SubmitFeedback.g.cs @@ -622,1064 +622,5 @@ request.Medianame is null requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } - - /// - /// Submit Feedback
- /// Submit moderation feedback to improve model accuracy.
- /// Feedback submissions are free and do not count as operations.
- /// The image is used to continuously improve the specified model. - ///
- /// - /// Public URL to the image (use this OR media). - /// - /// - /// The image file (use this OR url). - /// - /// - /// The image file (use this OR url). - /// - /// - /// The model that classified the image.
- /// Available: nudity, gore, weapon, drugs, violence,
- /// alcohol, offensive, self-harm, scam, genai. - /// - /// - /// The expected/correct classification result. - /// - /// 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 SubmitFeedbackAsync( - string model, - string @class, - string? url = default, - global::System.IO.Stream? media = default, - string? medianame = default, - global::Sightengine.AutoSDKRequestOptions? requestOptions = default, - global::System.Threading.CancellationToken cancellationToken = default) - { - - var request = new global::Sightengine.SubmitFeedbackRequest - { - Url = url, - Media = global::System.Array.Empty(), - Medianame = medianame, - Model = model, - Class = @class, - }; - PrepareArguments( - client: HttpClient); - PrepareSubmitFeedbackArguments( - httpClient: HttpClient, - request: request); - - - var __authorizations = global::Sightengine.EndPointSecurityResolver.ResolveAuthorizations( - availableAuthorizations: Authorizations, - securityRequirements: s_SubmitFeedbackSecurityRequirements, - operationName: "SubmitFeedbackAsync"); - - using var __timeoutCancellationTokenSource = global::Sightengine.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( - clientOptions: Options, - requestOptions: requestOptions, - cancellationToken: cancellationToken); - var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; - var __effectiveReadResponseAsString = global::Sightengine.AutoSDKRequestOptionsSupport.GetReadResponseAsString( - clientOptions: Options, - requestOptions: requestOptions, - fallbackValue: ReadResponseAsString); - var __maxAttempts = global::Sightengine.AutoSDKRequestOptionsSupport.GetMaxAttempts( - clientOptions: Options, - requestOptions: requestOptions, - supportsRetry: false); - - global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() - { - - var __pathBuilder = new global::Sightengine.PathBuilder( - path: "/feedback.json", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - __path = global::Sightengine.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.Url != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.Url ?? string.Empty), - name: "\"url\""); - - } - if (media != default) - { - - var __contentMedia = new global::System.Net.Http.StreamContent(media); - __contentMedia.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( - request.Medianame is null - ? "application/octet-stream" - : (global::System.IO.Path.GetExtension(request.Medianame) ?? 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: __contentMedia, - name: "\"media\"", - fileName: request.Medianame != null ? $"\"{request.Medianame}\"" : string.Empty); - if (__contentMedia.Headers.ContentDisposition != null) - { - __contentMedia.Headers.ContentDisposition.FileNameStar = null; - } - - } - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.Model ?? string.Empty), - name: "\"model\""); - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.Class ?? string.Empty), - name: "\"class\""); - - __httpRequest.Content = __httpRequestContent; - - global::Sightengine.AutoSDKRequestOptionsSupport.ApplyHeaders( - request: __httpRequest, - clientHeaders: Options.Headers, - requestHeaders: requestOptions?.Headers); - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareSubmitFeedbackRequest( - 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::Sightengine.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( - clientOptions: Options, - context: global::Sightengine.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "SubmitFeedback", - methodName: "SubmitFeedbackAsync", - pathTemplate: "\"/feedback.json\"", - 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::Sightengine.AutoSDKRequestOptionsSupport.GetRetryDelay( - clientOptions: Options, - requestOptions: requestOptions, - response: null, - attempt: __attempt); - var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; - await global::Sightengine.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( - clientOptions: Options, - context: global::Sightengine.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "SubmitFeedback", - methodName: "SubmitFeedbackAsync", - pathTemplate: "\"/feedback.json\"", - 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::Sightengine.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - retryDelay: __retryDelay, - cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); - continue; - } - - if (__response != null && - __attempt < __maxAttempts && - global::Sightengine.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) - { - var __retryDelay = global::Sightengine.AutoSDKRequestOptionsSupport.GetRetryDelay( - clientOptions: Options, - requestOptions: requestOptions, - response: __response, - attempt: __attempt); - await global::Sightengine.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( - clientOptions: Options, - context: global::Sightengine.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "SubmitFeedback", - methodName: "SubmitFeedbackAsync", - pathTemplate: "\"/feedback.json\"", - 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::Sightengine.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); - ProcessSubmitFeedbackResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - if (__response.IsSuccessStatusCode) - { - await global::Sightengine.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( - clientOptions: Options, - context: global::Sightengine.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "SubmitFeedback", - methodName: "SubmitFeedbackAsync", - pathTemplate: "\"/feedback.json\"", - 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::Sightengine.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( - clientOptions: Options, - context: global::Sightengine.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "SubmitFeedback", - methodName: "SubmitFeedbackAsync", - pathTemplate: "\"/feedback.json\"", - 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::Sightengine.ErrorResponse? __value_400 = null; - try - { - if (__effectiveReadResponseAsString) - { - __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - __value_400 = global::Sightengine.ErrorResponse.FromJson(__content_400, JsonSerializerContext); - } - else - { - __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - - __value_400 = global::Sightengine.ErrorResponse.FromJson(__content_400, JsonSerializerContext); - } - } - catch (global::System.Exception __ex) - { - __exception_400 = __ex; - } - - throw new global::Sightengine.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::Sightengine.ErrorResponse? __value_401 = null; - try - { - if (__effectiveReadResponseAsString) - { - __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - __value_401 = global::Sightengine.ErrorResponse.FromJson(__content_401, JsonSerializerContext); - } - else - { - __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - - __value_401 = global::Sightengine.ErrorResponse.FromJson(__content_401, JsonSerializerContext); - } - } - catch (global::System.Exception __ex) - { - __exception_401 = __ex; - } - - throw new global::Sightengine.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), - }; - } - - 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); - ProcessSubmitFeedbackResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try - { - __response.EnsureSuccessStatusCode(); - - return - global::Sightengine.FeedbackResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); - } - catch (global::System.Exception __ex) - { - throw new global::Sightengine.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::Sightengine.FeedbackResponse.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::Sightengine.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(); - } - } - /// - /// Submit Feedback
- /// Submit moderation feedback to improve model accuracy.
- /// Feedback submissions are free and do not count as operations.
- /// The image is used to continuously improve the specified model. - ///
- /// - /// Public URL to the image (use this OR media). - /// - /// - /// The image file (use this OR url). - /// - /// - /// The image file (use this OR url). - /// - /// - /// The model that classified the image.
- /// Available: nudity, gore, weapon, drugs, violence,
- /// alcohol, offensive, self-harm, scam, genai. - /// - /// - /// The expected/correct classification result. - /// - /// 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> SubmitFeedbackAsResponseAsync( - string model, - string @class, - string? url = default, - global::System.IO.Stream? media = default, - string? medianame = default, - global::Sightengine.AutoSDKRequestOptions? requestOptions = default, - global::System.Threading.CancellationToken cancellationToken = default) - { - - var request = new global::Sightengine.SubmitFeedbackRequest - { - Url = url, - Media = global::System.Array.Empty(), - Medianame = medianame, - Model = model, - Class = @class, - }; - PrepareArguments( - client: HttpClient); - PrepareSubmitFeedbackArguments( - httpClient: HttpClient, - request: request); - - - var __authorizations = global::Sightengine.EndPointSecurityResolver.ResolveAuthorizations( - availableAuthorizations: Authorizations, - securityRequirements: s_SubmitFeedbackSecurityRequirements, - operationName: "SubmitFeedbackAsync"); - - using var __timeoutCancellationTokenSource = global::Sightengine.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( - clientOptions: Options, - requestOptions: requestOptions, - cancellationToken: cancellationToken); - var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; - var __effectiveReadResponseAsString = global::Sightengine.AutoSDKRequestOptionsSupport.GetReadResponseAsString( - clientOptions: Options, - requestOptions: requestOptions, - fallbackValue: ReadResponseAsString); - var __maxAttempts = global::Sightengine.AutoSDKRequestOptionsSupport.GetMaxAttempts( - clientOptions: Options, - requestOptions: requestOptions, - supportsRetry: false); - - global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() - { - - var __pathBuilder = new global::Sightengine.PathBuilder( - path: "/feedback.json", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - __path = global::Sightengine.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.Url != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.Url ?? string.Empty), - name: "\"url\""); - - } - if (media != default) - { - - var __contentMedia = new global::System.Net.Http.StreamContent(media); - __contentMedia.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( - request.Medianame is null - ? "application/octet-stream" - : (global::System.IO.Path.GetExtension(request.Medianame) ?? 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: __contentMedia, - name: "\"media\"", - fileName: request.Medianame != null ? $"\"{request.Medianame}\"" : string.Empty); - if (__contentMedia.Headers.ContentDisposition != null) - { - __contentMedia.Headers.ContentDisposition.FileNameStar = null; - } - - } - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.Model ?? string.Empty), - name: "\"model\""); - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.Class ?? string.Empty), - name: "\"class\""); - - __httpRequest.Content = __httpRequestContent; - - global::Sightengine.AutoSDKRequestOptionsSupport.ApplyHeaders( - request: __httpRequest, - clientHeaders: Options.Headers, - requestHeaders: requestOptions?.Headers); - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareSubmitFeedbackRequest( - 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::Sightengine.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( - clientOptions: Options, - context: global::Sightengine.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "SubmitFeedback", - methodName: "SubmitFeedbackAsync", - pathTemplate: "\"/feedback.json\"", - 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::Sightengine.AutoSDKRequestOptionsSupport.GetRetryDelay( - clientOptions: Options, - requestOptions: requestOptions, - response: null, - attempt: __attempt); - var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; - await global::Sightengine.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( - clientOptions: Options, - context: global::Sightengine.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "SubmitFeedback", - methodName: "SubmitFeedbackAsync", - pathTemplate: "\"/feedback.json\"", - 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::Sightengine.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - retryDelay: __retryDelay, - cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); - continue; - } - - if (__response != null && - __attempt < __maxAttempts && - global::Sightengine.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) - { - var __retryDelay = global::Sightengine.AutoSDKRequestOptionsSupport.GetRetryDelay( - clientOptions: Options, - requestOptions: requestOptions, - response: __response, - attempt: __attempt); - await global::Sightengine.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( - clientOptions: Options, - context: global::Sightengine.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "SubmitFeedback", - methodName: "SubmitFeedbackAsync", - pathTemplate: "\"/feedback.json\"", - 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::Sightengine.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); - ProcessSubmitFeedbackResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - if (__response.IsSuccessStatusCode) - { - await global::Sightengine.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( - clientOptions: Options, - context: global::Sightengine.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "SubmitFeedback", - methodName: "SubmitFeedbackAsync", - pathTemplate: "\"/feedback.json\"", - 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::Sightengine.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( - clientOptions: Options, - context: global::Sightengine.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "SubmitFeedback", - methodName: "SubmitFeedbackAsync", - pathTemplate: "\"/feedback.json\"", - 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::Sightengine.ErrorResponse? __value_400 = null; - try - { - if (__effectiveReadResponseAsString) - { - __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - __value_400 = global::Sightengine.ErrorResponse.FromJson(__content_400, JsonSerializerContext); - } - else - { - __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - - __value_400 = global::Sightengine.ErrorResponse.FromJson(__content_400, JsonSerializerContext); - } - } - catch (global::System.Exception __ex) - { - __exception_400 = __ex; - } - - throw new global::Sightengine.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::Sightengine.ErrorResponse? __value_401 = null; - try - { - if (__effectiveReadResponseAsString) - { - __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - __value_401 = global::Sightengine.ErrorResponse.FromJson(__content_401, JsonSerializerContext); - } - else - { - __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - - __value_401 = global::Sightengine.ErrorResponse.FromJson(__content_401, JsonSerializerContext); - } - } - catch (global::System.Exception __ex) - { - __exception_401 = __ex; - } - - throw new global::Sightengine.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), - }; - } - - 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); - ProcessSubmitFeedbackResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try - { - __response.EnsureSuccessStatusCode(); - - var __value = global::Sightengine.FeedbackResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); - return new global::Sightengine.AutoSDKHttpResponse( - statusCode: __response.StatusCode, - headers: global::Sightengine.AutoSDKHttpResponse.CreateHeaders(__response), - requestUri: __response.RequestMessage?.RequestUri, - body: __value); - } - catch (global::System.Exception __ex) - { - throw new global::Sightengine.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::Sightengine.FeedbackResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - return new global::Sightengine.AutoSDKHttpResponse( - statusCode: __response.StatusCode, - headers: global::Sightengine.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::Sightengine.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