diff --git a/src/libs/Presenton/Generated/Presenton.AuthClient.PatchMeApiV1AuthProfileUpdatePatch.g.cs b/src/libs/Presenton/Generated/Presenton.AuthClient.PatchMeApiV1AuthProfileUpdatePatch.g.cs index ea813dc..d6415b2 100644 --- a/src/libs/Presenton/Generated/Presenton.AuthClient.PatchMeApiV1AuthProfileUpdatePatch.g.cs +++ b/src/libs/Presenton/Generated/Presenton.AuthClient.PatchMeApiV1AuthProfileUpdatePatch.g.cs @@ -546,928 +546,5 @@ request.ProfilePicturename is null requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } - - /// - /// Patch Me - /// - /// - /// The stream to send as the multipart 'profile_picture' file part. - /// - /// - /// - /// 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 PatchMeApiV1AuthProfileUpdatePatchAsync( - global::System.IO.Stream? profilePicture = default, - string? profilePicturename = default, - string? name = default, - global::Presenton.AutoSDKRequestOptions? requestOptions = default, - global::System.Threading.CancellationToken cancellationToken = default) - { - - var request = new global::Presenton.BodyPatchMeApiV1AuthProfileUpdatePatch - { - ProfilePicture = global::System.Array.Empty(), - ProfilePicturename = profilePicturename, - Name = name, - }; - PrepareArguments( - client: HttpClient); - PreparePatchMeApiV1AuthProfileUpdatePatchArguments( - httpClient: HttpClient, - request: request); - - - var __authorizations = global::Presenton.EndPointSecurityResolver.ResolveAuthorizations( - availableAuthorizations: Authorizations, - securityRequirements: s_PatchMeApiV1AuthProfileUpdatePatchSecurityRequirements, - operationName: "PatchMeApiV1AuthProfileUpdatePatchAsync"); - - using var __timeoutCancellationTokenSource = global::Presenton.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( - clientOptions: Options, - requestOptions: requestOptions, - cancellationToken: cancellationToken); - var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; - var __effectiveReadResponseAsString = global::Presenton.AutoSDKRequestOptionsSupport.GetReadResponseAsString( - clientOptions: Options, - requestOptions: requestOptions, - fallbackValue: ReadResponseAsString); - var __maxAttempts = global::Presenton.AutoSDKRequestOptionsSupport.GetMaxAttempts( - clientOptions: Options, - requestOptions: requestOptions, - supportsRetry: false); - - global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() - { - - var __pathBuilder = new global::Presenton.PathBuilder( - path: "/api/v1/auth/profile/update", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - __path = global::Presenton.AutoSDKRequestOptionsSupport.AppendQueryParameters( - path: __path, - clientParameters: Options.QueryParameters, - requestParameters: requestOptions?.QueryParameters); - var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: new global::System.Net.Http.HttpMethod("PATCH"), - 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 (profilePicture != default) - { - - var __contentProfilePicture = new global::System.Net.Http.StreamContent(profilePicture); - __contentProfilePicture.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( - request.ProfilePicturename is null - ? "application/octet-stream" - : (global::System.IO.Path.GetExtension(request.ProfilePicturename) ?? 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: __contentProfilePicture, - name: "\"profile_picture\"", - fileName: request.ProfilePicturename != null ? $"\"{request.ProfilePicturename}\"" : string.Empty); - if (__contentProfilePicture.Headers.ContentDisposition != null) - { - __contentProfilePicture.Headers.ContentDisposition.FileNameStar = null; - } - - } - if (request.Name != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.Name ?? string.Empty), - name: "\"name\""); - - } - - __httpRequest.Content = __httpRequestContent; - - global::Presenton.AutoSDKRequestOptionsSupport.ApplyHeaders( - request: __httpRequest, - clientHeaders: Options.Headers, - requestHeaders: requestOptions?.Headers); - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PreparePatchMeApiV1AuthProfileUpdatePatchRequest( - 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::Presenton.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( - clientOptions: Options, - context: global::Presenton.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "PatchMeApiV1AuthProfileUpdatePatch", - methodName: "PatchMeApiV1AuthProfileUpdatePatchAsync", - pathTemplate: "\"/api/v1/auth/profile/update\"", - httpMethod: "PATCH", - 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::Presenton.AutoSDKRequestOptionsSupport.GetRetryDelay( - clientOptions: Options, - requestOptions: requestOptions, - response: null, - attempt: __attempt); - var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; - await global::Presenton.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( - clientOptions: Options, - context: global::Presenton.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "PatchMeApiV1AuthProfileUpdatePatch", - methodName: "PatchMeApiV1AuthProfileUpdatePatchAsync", - pathTemplate: "\"/api/v1/auth/profile/update\"", - httpMethod: "PATCH", - 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::Presenton.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - retryDelay: __retryDelay, - cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); - continue; - } - - if (__response != null && - __attempt < __maxAttempts && - global::Presenton.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) - { - var __retryDelay = global::Presenton.AutoSDKRequestOptionsSupport.GetRetryDelay( - clientOptions: Options, - requestOptions: requestOptions, - response: __response, - attempt: __attempt); - await global::Presenton.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( - clientOptions: Options, - context: global::Presenton.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "PatchMeApiV1AuthProfileUpdatePatch", - methodName: "PatchMeApiV1AuthProfileUpdatePatchAsync", - pathTemplate: "\"/api/v1/auth/profile/update\"", - httpMethod: "PATCH", - 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::Presenton.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); - ProcessPatchMeApiV1AuthProfileUpdatePatchResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - if (__response.IsSuccessStatusCode) - { - await global::Presenton.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( - clientOptions: Options, - context: global::Presenton.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "PatchMeApiV1AuthProfileUpdatePatch", - methodName: "PatchMeApiV1AuthProfileUpdatePatchAsync", - pathTemplate: "\"/api/v1/auth/profile/update\"", - httpMethod: "PATCH", - 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::Presenton.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( - clientOptions: Options, - context: global::Presenton.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "PatchMeApiV1AuthProfileUpdatePatch", - methodName: "PatchMeApiV1AuthProfileUpdatePatchAsync", - pathTemplate: "\"/api/v1/auth/profile/update\"", - httpMethod: "PATCH", - 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); - } - // Validation Error - if ((int)__response.StatusCode == 422) - { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Presenton.HTTPValidationError? __value_422 = null; - try - { - if (__effectiveReadResponseAsString) - { - __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - __value_422 = global::Presenton.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); - } - else - { - __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - - __value_422 = global::Presenton.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); - } - } - catch (global::System.Exception __ex) - { - __exception_422 = __ex; - } - - throw new global::Presenton.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) - { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - 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); - ProcessPatchMeApiV1AuthProfileUpdatePatchResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try - { - __response.EnsureSuccessStatusCode(); - - return __content; - } - catch (global::System.Exception __ex) - { - throw new global::Presenton.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(); - var __content = await __response.Content.ReadAsStringAsync( - #if NET5_0_OR_GREATER - __effectiveCancellationToken - #endif - ).ConfigureAwait(false); - - return __content; - } - 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::Presenton.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(); - } - } - /// - /// Patch Me - /// - /// - /// The stream to send as the multipart 'profile_picture' file part. - /// - /// - /// - /// 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> PatchMeApiV1AuthProfileUpdatePatchAsResponseAsync( - global::System.IO.Stream? profilePicture = default, - string? profilePicturename = default, - string? name = default, - global::Presenton.AutoSDKRequestOptions? requestOptions = default, - global::System.Threading.CancellationToken cancellationToken = default) - { - - var request = new global::Presenton.BodyPatchMeApiV1AuthProfileUpdatePatch - { - ProfilePicture = global::System.Array.Empty(), - ProfilePicturename = profilePicturename, - Name = name, - }; - PrepareArguments( - client: HttpClient); - PreparePatchMeApiV1AuthProfileUpdatePatchArguments( - httpClient: HttpClient, - request: request); - - - var __authorizations = global::Presenton.EndPointSecurityResolver.ResolveAuthorizations( - availableAuthorizations: Authorizations, - securityRequirements: s_PatchMeApiV1AuthProfileUpdatePatchSecurityRequirements, - operationName: "PatchMeApiV1AuthProfileUpdatePatchAsync"); - - using var __timeoutCancellationTokenSource = global::Presenton.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( - clientOptions: Options, - requestOptions: requestOptions, - cancellationToken: cancellationToken); - var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; - var __effectiveReadResponseAsString = global::Presenton.AutoSDKRequestOptionsSupport.GetReadResponseAsString( - clientOptions: Options, - requestOptions: requestOptions, - fallbackValue: ReadResponseAsString); - var __maxAttempts = global::Presenton.AutoSDKRequestOptionsSupport.GetMaxAttempts( - clientOptions: Options, - requestOptions: requestOptions, - supportsRetry: false); - - global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() - { - - var __pathBuilder = new global::Presenton.PathBuilder( - path: "/api/v1/auth/profile/update", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - __path = global::Presenton.AutoSDKRequestOptionsSupport.AppendQueryParameters( - path: __path, - clientParameters: Options.QueryParameters, - requestParameters: requestOptions?.QueryParameters); - var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: new global::System.Net.Http.HttpMethod("PATCH"), - 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 (profilePicture != default) - { - - var __contentProfilePicture = new global::System.Net.Http.StreamContent(profilePicture); - __contentProfilePicture.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( - request.ProfilePicturename is null - ? "application/octet-stream" - : (global::System.IO.Path.GetExtension(request.ProfilePicturename) ?? 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: __contentProfilePicture, - name: "\"profile_picture\"", - fileName: request.ProfilePicturename != null ? $"\"{request.ProfilePicturename}\"" : string.Empty); - if (__contentProfilePicture.Headers.ContentDisposition != null) - { - __contentProfilePicture.Headers.ContentDisposition.FileNameStar = null; - } - - } - if (request.Name != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.Name ?? string.Empty), - name: "\"name\""); - - } - - __httpRequest.Content = __httpRequestContent; - - global::Presenton.AutoSDKRequestOptionsSupport.ApplyHeaders( - request: __httpRequest, - clientHeaders: Options.Headers, - requestHeaders: requestOptions?.Headers); - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PreparePatchMeApiV1AuthProfileUpdatePatchRequest( - 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::Presenton.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( - clientOptions: Options, - context: global::Presenton.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "PatchMeApiV1AuthProfileUpdatePatch", - methodName: "PatchMeApiV1AuthProfileUpdatePatchAsync", - pathTemplate: "\"/api/v1/auth/profile/update\"", - httpMethod: "PATCH", - 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::Presenton.AutoSDKRequestOptionsSupport.GetRetryDelay( - clientOptions: Options, - requestOptions: requestOptions, - response: null, - attempt: __attempt); - var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; - await global::Presenton.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( - clientOptions: Options, - context: global::Presenton.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "PatchMeApiV1AuthProfileUpdatePatch", - methodName: "PatchMeApiV1AuthProfileUpdatePatchAsync", - pathTemplate: "\"/api/v1/auth/profile/update\"", - httpMethod: "PATCH", - 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::Presenton.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - retryDelay: __retryDelay, - cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); - continue; - } - - if (__response != null && - __attempt < __maxAttempts && - global::Presenton.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) - { - var __retryDelay = global::Presenton.AutoSDKRequestOptionsSupport.GetRetryDelay( - clientOptions: Options, - requestOptions: requestOptions, - response: __response, - attempt: __attempt); - await global::Presenton.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( - clientOptions: Options, - context: global::Presenton.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "PatchMeApiV1AuthProfileUpdatePatch", - methodName: "PatchMeApiV1AuthProfileUpdatePatchAsync", - pathTemplate: "\"/api/v1/auth/profile/update\"", - httpMethod: "PATCH", - 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::Presenton.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); - ProcessPatchMeApiV1AuthProfileUpdatePatchResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - if (__response.IsSuccessStatusCode) - { - await global::Presenton.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( - clientOptions: Options, - context: global::Presenton.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "PatchMeApiV1AuthProfileUpdatePatch", - methodName: "PatchMeApiV1AuthProfileUpdatePatchAsync", - pathTemplate: "\"/api/v1/auth/profile/update\"", - httpMethod: "PATCH", - 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::Presenton.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( - clientOptions: Options, - context: global::Presenton.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "PatchMeApiV1AuthProfileUpdatePatch", - methodName: "PatchMeApiV1AuthProfileUpdatePatchAsync", - pathTemplate: "\"/api/v1/auth/profile/update\"", - httpMethod: "PATCH", - 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); - } - // Validation Error - if ((int)__response.StatusCode == 422) - { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Presenton.HTTPValidationError? __value_422 = null; - try - { - if (__effectiveReadResponseAsString) - { - __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - __value_422 = global::Presenton.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); - } - else - { - __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - - __value_422 = global::Presenton.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); - } - } - catch (global::System.Exception __ex) - { - __exception_422 = __ex; - } - - throw new global::Presenton.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) - { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - 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); - ProcessPatchMeApiV1AuthProfileUpdatePatchResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try - { - __response.EnsureSuccessStatusCode(); - - return new global::Presenton.AutoSDKHttpResponse( - statusCode: __response.StatusCode, - headers: global::Presenton.AutoSDKHttpResponse.CreateHeaders(__response), - requestUri: __response.RequestMessage?.RequestUri, - body: __content); - } - catch (global::System.Exception __ex) - { - throw new global::Presenton.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(); - var __content = await __response.Content.ReadAsStringAsync( - #if NET5_0_OR_GREATER - __effectiveCancellationToken - #endif - ).ConfigureAwait(false); - - return new global::Presenton.AutoSDKHttpResponse( - statusCode: __response.StatusCode, - headers: global::Presenton.AutoSDKHttpResponse.CreateHeaders(__response), - requestUri: __response.RequestMessage?.RequestUri, - body: __content); - } - 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::Presenton.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/Presenton/Generated/Presenton.HtmlCreateClient.InitHtmlCreateApiV1PptHtmlCreateInitPost.g.cs b/src/libs/Presenton/Generated/Presenton.HtmlCreateClient.InitHtmlCreateApiV1PptHtmlCreateInitPost.g.cs index 0575a7b..88f659f 100644 --- a/src/libs/Presenton/Generated/Presenton.HtmlCreateClient.InitHtmlCreateApiV1PptHtmlCreateInitPost.g.cs +++ b/src/libs/Presenton/Generated/Presenton.HtmlCreateClient.InitHtmlCreateApiV1PptHtmlCreateInitPost.g.cs @@ -589,1010 +589,5 @@ request.SketchImagename is null requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } - - /// - /// Init Html Create - /// - /// - /// Primary reference/sketch image (optional) - /// - /// - /// Primary reference/sketch image (optional) - /// - /// - /// - /// Optional existing HTML content to inform create - /// - /// - /// Text prompt describing the slide to create - /// - /// - /// Template identifier (any string) whose design system should guide create - /// - /// 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 InitHtmlCreateApiV1PptHtmlCreateInitPostAsync( - string prompt, - global::System.IO.Stream? sketchImage = default, - string? sketchImagename = default, - global::System.Collections.Generic.IList? additionalImages = default, - string? html = default, - string? templateId = default, - global::Presenton.AutoSDKRequestOptions? requestOptions = default, - global::System.Threading.CancellationToken cancellationToken = default) - { - - var request = new global::Presenton.BodyInitHtmlCreateApiV1PptHtmlCreateInitPost - { - SketchImage = global::System.Array.Empty(), - SketchImagename = sketchImagename, - AdditionalImages = additionalImages, - Html = html, - Prompt = prompt, - TemplateId = templateId, - }; - PrepareArguments( - client: HttpClient); - PrepareInitHtmlCreateApiV1PptHtmlCreateInitPostArguments( - httpClient: HttpClient, - request: request); - - - var __authorizations = global::Presenton.EndPointSecurityResolver.ResolveAuthorizations( - availableAuthorizations: Authorizations, - securityRequirements: s_InitHtmlCreateApiV1PptHtmlCreateInitPostSecurityRequirements, - operationName: "InitHtmlCreateApiV1PptHtmlCreateInitPostAsync"); - - using var __timeoutCancellationTokenSource = global::Presenton.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( - clientOptions: Options, - requestOptions: requestOptions, - cancellationToken: cancellationToken); - var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; - var __effectiveReadResponseAsString = global::Presenton.AutoSDKRequestOptionsSupport.GetReadResponseAsString( - clientOptions: Options, - requestOptions: requestOptions, - fallbackValue: ReadResponseAsString); - var __maxAttempts = global::Presenton.AutoSDKRequestOptionsSupport.GetMaxAttempts( - clientOptions: Options, - requestOptions: requestOptions, - supportsRetry: false); - - global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() - { - - var __pathBuilder = new global::Presenton.PathBuilder( - path: "/api/v1/ppt/html-create/init", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - __path = global::Presenton.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 (sketchImage != default) - { - - var __contentSketchImage = new global::System.Net.Http.StreamContent(sketchImage); - __contentSketchImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( - request.SketchImagename is null - ? "application/octet-stream" - : (global::System.IO.Path.GetExtension(request.SketchImagename) ?? 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: __contentSketchImage, - name: "\"sketch_image\"", - fileName: request.SketchImagename != null ? $"\"{request.SketchImagename}\"" : string.Empty); - if (__contentSketchImage.Headers.ContentDisposition != null) - { - __contentSketchImage.Headers.ContentDisposition.FileNameStar = null; - } - - } - if (request.AdditionalImages != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.AdditionalImages.ToString() ?? string.Empty), - name: "\"additional_images\""); - - } - if (request.Html != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.Html ?? string.Empty), - name: "\"html\""); - - } - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty), - name: "\"prompt\""); - - if (request.TemplateId != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.TemplateId ?? string.Empty), - name: "\"template_id\""); - - } - - __httpRequest.Content = __httpRequestContent; - - global::Presenton.AutoSDKRequestOptionsSupport.ApplyHeaders( - request: __httpRequest, - clientHeaders: Options.Headers, - requestHeaders: requestOptions?.Headers); - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareInitHtmlCreateApiV1PptHtmlCreateInitPostRequest( - 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::Presenton.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( - clientOptions: Options, - context: global::Presenton.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "InitHtmlCreateApiV1PptHtmlCreateInitPost", - methodName: "InitHtmlCreateApiV1PptHtmlCreateInitPostAsync", - pathTemplate: "\"/api/v1/ppt/html-create/init\"", - 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::Presenton.AutoSDKRequestOptionsSupport.GetRetryDelay( - clientOptions: Options, - requestOptions: requestOptions, - response: null, - attempt: __attempt); - var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; - await global::Presenton.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( - clientOptions: Options, - context: global::Presenton.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "InitHtmlCreateApiV1PptHtmlCreateInitPost", - methodName: "InitHtmlCreateApiV1PptHtmlCreateInitPostAsync", - pathTemplate: "\"/api/v1/ppt/html-create/init\"", - 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::Presenton.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - retryDelay: __retryDelay, - cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); - continue; - } - - if (__response != null && - __attempt < __maxAttempts && - global::Presenton.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) - { - var __retryDelay = global::Presenton.AutoSDKRequestOptionsSupport.GetRetryDelay( - clientOptions: Options, - requestOptions: requestOptions, - response: __response, - attempt: __attempt); - await global::Presenton.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( - clientOptions: Options, - context: global::Presenton.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "InitHtmlCreateApiV1PptHtmlCreateInitPost", - methodName: "InitHtmlCreateApiV1PptHtmlCreateInitPostAsync", - pathTemplate: "\"/api/v1/ppt/html-create/init\"", - 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::Presenton.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); - ProcessInitHtmlCreateApiV1PptHtmlCreateInitPostResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - if (__response.IsSuccessStatusCode) - { - await global::Presenton.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( - clientOptions: Options, - context: global::Presenton.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "InitHtmlCreateApiV1PptHtmlCreateInitPost", - methodName: "InitHtmlCreateApiV1PptHtmlCreateInitPostAsync", - pathTemplate: "\"/api/v1/ppt/html-create/init\"", - 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::Presenton.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( - clientOptions: Options, - context: global::Presenton.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "InitHtmlCreateApiV1PptHtmlCreateInitPost", - methodName: "InitHtmlCreateApiV1PptHtmlCreateInitPostAsync", - pathTemplate: "\"/api/v1/ppt/html-create/init\"", - 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); - } - // Validation Error - if ((int)__response.StatusCode == 422) - { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Presenton.HTTPValidationError? __value_422 = null; - try - { - if (__effectiveReadResponseAsString) - { - __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - __value_422 = global::Presenton.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); - } - else - { - __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - - __value_422 = global::Presenton.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); - } - } - catch (global::System.Exception __ex) - { - __exception_422 = __ex; - } - - throw new global::Presenton.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) - { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - 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); - ProcessInitHtmlCreateApiV1PptHtmlCreateInitPostResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try - { - __response.EnsureSuccessStatusCode(); - - return - global::Presenton.HtmlEditInitResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); - } - catch (global::System.Exception __ex) - { - throw new global::Presenton.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::Presenton.HtmlEditInitResponse.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::Presenton.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(); - } - } - /// - /// Init Html Create - /// - /// - /// Primary reference/sketch image (optional) - /// - /// - /// Primary reference/sketch image (optional) - /// - /// - /// - /// Optional existing HTML content to inform create - /// - /// - /// Text prompt describing the slide to create - /// - /// - /// Template identifier (any string) whose design system should guide create - /// - /// 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> InitHtmlCreateApiV1PptHtmlCreateInitPostAsResponseAsync( - string prompt, - global::System.IO.Stream? sketchImage = default, - string? sketchImagename = default, - global::System.Collections.Generic.IList? additionalImages = default, - string? html = default, - string? templateId = default, - global::Presenton.AutoSDKRequestOptions? requestOptions = default, - global::System.Threading.CancellationToken cancellationToken = default) - { - - var request = new global::Presenton.BodyInitHtmlCreateApiV1PptHtmlCreateInitPost - { - SketchImage = global::System.Array.Empty(), - SketchImagename = sketchImagename, - AdditionalImages = additionalImages, - Html = html, - Prompt = prompt, - TemplateId = templateId, - }; - PrepareArguments( - client: HttpClient); - PrepareInitHtmlCreateApiV1PptHtmlCreateInitPostArguments( - httpClient: HttpClient, - request: request); - - - var __authorizations = global::Presenton.EndPointSecurityResolver.ResolveAuthorizations( - availableAuthorizations: Authorizations, - securityRequirements: s_InitHtmlCreateApiV1PptHtmlCreateInitPostSecurityRequirements, - operationName: "InitHtmlCreateApiV1PptHtmlCreateInitPostAsync"); - - using var __timeoutCancellationTokenSource = global::Presenton.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( - clientOptions: Options, - requestOptions: requestOptions, - cancellationToken: cancellationToken); - var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; - var __effectiveReadResponseAsString = global::Presenton.AutoSDKRequestOptionsSupport.GetReadResponseAsString( - clientOptions: Options, - requestOptions: requestOptions, - fallbackValue: ReadResponseAsString); - var __maxAttempts = global::Presenton.AutoSDKRequestOptionsSupport.GetMaxAttempts( - clientOptions: Options, - requestOptions: requestOptions, - supportsRetry: false); - - global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() - { - - var __pathBuilder = new global::Presenton.PathBuilder( - path: "/api/v1/ppt/html-create/init", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - __path = global::Presenton.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 (sketchImage != default) - { - - var __contentSketchImage = new global::System.Net.Http.StreamContent(sketchImage); - __contentSketchImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( - request.SketchImagename is null - ? "application/octet-stream" - : (global::System.IO.Path.GetExtension(request.SketchImagename) ?? 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: __contentSketchImage, - name: "\"sketch_image\"", - fileName: request.SketchImagename != null ? $"\"{request.SketchImagename}\"" : string.Empty); - if (__contentSketchImage.Headers.ContentDisposition != null) - { - __contentSketchImage.Headers.ContentDisposition.FileNameStar = null; - } - - } - if (request.AdditionalImages != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.AdditionalImages.ToString() ?? string.Empty), - name: "\"additional_images\""); - - } - if (request.Html != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.Html ?? string.Empty), - name: "\"html\""); - - } - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty), - name: "\"prompt\""); - - if (request.TemplateId != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.TemplateId ?? string.Empty), - name: "\"template_id\""); - - } - - __httpRequest.Content = __httpRequestContent; - - global::Presenton.AutoSDKRequestOptionsSupport.ApplyHeaders( - request: __httpRequest, - clientHeaders: Options.Headers, - requestHeaders: requestOptions?.Headers); - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareInitHtmlCreateApiV1PptHtmlCreateInitPostRequest( - 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::Presenton.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( - clientOptions: Options, - context: global::Presenton.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "InitHtmlCreateApiV1PptHtmlCreateInitPost", - methodName: "InitHtmlCreateApiV1PptHtmlCreateInitPostAsync", - pathTemplate: "\"/api/v1/ppt/html-create/init\"", - 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::Presenton.AutoSDKRequestOptionsSupport.GetRetryDelay( - clientOptions: Options, - requestOptions: requestOptions, - response: null, - attempt: __attempt); - var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; - await global::Presenton.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( - clientOptions: Options, - context: global::Presenton.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "InitHtmlCreateApiV1PptHtmlCreateInitPost", - methodName: "InitHtmlCreateApiV1PptHtmlCreateInitPostAsync", - pathTemplate: "\"/api/v1/ppt/html-create/init\"", - 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::Presenton.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - retryDelay: __retryDelay, - cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); - continue; - } - - if (__response != null && - __attempt < __maxAttempts && - global::Presenton.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) - { - var __retryDelay = global::Presenton.AutoSDKRequestOptionsSupport.GetRetryDelay( - clientOptions: Options, - requestOptions: requestOptions, - response: __response, - attempt: __attempt); - await global::Presenton.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( - clientOptions: Options, - context: global::Presenton.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "InitHtmlCreateApiV1PptHtmlCreateInitPost", - methodName: "InitHtmlCreateApiV1PptHtmlCreateInitPostAsync", - pathTemplate: "\"/api/v1/ppt/html-create/init\"", - 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::Presenton.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); - ProcessInitHtmlCreateApiV1PptHtmlCreateInitPostResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - if (__response.IsSuccessStatusCode) - { - await global::Presenton.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( - clientOptions: Options, - context: global::Presenton.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "InitHtmlCreateApiV1PptHtmlCreateInitPost", - methodName: "InitHtmlCreateApiV1PptHtmlCreateInitPostAsync", - pathTemplate: "\"/api/v1/ppt/html-create/init\"", - 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::Presenton.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( - clientOptions: Options, - context: global::Presenton.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "InitHtmlCreateApiV1PptHtmlCreateInitPost", - methodName: "InitHtmlCreateApiV1PptHtmlCreateInitPostAsync", - pathTemplate: "\"/api/v1/ppt/html-create/init\"", - 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); - } - // Validation Error - if ((int)__response.StatusCode == 422) - { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Presenton.HTTPValidationError? __value_422 = null; - try - { - if (__effectiveReadResponseAsString) - { - __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - __value_422 = global::Presenton.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); - } - else - { - __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - - __value_422 = global::Presenton.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); - } - } - catch (global::System.Exception __ex) - { - __exception_422 = __ex; - } - - throw new global::Presenton.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) - { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - 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); - ProcessInitHtmlCreateApiV1PptHtmlCreateInitPostResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try - { - __response.EnsureSuccessStatusCode(); - - var __value = global::Presenton.HtmlEditInitResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); - return new global::Presenton.AutoSDKHttpResponse( - statusCode: __response.StatusCode, - headers: global::Presenton.AutoSDKHttpResponse.CreateHeaders(__response), - requestUri: __response.RequestMessage?.RequestUri, - body: __value); - } - catch (global::System.Exception __ex) - { - throw new global::Presenton.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::Presenton.HtmlEditInitResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - return new global::Presenton.AutoSDKHttpResponse( - statusCode: __response.StatusCode, - headers: global::Presenton.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::Presenton.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/Presenton/Generated/Presenton.IAuthClient.PatchMeApiV1AuthProfileUpdatePatch.g.cs b/src/libs/Presenton/Generated/Presenton.IAuthClient.PatchMeApiV1AuthProfileUpdatePatch.g.cs index 76fe312..4e47ae9 100644 --- a/src/libs/Presenton/Generated/Presenton.IAuthClient.PatchMeApiV1AuthProfileUpdatePatch.g.cs +++ b/src/libs/Presenton/Generated/Presenton.IAuthClient.PatchMeApiV1AuthProfileUpdatePatch.g.cs @@ -43,40 +43,5 @@ public partial interface IAuthClient string? name = default, global::Presenton.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); - - /// - /// Patch Me - /// - /// - /// The stream to send as the multipart 'profile_picture' file part. - /// - /// - /// - /// 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 PatchMeApiV1AuthProfileUpdatePatchAsync( - global::System.IO.Stream? profilePicture = default, - string? profilePicturename = default, - string? name = default, - global::Presenton.AutoSDKRequestOptions? requestOptions = default, - global::System.Threading.CancellationToken cancellationToken = default); - /// - /// Patch Me - /// - /// - /// The stream to send as the multipart 'profile_picture' file part. - /// - /// - /// - /// 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> PatchMeApiV1AuthProfileUpdatePatchAsResponseAsync( - global::System.IO.Stream? profilePicture = default, - string? profilePicturename = default, - string? name = default, - global::Presenton.AutoSDKRequestOptions? requestOptions = default, - global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Presenton/Generated/Presenton.IHtmlCreateClient.InitHtmlCreateApiV1PptHtmlCreateInitPost.g.cs b/src/libs/Presenton/Generated/Presenton.IHtmlCreateClient.InitHtmlCreateApiV1PptHtmlCreateInitPost.g.cs index 8807aae..95f793e 100644 --- a/src/libs/Presenton/Generated/Presenton.IHtmlCreateClient.InitHtmlCreateApiV1PptHtmlCreateInitPost.g.cs +++ b/src/libs/Presenton/Generated/Presenton.IHtmlCreateClient.InitHtmlCreateApiV1PptHtmlCreateInitPost.g.cs @@ -59,68 +59,5 @@ public partial interface IHtmlCreateClient string? templateId = default, global::Presenton.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); - - /// - /// Init Html Create - /// - /// - /// Primary reference/sketch image (optional) - /// - /// - /// Primary reference/sketch image (optional) - /// - /// - /// - /// Optional existing HTML content to inform create - /// - /// - /// Text prompt describing the slide to create - /// - /// - /// Template identifier (any string) whose design system should guide create - /// - /// 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 InitHtmlCreateApiV1PptHtmlCreateInitPostAsync( - string prompt, - global::System.IO.Stream? sketchImage = default, - string? sketchImagename = default, - global::System.Collections.Generic.IList? additionalImages = default, - string? html = default, - string? templateId = default, - global::Presenton.AutoSDKRequestOptions? requestOptions = default, - global::System.Threading.CancellationToken cancellationToken = default); - /// - /// Init Html Create - /// - /// - /// Primary reference/sketch image (optional) - /// - /// - /// Primary reference/sketch image (optional) - /// - /// - /// - /// Optional existing HTML content to inform create - /// - /// - /// Text prompt describing the slide to create - /// - /// - /// Template identifier (any string) whose design system should guide create - /// - /// 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> InitHtmlCreateApiV1PptHtmlCreateInitPostAsResponseAsync( - string prompt, - global::System.IO.Stream? sketchImage = default, - string? sketchImagename = default, - global::System.Collections.Generic.IList? additionalImages = default, - string? html = default, - string? templateId = default, - global::Presenton.AutoSDKRequestOptions? requestOptions = default, - global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Presenton/Generated/Presenton.IReactEditClient.EditReactWithImageEndpointApiV1PptReactEditPost.g.cs b/src/libs/Presenton/Generated/Presenton.IReactEditClient.EditReactWithImageEndpointApiV1PptReactEditPost.g.cs index f1fbf82..77a5f4b 100644 --- a/src/libs/Presenton/Generated/Presenton.IReactEditClient.EditReactWithImageEndpointApiV1PptReactEditPost.g.cs +++ b/src/libs/Presenton/Generated/Presenton.IReactEditClient.EditReactWithImageEndpointApiV1PptReactEditPost.g.cs @@ -65,80 +65,5 @@ public partial interface IReactEditClient string? designSystem = default, global::Presenton.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); - - /// - /// Edit React With Image Endpoint - /// - /// - /// Current UI image file (optional) - /// - /// - /// Current UI image file (optional) - /// - /// - /// Sketch/indication image file (optional) - /// - /// - /// Sketch/indication image file (optional) - /// - /// - /// Current React component code to edit - /// - /// - /// Text prompt describing the changes - /// - /// - /// Optional design system JSON to guide the edit - /// - /// 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 EditReactWithImageEndpointApiV1PptReactEditPostAsync( - string react, - string prompt, - global::System.IO.Stream? currentUiImage = default, - string? currentUiImagename = default, - global::System.IO.Stream? sketchImage = default, - string? sketchImagename = default, - string? designSystem = default, - global::Presenton.AutoSDKRequestOptions? requestOptions = default, - global::System.Threading.CancellationToken cancellationToken = default); - /// - /// Edit React With Image Endpoint - /// - /// - /// Current UI image file (optional) - /// - /// - /// Current UI image file (optional) - /// - /// - /// Sketch/indication image file (optional) - /// - /// - /// Sketch/indication image file (optional) - /// - /// - /// Current React component code to edit - /// - /// - /// Text prompt describing the changes - /// - /// - /// Optional design system JSON to guide the edit - /// - /// 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> EditReactWithImageEndpointApiV1PptReactEditPostAsResponseAsync( - string react, - string prompt, - global::System.IO.Stream? currentUiImage = default, - string? currentUiImagename = default, - global::System.IO.Stream? sketchImage = default, - string? sketchImagename = default, - string? designSystem = default, - global::Presenton.AutoSDKRequestOptions? requestOptions = default, - global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Presenton/Generated/Presenton.OptionsSupport.g.cs b/src/libs/Presenton/Generated/Presenton.OptionsSupport.g.cs index 5dfd145..b9c6bde 100644 --- a/src/libs/Presenton/Generated/Presenton.OptionsSupport.g.cs +++ b/src/libs/Presenton/Generated/Presenton.OptionsSupport.g.cs @@ -150,6 +150,84 @@ public interface IAutoSDKAuthorizationProvider global::Presenton.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::Presenton.AutoSDK ApplyAuthorization(context.Request, perRequest[index]); } + global::Presenton.AutoSDKHttpRequestOptions.StampAuthorizationOverride(context.Request); return; } @@ -195,6 +274,8 @@ public sealed class AutoSDKAuthorizationProviderHook : global::Presenton.AutoSDK { ApplyAuthorization(context.Request, resolved[index]); } + + global::Presenton.AutoSDKHttpRequestOptions.StampAuthorizationOverride(context.Request); } private static void ApplyAuthorization( diff --git a/src/libs/Presenton/Generated/Presenton.ReactEditClient.EditReactWithImageEndpointApiV1PptReactEditPost.g.cs b/src/libs/Presenton/Generated/Presenton.ReactEditClient.EditReactWithImageEndpointApiV1PptReactEditPost.g.cs index 11544f1..429b76c 100644 --- a/src/libs/Presenton/Generated/Presenton.ReactEditClient.EditReactWithImageEndpointApiV1PptReactEditPost.g.cs +++ b/src/libs/Presenton/Generated/Presenton.ReactEditClient.EditReactWithImageEndpointApiV1PptReactEditPost.g.cs @@ -626,1084 +626,5 @@ request.SketchImagename is null requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } - - /// - /// Edit React With Image Endpoint - /// - /// - /// Current UI image file (optional) - /// - /// - /// Current UI image file (optional) - /// - /// - /// Sketch/indication image file (optional) - /// - /// - /// Sketch/indication image file (optional) - /// - /// - /// Current React component code to edit - /// - /// - /// Text prompt describing the changes - /// - /// - /// Optional design system JSON to guide the edit - /// - /// 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 EditReactWithImageEndpointApiV1PptReactEditPostAsync( - string react, - string prompt, - global::System.IO.Stream? currentUiImage = default, - string? currentUiImagename = default, - global::System.IO.Stream? sketchImage = default, - string? sketchImagename = default, - string? designSystem = default, - global::Presenton.AutoSDKRequestOptions? requestOptions = default, - global::System.Threading.CancellationToken cancellationToken = default) - { - - var request = new global::Presenton.BodyEditReactWithImageEndpointApiV1PptReactEditPost - { - CurrentUiImage = global::System.Array.Empty(), - CurrentUiImagename = currentUiImagename, - SketchImage = global::System.Array.Empty(), - SketchImagename = sketchImagename, - React = react, - Prompt = prompt, - DesignSystem = designSystem, - }; - PrepareArguments( - client: HttpClient); - PrepareEditReactWithImageEndpointApiV1PptReactEditPostArguments( - httpClient: HttpClient, - request: request); - - - var __authorizations = global::Presenton.EndPointSecurityResolver.ResolveAuthorizations( - availableAuthorizations: Authorizations, - securityRequirements: s_EditReactWithImageEndpointApiV1PptReactEditPostSecurityRequirements, - operationName: "EditReactWithImageEndpointApiV1PptReactEditPostAsync"); - - using var __timeoutCancellationTokenSource = global::Presenton.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( - clientOptions: Options, - requestOptions: requestOptions, - cancellationToken: cancellationToken); - var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; - var __effectiveReadResponseAsString = global::Presenton.AutoSDKRequestOptionsSupport.GetReadResponseAsString( - clientOptions: Options, - requestOptions: requestOptions, - fallbackValue: ReadResponseAsString); - var __maxAttempts = global::Presenton.AutoSDKRequestOptionsSupport.GetMaxAttempts( - clientOptions: Options, - requestOptions: requestOptions, - supportsRetry: false); - - global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() - { - - var __pathBuilder = new global::Presenton.PathBuilder( - path: "/api/v1/ppt/react-edit/", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - __path = global::Presenton.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 (currentUiImage != default) - { - - var __contentCurrentUiImage = new global::System.Net.Http.StreamContent(currentUiImage); - __contentCurrentUiImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( - request.CurrentUiImagename is null - ? "application/octet-stream" - : (global::System.IO.Path.GetExtension(request.CurrentUiImagename) ?? 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: __contentCurrentUiImage, - name: "\"current_ui_image\"", - fileName: request.CurrentUiImagename != null ? $"\"{request.CurrentUiImagename}\"" : string.Empty); - if (__contentCurrentUiImage.Headers.ContentDisposition != null) - { - __contentCurrentUiImage.Headers.ContentDisposition.FileNameStar = null; - } - - } - if (sketchImage != default) - { - - var __contentSketchImage = new global::System.Net.Http.StreamContent(sketchImage); - __contentSketchImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( - request.SketchImagename is null - ? "application/octet-stream" - : (global::System.IO.Path.GetExtension(request.SketchImagename) ?? 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: __contentSketchImage, - name: "\"sketch_image\"", - fileName: request.SketchImagename != null ? $"\"{request.SketchImagename}\"" : string.Empty); - if (__contentSketchImage.Headers.ContentDisposition != null) - { - __contentSketchImage.Headers.ContentDisposition.FileNameStar = null; - } - - } - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.React ?? string.Empty), - name: "\"react\""); - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty), - name: "\"prompt\""); - - if (request.DesignSystem != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.DesignSystem ?? string.Empty), - name: "\"design_system\""); - - } - - __httpRequest.Content = __httpRequestContent; - - global::Presenton.AutoSDKRequestOptionsSupport.ApplyHeaders( - request: __httpRequest, - clientHeaders: Options.Headers, - requestHeaders: requestOptions?.Headers); - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareEditReactWithImageEndpointApiV1PptReactEditPostRequest( - 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::Presenton.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( - clientOptions: Options, - context: global::Presenton.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "EditReactWithImageEndpointApiV1PptReactEditPost", - methodName: "EditReactWithImageEndpointApiV1PptReactEditPostAsync", - pathTemplate: "\"/api/v1/ppt/react-edit/\"", - 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::Presenton.AutoSDKRequestOptionsSupport.GetRetryDelay( - clientOptions: Options, - requestOptions: requestOptions, - response: null, - attempt: __attempt); - var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; - await global::Presenton.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( - clientOptions: Options, - context: global::Presenton.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "EditReactWithImageEndpointApiV1PptReactEditPost", - methodName: "EditReactWithImageEndpointApiV1PptReactEditPostAsync", - pathTemplate: "\"/api/v1/ppt/react-edit/\"", - 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::Presenton.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - retryDelay: __retryDelay, - cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); - continue; - } - - if (__response != null && - __attempt < __maxAttempts && - global::Presenton.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) - { - var __retryDelay = global::Presenton.AutoSDKRequestOptionsSupport.GetRetryDelay( - clientOptions: Options, - requestOptions: requestOptions, - response: __response, - attempt: __attempt); - await global::Presenton.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( - clientOptions: Options, - context: global::Presenton.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "EditReactWithImageEndpointApiV1PptReactEditPost", - methodName: "EditReactWithImageEndpointApiV1PptReactEditPostAsync", - pathTemplate: "\"/api/v1/ppt/react-edit/\"", - 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::Presenton.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); - ProcessEditReactWithImageEndpointApiV1PptReactEditPostResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - if (__response.IsSuccessStatusCode) - { - await global::Presenton.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( - clientOptions: Options, - context: global::Presenton.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "EditReactWithImageEndpointApiV1PptReactEditPost", - methodName: "EditReactWithImageEndpointApiV1PptReactEditPostAsync", - pathTemplate: "\"/api/v1/ppt/react-edit/\"", - 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::Presenton.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( - clientOptions: Options, - context: global::Presenton.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "EditReactWithImageEndpointApiV1PptReactEditPost", - methodName: "EditReactWithImageEndpointApiV1PptReactEditPostAsync", - pathTemplate: "\"/api/v1/ppt/react-edit/\"", - 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); - } - // Validation Error - if ((int)__response.StatusCode == 422) - { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Presenton.HTTPValidationError? __value_422 = null; - try - { - if (__effectiveReadResponseAsString) - { - __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - __value_422 = global::Presenton.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); - } - else - { - __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - - __value_422 = global::Presenton.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); - } - } - catch (global::System.Exception __ex) - { - __exception_422 = __ex; - } - - throw new global::Presenton.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) - { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - 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); - ProcessEditReactWithImageEndpointApiV1PptReactEditPostResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try - { - __response.EnsureSuccessStatusCode(); - - return - global::Presenton.HtmlEditResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); - } - catch (global::System.Exception __ex) - { - throw new global::Presenton.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::Presenton.HtmlEditResponse.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::Presenton.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(); - } - } - /// - /// Edit React With Image Endpoint - /// - /// - /// Current UI image file (optional) - /// - /// - /// Current UI image file (optional) - /// - /// - /// Sketch/indication image file (optional) - /// - /// - /// Sketch/indication image file (optional) - /// - /// - /// Current React component code to edit - /// - /// - /// Text prompt describing the changes - /// - /// - /// Optional design system JSON to guide the edit - /// - /// 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> EditReactWithImageEndpointApiV1PptReactEditPostAsResponseAsync( - string react, - string prompt, - global::System.IO.Stream? currentUiImage = default, - string? currentUiImagename = default, - global::System.IO.Stream? sketchImage = default, - string? sketchImagename = default, - string? designSystem = default, - global::Presenton.AutoSDKRequestOptions? requestOptions = default, - global::System.Threading.CancellationToken cancellationToken = default) - { - - var request = new global::Presenton.BodyEditReactWithImageEndpointApiV1PptReactEditPost - { - CurrentUiImage = global::System.Array.Empty(), - CurrentUiImagename = currentUiImagename, - SketchImage = global::System.Array.Empty(), - SketchImagename = sketchImagename, - React = react, - Prompt = prompt, - DesignSystem = designSystem, - }; - PrepareArguments( - client: HttpClient); - PrepareEditReactWithImageEndpointApiV1PptReactEditPostArguments( - httpClient: HttpClient, - request: request); - - - var __authorizations = global::Presenton.EndPointSecurityResolver.ResolveAuthorizations( - availableAuthorizations: Authorizations, - securityRequirements: s_EditReactWithImageEndpointApiV1PptReactEditPostSecurityRequirements, - operationName: "EditReactWithImageEndpointApiV1PptReactEditPostAsync"); - - using var __timeoutCancellationTokenSource = global::Presenton.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( - clientOptions: Options, - requestOptions: requestOptions, - cancellationToken: cancellationToken); - var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; - var __effectiveReadResponseAsString = global::Presenton.AutoSDKRequestOptionsSupport.GetReadResponseAsString( - clientOptions: Options, - requestOptions: requestOptions, - fallbackValue: ReadResponseAsString); - var __maxAttempts = global::Presenton.AutoSDKRequestOptionsSupport.GetMaxAttempts( - clientOptions: Options, - requestOptions: requestOptions, - supportsRetry: false); - - global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() - { - - var __pathBuilder = new global::Presenton.PathBuilder( - path: "/api/v1/ppt/react-edit/", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - __path = global::Presenton.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 (currentUiImage != default) - { - - var __contentCurrentUiImage = new global::System.Net.Http.StreamContent(currentUiImage); - __contentCurrentUiImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( - request.CurrentUiImagename is null - ? "application/octet-stream" - : (global::System.IO.Path.GetExtension(request.CurrentUiImagename) ?? 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: __contentCurrentUiImage, - name: "\"current_ui_image\"", - fileName: request.CurrentUiImagename != null ? $"\"{request.CurrentUiImagename}\"" : string.Empty); - if (__contentCurrentUiImage.Headers.ContentDisposition != null) - { - __contentCurrentUiImage.Headers.ContentDisposition.FileNameStar = null; - } - - } - if (sketchImage != default) - { - - var __contentSketchImage = new global::System.Net.Http.StreamContent(sketchImage); - __contentSketchImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( - request.SketchImagename is null - ? "application/octet-stream" - : (global::System.IO.Path.GetExtension(request.SketchImagename) ?? 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: __contentSketchImage, - name: "\"sketch_image\"", - fileName: request.SketchImagename != null ? $"\"{request.SketchImagename}\"" : string.Empty); - if (__contentSketchImage.Headers.ContentDisposition != null) - { - __contentSketchImage.Headers.ContentDisposition.FileNameStar = null; - } - - } - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.React ?? string.Empty), - name: "\"react\""); - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty), - name: "\"prompt\""); - - if (request.DesignSystem != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.DesignSystem ?? string.Empty), - name: "\"design_system\""); - - } - - __httpRequest.Content = __httpRequestContent; - - global::Presenton.AutoSDKRequestOptionsSupport.ApplyHeaders( - request: __httpRequest, - clientHeaders: Options.Headers, - requestHeaders: requestOptions?.Headers); - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareEditReactWithImageEndpointApiV1PptReactEditPostRequest( - 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::Presenton.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( - clientOptions: Options, - context: global::Presenton.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "EditReactWithImageEndpointApiV1PptReactEditPost", - methodName: "EditReactWithImageEndpointApiV1PptReactEditPostAsync", - pathTemplate: "\"/api/v1/ppt/react-edit/\"", - 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::Presenton.AutoSDKRequestOptionsSupport.GetRetryDelay( - clientOptions: Options, - requestOptions: requestOptions, - response: null, - attempt: __attempt); - var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; - await global::Presenton.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( - clientOptions: Options, - context: global::Presenton.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "EditReactWithImageEndpointApiV1PptReactEditPost", - methodName: "EditReactWithImageEndpointApiV1PptReactEditPostAsync", - pathTemplate: "\"/api/v1/ppt/react-edit/\"", - 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::Presenton.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - retryDelay: __retryDelay, - cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); - continue; - } - - if (__response != null && - __attempt < __maxAttempts && - global::Presenton.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) - { - var __retryDelay = global::Presenton.AutoSDKRequestOptionsSupport.GetRetryDelay( - clientOptions: Options, - requestOptions: requestOptions, - response: __response, - attempt: __attempt); - await global::Presenton.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( - clientOptions: Options, - context: global::Presenton.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "EditReactWithImageEndpointApiV1PptReactEditPost", - methodName: "EditReactWithImageEndpointApiV1PptReactEditPostAsync", - pathTemplate: "\"/api/v1/ppt/react-edit/\"", - 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::Presenton.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); - ProcessEditReactWithImageEndpointApiV1PptReactEditPostResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - if (__response.IsSuccessStatusCode) - { - await global::Presenton.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( - clientOptions: Options, - context: global::Presenton.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "EditReactWithImageEndpointApiV1PptReactEditPost", - methodName: "EditReactWithImageEndpointApiV1PptReactEditPostAsync", - pathTemplate: "\"/api/v1/ppt/react-edit/\"", - 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::Presenton.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( - clientOptions: Options, - context: global::Presenton.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "EditReactWithImageEndpointApiV1PptReactEditPost", - methodName: "EditReactWithImageEndpointApiV1PptReactEditPostAsync", - pathTemplate: "\"/api/v1/ppt/react-edit/\"", - 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); - } - // Validation Error - if ((int)__response.StatusCode == 422) - { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Presenton.HTTPValidationError? __value_422 = null; - try - { - if (__effectiveReadResponseAsString) - { - __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - __value_422 = global::Presenton.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); - } - else - { - __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - - __value_422 = global::Presenton.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); - } - } - catch (global::System.Exception __ex) - { - __exception_422 = __ex; - } - - throw new global::Presenton.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) - { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - 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); - ProcessEditReactWithImageEndpointApiV1PptReactEditPostResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try - { - __response.EnsureSuccessStatusCode(); - - var __value = global::Presenton.HtmlEditResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); - return new global::Presenton.AutoSDKHttpResponse( - statusCode: __response.StatusCode, - headers: global::Presenton.AutoSDKHttpResponse.CreateHeaders(__response), - requestUri: __response.RequestMessage?.RequestUri, - body: __value); - } - catch (global::System.Exception __ex) - { - throw new global::Presenton.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::Presenton.HtmlEditResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - return new global::Presenton.AutoSDKHttpResponse( - statusCode: __response.StatusCode, - headers: global::Presenton.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::Presenton.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