diff --git a/src/libs/Tripo/Generated/Tripo.ITripoApi.g.cs b/src/libs/Tripo/Generated/Tripo.ITripoApi.g.cs index 2341997..4e9b098 100644 --- a/src/libs/Tripo/Generated/Tripo.ITripoApi.g.cs +++ b/src/libs/Tripo/Generated/Tripo.ITripoApi.g.cs @@ -10,6 +10,21 @@ namespace Tripo /// public partial interface ITripoApi : global::System.IDisposable { + /// + /// The HttpClient instance. + /// + public global::System.Net.Http.HttpClient HttpClient { get; } + + /// + /// The base URL for the API. + /// + public System.Uri? BaseUri { get; } + + /// + /// The authorizations to use for the requests. + /// + public global::System.Collections.Generic.List Authorizations { get; } + /// /// /// diff --git a/src/libs/Tripo/Generated/Tripo.TripoApi.Authorizations.Bearer.g.cs b/src/libs/Tripo/Generated/Tripo.TripoApi.Authorizations.Bearer.g.cs index fb54130..0aea7b1 100644 --- a/src/libs/Tripo/Generated/Tripo.TripoApi.Authorizations.Bearer.g.cs +++ b/src/libs/Tripo/Generated/Tripo.TripoApi.Authorizations.Bearer.g.cs @@ -14,8 +14,8 @@ public void AuthorizeUsingBearer( { apiKey = apiKey ?? throw new global::System.ArgumentNullException(nameof(apiKey)); - _authorizations.Clear(); - _authorizations.Add(new global::Tripo.EndPointAuthorization + Authorizations.Clear(); + Authorizations.Add(new global::Tripo.EndPointAuthorization { Type = "Http", Location = "Header", diff --git a/src/libs/Tripo/Generated/Tripo.TripoApi.Constructors.Bearer.g.cs b/src/libs/Tripo/Generated/Tripo.TripoApi.Constructors.Bearer.g.cs index dbcab07..705acae 100644 --- a/src/libs/Tripo/Generated/Tripo.TripoApi.Constructors.Bearer.g.cs +++ b/src/libs/Tripo/Generated/Tripo.TripoApi.Constructors.Bearer.g.cs @@ -5,18 +5,19 @@ namespace Tripo { public sealed partial class TripoApi { - /// + /// public TripoApi( string apiKey, global::System.Net.Http.HttpClient? httpClient = null, global::System.Uri? baseUri = null, - global::System.Collections.Generic.List? authorizations = null) : this(httpClient, baseUri, authorizations) + global::System.Collections.Generic.List? authorizations = null, + bool disposeHttpClient = true) : this(httpClient, baseUri, authorizations, disposeHttpClient) { - Authorizing(_httpClient, ref apiKey); + Authorizing(HttpClient, ref apiKey); AuthorizeUsingBearer(apiKey); - Authorized(_httpClient); + Authorized(HttpClient); } partial void Authorizing( diff --git a/src/libs/Tripo/Generated/Tripo.TripoApi.CreateTask.g.cs b/src/libs/Tripo/Generated/Tripo.TripoApi.CreateTask.g.cs index b80ca94..8fe7060 100644 --- a/src/libs/Tripo/Generated/Tripo.TripoApi.CreateTask.g.cs +++ b/src/libs/Tripo/Generated/Tripo.TripoApi.CreateTask.g.cs @@ -32,32 +32,32 @@ partial void ProcessCreateTaskResponseContent( global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( - client: _httpClient); + client: HttpClient); PrepareCreateTaskArguments( - httpClient: _httpClient, + httpClient: HttpClient, request: request); var __pathBuilder = new PathBuilder( path: "/task", - baseUri: _httpClient.BaseAddress); + baseUri: HttpClient.BaseAddress); var __path = __pathBuilder.ToString(); - using var httpRequest = new global::System.Net.Http.HttpRequestMessage( + using 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)); - foreach (var _authorization in _authorizations) + foreach (var __authorization in Authorizations) { - if (_authorization.Type == "Http" || - _authorization.Type == "OAuth2") + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2") { - httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( - scheme: _authorization.Name, - parameter: _authorization.Value); + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); } - else if (_authorization.Type == "ApiKey" && - _authorization.Location == "Header") + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") { - httpRequest.Headers.Add(_authorization.Name, _authorization.Value); + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } var __httpRequestContentBody = request.ToJson(JsonSerializerContext); @@ -65,46 +65,46 @@ partial void ProcessCreateTaskResponseContent( content: __httpRequestContentBody, encoding: global::System.Text.Encoding.UTF8, mediaType: "application/json"); - httpRequest.Content = __httpRequestContent; + __httpRequest.Content = __httpRequestContent; PrepareRequest( - client: _httpClient, - request: httpRequest); + client: HttpClient, + request: __httpRequest); PrepareCreateTaskRequest( - httpClient: _httpClient, - httpRequestMessage: httpRequest, + httpClient: HttpClient, + httpRequestMessage: __httpRequest, request: request); - using var response = await _httpClient.SendAsync( - request: httpRequest, + using var __response = await HttpClient.SendAsync( + request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, cancellationToken: cancellationToken).ConfigureAwait(false); ProcessResponse( - client: _httpClient, - response: response); + client: HttpClient, + response: __response); ProcessCreateTaskResponse( - httpClient: _httpClient, - httpResponseMessage: response); + httpClient: HttpClient, + httpResponseMessage: __response); - var __content = await response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __content = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); ProcessResponseContent( - client: _httpClient, - response: response, + client: HttpClient, + response: __response, content: ref __content); ProcessCreateTaskResponseContent( - httpClient: _httpClient, - httpResponseMessage: response, + httpClient: HttpClient, + httpResponseMessage: __response, content: ref __content); try { - response.EnsureSuccessStatusCode(); + __response.EnsureSuccessStatusCode(); } - catch (global::System.Net.Http.HttpRequestException ex) + catch (global::System.Net.Http.HttpRequestException __ex) { - throw new global::System.InvalidOperationException(__content, ex); + throw new global::System.InvalidOperationException(__content, __ex); } return @@ -120,12 +120,12 @@ partial void ProcessCreateTaskResponseContent( public async global::System.Threading.Tasks.Task CreateTaskAsync( global::System.Threading.CancellationToken cancellationToken = default) { - var request = new global::Tripo.OneOf + var __request = new global::Tripo.OneOf { }; return await CreateTaskAsync( - request: request, + request: __request, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Tripo/Generated/Tripo.TripoApi.GetBalance.g.cs b/src/libs/Tripo/Generated/Tripo.TripoApi.GetBalance.g.cs index 3807012..176f88a 100644 --- a/src/libs/Tripo/Generated/Tripo.TripoApi.GetBalance.g.cs +++ b/src/libs/Tripo/Generated/Tripo.TripoApi.GetBalance.g.cs @@ -28,71 +28,71 @@ partial void ProcessGetBalanceResponseContent( global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( - client: _httpClient); + client: HttpClient); PrepareGetBalanceArguments( - httpClient: _httpClient); + httpClient: HttpClient); var __pathBuilder = new PathBuilder( path: "/user/balance", - baseUri: _httpClient.BaseAddress); + baseUri: HttpClient.BaseAddress); var __path = __pathBuilder.ToString(); - using var httpRequest = new global::System.Net.Http.HttpRequestMessage( + using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( method: global::System.Net.Http.HttpMethod.Get, requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); - foreach (var _authorization in _authorizations) + foreach (var __authorization in Authorizations) { - if (_authorization.Type == "Http" || - _authorization.Type == "OAuth2") + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2") { - httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( - scheme: _authorization.Name, - parameter: _authorization.Value); + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); } - else if (_authorization.Type == "ApiKey" && - _authorization.Location == "Header") + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") { - httpRequest.Headers.Add(_authorization.Name, _authorization.Value); + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } PrepareRequest( - client: _httpClient, - request: httpRequest); + client: HttpClient, + request: __httpRequest); PrepareGetBalanceRequest( - httpClient: _httpClient, - httpRequestMessage: httpRequest); + httpClient: HttpClient, + httpRequestMessage: __httpRequest); - using var response = await _httpClient.SendAsync( - request: httpRequest, + using var __response = await HttpClient.SendAsync( + request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, cancellationToken: cancellationToken).ConfigureAwait(false); ProcessResponse( - client: _httpClient, - response: response); + client: HttpClient, + response: __response); ProcessGetBalanceResponse( - httpClient: _httpClient, - httpResponseMessage: response); + httpClient: HttpClient, + httpResponseMessage: __response); - var __content = await response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __content = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); ProcessResponseContent( - client: _httpClient, - response: response, + client: HttpClient, + response: __response, content: ref __content); ProcessGetBalanceResponseContent( - httpClient: _httpClient, - httpResponseMessage: response, + httpClient: HttpClient, + httpResponseMessage: __response, content: ref __content); try { - response.EnsureSuccessStatusCode(); + __response.EnsureSuccessStatusCode(); } - catch (global::System.Net.Http.HttpRequestException ex) + catch (global::System.Net.Http.HttpRequestException __ex) { - throw new global::System.InvalidOperationException(__content, ex); + throw new global::System.InvalidOperationException(__content, __ex); } return diff --git a/src/libs/Tripo/Generated/Tripo.TripoApi.GetTask.g.cs b/src/libs/Tripo/Generated/Tripo.TripoApi.GetTask.g.cs index 1280223..dbcc890 100644 --- a/src/libs/Tripo/Generated/Tripo.TripoApi.GetTask.g.cs +++ b/src/libs/Tripo/Generated/Tripo.TripoApi.GetTask.g.cs @@ -32,73 +32,73 @@ partial void ProcessGetTaskResponseContent( global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( - client: _httpClient); + client: HttpClient); PrepareGetTaskArguments( - httpClient: _httpClient, + httpClient: HttpClient, taskId: ref taskId); var __pathBuilder = new PathBuilder( path: $"/task/{taskId}", - baseUri: _httpClient.BaseAddress); + baseUri: HttpClient.BaseAddress); var __path = __pathBuilder.ToString(); - using var httpRequest = new global::System.Net.Http.HttpRequestMessage( + using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( method: global::System.Net.Http.HttpMethod.Get, requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); - foreach (var _authorization in _authorizations) + foreach (var __authorization in Authorizations) { - if (_authorization.Type == "Http" || - _authorization.Type == "OAuth2") + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2") { - httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( - scheme: _authorization.Name, - parameter: _authorization.Value); + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); } - else if (_authorization.Type == "ApiKey" && - _authorization.Location == "Header") + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") { - httpRequest.Headers.Add(_authorization.Name, _authorization.Value); + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } PrepareRequest( - client: _httpClient, - request: httpRequest); + client: HttpClient, + request: __httpRequest); PrepareGetTaskRequest( - httpClient: _httpClient, - httpRequestMessage: httpRequest, + httpClient: HttpClient, + httpRequestMessage: __httpRequest, taskId: taskId); - using var response = await _httpClient.SendAsync( - request: httpRequest, + using var __response = await HttpClient.SendAsync( + request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, cancellationToken: cancellationToken).ConfigureAwait(false); ProcessResponse( - client: _httpClient, - response: response); + client: HttpClient, + response: __response); ProcessGetTaskResponse( - httpClient: _httpClient, - httpResponseMessage: response); + httpClient: HttpClient, + httpResponseMessage: __response); - var __content = await response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __content = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); ProcessResponseContent( - client: _httpClient, - response: response, + client: HttpClient, + response: __response, content: ref __content); ProcessGetTaskResponseContent( - httpClient: _httpClient, - httpResponseMessage: response, + httpClient: HttpClient, + httpResponseMessage: __response, content: ref __content); try { - response.EnsureSuccessStatusCode(); + __response.EnsureSuccessStatusCode(); } - catch (global::System.Net.Http.HttpRequestException ex) + catch (global::System.Net.Http.HttpRequestException __ex) { - throw new global::System.InvalidOperationException(__content, ex); + throw new global::System.InvalidOperationException(__content, __ex); } return diff --git a/src/libs/Tripo/Generated/Tripo.TripoApi.UploadFile.g.cs b/src/libs/Tripo/Generated/Tripo.TripoApi.UploadFile.g.cs index a83eabb..dd50d5a 100644 --- a/src/libs/Tripo/Generated/Tripo.TripoApi.UploadFile.g.cs +++ b/src/libs/Tripo/Generated/Tripo.TripoApi.UploadFile.g.cs @@ -34,32 +34,32 @@ partial void ProcessUploadFileResponseContent( request = request ?? throw new global::System.ArgumentNullException(nameof(request)); PrepareArguments( - client: _httpClient); + client: HttpClient); PrepareUploadFileArguments( - httpClient: _httpClient, + httpClient: HttpClient, request: request); var __pathBuilder = new PathBuilder( path: "/upload", - baseUri: _httpClient.BaseAddress); + baseUri: HttpClient.BaseAddress); var __path = __pathBuilder.ToString(); - using var httpRequest = new global::System.Net.Http.HttpRequestMessage( + using 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)); - foreach (var _authorization in _authorizations) + foreach (var __authorization in Authorizations) { - if (_authorization.Type == "Http" || - _authorization.Type == "OAuth2") + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2") { - httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( - scheme: _authorization.Name, - parameter: _authorization.Value); + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); } - else if (_authorization.Type == "ApiKey" && - _authorization.Location == "Header") + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") { - httpRequest.Headers.Add(_authorization.Name, _authorization.Value); + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } using var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); @@ -73,46 +73,46 @@ partial void ProcessUploadFileResponseContent( }, name: "file", fileName: request.Filename ?? string.Empty); - httpRequest.Content = __httpRequestContent; + __httpRequest.Content = __httpRequestContent; PrepareRequest( - client: _httpClient, - request: httpRequest); + client: HttpClient, + request: __httpRequest); PrepareUploadFileRequest( - httpClient: _httpClient, - httpRequestMessage: httpRequest, + httpClient: HttpClient, + httpRequestMessage: __httpRequest, request: request); - using var response = await _httpClient.SendAsync( - request: httpRequest, + using var __response = await HttpClient.SendAsync( + request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, cancellationToken: cancellationToken).ConfigureAwait(false); ProcessResponse( - client: _httpClient, - response: response); + client: HttpClient, + response: __response); ProcessUploadFileResponse( - httpClient: _httpClient, - httpResponseMessage: response); + httpClient: HttpClient, + httpResponseMessage: __response); - var __content = await response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __content = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); ProcessResponseContent( - client: _httpClient, - response: response, + client: HttpClient, + response: __response, content: ref __content); ProcessUploadFileResponseContent( - httpClient: _httpClient, - httpResponseMessage: response, + httpClient: HttpClient, + httpResponseMessage: __response, content: ref __content); try { - response.EnsureSuccessStatusCode(); + __response.EnsureSuccessStatusCode(); } - catch (global::System.Net.Http.HttpRequestException ex) + catch (global::System.Net.Http.HttpRequestException __ex) { - throw new global::System.InvalidOperationException(__content, ex); + throw new global::System.InvalidOperationException(__content, __ex); } return @@ -132,14 +132,14 @@ partial void ProcessUploadFileResponseContent( string filename, global::System.Threading.CancellationToken cancellationToken = default) { - var request = new global::Tripo.UploadFileRequest + var __request = new global::Tripo.UploadFileRequest { File = file, Filename = filename, }; return await UploadFileAsync( - request: request, + request: __request, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Tripo/Generated/Tripo.TripoApi.g.cs b/src/libs/Tripo/Generated/Tripo.TripoApi.g.cs index 50deaf6..2e1ac6e 100644 --- a/src/libs/Tripo/Generated/Tripo.TripoApi.g.cs +++ b/src/libs/Tripo/Generated/Tripo.TripoApi.g.cs @@ -13,10 +13,18 @@ public sealed partial class TripoApi : global::Tripo.ITripoApi, global::System.I /// /// /// - public const string BaseUrl = "https://api.tripo3d.ai/v2/openapi"; + public const string DefaultBaseUrl = "https://api.tripo3d.ai/v2/openapi"; - private readonly global::System.Net.Http.HttpClient _httpClient; - private global::System.Collections.Generic.List _authorizations; + private bool _disposeHttpClient = true; + + /// + public global::System.Net.Http.HttpClient HttpClient { get; } + + /// + public System.Uri? BaseUri => HttpClient.BaseAddress; + + /// + public global::System.Collections.Generic.List Authorizations { get; } /// /// @@ -29,25 +37,31 @@ public sealed partial class TripoApi : global::Tripo.ITripoApi, global::System.I /// If no httpClient is provided, a new one will be created. /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. /// - /// - /// - /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The base URL for the API. If not provided, the default baseUri from OpenAPI spec will be used. + /// The authorizations to use for the requests. + /// Dispose the HttpClient when the instance is disposed. True by default. public TripoApi( global::System.Net.Http.HttpClient? httpClient = null, global::System.Uri? baseUri = null, - global::System.Collections.Generic.List? authorizations = null) + global::System.Collections.Generic.List? authorizations = null, + bool disposeHttpClient = true) { - _httpClient = httpClient ?? new global::System.Net.Http.HttpClient(); - _httpClient.BaseAddress ??= baseUri ?? new global::System.Uri(BaseUrl); - _authorizations = authorizations ?? new global::System.Collections.Generic.List(); + HttpClient = httpClient ?? new global::System.Net.Http.HttpClient(); + HttpClient.BaseAddress ??= baseUri ?? new global::System.Uri(DefaultBaseUrl); + Authorizations = authorizations ?? new global::System.Collections.Generic.List(); + _disposeHttpClient = disposeHttpClient; - Initialized(_httpClient); + Initialized(HttpClient); } /// public void Dispose() { - _httpClient.Dispose(); + if (_disposeHttpClient) + { + HttpClient.Dispose(); + } } partial void Initialized(