diff --git a/src/libs/Braintrust/Generated/Braintrust.AclsClient.AclBatchUpdate.g.cs b/src/libs/Braintrust/Generated/Braintrust.AclsClient.AclBatchUpdate.g.cs
index f25a6fe..af80179 100644
--- a/src/libs/Braintrust/Generated/Braintrust.AclsClient.AclBatchUpdate.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.AclsClient.AclBatchUpdate.g.cs
@@ -14,6 +14,7 @@ public partial class AclsClient
{ new global::Braintrust.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -54,11 +55,13 @@ partial void ProcessAclBatchUpdateResponseContent(
/// Batch update acls. This operation is idempotent, so adding acls which already exist will have no effect, and removing acls which do not exist will have no effect.
///
///
+ /// 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 AclBatchUpdateAsync(
global::Braintrust.AclBatchUpdateRequest request,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -75,22 +78,43 @@ partial void ProcessAclBatchUpdateResponseContent(
securityRequirements: s_AclBatchUpdateSecurityRequirements,
operationName: "AclBatchUpdateAsync");
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: "/v1/acl/batch_update",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- 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));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: "/v1/acl/batch_update",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.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;
+ __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 == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -100,308 +124,467 @@ partial void ProcessAclBatchUpdateResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
- var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
- var __httpRequestContent = new global::System.Net.Http.StringContent(
- content: __httpRequestContentBody,
- encoding: global::System.Text.Encoding.UTF8,
- mediaType: "application/json");
- __httpRequest.Content = __httpRequestContent;
-
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareAclBatchUpdateRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- request: request);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
-
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessAclBatchUpdateResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
- {
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
- {
- if (ReadResponseAsString)
- {
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
-
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_400 = __ex;
- }
+ var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
+ var __httpRequestContent = new global::System.Net.Http.StringContent(
+ content: __httpRequestContentBody,
+ encoding: global::System.Text.Encoding.UTF8,
+ mediaType: "application/json");
+ __httpRequest.Content = __httpRequestContent;
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
+
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareAclBatchUpdateRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ return __httpRequest;
}
- // No valid API key provided
- if ((int)__response.StatusCode == 401)
- {
- string? __content_401 = null;
- global::System.Exception? __exception_401 = null;
- string? __value_401 = null;
- try
- {
- if (ReadResponseAsString)
- {
- __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_401 = __ex;
- }
-
- throw new global::Braintrust.ApiException(
- message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_401,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_401,
- ResponseObject = __value_401,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // The API key doesn’t have permissions to perform the request
- if ((int)__response.StatusCode == 403)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_403 = null;
- global::System.Exception? __exception_403 = null;
- string? __value_403 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AclBatchUpdate",
+ methodName: "AclBatchUpdateAsync",
+ pathTemplate: "\"/v1/acl/batch_update\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
-
- __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AclBatchUpdate",
+ methodName: "AclBatchUpdateAsync",
+ pathTemplate: "\"/v1/acl/batch_update\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
- }
- catch (global::System.Exception __ex)
- {
- __exception_403 = __ex;
- }
- throw new global::Braintrust.ApiException(
- message: __content_403 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_403,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_403,
- ResponseObject = __value_403,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
- if ((int)__response.StatusCode == 429)
- {
- string? __content_429 = null;
- global::System.Exception? __exception_429 = null;
- string? __value_429 = null;
- try
- {
- if (ReadResponseAsString)
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
- __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AclBatchUpdate",
+ methodName: "AclBatchUpdateAsync",
+ pathTemplate: "\"/v1/acl/batch_update\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
- else
- {
- __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_429 = __ex;
+ break;
}
- throw new global::Braintrust.ApiException(
- message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_429,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_429,
- ResponseObject = __value_429,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // Something went wrong on Braintrust's end. (These are rare.)
- if ((int)__response.StatusCode == 500)
- {
- string? __content_500 = null;
- global::System.Exception? __exception_500 = null;
- string? __value_500 = null;
- try
+ if (__response == null)
{
- if (ReadResponseAsString)
- {
- __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
-
- __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_500 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_500 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_500,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_500,
- ResponseObject = __value_500,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessAclBatchUpdateResponseContent(
+ response: __response);
+ ProcessAclBatchUpdateResponse(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
- {
- __response.EnsureSuccessStatusCode();
-
- return
- global::Braintrust.AclBatchUpdateResponse.FromJson(__content, JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
- }
- catch (global::System.Exception __ex)
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AclBatchUpdate",
+ methodName: "AclBatchUpdateAsync",
+ pathTemplate: "\"/v1/acl/batch_update\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
+ else
{
- __response.EnsureSuccessStatusCode();
- using var __content = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- return
- await global::Braintrust.AclBatchUpdateResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AclBatchUpdate",
+ methodName: "AclBatchUpdateAsync",
+ pathTemplate: "\"/v1/acl/batch_update\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // No valid API key provided
+ if ((int)__response.StatusCode == 401)
+ {
+ string? __content_401 = null;
+ global::System.Exception? __exception_401 = null;
+ string? __value_401 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_401 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_401,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_401,
+ ResponseObject = __value_401,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // The API key doesn’t have permissions to perform the request
+ if ((int)__response.StatusCode == 403)
+ {
+ string? __content_403 = null;
+ global::System.Exception? __exception_403 = null;
+ string? __value_403 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_403 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_403 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_403,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_403,
+ ResponseObject = __value_403,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
+ if ((int)__response.StatusCode == 429)
+ {
+ string? __content_429 = null;
+ global::System.Exception? __exception_429 = null;
+ string? __value_429 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_429 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_429,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_429,
+ ResponseObject = __value_429,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // Something went wrong on Braintrust's end. (These are rare.)
+ if ((int)__response.StatusCode == 500)
+ {
+ string? __content_500 = null;
+ global::System.Exception? __exception_500 = null;
+ string? __value_500 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_500 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_500 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_500,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_500,
+ ResponseObject = __value_500,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+ ProcessAclBatchUpdateResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Braintrust.AclBatchUpdateResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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::Braintrust.AclBatchUpdateResponse.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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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();
+ }
}
///
/// Batch update acls
@@ -409,11 +592,13 @@ partial void ProcessAclBatchUpdateResponseContent(
///
///
///
+ /// 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 AclBatchUpdateAsync(
global::System.Collections.Generic.IList? addAcls = default,
global::System.Collections.Generic.IList? removeAcls = default,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::Braintrust.AclBatchUpdateRequest
@@ -424,6 +609,7 @@ partial void ProcessAclBatchUpdateResponseContent(
return await AclBatchUpdateAsync(
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/Braintrust/Generated/Braintrust.AclsClient.AclListOrg.g.cs b/src/libs/Braintrust/Generated/Braintrust.AclsClient.AclListOrg.g.cs
index b6a3fb5..2a9c8fa 100644
--- a/src/libs/Braintrust/Generated/Braintrust.AclsClient.AclListOrg.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.AclsClient.AclListOrg.g.cs
@@ -14,6 +14,7 @@ public partial class AclsClient
{ new global::Braintrust.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -114,6 +115,7 @@ partial void ProcessAclListOrgResponseContent(
///
/// Filter search results to within a particular organization
///
+ /// 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> AclListOrgAsync(
@@ -129,6 +131,7 @@ partial void ProcessAclListOrgResponseContent(
global::Braintrust.AclListRestrictObjectType? restrictObjectType = default,
global::System.Guid? roleId = default,
string? orgName = default,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -154,36 +157,57 @@ partial void ProcessAclListOrgResponseContent(
securityRequirements: s_AclListOrgSecurityRequirements,
operationName: "AclListOrgAsync");
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: "/v1/acl/list_org",
- baseUri: HttpClient.BaseAddress);
- __pathBuilder
- .AddOptionalParameter("limit", limit?.ToString())
- .AddOptionalParameter("ids", ids?.ToString())
- .AddOptionalParameter("starting_after", startingAfter?.ToString())
- .AddOptionalParameter("ending_before", endingBefore?.ToString())
- .AddOptionalParameter("object_type", objectType?.ToValueString())
- .AddOptionalParameter("object_id", objectId?.ToString())
- .AddOptionalParameter("user_id", userId?.ToString())
- .AddOptionalParameter("group_id", groupId?.ToString())
- .AddOptionalParameter("permission", permission?.ToValueString())
- .AddOptionalParameter("restrict_object_type", restrictObjectType?.ToValueString())
- .AddOptionalParameter("role_id", roleId?.ToString())
- .AddOptionalParameter("org_name", orgName)
- ;
- var __path = __pathBuilder.ToString();
- 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));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: "/v1/acl/list_org",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("limit", limit?.ToString())
+ .AddOptionalParameter("ids", ids?.ToString())
+ .AddOptionalParameter("starting_after", startingAfter?.ToString())
+ .AddOptionalParameter("ending_before", endingBefore?.ToString())
+ .AddOptionalParameter("object_type", objectType?.ToValueString())
+ .AddOptionalParameter("object_id", objectId?.ToString())
+ .AddOptionalParameter("user_id", userId?.ToString())
+ .AddOptionalParameter("group_id", groupId?.ToString())
+ .AddOptionalParameter("permission", permission?.ToValueString())
+ .AddOptionalParameter("restrict_object_type", restrictObjectType?.ToValueString())
+ .AddOptionalParameter("role_id", roleId?.ToString())
+ .AddOptionalParameter("org_name", orgName)
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ 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));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __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 == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -193,313 +217,472 @@ partial void ProcessAclListOrgResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareAclListOrgRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- limit: limit,
- ids: ids,
- startingAfter: startingAfter,
- endingBefore: endingBefore,
- objectType: objectType,
- objectId: objectId,
- userId: userId,
- groupId: groupId,
- permission: permission,
- restrictObjectType: restrictObjectType,
- roleId: roleId,
- orgName: orgName);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareAclListOrgRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ limit: limit,
+ ids: ids,
+ startingAfter: startingAfter,
+ endingBefore: endingBefore,
+ objectType: objectType,
+ objectId: objectId,
+ userId: userId,
+ groupId: groupId,
+ permission: permission,
+ restrictObjectType: restrictObjectType,
+ roleId: roleId,
+ orgName: orgName);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessAclListOrgResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AclListOrg",
+ methodName: "AclListOrgAsync",
+ pathTemplate: "\"/v1/acl/list_org\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AclListOrg",
+ methodName: "AclListOrgAsync",
+ pathTemplate: "\"/v1/acl/list_org\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
- }
- catch (global::System.Exception __ex)
- {
- __exception_400 = __ex;
- }
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // No valid API key provided
- if ((int)__response.StatusCode == 401)
- {
- string? __content_401 = null;
- global::System.Exception? __exception_401 = null;
- string? __value_401 = null;
- try
- {
- if (ReadResponseAsString)
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
- __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AclListOrg",
+ methodName: "AclListOrgAsync",
+ pathTemplate: "\"/v1/acl/list_org\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
- else
- {
- __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
- }
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_401 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_401,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_401,
- ResponseObject = __value_401,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // The API key doesn’t have permissions to perform the request
- if ((int)__response.StatusCode == 403)
- {
- string? __content_403 = null;
- global::System.Exception? __exception_403 = null;
- string? __value_403 = null;
- try
+ using (__response)
{
- if (ReadResponseAsString)
- {
- __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
- }
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessAclListOrgResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AclListOrg",
+ methodName: "AclListOrgAsync",
+ pathTemplate: "\"/v1/acl/list_org\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- __exception_403 = __ex;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AclListOrg",
+ methodName: "AclListOrgAsync",
+ pathTemplate: "\"/v1/acl/list_org\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- throw new global::Braintrust.ApiException(
- message: __content_403 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_403,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_403,
- ResponseObject = __value_403,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
- if ((int)__response.StatusCode == 429)
- {
- string? __content_429 = null;
- global::System.Exception? __exception_429 = null;
- string? __value_429 = null;
- try
- {
- if (ReadResponseAsString)
- {
- __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
- __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_429 = __ex;
- }
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // No valid API key provided
+ if ((int)__response.StatusCode == 401)
+ {
+ string? __content_401 = null;
+ global::System.Exception? __exception_401 = null;
+ string? __value_401 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- throw new global::Braintrust.ApiException(
- message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_429,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_429,
- ResponseObject = __value_429,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // Something went wrong on Braintrust's end. (These are rare.)
- if ((int)__response.StatusCode == 500)
- {
- string? __content_500 = null;
- global::System.Exception? __exception_500 = null;
- string? __value_500 = null;
- try
- {
- if (ReadResponseAsString)
- {
- __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_401 = __ex;
+ }
- __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_500 = __ex;
- }
+ throw new global::Braintrust.ApiException(
+ message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_401,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_401,
+ ResponseObject = __value_401,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // The API key doesn’t have permissions to perform the request
+ if ((int)__response.StatusCode == 403)
+ {
+ string? __content_403 = null;
+ global::System.Exception? __exception_403 = null;
+ string? __value_403 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- throw new global::Braintrust.ApiException(
- message: __content_500 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_500,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_500,
- ResponseObject = __value_500,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
+ __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_403 = __ex;
+ }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ throw new global::Braintrust.ApiException(
+ message: __content_403 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_403,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_403,
+ ResponseObject = __value_403,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
+ if ((int)__response.StatusCode == 429)
+ {
+ string? __content_429 = null;
+ global::System.Exception? __exception_429 = null;
+ string? __value_429 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessAclListOrgResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_429 = __ex;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ throw new global::Braintrust.ApiException(
+ message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_429,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_429,
+ ResponseObject = __value_429,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // Something went wrong on Braintrust's end. (These are rare.)
+ if ((int)__response.StatusCode == 500)
+ {
+ string? __content_500 = null;
+ global::System.Exception? __exception_500 = null;
+ string? __value_500 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- return
- (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
- }
- catch (global::System.Exception __ex)
- {
- throw new global::Braintrust.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
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_500 = __ex;
+ }
- return
- (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ throw new global::Braintrust.ApiException(
+ message: __content_500 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_500,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_500,
+ ResponseObject = __value_500,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+ ProcessAclListOrgResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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
+ (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.AclsClient.DeleteAcl.g.cs b/src/libs/Braintrust/Generated/Braintrust.AclsClient.DeleteAcl.g.cs
index 5936f4c..95170ce 100644
--- a/src/libs/Braintrust/Generated/Braintrust.AclsClient.DeleteAcl.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.AclsClient.DeleteAcl.g.cs
@@ -14,6 +14,7 @@ public partial class AclsClient
{ new global::Braintrust.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -54,11 +55,13 @@ partial void ProcessDeleteAclResponseContent(
/// Delete a single acl
///
///
+ /// 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 DeleteAclAsync(
global::Braintrust.AclItem request,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -75,22 +78,43 @@ partial void ProcessDeleteAclResponseContent(
securityRequirements: s_DeleteAclSecurityRequirements,
operationName: "DeleteAclAsync");
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: "/v1/acl",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Delete,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: "/v1/acl",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Delete,
+ 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;
+ __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 == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -100,308 +124,467 @@ partial void ProcessDeleteAclResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
- var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
- var __httpRequestContent = new global::System.Net.Http.StringContent(
- content: __httpRequestContentBody,
- encoding: global::System.Text.Encoding.UTF8,
- mediaType: "application/json");
- __httpRequest.Content = __httpRequestContent;
-
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareDeleteAclRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- request: request);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
-
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessDeleteAclResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
- {
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
- {
- if (ReadResponseAsString)
- {
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
-
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_400 = __ex;
- }
+ var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
+ var __httpRequestContent = new global::System.Net.Http.StringContent(
+ content: __httpRequestContentBody,
+ encoding: global::System.Text.Encoding.UTF8,
+ mediaType: "application/json");
+ __httpRequest.Content = __httpRequestContent;
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
+
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareDeleteAclRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ return __httpRequest;
}
- // No valid API key provided
- if ((int)__response.StatusCode == 401)
- {
- string? __content_401 = null;
- global::System.Exception? __exception_401 = null;
- string? __value_401 = null;
- try
- {
- if (ReadResponseAsString)
- {
- __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_401 = __ex;
- }
-
- throw new global::Braintrust.ApiException(
- message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_401,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_401,
- ResponseObject = __value_401,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // The API key doesn’t have permissions to perform the request
- if ((int)__response.StatusCode == 403)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_403 = null;
- global::System.Exception? __exception_403 = null;
- string? __value_403 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteAcl",
+ methodName: "DeleteAclAsync",
+ pathTemplate: "\"/v1/acl\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
-
- __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteAcl",
+ methodName: "DeleteAclAsync",
+ pathTemplate: "\"/v1/acl\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
- }
- catch (global::System.Exception __ex)
- {
- __exception_403 = __ex;
- }
- throw new global::Braintrust.ApiException(
- message: __content_403 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_403,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_403,
- ResponseObject = __value_403,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
- if ((int)__response.StatusCode == 429)
- {
- string? __content_429 = null;
- global::System.Exception? __exception_429 = null;
- string? __value_429 = null;
- try
- {
- if (ReadResponseAsString)
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
- __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteAcl",
+ methodName: "DeleteAclAsync",
+ pathTemplate: "\"/v1/acl\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
- else
- {
- __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_429 = __ex;
+ break;
}
- throw new global::Braintrust.ApiException(
- message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_429,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_429,
- ResponseObject = __value_429,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // Something went wrong on Braintrust's end. (These are rare.)
- if ((int)__response.StatusCode == 500)
- {
- string? __content_500 = null;
- global::System.Exception? __exception_500 = null;
- string? __value_500 = null;
- try
+ if (__response == null)
{
- if (ReadResponseAsString)
- {
- __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
-
- __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_500 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_500 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_500,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_500,
- ResponseObject = __value_500,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessDeleteAclResponseContent(
+ response: __response);
+ ProcessDeleteAclResponse(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
- {
- __response.EnsureSuccessStatusCode();
-
- return
- global::Braintrust.Acl.FromJson(__content, JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
- }
- catch (global::System.Exception __ex)
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteAcl",
+ methodName: "DeleteAclAsync",
+ pathTemplate: "\"/v1/acl\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
+ else
{
- __response.EnsureSuccessStatusCode();
- using var __content = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- return
- await global::Braintrust.Acl.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteAcl",
+ methodName: "DeleteAclAsync",
+ pathTemplate: "\"/v1/acl\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // No valid API key provided
+ if ((int)__response.StatusCode == 401)
+ {
+ string? __content_401 = null;
+ global::System.Exception? __exception_401 = null;
+ string? __value_401 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_401 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_401,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_401,
+ ResponseObject = __value_401,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // The API key doesn’t have permissions to perform the request
+ if ((int)__response.StatusCode == 403)
+ {
+ string? __content_403 = null;
+ global::System.Exception? __exception_403 = null;
+ string? __value_403 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_403 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_403 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_403,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_403,
+ ResponseObject = __value_403,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
+ if ((int)__response.StatusCode == 429)
+ {
+ string? __content_429 = null;
+ global::System.Exception? __exception_429 = null;
+ string? __value_429 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_429 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_429,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_429,
+ ResponseObject = __value_429,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // Something went wrong on Braintrust's end. (These are rare.)
+ if ((int)__response.StatusCode == 500)
+ {
+ string? __content_500 = null;
+ global::System.Exception? __exception_500 = null;
+ string? __value_500 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_500 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_500 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_500,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_500,
+ ResponseObject = __value_500,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+ ProcessDeleteAclResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Braintrust.Acl.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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::Braintrust.Acl.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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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();
+ }
}
///
/// Delete single acl
@@ -429,6 +612,7 @@ partial void ProcessDeleteAclResponseContent(
///
/// Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided
///
+ /// 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 DeleteAclAsync(
@@ -439,6 +623,7 @@ partial void ProcessDeleteAclResponseContent(
global::Braintrust.Permission? permission = default,
global::Braintrust.AclObjectType? restrictObjectType = default,
global::System.Guid? roleId = default,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::Braintrust.AclItem
@@ -454,6 +639,7 @@ partial void ProcessDeleteAclResponseContent(
return await DeleteAclAsync(
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/Braintrust/Generated/Braintrust.AclsClient.DeleteAclId.g.cs b/src/libs/Braintrust/Generated/Braintrust.AclsClient.DeleteAclId.g.cs
index 0d6c202..7dc0cb0 100644
--- a/src/libs/Braintrust/Generated/Braintrust.AclsClient.DeleteAclId.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.AclsClient.DeleteAclId.g.cs
@@ -14,6 +14,7 @@ public partial class AclsClient
{ new global::Braintrust.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -56,10 +57,12 @@ partial void ProcessDeleteAclIdResponseContent(
///
/// Acl id
///
+ /// 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 DeleteAclIdAsync(
global::System.Guid aclId,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -74,22 +77,43 @@ partial void ProcessDeleteAclIdResponseContent(
securityRequirements: s_DeleteAclIdSecurityRequirements,
operationName: "DeleteAclIdAsync");
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: $"/v1/acl/{aclId}",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Delete,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: $"/v1/acl/{aclId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Delete,
+ 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;
+ __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 == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -99,302 +123,461 @@ partial void ProcessDeleteAclIdResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareDeleteAclIdRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- aclId: aclId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareDeleteAclIdRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ aclId: aclId);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessDeleteAclIdResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteAclId",
+ methodName: "DeleteAclIdAsync",
+ pathTemplate: "$\"/v1/acl/{aclId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteAclId",
+ methodName: "DeleteAclIdAsync",
+ pathTemplate: "$\"/v1/acl/{aclId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
- }
- catch (global::System.Exception __ex)
- {
- __exception_400 = __ex;
- }
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // No valid API key provided
- if ((int)__response.StatusCode == 401)
- {
- string? __content_401 = null;
- global::System.Exception? __exception_401 = null;
- string? __value_401 = null;
- try
- {
- if (ReadResponseAsString)
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
- __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteAclId",
+ methodName: "DeleteAclIdAsync",
+ pathTemplate: "$\"/v1/acl/{aclId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
- else
- {
- __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
- }
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_401 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_401,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_401,
- ResponseObject = __value_401,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // The API key doesn’t have permissions to perform the request
- if ((int)__response.StatusCode == 403)
- {
- string? __content_403 = null;
- global::System.Exception? __exception_403 = null;
- string? __value_403 = null;
- try
+ using (__response)
{
- if (ReadResponseAsString)
- {
- __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
- }
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessDeleteAclIdResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteAclId",
+ methodName: "DeleteAclIdAsync",
+ pathTemplate: "$\"/v1/acl/{aclId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- __exception_403 = __ex;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteAclId",
+ methodName: "DeleteAclIdAsync",
+ pathTemplate: "$\"/v1/acl/{aclId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- throw new global::Braintrust.ApiException(
- message: __content_403 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_403,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_403,
- ResponseObject = __value_403,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
- if ((int)__response.StatusCode == 429)
- {
- string? __content_429 = null;
- global::System.Exception? __exception_429 = null;
- string? __value_429 = null;
- try
- {
- if (ReadResponseAsString)
- {
- __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
- __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_429 = __ex;
- }
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // No valid API key provided
+ if ((int)__response.StatusCode == 401)
+ {
+ string? __content_401 = null;
+ global::System.Exception? __exception_401 = null;
+ string? __value_401 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- throw new global::Braintrust.ApiException(
- message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_429,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_429,
- ResponseObject = __value_429,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // Something went wrong on Braintrust's end. (These are rare.)
- if ((int)__response.StatusCode == 500)
- {
- string? __content_500 = null;
- global::System.Exception? __exception_500 = null;
- string? __value_500 = null;
- try
- {
- if (ReadResponseAsString)
- {
- __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_401 = __ex;
+ }
- __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_500 = __ex;
- }
+ throw new global::Braintrust.ApiException(
+ message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_401,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_401,
+ ResponseObject = __value_401,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // The API key doesn’t have permissions to perform the request
+ if ((int)__response.StatusCode == 403)
+ {
+ string? __content_403 = null;
+ global::System.Exception? __exception_403 = null;
+ string? __value_403 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- throw new global::Braintrust.ApiException(
- message: __content_500 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_500,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_500,
- ResponseObject = __value_500,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
+ __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_403 = __ex;
+ }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ throw new global::Braintrust.ApiException(
+ message: __content_403 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_403,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_403,
+ ResponseObject = __value_403,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
+ if ((int)__response.StatusCode == 429)
+ {
+ string? __content_429 = null;
+ global::System.Exception? __exception_429 = null;
+ string? __value_429 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessDeleteAclIdResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_429 = __ex;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ throw new global::Braintrust.ApiException(
+ message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_429,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_429,
+ ResponseObject = __value_429,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // Something went wrong on Braintrust's end. (These are rare.)
+ if ((int)__response.StatusCode == 500)
+ {
+ string? __content_500 = null;
+ global::System.Exception? __exception_500 = null;
+ string? __value_500 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- return
- global::Braintrust.Acl.FromJson(__content, JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
- }
- catch (global::System.Exception __ex)
- {
- throw new global::Braintrust.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
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_500 = __ex;
+ }
- return
- await global::Braintrust.Acl.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
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ throw new global::Braintrust.ApiException(
+ message: __content_500 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_500,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_500,
+ ResponseObject = __value_500,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+ ProcessDeleteAclIdResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Braintrust.Acl.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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::Braintrust.Acl.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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.AclsClient.GetAcl.g.cs b/src/libs/Braintrust/Generated/Braintrust.AclsClient.GetAcl.g.cs
index 80ee313..85f11a3 100644
--- a/src/libs/Braintrust/Generated/Braintrust.AclsClient.GetAcl.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.AclsClient.GetAcl.g.cs
@@ -14,6 +14,7 @@ public partial class AclsClient
{ new global::Braintrust.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -109,6 +110,7 @@ partial void ProcessGetAclResponseContent(
///
/// Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided
///
+ /// 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 GetAclAsync(
@@ -123,6 +125,7 @@ partial void ProcessGetAclResponseContent(
global::Braintrust.AclListPermission? permission = default,
global::Braintrust.AclListRestrictObjectType? restrictObjectType = default,
global::System.Guid? roleId = default,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -147,35 +150,56 @@ partial void ProcessGetAclResponseContent(
securityRequirements: s_GetAclSecurityRequirements,
operationName: "GetAclAsync");
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: "/v1/acl",
- baseUri: HttpClient.BaseAddress);
- __pathBuilder
- .AddOptionalParameter("limit", limit?.ToString())
- .AddOptionalParameter("starting_after", startingAfter?.ToString())
- .AddOptionalParameter("ending_before", endingBefore?.ToString())
- .AddOptionalParameter("ids", ids?.ToString())
- .AddRequiredParameter("object_type", objectType.ToValueString())
- .AddRequiredParameter("object_id", objectId.ToString()!)
- .AddOptionalParameter("user_id", userId?.ToString())
- .AddOptionalParameter("group_id", groupId?.ToString())
- .AddOptionalParameter("permission", permission?.ToValueString())
- .AddOptionalParameter("restrict_object_type", restrictObjectType?.ToValueString())
- .AddOptionalParameter("role_id", roleId?.ToString())
- ;
- var __path = __pathBuilder.ToString();
- 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));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: "/v1/acl",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("limit", limit?.ToString())
+ .AddOptionalParameter("starting_after", startingAfter?.ToString())
+ .AddOptionalParameter("ending_before", endingBefore?.ToString())
+ .AddOptionalParameter("ids", ids?.ToString())
+ .AddRequiredParameter("object_type", objectType.ToValueString())
+ .AddRequiredParameter("object_id", objectId.ToString()!)
+ .AddOptionalParameter("user_id", userId?.ToString())
+ .AddOptionalParameter("group_id", groupId?.ToString())
+ .AddOptionalParameter("permission", permission?.ToValueString())
+ .AddOptionalParameter("restrict_object_type", restrictObjectType?.ToValueString())
+ .AddOptionalParameter("role_id", roleId?.ToString())
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ 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));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __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 == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -185,312 +209,471 @@ partial void ProcessGetAclResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareGetAclRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- limit: limit,
- startingAfter: startingAfter,
- endingBefore: endingBefore,
- ids: ids,
- objectType: objectType,
- objectId: objectId,
- userId: userId,
- groupId: groupId,
- permission: permission,
- restrictObjectType: restrictObjectType,
- roleId: roleId);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareGetAclRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ limit: limit,
+ startingAfter: startingAfter,
+ endingBefore: endingBefore,
+ ids: ids,
+ objectType: objectType,
+ objectId: objectId,
+ userId: userId,
+ groupId: groupId,
+ permission: permission,
+ restrictObjectType: restrictObjectType,
+ roleId: roleId);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessGetAclResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetAcl",
+ methodName: "GetAclAsync",
+ pathTemplate: "\"/v1/acl\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetAcl",
+ methodName: "GetAclAsync",
+ pathTemplate: "\"/v1/acl\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
- }
- catch (global::System.Exception __ex)
- {
- __exception_400 = __ex;
- }
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // No valid API key provided
- if ((int)__response.StatusCode == 401)
- {
- string? __content_401 = null;
- global::System.Exception? __exception_401 = null;
- string? __value_401 = null;
- try
- {
- if (ReadResponseAsString)
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
- __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetAcl",
+ methodName: "GetAclAsync",
+ pathTemplate: "\"/v1/acl\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
- else
- {
- __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
- }
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_401 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_401,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_401,
- ResponseObject = __value_401,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // The API key doesn’t have permissions to perform the request
- if ((int)__response.StatusCode == 403)
- {
- string? __content_403 = null;
- global::System.Exception? __exception_403 = null;
- string? __value_403 = null;
- try
+ using (__response)
{
- if (ReadResponseAsString)
- {
- __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
- }
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessGetAclResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetAcl",
+ methodName: "GetAclAsync",
+ pathTemplate: "\"/v1/acl\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- __exception_403 = __ex;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetAcl",
+ methodName: "GetAclAsync",
+ pathTemplate: "\"/v1/acl\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- throw new global::Braintrust.ApiException(
- message: __content_403 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_403,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_403,
- ResponseObject = __value_403,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
- if ((int)__response.StatusCode == 429)
- {
- string? __content_429 = null;
- global::System.Exception? __exception_429 = null;
- string? __value_429 = null;
- try
- {
- if (ReadResponseAsString)
- {
- __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
- __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_429 = __ex;
- }
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // No valid API key provided
+ if ((int)__response.StatusCode == 401)
+ {
+ string? __content_401 = null;
+ global::System.Exception? __exception_401 = null;
+ string? __value_401 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- throw new global::Braintrust.ApiException(
- message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_429,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_429,
- ResponseObject = __value_429,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // Something went wrong on Braintrust's end. (These are rare.)
- if ((int)__response.StatusCode == 500)
- {
- string? __content_500 = null;
- global::System.Exception? __exception_500 = null;
- string? __value_500 = null;
- try
- {
- if (ReadResponseAsString)
- {
- __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_401 = __ex;
+ }
- __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_500 = __ex;
- }
+ throw new global::Braintrust.ApiException(
+ message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_401,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_401,
+ ResponseObject = __value_401,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // The API key doesn’t have permissions to perform the request
+ if ((int)__response.StatusCode == 403)
+ {
+ string? __content_403 = null;
+ global::System.Exception? __exception_403 = null;
+ string? __value_403 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- throw new global::Braintrust.ApiException(
- message: __content_500 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_500,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_500,
- ResponseObject = __value_500,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
+ __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_403 = __ex;
+ }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ throw new global::Braintrust.ApiException(
+ message: __content_403 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_403,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_403,
+ ResponseObject = __value_403,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
+ if ((int)__response.StatusCode == 429)
+ {
+ string? __content_429 = null;
+ global::System.Exception? __exception_429 = null;
+ string? __value_429 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessGetAclResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_429 = __ex;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ throw new global::Braintrust.ApiException(
+ message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_429,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_429,
+ ResponseObject = __value_429,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // Something went wrong on Braintrust's end. (These are rare.)
+ if ((int)__response.StatusCode == 500)
+ {
+ string? __content_500 = null;
+ global::System.Exception? __exception_500 = null;
+ string? __value_500 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- return
- global::Braintrust.GetAclResponse.FromJson(__content, JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
- }
- catch (global::System.Exception __ex)
- {
- throw new global::Braintrust.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
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_500 = __ex;
+ }
- return
- await global::Braintrust.GetAclResponse.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
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ throw new global::Braintrust.ApiException(
+ message: __content_500 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_500,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_500,
+ ResponseObject = __value_500,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+ ProcessGetAclResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Braintrust.GetAclResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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::Braintrust.GetAclResponse.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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.AclsClient.GetAclId.g.cs b/src/libs/Braintrust/Generated/Braintrust.AclsClient.GetAclId.g.cs
index a03c7ca..10bba27 100644
--- a/src/libs/Braintrust/Generated/Braintrust.AclsClient.GetAclId.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.AclsClient.GetAclId.g.cs
@@ -14,6 +14,7 @@ public partial class AclsClient
{ new global::Braintrust.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -56,10 +57,12 @@ partial void ProcessGetAclIdResponseContent(
///
/// Acl id
///
+ /// 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 GetAclIdAsync(
global::System.Guid aclId,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -74,22 +77,43 @@ partial void ProcessGetAclIdResponseContent(
securityRequirements: s_GetAclIdSecurityRequirements,
operationName: "GetAclIdAsync");
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: $"/v1/acl/{aclId}",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- 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));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: $"/v1/acl/{aclId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ 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));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __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 == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -99,302 +123,461 @@ partial void ProcessGetAclIdResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareGetAclIdRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- aclId: aclId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareGetAclIdRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ aclId: aclId);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessGetAclIdResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetAclId",
+ methodName: "GetAclIdAsync",
+ pathTemplate: "$\"/v1/acl/{aclId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetAclId",
+ methodName: "GetAclIdAsync",
+ pathTemplate: "$\"/v1/acl/{aclId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
- }
- catch (global::System.Exception __ex)
- {
- __exception_400 = __ex;
- }
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // No valid API key provided
- if ((int)__response.StatusCode == 401)
- {
- string? __content_401 = null;
- global::System.Exception? __exception_401 = null;
- string? __value_401 = null;
- try
- {
- if (ReadResponseAsString)
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
- __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetAclId",
+ methodName: "GetAclIdAsync",
+ pathTemplate: "$\"/v1/acl/{aclId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
- else
- {
- __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
- }
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_401 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_401,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_401,
- ResponseObject = __value_401,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // The API key doesn’t have permissions to perform the request
- if ((int)__response.StatusCode == 403)
- {
- string? __content_403 = null;
- global::System.Exception? __exception_403 = null;
- string? __value_403 = null;
- try
+ using (__response)
{
- if (ReadResponseAsString)
- {
- __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
- }
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessGetAclIdResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetAclId",
+ methodName: "GetAclIdAsync",
+ pathTemplate: "$\"/v1/acl/{aclId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- __exception_403 = __ex;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetAclId",
+ methodName: "GetAclIdAsync",
+ pathTemplate: "$\"/v1/acl/{aclId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- throw new global::Braintrust.ApiException(
- message: __content_403 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_403,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_403,
- ResponseObject = __value_403,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
- if ((int)__response.StatusCode == 429)
- {
- string? __content_429 = null;
- global::System.Exception? __exception_429 = null;
- string? __value_429 = null;
- try
- {
- if (ReadResponseAsString)
- {
- __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
- __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_429 = __ex;
- }
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // No valid API key provided
+ if ((int)__response.StatusCode == 401)
+ {
+ string? __content_401 = null;
+ global::System.Exception? __exception_401 = null;
+ string? __value_401 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- throw new global::Braintrust.ApiException(
- message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_429,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_429,
- ResponseObject = __value_429,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // Something went wrong on Braintrust's end. (These are rare.)
- if ((int)__response.StatusCode == 500)
- {
- string? __content_500 = null;
- global::System.Exception? __exception_500 = null;
- string? __value_500 = null;
- try
- {
- if (ReadResponseAsString)
- {
- __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_401 = __ex;
+ }
- __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_500 = __ex;
- }
+ throw new global::Braintrust.ApiException(
+ message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_401,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_401,
+ ResponseObject = __value_401,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // The API key doesn’t have permissions to perform the request
+ if ((int)__response.StatusCode == 403)
+ {
+ string? __content_403 = null;
+ global::System.Exception? __exception_403 = null;
+ string? __value_403 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- throw new global::Braintrust.ApiException(
- message: __content_500 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_500,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_500,
- ResponseObject = __value_500,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
+ __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_403 = __ex;
+ }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ throw new global::Braintrust.ApiException(
+ message: __content_403 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_403,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_403,
+ ResponseObject = __value_403,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
+ if ((int)__response.StatusCode == 429)
+ {
+ string? __content_429 = null;
+ global::System.Exception? __exception_429 = null;
+ string? __value_429 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessGetAclIdResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_429 = __ex;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ throw new global::Braintrust.ApiException(
+ message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_429,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_429,
+ ResponseObject = __value_429,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // Something went wrong on Braintrust's end. (These are rare.)
+ if ((int)__response.StatusCode == 500)
+ {
+ string? __content_500 = null;
+ global::System.Exception? __exception_500 = null;
+ string? __value_500 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- return
- global::Braintrust.Acl.FromJson(__content, JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
- }
- catch (global::System.Exception __ex)
- {
- throw new global::Braintrust.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
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_500 = __ex;
+ }
- return
- await global::Braintrust.Acl.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
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ throw new global::Braintrust.ApiException(
+ message: __content_500 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_500,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_500,
+ ResponseObject = __value_500,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+ ProcessGetAclIdResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Braintrust.Acl.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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::Braintrust.Acl.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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.AclsClient.PostAcl.g.cs b/src/libs/Braintrust/Generated/Braintrust.AclsClient.PostAcl.g.cs
index bea2eb1..4ef330d 100644
--- a/src/libs/Braintrust/Generated/Braintrust.AclsClient.PostAcl.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.AclsClient.PostAcl.g.cs
@@ -14,6 +14,7 @@ public partial class AclsClient
{ new global::Braintrust.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -54,11 +55,13 @@ partial void ProcessPostAclResponseContent(
/// Create a new acl. If there is an existing acl with the same contents as the one specified in the request, will return the existing acl unmodified
///
///
+ /// 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 PostAclAsync(
global::Braintrust.AclItem request,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -75,22 +78,43 @@ partial void ProcessPostAclResponseContent(
securityRequirements: s_PostAclSecurityRequirements,
operationName: "PostAclAsync");
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: "/v1/acl",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- 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));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: "/v1/acl",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.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;
+ __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 == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -100,308 +124,467 @@ partial void ProcessPostAclResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
- var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
- var __httpRequestContent = new global::System.Net.Http.StringContent(
- content: __httpRequestContentBody,
- encoding: global::System.Text.Encoding.UTF8,
- mediaType: "application/json");
- __httpRequest.Content = __httpRequestContent;
-
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PreparePostAclRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- request: request);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
-
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessPostAclResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
- {
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
- {
- if (ReadResponseAsString)
- {
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
-
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_400 = __ex;
- }
+ var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
+ var __httpRequestContent = new global::System.Net.Http.StringContent(
+ content: __httpRequestContentBody,
+ encoding: global::System.Text.Encoding.UTF8,
+ mediaType: "application/json");
+ __httpRequest.Content = __httpRequestContent;
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
+
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PreparePostAclRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ return __httpRequest;
}
- // No valid API key provided
- if ((int)__response.StatusCode == 401)
- {
- string? __content_401 = null;
- global::System.Exception? __exception_401 = null;
- string? __value_401 = null;
- try
- {
- if (ReadResponseAsString)
- {
- __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_401 = __ex;
- }
-
- throw new global::Braintrust.ApiException(
- message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_401,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_401,
- ResponseObject = __value_401,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // The API key doesn’t have permissions to perform the request
- if ((int)__response.StatusCode == 403)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_403 = null;
- global::System.Exception? __exception_403 = null;
- string? __value_403 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostAcl",
+ methodName: "PostAclAsync",
+ pathTemplate: "\"/v1/acl\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
-
- __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostAcl",
+ methodName: "PostAclAsync",
+ pathTemplate: "\"/v1/acl\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
- }
- catch (global::System.Exception __ex)
- {
- __exception_403 = __ex;
- }
- throw new global::Braintrust.ApiException(
- message: __content_403 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_403,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_403,
- ResponseObject = __value_403,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
- if ((int)__response.StatusCode == 429)
- {
- string? __content_429 = null;
- global::System.Exception? __exception_429 = null;
- string? __value_429 = null;
- try
- {
- if (ReadResponseAsString)
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
- __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostAcl",
+ methodName: "PostAclAsync",
+ pathTemplate: "\"/v1/acl\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
- else
- {
- __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_429 = __ex;
+ break;
}
- throw new global::Braintrust.ApiException(
- message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_429,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_429,
- ResponseObject = __value_429,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // Something went wrong on Braintrust's end. (These are rare.)
- if ((int)__response.StatusCode == 500)
- {
- string? __content_500 = null;
- global::System.Exception? __exception_500 = null;
- string? __value_500 = null;
- try
+ if (__response == null)
{
- if (ReadResponseAsString)
- {
- __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
-
- __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_500 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_500 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_500,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_500,
- ResponseObject = __value_500,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessPostAclResponseContent(
+ response: __response);
+ ProcessPostAclResponse(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
- {
- __response.EnsureSuccessStatusCode();
-
- return
- global::Braintrust.Acl.FromJson(__content, JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
- }
- catch (global::System.Exception __ex)
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostAcl",
+ methodName: "PostAclAsync",
+ pathTemplate: "\"/v1/acl\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
+ else
{
- __response.EnsureSuccessStatusCode();
- using var __content = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- return
- await global::Braintrust.Acl.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostAcl",
+ methodName: "PostAclAsync",
+ pathTemplate: "\"/v1/acl\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // No valid API key provided
+ if ((int)__response.StatusCode == 401)
+ {
+ string? __content_401 = null;
+ global::System.Exception? __exception_401 = null;
+ string? __value_401 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_401 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_401,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_401,
+ ResponseObject = __value_401,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // The API key doesn’t have permissions to perform the request
+ if ((int)__response.StatusCode == 403)
+ {
+ string? __content_403 = null;
+ global::System.Exception? __exception_403 = null;
+ string? __value_403 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_403 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_403 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_403,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_403,
+ ResponseObject = __value_403,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
+ if ((int)__response.StatusCode == 429)
+ {
+ string? __content_429 = null;
+ global::System.Exception? __exception_429 = null;
+ string? __value_429 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_429 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_429,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_429,
+ ResponseObject = __value_429,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // Something went wrong on Braintrust's end. (These are rare.)
+ if ((int)__response.StatusCode == 500)
+ {
+ string? __content_500 = null;
+ global::System.Exception? __exception_500 = null;
+ string? __value_500 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_500 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_500 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_500,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_500,
+ ResponseObject = __value_500,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+ ProcessPostAclResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Braintrust.Acl.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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::Braintrust.Acl.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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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();
+ }
}
///
/// Create acl
@@ -429,6 +612,7 @@ partial void ProcessPostAclResponseContent(
///
/// Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided
///
+ /// 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 PostAclAsync(
@@ -439,6 +623,7 @@ partial void ProcessPostAclResponseContent(
global::Braintrust.Permission? permission = default,
global::Braintrust.AclObjectType? restrictObjectType = default,
global::System.Guid? roleId = default,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::Braintrust.AclItem
@@ -454,6 +639,7 @@ partial void ProcessPostAclResponseContent(
return await PostAclAsync(
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/Braintrust/Generated/Braintrust.AclsClient.g.cs b/src/libs/Braintrust/Generated/Braintrust.AclsClient.g.cs
index 4caad36..a4769a9 100644
--- a/src/libs/Braintrust/Generated/Braintrust.AclsClient.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.AclsClient.g.cs
@@ -30,6 +30,9 @@ public sealed partial class AclsClient : global::Braintrust.IAclsClient, global:
#if DEBUG
= true;
#endif
+
+ ///
+ public global::Braintrust.AutoSDKClientOptions Options { get; }
///
///
///
@@ -49,11 +52,37 @@ public AclsClient(
global::System.Net.Http.HttpClient? httpClient = null,
global::System.Uri? baseUri = null,
global::System.Collections.Generic.List? authorizations = null,
+ bool disposeHttpClient = true) : this(
+ httpClient,
+ baseUri,
+ authorizations,
+ options: null,
+ disposeHttpClient: disposeHttpClient)
+ {
+ }
+
+ ///
+ /// Creates a new instance of the AclsClient.
+ /// 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.
+ /// Client-wide request defaults such as headers, query parameters, retries, and timeout.
+ /// Dispose the HttpClient when the instance is disposed. True by default.
+ public AclsClient(
+ global::System.Net.Http.HttpClient? httpClient = null,
+ global::System.Uri? baseUri = null,
+ global::System.Collections.Generic.List? authorizations = null,
+ global::Braintrust.AutoSDKClientOptions? options = null,
bool disposeHttpClient = true)
{
+
HttpClient = httpClient ?? new global::System.Net.Http.HttpClient();
HttpClient.BaseAddress ??= baseUri ?? new global::System.Uri(DefaultBaseUrl);
Authorizations = authorizations ?? new global::System.Collections.Generic.List();
+ Options = options ?? new global::Braintrust.AutoSDKClientOptions();
_disposeHttpClient = disposeHttpClient;
Initialized(HttpClient);
diff --git a/src/libs/Braintrust/Generated/Braintrust.AiSecretsClient.DeleteAiSecret.g.cs b/src/libs/Braintrust/Generated/Braintrust.AiSecretsClient.DeleteAiSecret.g.cs
index ffb6b51..867068e 100644
--- a/src/libs/Braintrust/Generated/Braintrust.AiSecretsClient.DeleteAiSecret.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.AiSecretsClient.DeleteAiSecret.g.cs
@@ -14,6 +14,7 @@ public partial class AiSecretsClient
{ new global::Braintrust.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -54,11 +55,13 @@ partial void ProcessDeleteAiSecretResponseContent(
/// Delete a single ai_secret
///
///
+ /// 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 DeleteAiSecretAsync(
global::Braintrust.DeleteAISecret request,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -75,22 +78,43 @@ partial void ProcessDeleteAiSecretResponseContent(
securityRequirements: s_DeleteAiSecretSecurityRequirements,
operationName: "DeleteAiSecretAsync");
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: "/v1/ai_secret",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Delete,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: "/v1/ai_secret",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Delete,
+ 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;
+ __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 == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -100,308 +124,467 @@ partial void ProcessDeleteAiSecretResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
- var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
- var __httpRequestContent = new global::System.Net.Http.StringContent(
- content: __httpRequestContentBody,
- encoding: global::System.Text.Encoding.UTF8,
- mediaType: "application/json");
- __httpRequest.Content = __httpRequestContent;
-
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareDeleteAiSecretRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- request: request);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
-
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessDeleteAiSecretResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
- {
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
- {
- if (ReadResponseAsString)
- {
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
-
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_400 = __ex;
- }
+ var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
+ var __httpRequestContent = new global::System.Net.Http.StringContent(
+ content: __httpRequestContentBody,
+ encoding: global::System.Text.Encoding.UTF8,
+ mediaType: "application/json");
+ __httpRequest.Content = __httpRequestContent;
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
+
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareDeleteAiSecretRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ return __httpRequest;
}
- // No valid API key provided
- if ((int)__response.StatusCode == 401)
- {
- string? __content_401 = null;
- global::System.Exception? __exception_401 = null;
- string? __value_401 = null;
- try
- {
- if (ReadResponseAsString)
- {
- __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_401 = __ex;
- }
-
- throw new global::Braintrust.ApiException(
- message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_401,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_401,
- ResponseObject = __value_401,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // The API key doesn’t have permissions to perform the request
- if ((int)__response.StatusCode == 403)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_403 = null;
- global::System.Exception? __exception_403 = null;
- string? __value_403 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteAiSecret",
+ methodName: "DeleteAiSecretAsync",
+ pathTemplate: "\"/v1/ai_secret\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
-
- __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteAiSecret",
+ methodName: "DeleteAiSecretAsync",
+ pathTemplate: "\"/v1/ai_secret\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
- }
- catch (global::System.Exception __ex)
- {
- __exception_403 = __ex;
- }
- throw new global::Braintrust.ApiException(
- message: __content_403 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_403,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_403,
- ResponseObject = __value_403,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
- if ((int)__response.StatusCode == 429)
- {
- string? __content_429 = null;
- global::System.Exception? __exception_429 = null;
- string? __value_429 = null;
- try
- {
- if (ReadResponseAsString)
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
- __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteAiSecret",
+ methodName: "DeleteAiSecretAsync",
+ pathTemplate: "\"/v1/ai_secret\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
- else
- {
- __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_429 = __ex;
+ break;
}
- throw new global::Braintrust.ApiException(
- message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_429,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_429,
- ResponseObject = __value_429,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // Something went wrong on Braintrust's end. (These are rare.)
- if ((int)__response.StatusCode == 500)
- {
- string? __content_500 = null;
- global::System.Exception? __exception_500 = null;
- string? __value_500 = null;
- try
+ if (__response == null)
{
- if (ReadResponseAsString)
- {
- __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
-
- __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_500 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_500 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_500,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_500,
- ResponseObject = __value_500,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessDeleteAiSecretResponseContent(
+ response: __response);
+ ProcessDeleteAiSecretResponse(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
- {
- __response.EnsureSuccessStatusCode();
-
- return
- global::Braintrust.AISecret.FromJson(__content, JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
- }
- catch (global::System.Exception __ex)
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteAiSecret",
+ methodName: "DeleteAiSecretAsync",
+ pathTemplate: "\"/v1/ai_secret\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
+ else
{
- __response.EnsureSuccessStatusCode();
- using var __content = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- return
- await global::Braintrust.AISecret.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteAiSecret",
+ methodName: "DeleteAiSecretAsync",
+ pathTemplate: "\"/v1/ai_secret\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // No valid API key provided
+ if ((int)__response.StatusCode == 401)
+ {
+ string? __content_401 = null;
+ global::System.Exception? __exception_401 = null;
+ string? __value_401 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_401 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_401,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_401,
+ ResponseObject = __value_401,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // The API key doesn’t have permissions to perform the request
+ if ((int)__response.StatusCode == 403)
+ {
+ string? __content_403 = null;
+ global::System.Exception? __exception_403 = null;
+ string? __value_403 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_403 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_403 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_403,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_403,
+ ResponseObject = __value_403,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
+ if ((int)__response.StatusCode == 429)
+ {
+ string? __content_429 = null;
+ global::System.Exception? __exception_429 = null;
+ string? __value_429 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_429 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_429,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_429,
+ ResponseObject = __value_429,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // Something went wrong on Braintrust's end. (These are rare.)
+ if ((int)__response.StatusCode == 500)
+ {
+ string? __content_500 = null;
+ global::System.Exception? __exception_500 = null;
+ string? __value_500 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_500 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_500 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_500,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_500,
+ ResponseObject = __value_500,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+ ProcessDeleteAiSecretResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Braintrust.AISecret.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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::Braintrust.AISecret.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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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();
+ }
}
///
/// Delete single ai_secret
@@ -413,11 +596,13 @@ partial void ProcessDeleteAiSecretResponseContent(
///
/// For nearly all users, this parameter should be unnecessary. But in the rare case that your API key belongs to multiple organizations, you may specify the name of the organization the AI Secret belongs in.
///
+ /// 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 DeleteAiSecretAsync(
string name,
string? orgName = default,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::Braintrust.DeleteAISecret
@@ -428,6 +613,7 @@ partial void ProcessDeleteAiSecretResponseContent(
return await DeleteAiSecretAsync(
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/Braintrust/Generated/Braintrust.AiSecretsClient.DeleteAiSecretId.g.cs b/src/libs/Braintrust/Generated/Braintrust.AiSecretsClient.DeleteAiSecretId.g.cs
index fedf56d..b7b5324 100644
--- a/src/libs/Braintrust/Generated/Braintrust.AiSecretsClient.DeleteAiSecretId.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.AiSecretsClient.DeleteAiSecretId.g.cs
@@ -14,6 +14,7 @@ public partial class AiSecretsClient
{ new global::Braintrust.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -56,10 +57,12 @@ partial void ProcessDeleteAiSecretIdResponseContent(
///
/// AiSecret id
///
+ /// 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 DeleteAiSecretIdAsync(
global::System.Guid aiSecretId,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -74,22 +77,43 @@ partial void ProcessDeleteAiSecretIdResponseContent(
securityRequirements: s_DeleteAiSecretIdSecurityRequirements,
operationName: "DeleteAiSecretIdAsync");
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: $"/v1/ai_secret/{aiSecretId}",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Delete,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: $"/v1/ai_secret/{aiSecretId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Delete,
+ 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;
+ __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 == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -99,302 +123,461 @@ partial void ProcessDeleteAiSecretIdResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareDeleteAiSecretIdRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- aiSecretId: aiSecretId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareDeleteAiSecretIdRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ aiSecretId: aiSecretId);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessDeleteAiSecretIdResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteAiSecretId",
+ methodName: "DeleteAiSecretIdAsync",
+ pathTemplate: "$\"/v1/ai_secret/{aiSecretId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteAiSecretId",
+ methodName: "DeleteAiSecretIdAsync",
+ pathTemplate: "$\"/v1/ai_secret/{aiSecretId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
- }
- catch (global::System.Exception __ex)
- {
- __exception_400 = __ex;
- }
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // No valid API key provided
- if ((int)__response.StatusCode == 401)
- {
- string? __content_401 = null;
- global::System.Exception? __exception_401 = null;
- string? __value_401 = null;
- try
- {
- if (ReadResponseAsString)
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
- __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteAiSecretId",
+ methodName: "DeleteAiSecretIdAsync",
+ pathTemplate: "$\"/v1/ai_secret/{aiSecretId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
- else
- {
- __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
- }
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_401 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_401,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_401,
- ResponseObject = __value_401,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // The API key doesn’t have permissions to perform the request
- if ((int)__response.StatusCode == 403)
- {
- string? __content_403 = null;
- global::System.Exception? __exception_403 = null;
- string? __value_403 = null;
- try
+ using (__response)
{
- if (ReadResponseAsString)
- {
- __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
- }
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessDeleteAiSecretIdResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteAiSecretId",
+ methodName: "DeleteAiSecretIdAsync",
+ pathTemplate: "$\"/v1/ai_secret/{aiSecretId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- __exception_403 = __ex;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteAiSecretId",
+ methodName: "DeleteAiSecretIdAsync",
+ pathTemplate: "$\"/v1/ai_secret/{aiSecretId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- throw new global::Braintrust.ApiException(
- message: __content_403 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_403,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_403,
- ResponseObject = __value_403,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
- if ((int)__response.StatusCode == 429)
- {
- string? __content_429 = null;
- global::System.Exception? __exception_429 = null;
- string? __value_429 = null;
- try
- {
- if (ReadResponseAsString)
- {
- __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
- __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_429 = __ex;
- }
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // No valid API key provided
+ if ((int)__response.StatusCode == 401)
+ {
+ string? __content_401 = null;
+ global::System.Exception? __exception_401 = null;
+ string? __value_401 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- throw new global::Braintrust.ApiException(
- message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_429,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_429,
- ResponseObject = __value_429,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // Something went wrong on Braintrust's end. (These are rare.)
- if ((int)__response.StatusCode == 500)
- {
- string? __content_500 = null;
- global::System.Exception? __exception_500 = null;
- string? __value_500 = null;
- try
- {
- if (ReadResponseAsString)
- {
- __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_401 = __ex;
+ }
- __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_500 = __ex;
- }
+ throw new global::Braintrust.ApiException(
+ message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_401,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_401,
+ ResponseObject = __value_401,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // The API key doesn’t have permissions to perform the request
+ if ((int)__response.StatusCode == 403)
+ {
+ string? __content_403 = null;
+ global::System.Exception? __exception_403 = null;
+ string? __value_403 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- throw new global::Braintrust.ApiException(
- message: __content_500 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_500,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_500,
- ResponseObject = __value_500,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
+ __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_403 = __ex;
+ }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ throw new global::Braintrust.ApiException(
+ message: __content_403 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_403,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_403,
+ ResponseObject = __value_403,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
+ if ((int)__response.StatusCode == 429)
+ {
+ string? __content_429 = null;
+ global::System.Exception? __exception_429 = null;
+ string? __value_429 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessDeleteAiSecretIdResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_429 = __ex;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ throw new global::Braintrust.ApiException(
+ message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_429,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_429,
+ ResponseObject = __value_429,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // Something went wrong on Braintrust's end. (These are rare.)
+ if ((int)__response.StatusCode == 500)
+ {
+ string? __content_500 = null;
+ global::System.Exception? __exception_500 = null;
+ string? __value_500 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- return
- global::Braintrust.AISecret.FromJson(__content, JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
- }
- catch (global::System.Exception __ex)
- {
- throw new global::Braintrust.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
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_500 = __ex;
+ }
- return
- await global::Braintrust.AISecret.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
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ throw new global::Braintrust.ApiException(
+ message: __content_500 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_500,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_500,
+ ResponseObject = __value_500,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+ ProcessDeleteAiSecretIdResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Braintrust.AISecret.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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::Braintrust.AISecret.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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.AiSecretsClient.GetAiSecret.g.cs b/src/libs/Braintrust/Generated/Braintrust.AiSecretsClient.GetAiSecret.g.cs
index e4f66ac..fb7d0d8 100644
--- a/src/libs/Braintrust/Generated/Braintrust.AiSecretsClient.GetAiSecret.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.AiSecretsClient.GetAiSecret.g.cs
@@ -14,6 +14,7 @@ public partial class AiSecretsClient
{ new global::Braintrust.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -86,6 +87,7 @@ partial void ProcessGetAiSecretResponseContent(
/// Filter search results to within a particular organization
///
///
+ /// 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 GetAiSecretAsync(
@@ -96,6 +98,7 @@ partial void ProcessGetAiSecretResponseContent(
string? aiSecretName = default,
string? orgName = default,
global::Braintrust.AISecretType? aiSecretType = default,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -116,31 +119,52 @@ partial void ProcessGetAiSecretResponseContent(
securityRequirements: s_GetAiSecretSecurityRequirements,
operationName: "GetAiSecretAsync");
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: "/v1/ai_secret",
- baseUri: HttpClient.BaseAddress);
- __pathBuilder
- .AddOptionalParameter("limit", limit?.ToString())
- .AddOptionalParameter("starting_after", startingAfter?.ToString())
- .AddOptionalParameter("ending_before", endingBefore?.ToString())
- .AddOptionalParameter("ids", ids?.ToString())
- .AddOptionalParameter("ai_secret_name", aiSecretName)
- .AddOptionalParameter("org_name", orgName)
- .AddOptionalParameter("ai_secret_type", aiSecretType?.ToString())
- ;
- var __path = __pathBuilder.ToString();
- 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));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: "/v1/ai_secret",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("limit", limit?.ToString())
+ .AddOptionalParameter("starting_after", startingAfter?.ToString())
+ .AddOptionalParameter("ending_before", endingBefore?.ToString())
+ .AddOptionalParameter("ids", ids?.ToString())
+ .AddOptionalParameter("ai_secret_name", aiSecretName)
+ .AddOptionalParameter("org_name", orgName)
+ .AddOptionalParameter("ai_secret_type", aiSecretType?.ToString())
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ 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));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __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 == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -150,308 +174,467 @@ partial void ProcessGetAiSecretResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareGetAiSecretRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- limit: limit,
- startingAfter: startingAfter,
- endingBefore: endingBefore,
- ids: ids,
- aiSecretName: aiSecretName,
- orgName: orgName,
- aiSecretType: aiSecretType);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareGetAiSecretRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ limit: limit,
+ startingAfter: startingAfter,
+ endingBefore: endingBefore,
+ ids: ids,
+ aiSecretName: aiSecretName,
+ orgName: orgName,
+ aiSecretType: aiSecretType);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessGetAiSecretResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetAiSecret",
+ methodName: "GetAiSecretAsync",
+ pathTemplate: "\"/v1/ai_secret\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetAiSecret",
+ methodName: "GetAiSecretAsync",
+ pathTemplate: "\"/v1/ai_secret\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
- }
- catch (global::System.Exception __ex)
- {
- __exception_400 = __ex;
- }
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // No valid API key provided
- if ((int)__response.StatusCode == 401)
- {
- string? __content_401 = null;
- global::System.Exception? __exception_401 = null;
- string? __value_401 = null;
- try
- {
- if (ReadResponseAsString)
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
- __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetAiSecret",
+ methodName: "GetAiSecretAsync",
+ pathTemplate: "\"/v1/ai_secret\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
- else
- {
- __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
- }
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_401 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_401,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_401,
- ResponseObject = __value_401,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // The API key doesn’t have permissions to perform the request
- if ((int)__response.StatusCode == 403)
- {
- string? __content_403 = null;
- global::System.Exception? __exception_403 = null;
- string? __value_403 = null;
- try
+ using (__response)
{
- if (ReadResponseAsString)
- {
- __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
- }
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessGetAiSecretResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetAiSecret",
+ methodName: "GetAiSecretAsync",
+ pathTemplate: "\"/v1/ai_secret\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- __exception_403 = __ex;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetAiSecret",
+ methodName: "GetAiSecretAsync",
+ pathTemplate: "\"/v1/ai_secret\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- throw new global::Braintrust.ApiException(
- message: __content_403 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_403,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_403,
- ResponseObject = __value_403,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
- if ((int)__response.StatusCode == 429)
- {
- string? __content_429 = null;
- global::System.Exception? __exception_429 = null;
- string? __value_429 = null;
- try
- {
- if (ReadResponseAsString)
- {
- __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
- __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_429 = __ex;
- }
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // No valid API key provided
+ if ((int)__response.StatusCode == 401)
+ {
+ string? __content_401 = null;
+ global::System.Exception? __exception_401 = null;
+ string? __value_401 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- throw new global::Braintrust.ApiException(
- message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_429,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_429,
- ResponseObject = __value_429,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // Something went wrong on Braintrust's end. (These are rare.)
- if ((int)__response.StatusCode == 500)
- {
- string? __content_500 = null;
- global::System.Exception? __exception_500 = null;
- string? __value_500 = null;
- try
- {
- if (ReadResponseAsString)
- {
- __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_401 = __ex;
+ }
- __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_500 = __ex;
- }
+ throw new global::Braintrust.ApiException(
+ message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_401,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_401,
+ ResponseObject = __value_401,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // The API key doesn’t have permissions to perform the request
+ if ((int)__response.StatusCode == 403)
+ {
+ string? __content_403 = null;
+ global::System.Exception? __exception_403 = null;
+ string? __value_403 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- throw new global::Braintrust.ApiException(
- message: __content_500 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_500,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_500,
- ResponseObject = __value_500,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
+ __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_403 = __ex;
+ }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ throw new global::Braintrust.ApiException(
+ message: __content_403 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_403,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_403,
+ ResponseObject = __value_403,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
+ if ((int)__response.StatusCode == 429)
+ {
+ string? __content_429 = null;
+ global::System.Exception? __exception_429 = null;
+ string? __value_429 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessGetAiSecretResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_429 = __ex;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ throw new global::Braintrust.ApiException(
+ message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_429,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_429,
+ ResponseObject = __value_429,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // Something went wrong on Braintrust's end. (These are rare.)
+ if ((int)__response.StatusCode == 500)
+ {
+ string? __content_500 = null;
+ global::System.Exception? __exception_500 = null;
+ string? __value_500 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- return
- global::Braintrust.GetAiSecretResponse.FromJson(__content, JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
- }
- catch (global::System.Exception __ex)
- {
- throw new global::Braintrust.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
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_500 = __ex;
+ }
- return
- await global::Braintrust.GetAiSecretResponse.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
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ throw new global::Braintrust.ApiException(
+ message: __content_500 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_500,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_500,
+ ResponseObject = __value_500,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+ ProcessGetAiSecretResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Braintrust.GetAiSecretResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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::Braintrust.GetAiSecretResponse.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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.AiSecretsClient.GetAiSecretId.g.cs b/src/libs/Braintrust/Generated/Braintrust.AiSecretsClient.GetAiSecretId.g.cs
index 849bb96..42fd595 100644
--- a/src/libs/Braintrust/Generated/Braintrust.AiSecretsClient.GetAiSecretId.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.AiSecretsClient.GetAiSecretId.g.cs
@@ -14,6 +14,7 @@ public partial class AiSecretsClient
{ new global::Braintrust.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -56,10 +57,12 @@ partial void ProcessGetAiSecretIdResponseContent(
///
/// AiSecret id
///
+ /// 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 GetAiSecretIdAsync(
global::System.Guid aiSecretId,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -74,22 +77,43 @@ partial void ProcessGetAiSecretIdResponseContent(
securityRequirements: s_GetAiSecretIdSecurityRequirements,
operationName: "GetAiSecretIdAsync");
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: $"/v1/ai_secret/{aiSecretId}",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- 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));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: $"/v1/ai_secret/{aiSecretId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ 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));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __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 == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -99,302 +123,461 @@ partial void ProcessGetAiSecretIdResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareGetAiSecretIdRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- aiSecretId: aiSecretId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareGetAiSecretIdRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ aiSecretId: aiSecretId);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessGetAiSecretIdResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetAiSecretId",
+ methodName: "GetAiSecretIdAsync",
+ pathTemplate: "$\"/v1/ai_secret/{aiSecretId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetAiSecretId",
+ methodName: "GetAiSecretIdAsync",
+ pathTemplate: "$\"/v1/ai_secret/{aiSecretId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
- }
- catch (global::System.Exception __ex)
- {
- __exception_400 = __ex;
- }
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // No valid API key provided
- if ((int)__response.StatusCode == 401)
- {
- string? __content_401 = null;
- global::System.Exception? __exception_401 = null;
- string? __value_401 = null;
- try
- {
- if (ReadResponseAsString)
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
- __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetAiSecretId",
+ methodName: "GetAiSecretIdAsync",
+ pathTemplate: "$\"/v1/ai_secret/{aiSecretId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
- else
- {
- __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
- }
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_401 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_401,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_401,
- ResponseObject = __value_401,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // The API key doesn’t have permissions to perform the request
- if ((int)__response.StatusCode == 403)
- {
- string? __content_403 = null;
- global::System.Exception? __exception_403 = null;
- string? __value_403 = null;
- try
+ using (__response)
{
- if (ReadResponseAsString)
- {
- __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
- }
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessGetAiSecretIdResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetAiSecretId",
+ methodName: "GetAiSecretIdAsync",
+ pathTemplate: "$\"/v1/ai_secret/{aiSecretId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- __exception_403 = __ex;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetAiSecretId",
+ methodName: "GetAiSecretIdAsync",
+ pathTemplate: "$\"/v1/ai_secret/{aiSecretId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- throw new global::Braintrust.ApiException(
- message: __content_403 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_403,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_403,
- ResponseObject = __value_403,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
- if ((int)__response.StatusCode == 429)
- {
- string? __content_429 = null;
- global::System.Exception? __exception_429 = null;
- string? __value_429 = null;
- try
- {
- if (ReadResponseAsString)
- {
- __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
- __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_429 = __ex;
- }
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // No valid API key provided
+ if ((int)__response.StatusCode == 401)
+ {
+ string? __content_401 = null;
+ global::System.Exception? __exception_401 = null;
+ string? __value_401 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- throw new global::Braintrust.ApiException(
- message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_429,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_429,
- ResponseObject = __value_429,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // Something went wrong on Braintrust's end. (These are rare.)
- if ((int)__response.StatusCode == 500)
- {
- string? __content_500 = null;
- global::System.Exception? __exception_500 = null;
- string? __value_500 = null;
- try
- {
- if (ReadResponseAsString)
- {
- __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_401 = __ex;
+ }
- __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_500 = __ex;
- }
+ throw new global::Braintrust.ApiException(
+ message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_401,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_401,
+ ResponseObject = __value_401,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // The API key doesn’t have permissions to perform the request
+ if ((int)__response.StatusCode == 403)
+ {
+ string? __content_403 = null;
+ global::System.Exception? __exception_403 = null;
+ string? __value_403 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- throw new global::Braintrust.ApiException(
- message: __content_500 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_500,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_500,
- ResponseObject = __value_500,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
+ __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_403 = __ex;
+ }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ throw new global::Braintrust.ApiException(
+ message: __content_403 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_403,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_403,
+ ResponseObject = __value_403,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
+ if ((int)__response.StatusCode == 429)
+ {
+ string? __content_429 = null;
+ global::System.Exception? __exception_429 = null;
+ string? __value_429 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessGetAiSecretIdResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_429 = __ex;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ throw new global::Braintrust.ApiException(
+ message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_429,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_429,
+ ResponseObject = __value_429,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // Something went wrong on Braintrust's end. (These are rare.)
+ if ((int)__response.StatusCode == 500)
+ {
+ string? __content_500 = null;
+ global::System.Exception? __exception_500 = null;
+ string? __value_500 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- return
- global::Braintrust.AISecret.FromJson(__content, JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
- }
- catch (global::System.Exception __ex)
- {
- throw new global::Braintrust.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
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_500 = __ex;
+ }
- return
- await global::Braintrust.AISecret.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
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ throw new global::Braintrust.ApiException(
+ message: __content_500 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_500,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_500,
+ ResponseObject = __value_500,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+ ProcessGetAiSecretIdResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Braintrust.AISecret.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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::Braintrust.AISecret.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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.AiSecretsClient.PatchAiSecretId.g.cs b/src/libs/Braintrust/Generated/Braintrust.AiSecretsClient.PatchAiSecretId.g.cs
index 76b411c..501901e 100644
--- a/src/libs/Braintrust/Generated/Braintrust.AiSecretsClient.PatchAiSecretId.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.AiSecretsClient.PatchAiSecretId.g.cs
@@ -14,6 +14,7 @@ public partial class AiSecretsClient
{ new global::Braintrust.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -59,12 +60,14 @@ partial void ProcessPatchAiSecretIdResponseContent(
/// AiSecret id
///
///
+ /// 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 PatchAiSecretIdAsync(
global::System.Guid aiSecretId,
global::Braintrust.PatchAISecret request,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -82,22 +85,43 @@ partial void ProcessPatchAiSecretIdResponseContent(
securityRequirements: s_PatchAiSecretIdSecurityRequirements,
operationName: "PatchAiSecretIdAsync");
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: $"/v1/ai_secret/{aiSecretId}",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using 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));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: $"/v1/ai_secret/{aiSecretId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.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;
+ __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 == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -107,309 +131,468 @@ partial void ProcessPatchAiSecretIdResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
- var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
- var __httpRequestContent = new global::System.Net.Http.StringContent(
- content: __httpRequestContentBody,
- encoding: global::System.Text.Encoding.UTF8,
- mediaType: "application/json");
- __httpRequest.Content = __httpRequestContent;
-
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PreparePatchAiSecretIdRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- aiSecretId: aiSecretId,
- request: request);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
-
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessPatchAiSecretIdResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
- {
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
- {
- if (ReadResponseAsString)
- {
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
-
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_400 = __ex;
- }
+ var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
+ var __httpRequestContent = new global::System.Net.Http.StringContent(
+ content: __httpRequestContentBody,
+ encoding: global::System.Text.Encoding.UTF8,
+ mediaType: "application/json");
+ __httpRequest.Content = __httpRequestContent;
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
+
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PreparePatchAiSecretIdRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ aiSecretId: aiSecretId,
+ request: request);
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ return __httpRequest;
}
- // No valid API key provided
- if ((int)__response.StatusCode == 401)
- {
- string? __content_401 = null;
- global::System.Exception? __exception_401 = null;
- string? __value_401 = null;
- try
- {
- if (ReadResponseAsString)
- {
- __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_401 = __ex;
- }
-
- throw new global::Braintrust.ApiException(
- message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_401,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_401,
- ResponseObject = __value_401,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // The API key doesn’t have permissions to perform the request
- if ((int)__response.StatusCode == 403)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_403 = null;
- global::System.Exception? __exception_403 = null;
- string? __value_403 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PatchAiSecretId",
+ methodName: "PatchAiSecretIdAsync",
+ pathTemplate: "$\"/v1/ai_secret/{aiSecretId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
-
- __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PatchAiSecretId",
+ methodName: "PatchAiSecretIdAsync",
+ pathTemplate: "$\"/v1/ai_secret/{aiSecretId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
- }
- catch (global::System.Exception __ex)
- {
- __exception_403 = __ex;
- }
- throw new global::Braintrust.ApiException(
- message: __content_403 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_403,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_403,
- ResponseObject = __value_403,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
- if ((int)__response.StatusCode == 429)
- {
- string? __content_429 = null;
- global::System.Exception? __exception_429 = null;
- string? __value_429 = null;
- try
- {
- if (ReadResponseAsString)
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
- __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PatchAiSecretId",
+ methodName: "PatchAiSecretIdAsync",
+ pathTemplate: "$\"/v1/ai_secret/{aiSecretId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
- else
- {
- __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_429 = __ex;
+ break;
}
- throw new global::Braintrust.ApiException(
- message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_429,
- statusCode: __response.StatusCode)
+ if (__response == null)
{
- ResponseBody = __content_429,
- ResponseObject = __value_429,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // Something went wrong on Braintrust's end. (These are rare.)
- if ((int)__response.StatusCode == 500)
- {
- string? __content_500 = null;
- global::System.Exception? __exception_500 = null;
- string? __value_500 = null;
- try
- {
- if (ReadResponseAsString)
- {
- __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
-
- __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_500 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_500 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_500,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_500,
- ResponseObject = __value_500,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
-
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessPatchAiSecretIdResponseContent(
+ response: __response);
+ ProcessPatchAiSecretIdResponse(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
- return
- global::Braintrust.AISecret.FromJson(__content, JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PatchAiSecretId",
+ methodName: "PatchAiSecretIdAsync",
+ pathTemplate: "$\"/v1/ai_secret/{aiSecretId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PatchAiSecretId",
+ methodName: "PatchAiSecretIdAsync",
+ pathTemplate: "$\"/v1/ai_secret/{aiSecretId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- using var __content = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // No valid API key provided
+ if ((int)__response.StatusCode == 401)
+ {
+ string? __content_401 = null;
+ global::System.Exception? __exception_401 = null;
+ string? __value_401 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_401 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_401,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_401,
+ ResponseObject = __value_401,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // The API key doesn’t have permissions to perform the request
+ if ((int)__response.StatusCode == 403)
+ {
+ string? __content_403 = null;
+ global::System.Exception? __exception_403 = null;
+ string? __value_403 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_403 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_403 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_403,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_403,
+ ResponseObject = __value_403,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
+ if ((int)__response.StatusCode == 429)
+ {
+ string? __content_429 = null;
+ global::System.Exception? __exception_429 = null;
+ string? __value_429 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_429 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_429,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_429,
+ ResponseObject = __value_429,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // Something went wrong on Braintrust's end. (These are rare.)
+ if ((int)__response.StatusCode == 500)
+ {
+ string? __content_500 = null;
+ global::System.Exception? __exception_500 = null;
+ string? __value_500 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_500 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_500 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_500,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_500,
+ ResponseObject = __value_500,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+ ProcessPatchAiSecretIdResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Braintrust.AISecret.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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::Braintrust.AISecret.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::Braintrust.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),
+ };
+ }
+ }
- return
- await global::Braintrust.AISecret.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
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
-
- throw new global::Braintrust.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();
+ }
}
///
/// Partially update ai_secret
@@ -424,6 +607,7 @@ partial void ProcessPatchAiSecretIdResponseContent(
///
///
///
+ /// 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 PatchAiSecretIdAsync(
@@ -432,6 +616,7 @@ partial void ProcessPatchAiSecretIdResponseContent(
string? type = default,
global::System.Collections.Generic.Dictionary? metadata = default,
string? secret = default,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::Braintrust.PatchAISecret
@@ -445,6 +630,7 @@ partial void ProcessPatchAiSecretIdResponseContent(
return await PatchAiSecretIdAsync(
aiSecretId: aiSecretId,
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/Braintrust/Generated/Braintrust.AiSecretsClient.PostAiSecret.g.cs b/src/libs/Braintrust/Generated/Braintrust.AiSecretsClient.PostAiSecret.g.cs
index d9bdbb0..244b68d 100644
--- a/src/libs/Braintrust/Generated/Braintrust.AiSecretsClient.PostAiSecret.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.AiSecretsClient.PostAiSecret.g.cs
@@ -14,6 +14,7 @@ public partial class AiSecretsClient
{ new global::Braintrust.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -54,11 +55,13 @@ partial void ProcessPostAiSecretResponseContent(
/// Create a new ai_secret. If there is an existing ai_secret with the same name as the one specified in the request, will return the existing ai_secret unmodified
///
///
+ /// 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 PostAiSecretAsync(
global::Braintrust.CreateAISecret request,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -75,22 +78,43 @@ partial void ProcessPostAiSecretResponseContent(
securityRequirements: s_PostAiSecretSecurityRequirements,
operationName: "PostAiSecretAsync");
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: "/v1/ai_secret",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- 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));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: "/v1/ai_secret",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.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;
+ __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 == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -100,308 +124,467 @@ partial void ProcessPostAiSecretResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
- var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
- var __httpRequestContent = new global::System.Net.Http.StringContent(
- content: __httpRequestContentBody,
- encoding: global::System.Text.Encoding.UTF8,
- mediaType: "application/json");
- __httpRequest.Content = __httpRequestContent;
-
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PreparePostAiSecretRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- request: request);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
-
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessPostAiSecretResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
- {
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
- {
- if (ReadResponseAsString)
- {
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
-
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_400 = __ex;
- }
+ var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
+ var __httpRequestContent = new global::System.Net.Http.StringContent(
+ content: __httpRequestContentBody,
+ encoding: global::System.Text.Encoding.UTF8,
+ mediaType: "application/json");
+ __httpRequest.Content = __httpRequestContent;
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
+
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PreparePostAiSecretRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ return __httpRequest;
}
- // No valid API key provided
- if ((int)__response.StatusCode == 401)
- {
- string? __content_401 = null;
- global::System.Exception? __exception_401 = null;
- string? __value_401 = null;
- try
- {
- if (ReadResponseAsString)
- {
- __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_401 = __ex;
- }
-
- throw new global::Braintrust.ApiException(
- message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_401,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_401,
- ResponseObject = __value_401,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // The API key doesn’t have permissions to perform the request
- if ((int)__response.StatusCode == 403)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_403 = null;
- global::System.Exception? __exception_403 = null;
- string? __value_403 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostAiSecret",
+ methodName: "PostAiSecretAsync",
+ pathTemplate: "\"/v1/ai_secret\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
-
- __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostAiSecret",
+ methodName: "PostAiSecretAsync",
+ pathTemplate: "\"/v1/ai_secret\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
- }
- catch (global::System.Exception __ex)
- {
- __exception_403 = __ex;
- }
- throw new global::Braintrust.ApiException(
- message: __content_403 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_403,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_403,
- ResponseObject = __value_403,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
- if ((int)__response.StatusCode == 429)
- {
- string? __content_429 = null;
- global::System.Exception? __exception_429 = null;
- string? __value_429 = null;
- try
- {
- if (ReadResponseAsString)
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
- __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostAiSecret",
+ methodName: "PostAiSecretAsync",
+ pathTemplate: "\"/v1/ai_secret\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
- else
- {
- __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_429 = __ex;
+ break;
}
- throw new global::Braintrust.ApiException(
- message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_429,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_429,
- ResponseObject = __value_429,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // Something went wrong on Braintrust's end. (These are rare.)
- if ((int)__response.StatusCode == 500)
- {
- string? __content_500 = null;
- global::System.Exception? __exception_500 = null;
- string? __value_500 = null;
- try
+ if (__response == null)
{
- if (ReadResponseAsString)
- {
- __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
-
- __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_500 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_500 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_500,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_500,
- ResponseObject = __value_500,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessPostAiSecretResponseContent(
+ response: __response);
+ ProcessPostAiSecretResponse(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
- {
- __response.EnsureSuccessStatusCode();
-
- return
- global::Braintrust.AISecret.FromJson(__content, JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
- }
- catch (global::System.Exception __ex)
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostAiSecret",
+ methodName: "PostAiSecretAsync",
+ pathTemplate: "\"/v1/ai_secret\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
+ else
{
- __response.EnsureSuccessStatusCode();
- using var __content = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- return
- await global::Braintrust.AISecret.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostAiSecret",
+ methodName: "PostAiSecretAsync",
+ pathTemplate: "\"/v1/ai_secret\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // No valid API key provided
+ if ((int)__response.StatusCode == 401)
+ {
+ string? __content_401 = null;
+ global::System.Exception? __exception_401 = null;
+ string? __value_401 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_401 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_401,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_401,
+ ResponseObject = __value_401,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // The API key doesn’t have permissions to perform the request
+ if ((int)__response.StatusCode == 403)
+ {
+ string? __content_403 = null;
+ global::System.Exception? __exception_403 = null;
+ string? __value_403 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_403 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_403 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_403,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_403,
+ ResponseObject = __value_403,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
+ if ((int)__response.StatusCode == 429)
+ {
+ string? __content_429 = null;
+ global::System.Exception? __exception_429 = null;
+ string? __value_429 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_429 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_429,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_429,
+ ResponseObject = __value_429,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // Something went wrong on Braintrust's end. (These are rare.)
+ if ((int)__response.StatusCode == 500)
+ {
+ string? __content_500 = null;
+ global::System.Exception? __exception_500 = null;
+ string? __value_500 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_500 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_500 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_500,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_500,
+ ResponseObject = __value_500,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+ ProcessPostAiSecretResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Braintrust.AISecret.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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::Braintrust.AISecret.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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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();
+ }
}
///
/// Create ai_secret
@@ -418,6 +601,7 @@ partial void ProcessPostAiSecretResponseContent(
///
/// For nearly all users, this parameter should be unnecessary. But in the rare case that your API key belongs to multiple organizations, you may specify the name of the organization the AI Secret belongs in.
///
+ /// 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 PostAiSecretAsync(
@@ -426,6 +610,7 @@ partial void ProcessPostAiSecretResponseContent(
global::System.Collections.Generic.Dictionary? metadata = default,
string? secret = default,
string? orgName = default,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::Braintrust.CreateAISecret
@@ -439,6 +624,7 @@ partial void ProcessPostAiSecretResponseContent(
return await PostAiSecretAsync(
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/Braintrust/Generated/Braintrust.AiSecretsClient.PutAiSecret.g.cs b/src/libs/Braintrust/Generated/Braintrust.AiSecretsClient.PutAiSecret.g.cs
index 95c19df..25537b1 100644
--- a/src/libs/Braintrust/Generated/Braintrust.AiSecretsClient.PutAiSecret.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.AiSecretsClient.PutAiSecret.g.cs
@@ -14,6 +14,7 @@ public partial class AiSecretsClient
{ new global::Braintrust.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -54,11 +55,13 @@ partial void ProcessPutAiSecretResponseContent(
/// Create or replace ai_secret. If there is an existing ai_secret with the same name as the one specified in the request, will replace the existing ai_secret with the provided fields
///
///
+ /// 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 PutAiSecretAsync(
global::Braintrust.CreateAISecret request,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -75,22 +78,43 @@ partial void ProcessPutAiSecretResponseContent(
securityRequirements: s_PutAiSecretSecurityRequirements,
operationName: "PutAiSecretAsync");
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: "/v1/ai_secret",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Put,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: "/v1/ai_secret",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Put,
+ 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;
+ __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 == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -100,308 +124,467 @@ partial void ProcessPutAiSecretResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
- var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
- var __httpRequestContent = new global::System.Net.Http.StringContent(
- content: __httpRequestContentBody,
- encoding: global::System.Text.Encoding.UTF8,
- mediaType: "application/json");
- __httpRequest.Content = __httpRequestContent;
-
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PreparePutAiSecretRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- request: request);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
-
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessPutAiSecretResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
- {
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
- {
- if (ReadResponseAsString)
- {
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
-
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_400 = __ex;
- }
+ var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
+ var __httpRequestContent = new global::System.Net.Http.StringContent(
+ content: __httpRequestContentBody,
+ encoding: global::System.Text.Encoding.UTF8,
+ mediaType: "application/json");
+ __httpRequest.Content = __httpRequestContent;
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
+
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PreparePutAiSecretRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ return __httpRequest;
}
- // No valid API key provided
- if ((int)__response.StatusCode == 401)
- {
- string? __content_401 = null;
- global::System.Exception? __exception_401 = null;
- string? __value_401 = null;
- try
- {
- if (ReadResponseAsString)
- {
- __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_401 = __ex;
- }
-
- throw new global::Braintrust.ApiException(
- message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_401,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_401,
- ResponseObject = __value_401,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // The API key doesn’t have permissions to perform the request
- if ((int)__response.StatusCode == 403)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_403 = null;
- global::System.Exception? __exception_403 = null;
- string? __value_403 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PutAiSecret",
+ methodName: "PutAiSecretAsync",
+ pathTemplate: "\"/v1/ai_secret\"",
+ httpMethod: "PUT",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
-
- __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PutAiSecret",
+ methodName: "PutAiSecretAsync",
+ pathTemplate: "\"/v1/ai_secret\"",
+ httpMethod: "PUT",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
- }
- catch (global::System.Exception __ex)
- {
- __exception_403 = __ex;
- }
- throw new global::Braintrust.ApiException(
- message: __content_403 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_403,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_403,
- ResponseObject = __value_403,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
- if ((int)__response.StatusCode == 429)
- {
- string? __content_429 = null;
- global::System.Exception? __exception_429 = null;
- string? __value_429 = null;
- try
- {
- if (ReadResponseAsString)
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
- __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PutAiSecret",
+ methodName: "PutAiSecretAsync",
+ pathTemplate: "\"/v1/ai_secret\"",
+ httpMethod: "PUT",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
- else
- {
- __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_429 = __ex;
+ break;
}
- throw new global::Braintrust.ApiException(
- message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_429,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_429,
- ResponseObject = __value_429,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // Something went wrong on Braintrust's end. (These are rare.)
- if ((int)__response.StatusCode == 500)
- {
- string? __content_500 = null;
- global::System.Exception? __exception_500 = null;
- string? __value_500 = null;
- try
+ if (__response == null)
{
- if (ReadResponseAsString)
- {
- __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
-
- __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_500 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_500 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_500,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_500,
- ResponseObject = __value_500,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessPutAiSecretResponseContent(
+ response: __response);
+ ProcessPutAiSecretResponse(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
- {
- __response.EnsureSuccessStatusCode();
-
- return
- global::Braintrust.AISecret.FromJson(__content, JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
- }
- catch (global::System.Exception __ex)
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PutAiSecret",
+ methodName: "PutAiSecretAsync",
+ pathTemplate: "\"/v1/ai_secret\"",
+ httpMethod: "PUT",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
+ else
{
- __response.EnsureSuccessStatusCode();
- using var __content = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- return
- await global::Braintrust.AISecret.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PutAiSecret",
+ methodName: "PutAiSecretAsync",
+ pathTemplate: "\"/v1/ai_secret\"",
+ httpMethod: "PUT",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // No valid API key provided
+ if ((int)__response.StatusCode == 401)
+ {
+ string? __content_401 = null;
+ global::System.Exception? __exception_401 = null;
+ string? __value_401 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_401 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_401,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_401,
+ ResponseObject = __value_401,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // The API key doesn’t have permissions to perform the request
+ if ((int)__response.StatusCode == 403)
+ {
+ string? __content_403 = null;
+ global::System.Exception? __exception_403 = null;
+ string? __value_403 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_403 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_403 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_403,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_403,
+ ResponseObject = __value_403,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
+ if ((int)__response.StatusCode == 429)
+ {
+ string? __content_429 = null;
+ global::System.Exception? __exception_429 = null;
+ string? __value_429 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_429 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_429,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_429,
+ ResponseObject = __value_429,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // Something went wrong on Braintrust's end. (These are rare.)
+ if ((int)__response.StatusCode == 500)
+ {
+ string? __content_500 = null;
+ global::System.Exception? __exception_500 = null;
+ string? __value_500 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_500 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_500 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_500,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_500,
+ ResponseObject = __value_500,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+ ProcessPutAiSecretResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Braintrust.AISecret.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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::Braintrust.AISecret.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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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();
+ }
}
///
/// Create or replace ai_secret
@@ -418,6 +601,7 @@ partial void ProcessPutAiSecretResponseContent(
///
/// For nearly all users, this parameter should be unnecessary. But in the rare case that your API key belongs to multiple organizations, you may specify the name of the organization the AI Secret belongs in.
///
+ /// 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 PutAiSecretAsync(
@@ -426,6 +610,7 @@ partial void ProcessPutAiSecretResponseContent(
global::System.Collections.Generic.Dictionary? metadata = default,
string? secret = default,
string? orgName = default,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::Braintrust.CreateAISecret
@@ -439,6 +624,7 @@ partial void ProcessPutAiSecretResponseContent(
return await PutAiSecretAsync(
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/Braintrust/Generated/Braintrust.AiSecretsClient.g.cs b/src/libs/Braintrust/Generated/Braintrust.AiSecretsClient.g.cs
index c2fa79c..5e05f01 100644
--- a/src/libs/Braintrust/Generated/Braintrust.AiSecretsClient.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.AiSecretsClient.g.cs
@@ -30,6 +30,9 @@ public sealed partial class AiSecretsClient : global::Braintrust.IAiSecretsClien
#if DEBUG
= true;
#endif
+
+ ///
+ public global::Braintrust.AutoSDKClientOptions Options { get; }
///
///
///
@@ -49,11 +52,37 @@ public AiSecretsClient(
global::System.Net.Http.HttpClient? httpClient = null,
global::System.Uri? baseUri = null,
global::System.Collections.Generic.List? authorizations = null,
+ bool disposeHttpClient = true) : this(
+ httpClient,
+ baseUri,
+ authorizations,
+ options: null,
+ disposeHttpClient: disposeHttpClient)
+ {
+ }
+
+ ///
+ /// Creates a new instance of the AiSecretsClient.
+ /// 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.
+ /// Client-wide request defaults such as headers, query parameters, retries, and timeout.
+ /// Dispose the HttpClient when the instance is disposed. True by default.
+ public AiSecretsClient(
+ global::System.Net.Http.HttpClient? httpClient = null,
+ global::System.Uri? baseUri = null,
+ global::System.Collections.Generic.List? authorizations = null,
+ global::Braintrust.AutoSDKClientOptions? options = null,
bool disposeHttpClient = true)
{
+
HttpClient = httpClient ?? new global::System.Net.Http.HttpClient();
HttpClient.BaseAddress ??= baseUri ?? new global::System.Uri(DefaultBaseUrl);
Authorizations = authorizations ?? new global::System.Collections.Generic.List();
+ Options = options ?? new global::Braintrust.AutoSDKClientOptions();
_disposeHttpClient = disposeHttpClient;
Initialized(HttpClient);
diff --git a/src/libs/Braintrust/Generated/Braintrust.ApiKeysClient.DeleteApiKeyId.g.cs b/src/libs/Braintrust/Generated/Braintrust.ApiKeysClient.DeleteApiKeyId.g.cs
index 0e2efd4..3e63623 100644
--- a/src/libs/Braintrust/Generated/Braintrust.ApiKeysClient.DeleteApiKeyId.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.ApiKeysClient.DeleteApiKeyId.g.cs
@@ -14,6 +14,7 @@ public partial class ApiKeysClient
{ new global::Braintrust.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -56,10 +57,12 @@ partial void ProcessDeleteApiKeyIdResponseContent(
///
/// ApiKey id
///
+ /// 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 DeleteApiKeyIdAsync(
global::System.Guid apiKeyId,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -74,22 +77,43 @@ partial void ProcessDeleteApiKeyIdResponseContent(
securityRequirements: s_DeleteApiKeyIdSecurityRequirements,
operationName: "DeleteApiKeyIdAsync");
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: $"/v1/api_key/{apiKeyId}",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Delete,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: $"/v1/api_key/{apiKeyId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Delete,
+ 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;
+ __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 == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -99,302 +123,461 @@ partial void ProcessDeleteApiKeyIdResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareDeleteApiKeyIdRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- apiKeyId: apiKeyId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareDeleteApiKeyIdRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ apiKeyId: apiKeyId);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessDeleteApiKeyIdResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteApiKeyId",
+ methodName: "DeleteApiKeyIdAsync",
+ pathTemplate: "$\"/v1/api_key/{apiKeyId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteApiKeyId",
+ methodName: "DeleteApiKeyIdAsync",
+ pathTemplate: "$\"/v1/api_key/{apiKeyId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
- }
- catch (global::System.Exception __ex)
- {
- __exception_400 = __ex;
- }
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // No valid API key provided
- if ((int)__response.StatusCode == 401)
- {
- string? __content_401 = null;
- global::System.Exception? __exception_401 = null;
- string? __value_401 = null;
- try
- {
- if (ReadResponseAsString)
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
- __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteApiKeyId",
+ methodName: "DeleteApiKeyIdAsync",
+ pathTemplate: "$\"/v1/api_key/{apiKeyId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
- else
- {
- __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
- }
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_401 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_401,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_401,
- ResponseObject = __value_401,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // The API key doesn’t have permissions to perform the request
- if ((int)__response.StatusCode == 403)
- {
- string? __content_403 = null;
- global::System.Exception? __exception_403 = null;
- string? __value_403 = null;
- try
+ using (__response)
{
- if (ReadResponseAsString)
- {
- __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
- }
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessDeleteApiKeyIdResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteApiKeyId",
+ methodName: "DeleteApiKeyIdAsync",
+ pathTemplate: "$\"/v1/api_key/{apiKeyId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- __exception_403 = __ex;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteApiKeyId",
+ methodName: "DeleteApiKeyIdAsync",
+ pathTemplate: "$\"/v1/api_key/{apiKeyId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- throw new global::Braintrust.ApiException(
- message: __content_403 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_403,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_403,
- ResponseObject = __value_403,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
- if ((int)__response.StatusCode == 429)
- {
- string? __content_429 = null;
- global::System.Exception? __exception_429 = null;
- string? __value_429 = null;
- try
- {
- if (ReadResponseAsString)
- {
- __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
- __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_429 = __ex;
- }
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // No valid API key provided
+ if ((int)__response.StatusCode == 401)
+ {
+ string? __content_401 = null;
+ global::System.Exception? __exception_401 = null;
+ string? __value_401 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- throw new global::Braintrust.ApiException(
- message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_429,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_429,
- ResponseObject = __value_429,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // Something went wrong on Braintrust's end. (These are rare.)
- if ((int)__response.StatusCode == 500)
- {
- string? __content_500 = null;
- global::System.Exception? __exception_500 = null;
- string? __value_500 = null;
- try
- {
- if (ReadResponseAsString)
- {
- __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_401 = __ex;
+ }
- __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_500 = __ex;
- }
+ throw new global::Braintrust.ApiException(
+ message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_401,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_401,
+ ResponseObject = __value_401,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // The API key doesn’t have permissions to perform the request
+ if ((int)__response.StatusCode == 403)
+ {
+ string? __content_403 = null;
+ global::System.Exception? __exception_403 = null;
+ string? __value_403 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- throw new global::Braintrust.ApiException(
- message: __content_500 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_500,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_500,
- ResponseObject = __value_500,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
+ __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_403 = __ex;
+ }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ throw new global::Braintrust.ApiException(
+ message: __content_403 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_403,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_403,
+ ResponseObject = __value_403,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
+ if ((int)__response.StatusCode == 429)
+ {
+ string? __content_429 = null;
+ global::System.Exception? __exception_429 = null;
+ string? __value_429 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessDeleteApiKeyIdResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_429 = __ex;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ throw new global::Braintrust.ApiException(
+ message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_429,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_429,
+ ResponseObject = __value_429,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // Something went wrong on Braintrust's end. (These are rare.)
+ if ((int)__response.StatusCode == 500)
+ {
+ string? __content_500 = null;
+ global::System.Exception? __exception_500 = null;
+ string? __value_500 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- return
- global::Braintrust.ApiKey.FromJson(__content, JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
- }
- catch (global::System.Exception __ex)
- {
- throw new global::Braintrust.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
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_500 = __ex;
+ }
- return
- await global::Braintrust.ApiKey.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
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ throw new global::Braintrust.ApiException(
+ message: __content_500 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_500,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_500,
+ ResponseObject = __value_500,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+ ProcessDeleteApiKeyIdResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Braintrust.ApiKey.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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::Braintrust.ApiKey.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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.ApiKeysClient.GetApiKey.g.cs b/src/libs/Braintrust/Generated/Braintrust.ApiKeysClient.GetApiKey.g.cs
index e689829..23b29b9 100644
--- a/src/libs/Braintrust/Generated/Braintrust.ApiKeysClient.GetApiKey.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.ApiKeysClient.GetApiKey.g.cs
@@ -14,6 +14,7 @@ public partial class ApiKeysClient
{ new global::Braintrust.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -83,6 +84,7 @@ partial void ProcessGetApiKeyResponseContent(
///
/// Filter search results to within a particular organization
///
+ /// 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 GetApiKeyAsync(
@@ -92,6 +94,7 @@ partial void ProcessGetApiKeyResponseContent(
global::Braintrust.Ids? ids = default,
string? apiKeyName = default,
string? orgName = default,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -111,30 +114,51 @@ partial void ProcessGetApiKeyResponseContent(
securityRequirements: s_GetApiKeySecurityRequirements,
operationName: "GetApiKeyAsync");
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: "/v1/api_key",
- baseUri: HttpClient.BaseAddress);
- __pathBuilder
- .AddOptionalParameter("limit", limit?.ToString())
- .AddOptionalParameter("starting_after", startingAfter?.ToString())
- .AddOptionalParameter("ending_before", endingBefore?.ToString())
- .AddOptionalParameter("ids", ids?.ToString())
- .AddOptionalParameter("api_key_name", apiKeyName)
- .AddOptionalParameter("org_name", orgName)
- ;
- var __path = __pathBuilder.ToString();
- 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));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: "/v1/api_key",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("limit", limit?.ToString())
+ .AddOptionalParameter("starting_after", startingAfter?.ToString())
+ .AddOptionalParameter("ending_before", endingBefore?.ToString())
+ .AddOptionalParameter("ids", ids?.ToString())
+ .AddOptionalParameter("api_key_name", apiKeyName)
+ .AddOptionalParameter("org_name", orgName)
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ 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));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __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 == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -144,307 +168,466 @@ partial void ProcessGetApiKeyResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareGetApiKeyRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- limit: limit,
- startingAfter: startingAfter,
- endingBefore: endingBefore,
- ids: ids,
- apiKeyName: apiKeyName,
- orgName: orgName);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareGetApiKeyRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ limit: limit,
+ startingAfter: startingAfter,
+ endingBefore: endingBefore,
+ ids: ids,
+ apiKeyName: apiKeyName,
+ orgName: orgName);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessGetApiKeyResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetApiKey",
+ methodName: "GetApiKeyAsync",
+ pathTemplate: "\"/v1/api_key\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetApiKey",
+ methodName: "GetApiKeyAsync",
+ pathTemplate: "\"/v1/api_key\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
- }
- catch (global::System.Exception __ex)
- {
- __exception_400 = __ex;
- }
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // No valid API key provided
- if ((int)__response.StatusCode == 401)
- {
- string? __content_401 = null;
- global::System.Exception? __exception_401 = null;
- string? __value_401 = null;
- try
- {
- if (ReadResponseAsString)
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
- __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetApiKey",
+ methodName: "GetApiKeyAsync",
+ pathTemplate: "\"/v1/api_key\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
- else
- {
- __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
- }
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_401 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_401,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_401,
- ResponseObject = __value_401,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // The API key doesn’t have permissions to perform the request
- if ((int)__response.StatusCode == 403)
- {
- string? __content_403 = null;
- global::System.Exception? __exception_403 = null;
- string? __value_403 = null;
- try
+ using (__response)
{
- if (ReadResponseAsString)
- {
- __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
- }
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessGetApiKeyResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetApiKey",
+ methodName: "GetApiKeyAsync",
+ pathTemplate: "\"/v1/api_key\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- __exception_403 = __ex;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetApiKey",
+ methodName: "GetApiKeyAsync",
+ pathTemplate: "\"/v1/api_key\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- throw new global::Braintrust.ApiException(
- message: __content_403 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_403,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_403,
- ResponseObject = __value_403,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
- if ((int)__response.StatusCode == 429)
- {
- string? __content_429 = null;
- global::System.Exception? __exception_429 = null;
- string? __value_429 = null;
- try
- {
- if (ReadResponseAsString)
- {
- __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
- __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_429 = __ex;
- }
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // No valid API key provided
+ if ((int)__response.StatusCode == 401)
+ {
+ string? __content_401 = null;
+ global::System.Exception? __exception_401 = null;
+ string? __value_401 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- throw new global::Braintrust.ApiException(
- message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_429,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_429,
- ResponseObject = __value_429,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // Something went wrong on Braintrust's end. (These are rare.)
- if ((int)__response.StatusCode == 500)
- {
- string? __content_500 = null;
- global::System.Exception? __exception_500 = null;
- string? __value_500 = null;
- try
- {
- if (ReadResponseAsString)
- {
- __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_401 = __ex;
+ }
- __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_500 = __ex;
- }
+ throw new global::Braintrust.ApiException(
+ message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_401,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_401,
+ ResponseObject = __value_401,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // The API key doesn’t have permissions to perform the request
+ if ((int)__response.StatusCode == 403)
+ {
+ string? __content_403 = null;
+ global::System.Exception? __exception_403 = null;
+ string? __value_403 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- throw new global::Braintrust.ApiException(
- message: __content_500 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_500,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_500,
- ResponseObject = __value_500,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
+ __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_403 = __ex;
+ }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ throw new global::Braintrust.ApiException(
+ message: __content_403 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_403,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_403,
+ ResponseObject = __value_403,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
+ if ((int)__response.StatusCode == 429)
+ {
+ string? __content_429 = null;
+ global::System.Exception? __exception_429 = null;
+ string? __value_429 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessGetApiKeyResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_429 = __ex;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ throw new global::Braintrust.ApiException(
+ message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_429,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_429,
+ ResponseObject = __value_429,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // Something went wrong on Braintrust's end. (These are rare.)
+ if ((int)__response.StatusCode == 500)
+ {
+ string? __content_500 = null;
+ global::System.Exception? __exception_500 = null;
+ string? __value_500 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- return
- global::Braintrust.GetApiKeyResponse.FromJson(__content, JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
- }
- catch (global::System.Exception __ex)
- {
- throw new global::Braintrust.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
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_500 = __ex;
+ }
- return
- await global::Braintrust.GetApiKeyResponse.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
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ throw new global::Braintrust.ApiException(
+ message: __content_500 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_500,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_500,
+ ResponseObject = __value_500,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+ ProcessGetApiKeyResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Braintrust.GetApiKeyResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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::Braintrust.GetApiKeyResponse.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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.ApiKeysClient.GetApiKeyId.g.cs b/src/libs/Braintrust/Generated/Braintrust.ApiKeysClient.GetApiKeyId.g.cs
index 950a68f..7c2e8a2 100644
--- a/src/libs/Braintrust/Generated/Braintrust.ApiKeysClient.GetApiKeyId.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.ApiKeysClient.GetApiKeyId.g.cs
@@ -14,6 +14,7 @@ public partial class ApiKeysClient
{ new global::Braintrust.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -56,10 +57,12 @@ partial void ProcessGetApiKeyIdResponseContent(
///
/// ApiKey id
///
+ /// 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 GetApiKeyIdAsync(
global::System.Guid apiKeyId,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -74,22 +77,43 @@ partial void ProcessGetApiKeyIdResponseContent(
securityRequirements: s_GetApiKeyIdSecurityRequirements,
operationName: "GetApiKeyIdAsync");
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: $"/v1/api_key/{apiKeyId}",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- 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));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: $"/v1/api_key/{apiKeyId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ 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));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __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 == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -99,302 +123,461 @@ partial void ProcessGetApiKeyIdResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareGetApiKeyIdRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- apiKeyId: apiKeyId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareGetApiKeyIdRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ apiKeyId: apiKeyId);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessGetApiKeyIdResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetApiKeyId",
+ methodName: "GetApiKeyIdAsync",
+ pathTemplate: "$\"/v1/api_key/{apiKeyId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetApiKeyId",
+ methodName: "GetApiKeyIdAsync",
+ pathTemplate: "$\"/v1/api_key/{apiKeyId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
- }
- catch (global::System.Exception __ex)
- {
- __exception_400 = __ex;
- }
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // No valid API key provided
- if ((int)__response.StatusCode == 401)
- {
- string? __content_401 = null;
- global::System.Exception? __exception_401 = null;
- string? __value_401 = null;
- try
- {
- if (ReadResponseAsString)
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
- __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetApiKeyId",
+ methodName: "GetApiKeyIdAsync",
+ pathTemplate: "$\"/v1/api_key/{apiKeyId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
- else
- {
- __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
- }
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_401 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_401,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_401,
- ResponseObject = __value_401,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // The API key doesn’t have permissions to perform the request
- if ((int)__response.StatusCode == 403)
- {
- string? __content_403 = null;
- global::System.Exception? __exception_403 = null;
- string? __value_403 = null;
- try
+ using (__response)
{
- if (ReadResponseAsString)
- {
- __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
- }
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessGetApiKeyIdResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetApiKeyId",
+ methodName: "GetApiKeyIdAsync",
+ pathTemplate: "$\"/v1/api_key/{apiKeyId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- __exception_403 = __ex;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetApiKeyId",
+ methodName: "GetApiKeyIdAsync",
+ pathTemplate: "$\"/v1/api_key/{apiKeyId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- throw new global::Braintrust.ApiException(
- message: __content_403 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_403,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_403,
- ResponseObject = __value_403,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
- if ((int)__response.StatusCode == 429)
- {
- string? __content_429 = null;
- global::System.Exception? __exception_429 = null;
- string? __value_429 = null;
- try
- {
- if (ReadResponseAsString)
- {
- __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
- __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_429 = __ex;
- }
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // No valid API key provided
+ if ((int)__response.StatusCode == 401)
+ {
+ string? __content_401 = null;
+ global::System.Exception? __exception_401 = null;
+ string? __value_401 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- throw new global::Braintrust.ApiException(
- message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_429,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_429,
- ResponseObject = __value_429,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // Something went wrong on Braintrust's end. (These are rare.)
- if ((int)__response.StatusCode == 500)
- {
- string? __content_500 = null;
- global::System.Exception? __exception_500 = null;
- string? __value_500 = null;
- try
- {
- if (ReadResponseAsString)
- {
- __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_401 = __ex;
+ }
- __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_500 = __ex;
- }
+ throw new global::Braintrust.ApiException(
+ message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_401,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_401,
+ ResponseObject = __value_401,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // The API key doesn’t have permissions to perform the request
+ if ((int)__response.StatusCode == 403)
+ {
+ string? __content_403 = null;
+ global::System.Exception? __exception_403 = null;
+ string? __value_403 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- throw new global::Braintrust.ApiException(
- message: __content_500 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_500,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_500,
- ResponseObject = __value_500,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
+ __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_403 = __ex;
+ }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ throw new global::Braintrust.ApiException(
+ message: __content_403 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_403,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_403,
+ ResponseObject = __value_403,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
+ if ((int)__response.StatusCode == 429)
+ {
+ string? __content_429 = null;
+ global::System.Exception? __exception_429 = null;
+ string? __value_429 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessGetApiKeyIdResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_429 = __ex;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ throw new global::Braintrust.ApiException(
+ message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_429,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_429,
+ ResponseObject = __value_429,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // Something went wrong on Braintrust's end. (These are rare.)
+ if ((int)__response.StatusCode == 500)
+ {
+ string? __content_500 = null;
+ global::System.Exception? __exception_500 = null;
+ string? __value_500 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- return
- global::Braintrust.ApiKey.FromJson(__content, JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
- }
- catch (global::System.Exception __ex)
- {
- throw new global::Braintrust.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
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_500 = __ex;
+ }
- return
- await global::Braintrust.ApiKey.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
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ throw new global::Braintrust.ApiException(
+ message: __content_500 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_500,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_500,
+ ResponseObject = __value_500,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+ ProcessGetApiKeyIdResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Braintrust.ApiKey.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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::Braintrust.ApiKey.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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.ApiKeysClient.PostApiKey.g.cs b/src/libs/Braintrust/Generated/Braintrust.ApiKeysClient.PostApiKey.g.cs
index 951466e..6acf75c 100644
--- a/src/libs/Braintrust/Generated/Braintrust.ApiKeysClient.PostApiKey.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.ApiKeysClient.PostApiKey.g.cs
@@ -14,6 +14,7 @@ public partial class ApiKeysClient
{ new global::Braintrust.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -54,11 +55,13 @@ partial void ProcessPostApiKeyResponseContent(
/// Create a new api_key. It is possible to have multiple API keys with the same name. There is no de-duplication
///
///
+ /// 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 PostApiKeyAsync(
global::Braintrust.PostApiKeyRequest request,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -75,22 +78,43 @@ partial void ProcessPostApiKeyResponseContent(
securityRequirements: s_PostApiKeySecurityRequirements,
operationName: "PostApiKeyAsync");
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: "/v1/api_key",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- 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));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: "/v1/api_key",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.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;
+ __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 == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -100,308 +124,467 @@ partial void ProcessPostApiKeyResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
- var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
- var __httpRequestContent = new global::System.Net.Http.StringContent(
- content: __httpRequestContentBody,
- encoding: global::System.Text.Encoding.UTF8,
- mediaType: "application/json");
- __httpRequest.Content = __httpRequestContent;
-
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PreparePostApiKeyRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- request: request);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
-
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessPostApiKeyResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
- {
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
- {
- if (ReadResponseAsString)
- {
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
-
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_400 = __ex;
- }
+ var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
+ var __httpRequestContent = new global::System.Net.Http.StringContent(
+ content: __httpRequestContentBody,
+ encoding: global::System.Text.Encoding.UTF8,
+ mediaType: "application/json");
+ __httpRequest.Content = __httpRequestContent;
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
+
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PreparePostApiKeyRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ return __httpRequest;
}
- // No valid API key provided
- if ((int)__response.StatusCode == 401)
- {
- string? __content_401 = null;
- global::System.Exception? __exception_401 = null;
- string? __value_401 = null;
- try
- {
- if (ReadResponseAsString)
- {
- __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_401 = __ex;
- }
-
- throw new global::Braintrust.ApiException(
- message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_401,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_401,
- ResponseObject = __value_401,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // The API key doesn’t have permissions to perform the request
- if ((int)__response.StatusCode == 403)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_403 = null;
- global::System.Exception? __exception_403 = null;
- string? __value_403 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostApiKey",
+ methodName: "PostApiKeyAsync",
+ pathTemplate: "\"/v1/api_key\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
-
- __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostApiKey",
+ methodName: "PostApiKeyAsync",
+ pathTemplate: "\"/v1/api_key\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
- }
- catch (global::System.Exception __ex)
- {
- __exception_403 = __ex;
- }
- throw new global::Braintrust.ApiException(
- message: __content_403 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_403,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_403,
- ResponseObject = __value_403,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
- if ((int)__response.StatusCode == 429)
- {
- string? __content_429 = null;
- global::System.Exception? __exception_429 = null;
- string? __value_429 = null;
- try
- {
- if (ReadResponseAsString)
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
- __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostApiKey",
+ methodName: "PostApiKeyAsync",
+ pathTemplate: "\"/v1/api_key\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
- else
- {
- __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_429 = __ex;
+ break;
}
- throw new global::Braintrust.ApiException(
- message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_429,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_429,
- ResponseObject = __value_429,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // Something went wrong on Braintrust's end. (These are rare.)
- if ((int)__response.StatusCode == 500)
- {
- string? __content_500 = null;
- global::System.Exception? __exception_500 = null;
- string? __value_500 = null;
- try
+ if (__response == null)
{
- if (ReadResponseAsString)
- {
- __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
-
- __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_500 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_500 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_500,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_500,
- ResponseObject = __value_500,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessPostApiKeyResponseContent(
+ response: __response);
+ ProcessPostApiKeyResponse(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
- {
- __response.EnsureSuccessStatusCode();
-
- return
- global::Braintrust.CreateApiKeyOutput.FromJson(__content, JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
- }
- catch (global::System.Exception __ex)
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostApiKey",
+ methodName: "PostApiKeyAsync",
+ pathTemplate: "\"/v1/api_key\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
+ else
{
- __response.EnsureSuccessStatusCode();
- using var __content = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- return
- await global::Braintrust.CreateApiKeyOutput.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostApiKey",
+ methodName: "PostApiKeyAsync",
+ pathTemplate: "\"/v1/api_key\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // No valid API key provided
+ if ((int)__response.StatusCode == 401)
+ {
+ string? __content_401 = null;
+ global::System.Exception? __exception_401 = null;
+ string? __value_401 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_401 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_401,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_401,
+ ResponseObject = __value_401,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // The API key doesn’t have permissions to perform the request
+ if ((int)__response.StatusCode == 403)
+ {
+ string? __content_403 = null;
+ global::System.Exception? __exception_403 = null;
+ string? __value_403 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_403 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_403 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_403,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_403,
+ ResponseObject = __value_403,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
+ if ((int)__response.StatusCode == 429)
+ {
+ string? __content_429 = null;
+ global::System.Exception? __exception_429 = null;
+ string? __value_429 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_429 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_429,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_429,
+ ResponseObject = __value_429,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // Something went wrong on Braintrust's end. (These are rare.)
+ if ((int)__response.StatusCode == 500)
+ {
+ string? __content_500 = null;
+ global::System.Exception? __exception_500 = null;
+ string? __value_500 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_500 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_500 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_500,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_500,
+ ResponseObject = __value_500,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+ ProcessPostApiKeyResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Braintrust.CreateApiKeyOutput.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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::Braintrust.CreateApiKeyOutput.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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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();
+ }
}
///
/// Create api_key
@@ -413,11 +596,13 @@ partial void ProcessPostApiKeyResponseContent(
///
/// For nearly all users, this parameter should be unnecessary. But in the rare case that your API key belongs to multiple organizations, you may specify the name of the organization the API key belongs in.
///
+ /// 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 PostApiKeyAsync(
string name,
string? orgName = default,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::Braintrust.PostApiKeyRequest
@@ -428,6 +613,7 @@ partial void ProcessPostApiKeyResponseContent(
return await PostApiKeyAsync(
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/Braintrust/Generated/Braintrust.ApiKeysClient.g.cs b/src/libs/Braintrust/Generated/Braintrust.ApiKeysClient.g.cs
index cfff223..107f393 100644
--- a/src/libs/Braintrust/Generated/Braintrust.ApiKeysClient.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.ApiKeysClient.g.cs
@@ -30,6 +30,9 @@ public sealed partial class ApiKeysClient : global::Braintrust.IApiKeysClient, g
#if DEBUG
= true;
#endif
+
+ ///
+ public global::Braintrust.AutoSDKClientOptions Options { get; }
///
///
///
@@ -49,11 +52,37 @@ public ApiKeysClient(
global::System.Net.Http.HttpClient? httpClient = null,
global::System.Uri? baseUri = null,
global::System.Collections.Generic.List? authorizations = null,
+ bool disposeHttpClient = true) : this(
+ httpClient,
+ baseUri,
+ authorizations,
+ options: null,
+ disposeHttpClient: disposeHttpClient)
+ {
+ }
+
+ ///
+ /// Creates a new instance of the ApiKeysClient.
+ /// 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.
+ /// Client-wide request defaults such as headers, query parameters, retries, and timeout.
+ /// Dispose the HttpClient when the instance is disposed. True by default.
+ public ApiKeysClient(
+ global::System.Net.Http.HttpClient? httpClient = null,
+ global::System.Uri? baseUri = null,
+ global::System.Collections.Generic.List? authorizations = null,
+ global::Braintrust.AutoSDKClientOptions? options = null,
bool disposeHttpClient = true)
{
+
HttpClient = httpClient ?? new global::System.Net.Http.HttpClient();
HttpClient.BaseAddress ??= baseUri ?? new global::System.Uri(DefaultBaseUrl);
Authorizations = authorizations ?? new global::System.Collections.Generic.List();
+ Options = options ?? new global::Braintrust.AutoSDKClientOptions();
_disposeHttpClient = disposeHttpClient;
Initialized(HttpClient);
diff --git a/src/libs/Braintrust/Generated/Braintrust.BraintrustClient.Authorizations.Bearer.g.cs b/src/libs/Braintrust/Generated/Braintrust.BraintrustClient.Authorizations.Bearer.g.cs
index 5ae46c2..04aba21 100644
--- a/src/libs/Braintrust/Generated/Braintrust.BraintrustClient.Authorizations.Bearer.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.BraintrustClient.Authorizations.Bearer.g.cs
@@ -25,6 +25,7 @@ public void AuthorizeUsingBearer(
Authorizations.Add(new global::Braintrust.EndPointAuthorization
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
Value = apiKey,
diff --git a/src/libs/Braintrust/Generated/Braintrust.BraintrustClient.g.cs b/src/libs/Braintrust/Generated/Braintrust.BraintrustClient.g.cs
index d368e35..991dcc4 100644
--- a/src/libs/Braintrust/Generated/Braintrust.BraintrustClient.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.BraintrustClient.g.cs
@@ -33,6 +33,9 @@ public sealed partial class BraintrustClient : global::Braintrust.IBraintrustCli
#if DEBUG
= true;
#endif
+
+ ///
+ public global::Braintrust.AutoSDKClientOptions Options { get; }
///
///
///
@@ -42,7 +45,7 @@ public sealed partial class BraintrustClient : global::Braintrust.IBraintrustCli
///
///
///
- public AclsClient Acls => new AclsClient(HttpClient, authorizations: Authorizations)
+ public AclsClient Acls => new AclsClient(HttpClient, authorizations: Authorizations, options: Options)
{
ReadResponseAsString = ReadResponseAsString,
JsonSerializerContext = JsonSerializerContext,
@@ -51,7 +54,7 @@ public sealed partial class BraintrustClient : global::Braintrust.IBraintrustCli
///
///
///
- public AiSecretsClient AiSecrets => new AiSecretsClient(HttpClient, authorizations: Authorizations)
+ public AiSecretsClient AiSecrets => new AiSecretsClient(HttpClient, authorizations: Authorizations, options: Options)
{
ReadResponseAsString = ReadResponseAsString,
JsonSerializerContext = JsonSerializerContext,
@@ -60,7 +63,7 @@ public sealed partial class BraintrustClient : global::Braintrust.IBraintrustCli
///
///
///
- public ApiKeysClient ApiKeys => new ApiKeysClient(HttpClient, authorizations: Authorizations)
+ public ApiKeysClient ApiKeys => new ApiKeysClient(HttpClient, authorizations: Authorizations, options: Options)
{
ReadResponseAsString = ReadResponseAsString,
JsonSerializerContext = JsonSerializerContext,
@@ -69,7 +72,7 @@ public sealed partial class BraintrustClient : global::Braintrust.IBraintrustCli
///
///
///
- public CorsClient Cors => new CorsClient(HttpClient, authorizations: Authorizations)
+ public CorsClient Cors => new CorsClient(HttpClient, authorizations: Authorizations, options: Options)
{
ReadResponseAsString = ReadResponseAsString,
JsonSerializerContext = JsonSerializerContext,
@@ -78,7 +81,7 @@ public sealed partial class BraintrustClient : global::Braintrust.IBraintrustCli
///
///
///
- public CrossObjectClient CrossObject => new CrossObjectClient(HttpClient, authorizations: Authorizations)
+ public CrossObjectClient CrossObject => new CrossObjectClient(HttpClient, authorizations: Authorizations, options: Options)
{
ReadResponseAsString = ReadResponseAsString,
JsonSerializerContext = JsonSerializerContext,
@@ -87,7 +90,7 @@ public sealed partial class BraintrustClient : global::Braintrust.IBraintrustCli
///
///
///
- public DatasetSnapshotsClient DatasetSnapshots => new DatasetSnapshotsClient(HttpClient, authorizations: Authorizations)
+ public DatasetSnapshotsClient DatasetSnapshots => new DatasetSnapshotsClient(HttpClient, authorizations: Authorizations, options: Options)
{
ReadResponseAsString = ReadResponseAsString,
JsonSerializerContext = JsonSerializerContext,
@@ -96,7 +99,7 @@ public sealed partial class BraintrustClient : global::Braintrust.IBraintrustCli
///
///
///
- public DatasetsClient Datasets => new DatasetsClient(HttpClient, authorizations: Authorizations)
+ public DatasetsClient Datasets => new DatasetsClient(HttpClient, authorizations: Authorizations, options: Options)
{
ReadResponseAsString = ReadResponseAsString,
JsonSerializerContext = JsonSerializerContext,
@@ -105,7 +108,7 @@ public sealed partial class BraintrustClient : global::Braintrust.IBraintrustCli
///
///
///
- public EnvVarsClient EnvVars => new EnvVarsClient(HttpClient, authorizations: Authorizations)
+ public EnvVarsClient EnvVars => new EnvVarsClient(HttpClient, authorizations: Authorizations, options: Options)
{
ReadResponseAsString = ReadResponseAsString,
JsonSerializerContext = JsonSerializerContext,
@@ -114,7 +117,7 @@ public sealed partial class BraintrustClient : global::Braintrust.IBraintrustCli
///
///
///
- public EnvironmentsClient Environments => new EnvironmentsClient(HttpClient, authorizations: Authorizations)
+ public EnvironmentsClient Environments => new EnvironmentsClient(HttpClient, authorizations: Authorizations, options: Options)
{
ReadResponseAsString = ReadResponseAsString,
JsonSerializerContext = JsonSerializerContext,
@@ -123,7 +126,7 @@ public sealed partial class BraintrustClient : global::Braintrust.IBraintrustCli
///
///
///
- public EvalStatusPagesClient EvalStatusPages => new EvalStatusPagesClient(HttpClient, authorizations: Authorizations)
+ public EvalStatusPagesClient EvalStatusPages => new EvalStatusPagesClient(HttpClient, authorizations: Authorizations, options: Options)
{
ReadResponseAsString = ReadResponseAsString,
JsonSerializerContext = JsonSerializerContext,
@@ -132,7 +135,7 @@ public sealed partial class BraintrustClient : global::Braintrust.IBraintrustCli
///
///
///
- public EvalsClient Evals => new EvalsClient(HttpClient, authorizations: Authorizations)
+ public EvalsClient Evals => new EvalsClient(HttpClient, authorizations: Authorizations, options: Options)
{
ReadResponseAsString = ReadResponseAsString,
JsonSerializerContext = JsonSerializerContext,
@@ -141,7 +144,7 @@ public sealed partial class BraintrustClient : global::Braintrust.IBraintrustCli
///
///
///
- public ExperimentsClient Experiments => new ExperimentsClient(HttpClient, authorizations: Authorizations)
+ public ExperimentsClient Experiments => new ExperimentsClient(HttpClient, authorizations: Authorizations, options: Options)
{
ReadResponseAsString = ReadResponseAsString,
JsonSerializerContext = JsonSerializerContext,
@@ -150,7 +153,7 @@ public sealed partial class BraintrustClient : global::Braintrust.IBraintrustCli
///
///
///
- public FunctionsClient Functions => new FunctionsClient(HttpClient, authorizations: Authorizations)
+ public FunctionsClient Functions => new FunctionsClient(HttpClient, authorizations: Authorizations, options: Options)
{
ReadResponseAsString = ReadResponseAsString,
JsonSerializerContext = JsonSerializerContext,
@@ -159,7 +162,7 @@ public sealed partial class BraintrustClient : global::Braintrust.IBraintrustCli
///
///
///
- public GroupsClient Groups => new GroupsClient(HttpClient, authorizations: Authorizations)
+ public GroupsClient Groups => new GroupsClient(HttpClient, authorizations: Authorizations, options: Options)
{
ReadResponseAsString = ReadResponseAsString,
JsonSerializerContext = JsonSerializerContext,
@@ -168,7 +171,7 @@ public sealed partial class BraintrustClient : global::Braintrust.IBraintrustCli
///
///
///
- public LogsClient Logs => new LogsClient(HttpClient, authorizations: Authorizations)
+ public LogsClient Logs => new LogsClient(HttpClient, authorizations: Authorizations, options: Options)
{
ReadResponseAsString = ReadResponseAsString,
JsonSerializerContext = JsonSerializerContext,
@@ -177,7 +180,7 @@ public sealed partial class BraintrustClient : global::Braintrust.IBraintrustCli
///
///
///
- public McpServersClient McpServers => new McpServersClient(HttpClient, authorizations: Authorizations)
+ public McpServersClient McpServers => new McpServersClient(HttpClient, authorizations: Authorizations, options: Options)
{
ReadResponseAsString = ReadResponseAsString,
JsonSerializerContext = JsonSerializerContext,
@@ -186,7 +189,7 @@ public sealed partial class BraintrustClient : global::Braintrust.IBraintrustCli
///
///
///
- public OrganizationsClient Organizations => new OrganizationsClient(HttpClient, authorizations: Authorizations)
+ public OrganizationsClient Organizations => new OrganizationsClient(HttpClient, authorizations: Authorizations, options: Options)
{
ReadResponseAsString = ReadResponseAsString,
JsonSerializerContext = JsonSerializerContext,
@@ -195,7 +198,7 @@ public sealed partial class BraintrustClient : global::Braintrust.IBraintrustCli
///
///
///
- public OtherClient Other => new OtherClient(HttpClient, authorizations: Authorizations)
+ public OtherClient Other => new OtherClient(HttpClient, authorizations: Authorizations, options: Options)
{
ReadResponseAsString = ReadResponseAsString,
JsonSerializerContext = JsonSerializerContext,
@@ -204,7 +207,7 @@ public sealed partial class BraintrustClient : global::Braintrust.IBraintrustCli
///
///
///
- public ProjectAutomationsClient ProjectAutomations => new ProjectAutomationsClient(HttpClient, authorizations: Authorizations)
+ public ProjectAutomationsClient ProjectAutomations => new ProjectAutomationsClient(HttpClient, authorizations: Authorizations, options: Options)
{
ReadResponseAsString = ReadResponseAsString,
JsonSerializerContext = JsonSerializerContext,
@@ -213,7 +216,7 @@ public sealed partial class BraintrustClient : global::Braintrust.IBraintrustCli
///
///
///
- public ProjectScoresClient ProjectScores => new ProjectScoresClient(HttpClient, authorizations: Authorizations)
+ public ProjectScoresClient ProjectScores => new ProjectScoresClient(HttpClient, authorizations: Authorizations, options: Options)
{
ReadResponseAsString = ReadResponseAsString,
JsonSerializerContext = JsonSerializerContext,
@@ -222,7 +225,7 @@ public sealed partial class BraintrustClient : global::Braintrust.IBraintrustCli
///
///
///
- public ProjectTagsClient ProjectTags => new ProjectTagsClient(HttpClient, authorizations: Authorizations)
+ public ProjectTagsClient ProjectTags => new ProjectTagsClient(HttpClient, authorizations: Authorizations, options: Options)
{
ReadResponseAsString = ReadResponseAsString,
JsonSerializerContext = JsonSerializerContext,
@@ -231,7 +234,7 @@ public sealed partial class BraintrustClient : global::Braintrust.IBraintrustCli
///
///
///
- public ProjectsClient Projects => new ProjectsClient(HttpClient, authorizations: Authorizations)
+ public ProjectsClient Projects => new ProjectsClient(HttpClient, authorizations: Authorizations, options: Options)
{
ReadResponseAsString = ReadResponseAsString,
JsonSerializerContext = JsonSerializerContext,
@@ -240,7 +243,7 @@ public sealed partial class BraintrustClient : global::Braintrust.IBraintrustCli
///
///
///
- public PromptsClient Prompts => new PromptsClient(HttpClient, authorizations: Authorizations)
+ public PromptsClient Prompts => new PromptsClient(HttpClient, authorizations: Authorizations, options: Options)
{
ReadResponseAsString = ReadResponseAsString,
JsonSerializerContext = JsonSerializerContext,
@@ -249,7 +252,7 @@ public sealed partial class BraintrustClient : global::Braintrust.IBraintrustCli
///
///
///
- public ProxyClient Proxy => new ProxyClient(HttpClient, authorizations: Authorizations)
+ public ProxyClient Proxy => new ProxyClient(HttpClient, authorizations: Authorizations, options: Options)
{
ReadResponseAsString = ReadResponseAsString,
JsonSerializerContext = JsonSerializerContext,
@@ -258,7 +261,7 @@ public sealed partial class BraintrustClient : global::Braintrust.IBraintrustCli
///
///
///
- public RolesClient Roles => new RolesClient(HttpClient, authorizations: Authorizations)
+ public RolesClient Roles => new RolesClient(HttpClient, authorizations: Authorizations, options: Options)
{
ReadResponseAsString = ReadResponseAsString,
JsonSerializerContext = JsonSerializerContext,
@@ -267,7 +270,7 @@ public sealed partial class BraintrustClient : global::Braintrust.IBraintrustCli
///
///
///
- public ServiceTokensClient ServiceTokens => new ServiceTokensClient(HttpClient, authorizations: Authorizations)
+ public ServiceTokensClient ServiceTokens => new ServiceTokensClient(HttpClient, authorizations: Authorizations, options: Options)
{
ReadResponseAsString = ReadResponseAsString,
JsonSerializerContext = JsonSerializerContext,
@@ -276,7 +279,7 @@ public sealed partial class BraintrustClient : global::Braintrust.IBraintrustCli
///
///
///
- public SpanIframesClient SpanIframes => new SpanIframesClient(HttpClient, authorizations: Authorizations)
+ public SpanIframesClient SpanIframes => new SpanIframesClient(HttpClient, authorizations: Authorizations, options: Options)
{
ReadResponseAsString = ReadResponseAsString,
JsonSerializerContext = JsonSerializerContext,
@@ -285,7 +288,7 @@ public sealed partial class BraintrustClient : global::Braintrust.IBraintrustCli
///
///
///
- public UsersClient Users => new UsersClient(HttpClient, authorizations: Authorizations)
+ public UsersClient Users => new UsersClient(HttpClient, authorizations: Authorizations, options: Options)
{
ReadResponseAsString = ReadResponseAsString,
JsonSerializerContext = JsonSerializerContext,
@@ -294,7 +297,7 @@ public sealed partial class BraintrustClient : global::Braintrust.IBraintrustCli
///
///
///
- public ViewsClient Views => new ViewsClient(HttpClient, authorizations: Authorizations)
+ public ViewsClient Views => new ViewsClient(HttpClient, authorizations: Authorizations, options: Options)
{
ReadResponseAsString = ReadResponseAsString,
JsonSerializerContext = JsonSerializerContext,
@@ -313,11 +316,37 @@ public BraintrustClient(
global::System.Net.Http.HttpClient? httpClient = null,
global::System.Uri? baseUri = null,
global::System.Collections.Generic.List? authorizations = null,
+ bool disposeHttpClient = true) : this(
+ httpClient,
+ baseUri,
+ authorizations,
+ options: null,
+ disposeHttpClient: disposeHttpClient)
+ {
+ }
+
+ ///
+ /// Creates a new instance of the BraintrustClient.
+ /// 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.
+ /// Client-wide request defaults such as headers, query parameters, retries, and timeout.
+ /// Dispose the HttpClient when the instance is disposed. True by default.
+ public BraintrustClient(
+ global::System.Net.Http.HttpClient? httpClient = null,
+ global::System.Uri? baseUri = null,
+ global::System.Collections.Generic.List? authorizations = null,
+ global::Braintrust.AutoSDKClientOptions? options = null,
bool disposeHttpClient = true)
{
+
HttpClient = httpClient ?? new global::System.Net.Http.HttpClient();
HttpClient.BaseAddress ??= baseUri ?? new global::System.Uri(DefaultBaseUrl);
Authorizations = authorizations ?? new global::System.Collections.Generic.List();
+ Options = options ?? new global::Braintrust.AutoSDKClientOptions();
_disposeHttpClient = disposeHttpClient;
Initialized(HttpClient);
diff --git a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsAcl.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsAcl.g.cs
index ea42e86..7b3e607 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsAcl.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsAcl.g.cs
@@ -18,9 +18,11 @@ partial void ProcessOptionsAclResponse(
/// Enable CORS (`/v1/acl`)
/// Enable CORS
///
+ /// 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 OptionsAclAsync(
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -28,142 +30,321 @@ partial void ProcessOptionsAclResponse(
PrepareOptionsAclArguments(
httpClient: HttpClient);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: "/v1/acl",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: "/v1/acl",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsAclRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsAclRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __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);
- ProcessOptionsAclResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsAcl",
+ methodName: "OptionsAclAsync",
+ pathTemplate: "\"/v1/acl\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsAcl",
+ methodName: "OptionsAclAsync",
+ pathTemplate: "\"/v1/acl\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsAcl",
+ methodName: "OptionsAclAsync",
+ pathTemplate: "\"/v1/acl\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
+ response: __response);
+ ProcessOptionsAclResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsAcl",
+ methodName: "OptionsAclAsync",
+ pathTemplate: "\"/v1/acl\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsAcl",
+ methodName: "OptionsAclAsync",
+ pathTemplate: "\"/v1/acl\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsAclBatchUpdate.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsAclBatchUpdate.g.cs
index e44d2a1..223abe5 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsAclBatchUpdate.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsAclBatchUpdate.g.cs
@@ -18,9 +18,11 @@ partial void ProcessOptionsAclBatchUpdateResponse(
/// Enable CORS (`/v1/acl/acl/batch_update`)
/// Enable CORS
///
+ /// 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 OptionsAclBatchUpdateAsync(
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -28,142 +30,321 @@ partial void ProcessOptionsAclBatchUpdateResponse(
PrepareOptionsAclBatchUpdateArguments(
httpClient: HttpClient);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: "/v1/acl/acl/batch_update",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: "/v1/acl/acl/batch_update",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsAclBatchUpdateRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsAclBatchUpdateRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __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);
- ProcessOptionsAclBatchUpdateResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsAclBatchUpdate",
+ methodName: "OptionsAclBatchUpdateAsync",
+ pathTemplate: "\"/v1/acl/acl/batch_update\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsAclBatchUpdate",
+ methodName: "OptionsAclBatchUpdateAsync",
+ pathTemplate: "\"/v1/acl/acl/batch_update\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsAclBatchUpdate",
+ methodName: "OptionsAclBatchUpdateAsync",
+ pathTemplate: "\"/v1/acl/acl/batch_update\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
+ response: __response);
+ ProcessOptionsAclBatchUpdateResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsAclBatchUpdate",
+ methodName: "OptionsAclBatchUpdateAsync",
+ pathTemplate: "\"/v1/acl/acl/batch_update\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsAclBatchUpdate",
+ methodName: "OptionsAclBatchUpdateAsync",
+ pathTemplate: "\"/v1/acl/acl/batch_update\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsAclId.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsAclId.g.cs
index 10076b1..46c222d 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsAclId.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsAclId.g.cs
@@ -23,10 +23,12 @@ partial void ProcessOptionsAclIdResponse(
///
/// Acl id
///
+ /// 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 OptionsAclIdAsync(
global::System.Guid aclId,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -35,143 +37,322 @@ partial void ProcessOptionsAclIdResponse(
httpClient: HttpClient,
aclId: ref aclId);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: $"/v1/acl/{aclId}",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: $"/v1/acl/{aclId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsAclIdRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- aclId: aclId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsAclIdRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ aclId: aclId);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessOptionsAclIdResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsAclId",
+ methodName: "OptionsAclIdAsync",
+ pathTemplate: "$\"/v1/acl/{aclId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsAclId",
+ methodName: "OptionsAclIdAsync",
+ pathTemplate: "$\"/v1/acl/{aclId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsAclId",
+ methodName: "OptionsAclIdAsync",
+ pathTemplate: "$\"/v1/acl/{aclId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
- {
- __response.EnsureSuccessStatusCode();
-
- }
- catch (global::System.Exception __ex)
+ response: __response);
+ ProcessOptionsAclIdResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsAclId",
+ methodName: "OptionsAclIdAsync",
+ pathTemplate: "$\"/v1/acl/{aclId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
+ else
{
- __response.EnsureSuccessStatusCode();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsAclId",
+ methodName: "OptionsAclIdAsync",
+ pathTemplate: "$\"/v1/acl/{aclId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsAclListOrg.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsAclListOrg.g.cs
index e4de0b1..bd4866b 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsAclListOrg.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsAclListOrg.g.cs
@@ -18,9 +18,11 @@ partial void ProcessOptionsAclListOrgResponse(
/// Enable CORS (`/v1/acl/list_org`)
/// Enable CORS
///
+ /// 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 OptionsAclListOrgAsync(
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -28,142 +30,321 @@ partial void ProcessOptionsAclListOrgResponse(
PrepareOptionsAclListOrgArguments(
httpClient: HttpClient);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: "/v1/acl/list_org",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: "/v1/acl/list_org",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsAclListOrgRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsAclListOrgRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __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);
- ProcessOptionsAclListOrgResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsAclListOrg",
+ methodName: "OptionsAclListOrgAsync",
+ pathTemplate: "\"/v1/acl/list_org\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsAclListOrg",
+ methodName: "OptionsAclListOrgAsync",
+ pathTemplate: "\"/v1/acl/list_org\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsAclListOrg",
+ methodName: "OptionsAclListOrgAsync",
+ pathTemplate: "\"/v1/acl/list_org\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
+ response: __response);
+ ProcessOptionsAclListOrgResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsAclListOrg",
+ methodName: "OptionsAclListOrgAsync",
+ pathTemplate: "\"/v1/acl/list_org\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsAclListOrg",
+ methodName: "OptionsAclListOrgAsync",
+ pathTemplate: "\"/v1/acl/list_org\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsAiSecret.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsAiSecret.g.cs
index d54d023..0f566d8 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsAiSecret.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsAiSecret.g.cs
@@ -18,9 +18,11 @@ partial void ProcessOptionsAiSecretResponse(
/// Enable CORS (`/v1/ai_secret`)
/// Enable CORS
///
+ /// 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 OptionsAiSecretAsync(
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -28,142 +30,321 @@ partial void ProcessOptionsAiSecretResponse(
PrepareOptionsAiSecretArguments(
httpClient: HttpClient);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: "/v1/ai_secret",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: "/v1/ai_secret",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsAiSecretRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsAiSecretRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __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);
- ProcessOptionsAiSecretResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsAiSecret",
+ methodName: "OptionsAiSecretAsync",
+ pathTemplate: "\"/v1/ai_secret\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsAiSecret",
+ methodName: "OptionsAiSecretAsync",
+ pathTemplate: "\"/v1/ai_secret\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsAiSecret",
+ methodName: "OptionsAiSecretAsync",
+ pathTemplate: "\"/v1/ai_secret\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
+ response: __response);
+ ProcessOptionsAiSecretResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsAiSecret",
+ methodName: "OptionsAiSecretAsync",
+ pathTemplate: "\"/v1/ai_secret\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsAiSecret",
+ methodName: "OptionsAiSecretAsync",
+ pathTemplate: "\"/v1/ai_secret\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsAiSecretId.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsAiSecretId.g.cs
index d32b111..cc819af 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsAiSecretId.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsAiSecretId.g.cs
@@ -23,10 +23,12 @@ partial void ProcessOptionsAiSecretIdResponse(
///
/// AiSecret id
///
+ /// 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 OptionsAiSecretIdAsync(
global::System.Guid aiSecretId,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -35,143 +37,322 @@ partial void ProcessOptionsAiSecretIdResponse(
httpClient: HttpClient,
aiSecretId: ref aiSecretId);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: $"/v1/ai_secret/{aiSecretId}",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: $"/v1/ai_secret/{aiSecretId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsAiSecretIdRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- aiSecretId: aiSecretId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsAiSecretIdRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ aiSecretId: aiSecretId);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessOptionsAiSecretIdResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsAiSecretId",
+ methodName: "OptionsAiSecretIdAsync",
+ pathTemplate: "$\"/v1/ai_secret/{aiSecretId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsAiSecretId",
+ methodName: "OptionsAiSecretIdAsync",
+ pathTemplate: "$\"/v1/ai_secret/{aiSecretId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsAiSecretId",
+ methodName: "OptionsAiSecretIdAsync",
+ pathTemplate: "$\"/v1/ai_secret/{aiSecretId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
- {
- __response.EnsureSuccessStatusCode();
-
- }
- catch (global::System.Exception __ex)
+ response: __response);
+ ProcessOptionsAiSecretIdResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsAiSecretId",
+ methodName: "OptionsAiSecretIdAsync",
+ pathTemplate: "$\"/v1/ai_secret/{aiSecretId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
+ else
{
- __response.EnsureSuccessStatusCode();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsAiSecretId",
+ methodName: "OptionsAiSecretIdAsync",
+ pathTemplate: "$\"/v1/ai_secret/{aiSecretId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsApiKey.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsApiKey.g.cs
index 5a50fce..76da37b 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsApiKey.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsApiKey.g.cs
@@ -18,9 +18,11 @@ partial void ProcessOptionsApiKeyResponse(
/// Enable CORS (`/v1/api_key`)
/// Enable CORS
///
+ /// 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 OptionsApiKeyAsync(
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -28,142 +30,321 @@ partial void ProcessOptionsApiKeyResponse(
PrepareOptionsApiKeyArguments(
httpClient: HttpClient);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: "/v1/api_key",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: "/v1/api_key",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsApiKeyRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsApiKeyRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __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);
- ProcessOptionsApiKeyResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsApiKey",
+ methodName: "OptionsApiKeyAsync",
+ pathTemplate: "\"/v1/api_key\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsApiKey",
+ methodName: "OptionsApiKeyAsync",
+ pathTemplate: "\"/v1/api_key\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsApiKey",
+ methodName: "OptionsApiKeyAsync",
+ pathTemplate: "\"/v1/api_key\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
+ response: __response);
+ ProcessOptionsApiKeyResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsApiKey",
+ methodName: "OptionsApiKeyAsync",
+ pathTemplate: "\"/v1/api_key\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsApiKey",
+ methodName: "OptionsApiKeyAsync",
+ pathTemplate: "\"/v1/api_key\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsApiKeyId.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsApiKeyId.g.cs
index 988b4fe..3ead7f3 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsApiKeyId.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsApiKeyId.g.cs
@@ -23,10 +23,12 @@ partial void ProcessOptionsApiKeyIdResponse(
///
/// ApiKey id
///
+ /// 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 OptionsApiKeyIdAsync(
global::System.Guid apiKeyId,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -35,143 +37,322 @@ partial void ProcessOptionsApiKeyIdResponse(
httpClient: HttpClient,
apiKeyId: ref apiKeyId);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: $"/v1/api_key/{apiKeyId}",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: $"/v1/api_key/{apiKeyId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsApiKeyIdRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- apiKeyId: apiKeyId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsApiKeyIdRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ apiKeyId: apiKeyId);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessOptionsApiKeyIdResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsApiKeyId",
+ methodName: "OptionsApiKeyIdAsync",
+ pathTemplate: "$\"/v1/api_key/{apiKeyId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsApiKeyId",
+ methodName: "OptionsApiKeyIdAsync",
+ pathTemplate: "$\"/v1/api_key/{apiKeyId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsApiKeyId",
+ methodName: "OptionsApiKeyIdAsync",
+ pathTemplate: "$\"/v1/api_key/{apiKeyId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
- {
- __response.EnsureSuccessStatusCode();
-
- }
- catch (global::System.Exception __ex)
+ response: __response);
+ ProcessOptionsApiKeyIdResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsApiKeyId",
+ methodName: "OptionsApiKeyIdAsync",
+ pathTemplate: "$\"/v1/api_key/{apiKeyId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
+ else
{
- __response.EnsureSuccessStatusCode();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsApiKeyId",
+ methodName: "OptionsApiKeyIdAsync",
+ pathTemplate: "$\"/v1/api_key/{apiKeyId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsCrossObjectInsert.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsCrossObjectInsert.g.cs
index 81568ec..740f272 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsCrossObjectInsert.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsCrossObjectInsert.g.cs
@@ -18,9 +18,11 @@ partial void ProcessOptionsCrossObjectInsertResponse(
/// Enable CORS (`/v1/insert`)
/// Enable CORS
///
+ /// 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 OptionsCrossObjectInsertAsync(
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -28,142 +30,321 @@ partial void ProcessOptionsCrossObjectInsertResponse(
PrepareOptionsCrossObjectInsertArguments(
httpClient: HttpClient);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: "/v1/insert",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: "/v1/insert",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsCrossObjectInsertRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsCrossObjectInsertRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __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);
- ProcessOptionsCrossObjectInsertResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsCrossObjectInsert",
+ methodName: "OptionsCrossObjectInsertAsync",
+ pathTemplate: "\"/v1/insert\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsCrossObjectInsert",
+ methodName: "OptionsCrossObjectInsertAsync",
+ pathTemplate: "\"/v1/insert\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsCrossObjectInsert",
+ methodName: "OptionsCrossObjectInsertAsync",
+ pathTemplate: "\"/v1/insert\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
+ response: __response);
+ ProcessOptionsCrossObjectInsertResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsCrossObjectInsert",
+ methodName: "OptionsCrossObjectInsertAsync",
+ pathTemplate: "\"/v1/insert\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsCrossObjectInsert",
+ methodName: "OptionsCrossObjectInsertAsync",
+ pathTemplate: "\"/v1/insert\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsDataset.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsDataset.g.cs
index d51fee4..3ac5f51 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsDataset.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsDataset.g.cs
@@ -18,9 +18,11 @@ partial void ProcessOptionsDatasetResponse(
/// Enable CORS (`/v1/dataset`)
/// Enable CORS
///
+ /// 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 OptionsDatasetAsync(
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -28,142 +30,321 @@ partial void ProcessOptionsDatasetResponse(
PrepareOptionsDatasetArguments(
httpClient: HttpClient);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: "/v1/dataset",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: "/v1/dataset",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsDatasetRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsDatasetRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __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);
- ProcessOptionsDatasetResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsDataset",
+ methodName: "OptionsDatasetAsync",
+ pathTemplate: "\"/v1/dataset\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsDataset",
+ methodName: "OptionsDatasetAsync",
+ pathTemplate: "\"/v1/dataset\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsDataset",
+ methodName: "OptionsDatasetAsync",
+ pathTemplate: "\"/v1/dataset\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
+ response: __response);
+ ProcessOptionsDatasetResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsDataset",
+ methodName: "OptionsDatasetAsync",
+ pathTemplate: "\"/v1/dataset\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsDataset",
+ methodName: "OptionsDatasetAsync",
+ pathTemplate: "\"/v1/dataset\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsDatasetId.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsDatasetId.g.cs
index c322997..7d8b0dd 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsDatasetId.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsDatasetId.g.cs
@@ -23,10 +23,12 @@ partial void ProcessOptionsDatasetIdResponse(
///
/// Dataset id
///
+ /// 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 OptionsDatasetIdAsync(
global::System.Guid datasetId,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -35,143 +37,322 @@ partial void ProcessOptionsDatasetIdResponse(
httpClient: HttpClient,
datasetId: ref datasetId);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: $"/v1/dataset/{datasetId}",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: $"/v1/dataset/{datasetId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsDatasetIdRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- datasetId: datasetId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsDatasetIdRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ datasetId: datasetId);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessOptionsDatasetIdResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsDatasetId",
+ methodName: "OptionsDatasetIdAsync",
+ pathTemplate: "$\"/v1/dataset/{datasetId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsDatasetId",
+ methodName: "OptionsDatasetIdAsync",
+ pathTemplate: "$\"/v1/dataset/{datasetId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsDatasetId",
+ methodName: "OptionsDatasetIdAsync",
+ pathTemplate: "$\"/v1/dataset/{datasetId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
- {
- __response.EnsureSuccessStatusCode();
-
- }
- catch (global::System.Exception __ex)
+ response: __response);
+ ProcessOptionsDatasetIdResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsDatasetId",
+ methodName: "OptionsDatasetIdAsync",
+ pathTemplate: "$\"/v1/dataset/{datasetId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
+ else
{
- __response.EnsureSuccessStatusCode();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsDatasetId",
+ methodName: "OptionsDatasetIdAsync",
+ pathTemplate: "$\"/v1/dataset/{datasetId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsDatasetIdFeedback.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsDatasetIdFeedback.g.cs
index 86a2c51..a7a5a50 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsDatasetIdFeedback.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsDatasetIdFeedback.g.cs
@@ -23,10 +23,12 @@ partial void ProcessOptionsDatasetIdFeedbackResponse(
///
/// Dataset id
///
+ /// 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 OptionsDatasetIdFeedbackAsync(
global::System.Guid datasetId,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -35,143 +37,322 @@ partial void ProcessOptionsDatasetIdFeedbackResponse(
httpClient: HttpClient,
datasetId: ref datasetId);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: $"/v1/dataset/{datasetId}/feedback",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: $"/v1/dataset/{datasetId}/feedback",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsDatasetIdFeedbackRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- datasetId: datasetId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsDatasetIdFeedbackRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ datasetId: datasetId);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessOptionsDatasetIdFeedbackResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsDatasetIdFeedback",
+ methodName: "OptionsDatasetIdFeedbackAsync",
+ pathTemplate: "$\"/v1/dataset/{datasetId}/feedback\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsDatasetIdFeedback",
+ methodName: "OptionsDatasetIdFeedbackAsync",
+ pathTemplate: "$\"/v1/dataset/{datasetId}/feedback\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsDatasetIdFeedback",
+ methodName: "OptionsDatasetIdFeedbackAsync",
+ pathTemplate: "$\"/v1/dataset/{datasetId}/feedback\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
- {
- __response.EnsureSuccessStatusCode();
-
- }
- catch (global::System.Exception __ex)
+ response: __response);
+ ProcessOptionsDatasetIdFeedbackResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsDatasetIdFeedback",
+ methodName: "OptionsDatasetIdFeedbackAsync",
+ pathTemplate: "$\"/v1/dataset/{datasetId}/feedback\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
+ else
{
- __response.EnsureSuccessStatusCode();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsDatasetIdFeedback",
+ methodName: "OptionsDatasetIdFeedbackAsync",
+ pathTemplate: "$\"/v1/dataset/{datasetId}/feedback\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsDatasetIdFetch.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsDatasetIdFetch.g.cs
index d2c99dd..d2506d7 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsDatasetIdFetch.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsDatasetIdFetch.g.cs
@@ -23,10 +23,12 @@ partial void ProcessOptionsDatasetIdFetchResponse(
///
/// Dataset id
///
+ /// 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 OptionsDatasetIdFetchAsync(
global::System.Guid datasetId,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -35,143 +37,322 @@ partial void ProcessOptionsDatasetIdFetchResponse(
httpClient: HttpClient,
datasetId: ref datasetId);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: $"/v1/dataset/{datasetId}/fetch",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: $"/v1/dataset/{datasetId}/fetch",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsDatasetIdFetchRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- datasetId: datasetId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsDatasetIdFetchRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ datasetId: datasetId);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessOptionsDatasetIdFetchResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsDatasetIdFetch",
+ methodName: "OptionsDatasetIdFetchAsync",
+ pathTemplate: "$\"/v1/dataset/{datasetId}/fetch\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsDatasetIdFetch",
+ methodName: "OptionsDatasetIdFetchAsync",
+ pathTemplate: "$\"/v1/dataset/{datasetId}/fetch\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsDatasetIdFetch",
+ methodName: "OptionsDatasetIdFetchAsync",
+ pathTemplate: "$\"/v1/dataset/{datasetId}/fetch\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
- {
- __response.EnsureSuccessStatusCode();
-
- }
- catch (global::System.Exception __ex)
+ response: __response);
+ ProcessOptionsDatasetIdFetchResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsDatasetIdFetch",
+ methodName: "OptionsDatasetIdFetchAsync",
+ pathTemplate: "$\"/v1/dataset/{datasetId}/fetch\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
+ else
{
- __response.EnsureSuccessStatusCode();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsDatasetIdFetch",
+ methodName: "OptionsDatasetIdFetchAsync",
+ pathTemplate: "$\"/v1/dataset/{datasetId}/fetch\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsDatasetIdInsert.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsDatasetIdInsert.g.cs
index c92f564..8830474 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsDatasetIdInsert.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsDatasetIdInsert.g.cs
@@ -23,10 +23,12 @@ partial void ProcessOptionsDatasetIdInsertResponse(
///
/// Dataset id
///
+ /// 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 OptionsDatasetIdInsertAsync(
global::System.Guid datasetId,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -35,143 +37,322 @@ partial void ProcessOptionsDatasetIdInsertResponse(
httpClient: HttpClient,
datasetId: ref datasetId);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: $"/v1/dataset/{datasetId}/insert",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: $"/v1/dataset/{datasetId}/insert",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsDatasetIdInsertRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- datasetId: datasetId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsDatasetIdInsertRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ datasetId: datasetId);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessOptionsDatasetIdInsertResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsDatasetIdInsert",
+ methodName: "OptionsDatasetIdInsertAsync",
+ pathTemplate: "$\"/v1/dataset/{datasetId}/insert\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsDatasetIdInsert",
+ methodName: "OptionsDatasetIdInsertAsync",
+ pathTemplate: "$\"/v1/dataset/{datasetId}/insert\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsDatasetIdInsert",
+ methodName: "OptionsDatasetIdInsertAsync",
+ pathTemplate: "$\"/v1/dataset/{datasetId}/insert\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
- {
- __response.EnsureSuccessStatusCode();
-
- }
- catch (global::System.Exception __ex)
+ response: __response);
+ ProcessOptionsDatasetIdInsertResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsDatasetIdInsert",
+ methodName: "OptionsDatasetIdInsertAsync",
+ pathTemplate: "$\"/v1/dataset/{datasetId}/insert\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
+ else
{
- __response.EnsureSuccessStatusCode();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsDatasetIdInsert",
+ methodName: "OptionsDatasetIdInsertAsync",
+ pathTemplate: "$\"/v1/dataset/{datasetId}/insert\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsDatasetIdSummarize.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsDatasetIdSummarize.g.cs
index be7e4d0..618f2ff 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsDatasetIdSummarize.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsDatasetIdSummarize.g.cs
@@ -23,10 +23,12 @@ partial void ProcessOptionsDatasetIdSummarizeResponse(
///
/// Dataset id
///
+ /// 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 OptionsDatasetIdSummarizeAsync(
global::System.Guid datasetId,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -35,143 +37,322 @@ partial void ProcessOptionsDatasetIdSummarizeResponse(
httpClient: HttpClient,
datasetId: ref datasetId);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: $"/v1/dataset/{datasetId}/summarize",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: $"/v1/dataset/{datasetId}/summarize",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsDatasetIdSummarizeRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- datasetId: datasetId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsDatasetIdSummarizeRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ datasetId: datasetId);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessOptionsDatasetIdSummarizeResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsDatasetIdSummarize",
+ methodName: "OptionsDatasetIdSummarizeAsync",
+ pathTemplate: "$\"/v1/dataset/{datasetId}/summarize\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsDatasetIdSummarize",
+ methodName: "OptionsDatasetIdSummarizeAsync",
+ pathTemplate: "$\"/v1/dataset/{datasetId}/summarize\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsDatasetIdSummarize",
+ methodName: "OptionsDatasetIdSummarizeAsync",
+ pathTemplate: "$\"/v1/dataset/{datasetId}/summarize\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
- {
- __response.EnsureSuccessStatusCode();
-
- }
- catch (global::System.Exception __ex)
+ response: __response);
+ ProcessOptionsDatasetIdSummarizeResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsDatasetIdSummarize",
+ methodName: "OptionsDatasetIdSummarizeAsync",
+ pathTemplate: "$\"/v1/dataset/{datasetId}/summarize\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
+ else
{
- __response.EnsureSuccessStatusCode();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsDatasetIdSummarize",
+ methodName: "OptionsDatasetIdSummarizeAsync",
+ pathTemplate: "$\"/v1/dataset/{datasetId}/summarize\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsDatasetSnapshot.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsDatasetSnapshot.g.cs
index e966dd4..91b8b60 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsDatasetSnapshot.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsDatasetSnapshot.g.cs
@@ -18,9 +18,11 @@ partial void ProcessOptionsDatasetSnapshotResponse(
/// Enable CORS (`/v1/dataset_snapshot`)
/// Enable CORS
///
+ /// 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 OptionsDatasetSnapshotAsync(
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -28,142 +30,321 @@ partial void ProcessOptionsDatasetSnapshotResponse(
PrepareOptionsDatasetSnapshotArguments(
httpClient: HttpClient);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: "/v1/dataset_snapshot",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: "/v1/dataset_snapshot",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsDatasetSnapshotRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsDatasetSnapshotRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __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);
- ProcessOptionsDatasetSnapshotResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsDatasetSnapshot",
+ methodName: "OptionsDatasetSnapshotAsync",
+ pathTemplate: "\"/v1/dataset_snapshot\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsDatasetSnapshot",
+ methodName: "OptionsDatasetSnapshotAsync",
+ pathTemplate: "\"/v1/dataset_snapshot\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsDatasetSnapshot",
+ methodName: "OptionsDatasetSnapshotAsync",
+ pathTemplate: "\"/v1/dataset_snapshot\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
+ response: __response);
+ ProcessOptionsDatasetSnapshotResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsDatasetSnapshot",
+ methodName: "OptionsDatasetSnapshotAsync",
+ pathTemplate: "\"/v1/dataset_snapshot\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsDatasetSnapshot",
+ methodName: "OptionsDatasetSnapshotAsync",
+ pathTemplate: "\"/v1/dataset_snapshot\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsDatasetSnapshotId.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsDatasetSnapshotId.g.cs
index 734ecbd..0489cb3 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsDatasetSnapshotId.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsDatasetSnapshotId.g.cs
@@ -23,10 +23,12 @@ partial void ProcessOptionsDatasetSnapshotIdResponse(
///
/// DatasetSnapshot id
///
+ /// 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 OptionsDatasetSnapshotIdAsync(
global::System.Guid datasetSnapshotId,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -35,143 +37,322 @@ partial void ProcessOptionsDatasetSnapshotIdResponse(
httpClient: HttpClient,
datasetSnapshotId: ref datasetSnapshotId);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: $"/v1/dataset_snapshot/{datasetSnapshotId}",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: $"/v1/dataset_snapshot/{datasetSnapshotId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsDatasetSnapshotIdRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- datasetSnapshotId: datasetSnapshotId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsDatasetSnapshotIdRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ datasetSnapshotId: datasetSnapshotId);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessOptionsDatasetSnapshotIdResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsDatasetSnapshotId",
+ methodName: "OptionsDatasetSnapshotIdAsync",
+ pathTemplate: "$\"/v1/dataset_snapshot/{datasetSnapshotId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsDatasetSnapshotId",
+ methodName: "OptionsDatasetSnapshotIdAsync",
+ pathTemplate: "$\"/v1/dataset_snapshot/{datasetSnapshotId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsDatasetSnapshotId",
+ methodName: "OptionsDatasetSnapshotIdAsync",
+ pathTemplate: "$\"/v1/dataset_snapshot/{datasetSnapshotId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
- {
- __response.EnsureSuccessStatusCode();
-
- }
- catch (global::System.Exception __ex)
+ response: __response);
+ ProcessOptionsDatasetSnapshotIdResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsDatasetSnapshotId",
+ methodName: "OptionsDatasetSnapshotIdAsync",
+ pathTemplate: "$\"/v1/dataset_snapshot/{datasetSnapshotId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
+ else
{
- __response.EnsureSuccessStatusCode();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsDatasetSnapshotId",
+ methodName: "OptionsDatasetSnapshotIdAsync",
+ pathTemplate: "$\"/v1/dataset_snapshot/{datasetSnapshotId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsEnvVar.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsEnvVar.g.cs
index 8ac2e65..880a6f6 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsEnvVar.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsEnvVar.g.cs
@@ -18,9 +18,11 @@ partial void ProcessOptionsEnvVarResponse(
/// Enable CORS (`/v1/env_var`)
/// Enable CORS
///
+ /// 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 OptionsEnvVarAsync(
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -28,142 +30,321 @@ partial void ProcessOptionsEnvVarResponse(
PrepareOptionsEnvVarArguments(
httpClient: HttpClient);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: "/v1/env_var",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: "/v1/env_var",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsEnvVarRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsEnvVarRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __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);
- ProcessOptionsEnvVarResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsEnvVar",
+ methodName: "OptionsEnvVarAsync",
+ pathTemplate: "\"/v1/env_var\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsEnvVar",
+ methodName: "OptionsEnvVarAsync",
+ pathTemplate: "\"/v1/env_var\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsEnvVar",
+ methodName: "OptionsEnvVarAsync",
+ pathTemplate: "\"/v1/env_var\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
+ response: __response);
+ ProcessOptionsEnvVarResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsEnvVar",
+ methodName: "OptionsEnvVarAsync",
+ pathTemplate: "\"/v1/env_var\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsEnvVar",
+ methodName: "OptionsEnvVarAsync",
+ pathTemplate: "\"/v1/env_var\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsEnvVarId.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsEnvVarId.g.cs
index fc31c72..f3df942 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsEnvVarId.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsEnvVarId.g.cs
@@ -23,10 +23,12 @@ partial void ProcessOptionsEnvVarIdResponse(
///
/// EnvVar id
///
+ /// 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 OptionsEnvVarIdAsync(
global::System.Guid envVarId,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -35,143 +37,322 @@ partial void ProcessOptionsEnvVarIdResponse(
httpClient: HttpClient,
envVarId: ref envVarId);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: $"/v1/env_var/{envVarId}",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: $"/v1/env_var/{envVarId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsEnvVarIdRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- envVarId: envVarId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsEnvVarIdRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ envVarId: envVarId);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessOptionsEnvVarIdResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsEnvVarId",
+ methodName: "OptionsEnvVarIdAsync",
+ pathTemplate: "$\"/v1/env_var/{envVarId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsEnvVarId",
+ methodName: "OptionsEnvVarIdAsync",
+ pathTemplate: "$\"/v1/env_var/{envVarId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsEnvVarId",
+ methodName: "OptionsEnvVarIdAsync",
+ pathTemplate: "$\"/v1/env_var/{envVarId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
- {
- __response.EnsureSuccessStatusCode();
-
- }
- catch (global::System.Exception __ex)
+ response: __response);
+ ProcessOptionsEnvVarIdResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsEnvVarId",
+ methodName: "OptionsEnvVarIdAsync",
+ pathTemplate: "$\"/v1/env_var/{envVarId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
+ else
{
- __response.EnsureSuccessStatusCode();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsEnvVarId",
+ methodName: "OptionsEnvVarIdAsync",
+ pathTemplate: "$\"/v1/env_var/{envVarId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsEvalStatusPage.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsEvalStatusPage.g.cs
index e71eba6..a1789b3 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsEvalStatusPage.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsEvalStatusPage.g.cs
@@ -18,9 +18,11 @@ partial void ProcessOptionsEvalStatusPageResponse(
/// Enable CORS (`/v1/eval_status_page`)
/// Enable CORS
///
+ /// 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 OptionsEvalStatusPageAsync(
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -28,142 +30,321 @@ partial void ProcessOptionsEvalStatusPageResponse(
PrepareOptionsEvalStatusPageArguments(
httpClient: HttpClient);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: "/v1/eval_status_page",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: "/v1/eval_status_page",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsEvalStatusPageRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsEvalStatusPageRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __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);
- ProcessOptionsEvalStatusPageResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsEvalStatusPage",
+ methodName: "OptionsEvalStatusPageAsync",
+ pathTemplate: "\"/v1/eval_status_page\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsEvalStatusPage",
+ methodName: "OptionsEvalStatusPageAsync",
+ pathTemplate: "\"/v1/eval_status_page\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsEvalStatusPage",
+ methodName: "OptionsEvalStatusPageAsync",
+ pathTemplate: "\"/v1/eval_status_page\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
+ response: __response);
+ ProcessOptionsEvalStatusPageResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsEvalStatusPage",
+ methodName: "OptionsEvalStatusPageAsync",
+ pathTemplate: "\"/v1/eval_status_page\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsEvalStatusPage",
+ methodName: "OptionsEvalStatusPageAsync",
+ pathTemplate: "\"/v1/eval_status_page\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsEvalStatusPageId.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsEvalStatusPageId.g.cs
index 1e55a53..0991609 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsEvalStatusPageId.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsEvalStatusPageId.g.cs
@@ -23,10 +23,12 @@ partial void ProcessOptionsEvalStatusPageIdResponse(
///
/// EvalStatusPage id
///
+ /// 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 OptionsEvalStatusPageIdAsync(
global::System.Guid evalStatusPageId,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -35,143 +37,322 @@ partial void ProcessOptionsEvalStatusPageIdResponse(
httpClient: HttpClient,
evalStatusPageId: ref evalStatusPageId);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: $"/v1/eval_status_page/{evalStatusPageId}",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: $"/v1/eval_status_page/{evalStatusPageId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsEvalStatusPageIdRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- evalStatusPageId: evalStatusPageId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsEvalStatusPageIdRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ evalStatusPageId: evalStatusPageId);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessOptionsEvalStatusPageIdResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsEvalStatusPageId",
+ methodName: "OptionsEvalStatusPageIdAsync",
+ pathTemplate: "$\"/v1/eval_status_page/{evalStatusPageId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsEvalStatusPageId",
+ methodName: "OptionsEvalStatusPageIdAsync",
+ pathTemplate: "$\"/v1/eval_status_page/{evalStatusPageId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsEvalStatusPageId",
+ methodName: "OptionsEvalStatusPageIdAsync",
+ pathTemplate: "$\"/v1/eval_status_page/{evalStatusPageId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
- {
- __response.EnsureSuccessStatusCode();
-
- }
- catch (global::System.Exception __ex)
+ response: __response);
+ ProcessOptionsEvalStatusPageIdResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsEvalStatusPageId",
+ methodName: "OptionsEvalStatusPageIdAsync",
+ pathTemplate: "$\"/v1/eval_status_page/{evalStatusPageId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
+ else
{
- __response.EnsureSuccessStatusCode();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsEvalStatusPageId",
+ methodName: "OptionsEvalStatusPageIdAsync",
+ pathTemplate: "$\"/v1/eval_status_page/{evalStatusPageId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsExperiment.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsExperiment.g.cs
index c821192..bd819cf 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsExperiment.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsExperiment.g.cs
@@ -18,9 +18,11 @@ partial void ProcessOptionsExperimentResponse(
/// Enable CORS (`/v1/experiment`)
/// Enable CORS
///
+ /// 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 OptionsExperimentAsync(
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -28,142 +30,321 @@ partial void ProcessOptionsExperimentResponse(
PrepareOptionsExperimentArguments(
httpClient: HttpClient);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: "/v1/experiment",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: "/v1/experiment",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsExperimentRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsExperimentRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __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);
- ProcessOptionsExperimentResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsExperiment",
+ methodName: "OptionsExperimentAsync",
+ pathTemplate: "\"/v1/experiment\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsExperiment",
+ methodName: "OptionsExperimentAsync",
+ pathTemplate: "\"/v1/experiment\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsExperiment",
+ methodName: "OptionsExperimentAsync",
+ pathTemplate: "\"/v1/experiment\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
+ response: __response);
+ ProcessOptionsExperimentResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsExperiment",
+ methodName: "OptionsExperimentAsync",
+ pathTemplate: "\"/v1/experiment\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsExperiment",
+ methodName: "OptionsExperimentAsync",
+ pathTemplate: "\"/v1/experiment\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsExperimentId.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsExperimentId.g.cs
index 4658763..debd5a4 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsExperimentId.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsExperimentId.g.cs
@@ -23,10 +23,12 @@ partial void ProcessOptionsExperimentIdResponse(
///
/// Experiment id
///
+ /// 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 OptionsExperimentIdAsync(
global::System.Guid experimentId,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -35,143 +37,322 @@ partial void ProcessOptionsExperimentIdResponse(
httpClient: HttpClient,
experimentId: ref experimentId);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: $"/v1/experiment/{experimentId}",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: $"/v1/experiment/{experimentId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsExperimentIdRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- experimentId: experimentId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsExperimentIdRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ experimentId: experimentId);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessOptionsExperimentIdResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsExperimentId",
+ methodName: "OptionsExperimentIdAsync",
+ pathTemplate: "$\"/v1/experiment/{experimentId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsExperimentId",
+ methodName: "OptionsExperimentIdAsync",
+ pathTemplate: "$\"/v1/experiment/{experimentId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsExperimentId",
+ methodName: "OptionsExperimentIdAsync",
+ pathTemplate: "$\"/v1/experiment/{experimentId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
- {
- __response.EnsureSuccessStatusCode();
-
- }
- catch (global::System.Exception __ex)
+ response: __response);
+ ProcessOptionsExperimentIdResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsExperimentId",
+ methodName: "OptionsExperimentIdAsync",
+ pathTemplate: "$\"/v1/experiment/{experimentId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
+ else
{
- __response.EnsureSuccessStatusCode();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsExperimentId",
+ methodName: "OptionsExperimentIdAsync",
+ pathTemplate: "$\"/v1/experiment/{experimentId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsExperimentIdFeedback.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsExperimentIdFeedback.g.cs
index 76cf3a9..77f7b37 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsExperimentIdFeedback.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsExperimentIdFeedback.g.cs
@@ -23,10 +23,12 @@ partial void ProcessOptionsExperimentIdFeedbackResponse(
///
/// Experiment id
///
+ /// 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 OptionsExperimentIdFeedbackAsync(
global::System.Guid experimentId,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -35,143 +37,322 @@ partial void ProcessOptionsExperimentIdFeedbackResponse(
httpClient: HttpClient,
experimentId: ref experimentId);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: $"/v1/experiment/{experimentId}/feedback",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: $"/v1/experiment/{experimentId}/feedback",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsExperimentIdFeedbackRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- experimentId: experimentId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsExperimentIdFeedbackRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ experimentId: experimentId);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessOptionsExperimentIdFeedbackResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsExperimentIdFeedback",
+ methodName: "OptionsExperimentIdFeedbackAsync",
+ pathTemplate: "$\"/v1/experiment/{experimentId}/feedback\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsExperimentIdFeedback",
+ methodName: "OptionsExperimentIdFeedbackAsync",
+ pathTemplate: "$\"/v1/experiment/{experimentId}/feedback\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsExperimentIdFeedback",
+ methodName: "OptionsExperimentIdFeedbackAsync",
+ pathTemplate: "$\"/v1/experiment/{experimentId}/feedback\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
- {
- __response.EnsureSuccessStatusCode();
-
- }
- catch (global::System.Exception __ex)
+ response: __response);
+ ProcessOptionsExperimentIdFeedbackResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsExperimentIdFeedback",
+ methodName: "OptionsExperimentIdFeedbackAsync",
+ pathTemplate: "$\"/v1/experiment/{experimentId}/feedback\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
+ else
{
- __response.EnsureSuccessStatusCode();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsExperimentIdFeedback",
+ methodName: "OptionsExperimentIdFeedbackAsync",
+ pathTemplate: "$\"/v1/experiment/{experimentId}/feedback\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsExperimentIdFetch.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsExperimentIdFetch.g.cs
index a2965d0..6dce191 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsExperimentIdFetch.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsExperimentIdFetch.g.cs
@@ -23,10 +23,12 @@ partial void ProcessOptionsExperimentIdFetchResponse(
///
/// Experiment id
///
+ /// 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 OptionsExperimentIdFetchAsync(
global::System.Guid experimentId,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -35,143 +37,322 @@ partial void ProcessOptionsExperimentIdFetchResponse(
httpClient: HttpClient,
experimentId: ref experimentId);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: $"/v1/experiment/{experimentId}/fetch",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: $"/v1/experiment/{experimentId}/fetch",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsExperimentIdFetchRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- experimentId: experimentId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsExperimentIdFetchRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ experimentId: experimentId);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessOptionsExperimentIdFetchResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsExperimentIdFetch",
+ methodName: "OptionsExperimentIdFetchAsync",
+ pathTemplate: "$\"/v1/experiment/{experimentId}/fetch\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsExperimentIdFetch",
+ methodName: "OptionsExperimentIdFetchAsync",
+ pathTemplate: "$\"/v1/experiment/{experimentId}/fetch\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsExperimentIdFetch",
+ methodName: "OptionsExperimentIdFetchAsync",
+ pathTemplate: "$\"/v1/experiment/{experimentId}/fetch\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
- {
- __response.EnsureSuccessStatusCode();
-
- }
- catch (global::System.Exception __ex)
+ response: __response);
+ ProcessOptionsExperimentIdFetchResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsExperimentIdFetch",
+ methodName: "OptionsExperimentIdFetchAsync",
+ pathTemplate: "$\"/v1/experiment/{experimentId}/fetch\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
+ else
{
- __response.EnsureSuccessStatusCode();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsExperimentIdFetch",
+ methodName: "OptionsExperimentIdFetchAsync",
+ pathTemplate: "$\"/v1/experiment/{experimentId}/fetch\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsExperimentIdInsert.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsExperimentIdInsert.g.cs
index d3791c3..500bdce 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsExperimentIdInsert.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsExperimentIdInsert.g.cs
@@ -23,10 +23,12 @@ partial void ProcessOptionsExperimentIdInsertResponse(
///
/// Experiment id
///
+ /// 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 OptionsExperimentIdInsertAsync(
global::System.Guid experimentId,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -35,143 +37,322 @@ partial void ProcessOptionsExperimentIdInsertResponse(
httpClient: HttpClient,
experimentId: ref experimentId);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: $"/v1/experiment/{experimentId}/insert",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: $"/v1/experiment/{experimentId}/insert",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsExperimentIdInsertRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- experimentId: experimentId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsExperimentIdInsertRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ experimentId: experimentId);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessOptionsExperimentIdInsertResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsExperimentIdInsert",
+ methodName: "OptionsExperimentIdInsertAsync",
+ pathTemplate: "$\"/v1/experiment/{experimentId}/insert\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsExperimentIdInsert",
+ methodName: "OptionsExperimentIdInsertAsync",
+ pathTemplate: "$\"/v1/experiment/{experimentId}/insert\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsExperimentIdInsert",
+ methodName: "OptionsExperimentIdInsertAsync",
+ pathTemplate: "$\"/v1/experiment/{experimentId}/insert\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
- {
- __response.EnsureSuccessStatusCode();
-
- }
- catch (global::System.Exception __ex)
+ response: __response);
+ ProcessOptionsExperimentIdInsertResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsExperimentIdInsert",
+ methodName: "OptionsExperimentIdInsertAsync",
+ pathTemplate: "$\"/v1/experiment/{experimentId}/insert\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
+ else
{
- __response.EnsureSuccessStatusCode();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsExperimentIdInsert",
+ methodName: "OptionsExperimentIdInsertAsync",
+ pathTemplate: "$\"/v1/experiment/{experimentId}/insert\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsExperimentIdSummarize.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsExperimentIdSummarize.g.cs
index 63a7996..3334abb 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsExperimentIdSummarize.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsExperimentIdSummarize.g.cs
@@ -23,10 +23,12 @@ partial void ProcessOptionsExperimentIdSummarizeResponse(
///
/// Experiment id
///
+ /// 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 OptionsExperimentIdSummarizeAsync(
global::System.Guid experimentId,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -35,143 +37,322 @@ partial void ProcessOptionsExperimentIdSummarizeResponse(
httpClient: HttpClient,
experimentId: ref experimentId);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: $"/v1/experiment/{experimentId}/summarize",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: $"/v1/experiment/{experimentId}/summarize",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsExperimentIdSummarizeRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- experimentId: experimentId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsExperimentIdSummarizeRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ experimentId: experimentId);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessOptionsExperimentIdSummarizeResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsExperimentIdSummarize",
+ methodName: "OptionsExperimentIdSummarizeAsync",
+ pathTemplate: "$\"/v1/experiment/{experimentId}/summarize\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsExperimentIdSummarize",
+ methodName: "OptionsExperimentIdSummarizeAsync",
+ pathTemplate: "$\"/v1/experiment/{experimentId}/summarize\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsExperimentIdSummarize",
+ methodName: "OptionsExperimentIdSummarizeAsync",
+ pathTemplate: "$\"/v1/experiment/{experimentId}/summarize\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
- {
- __response.EnsureSuccessStatusCode();
-
- }
- catch (global::System.Exception __ex)
+ response: __response);
+ ProcessOptionsExperimentIdSummarizeResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsExperimentIdSummarize",
+ methodName: "OptionsExperimentIdSummarizeAsync",
+ pathTemplate: "$\"/v1/experiment/{experimentId}/summarize\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
+ else
{
- __response.EnsureSuccessStatusCode();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsExperimentIdSummarize",
+ methodName: "OptionsExperimentIdSummarizeAsync",
+ pathTemplate: "$\"/v1/experiment/{experimentId}/summarize\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsFunction.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsFunction.g.cs
index 64c65ad..38927e2 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsFunction.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsFunction.g.cs
@@ -18,9 +18,11 @@ partial void ProcessOptionsFunctionResponse(
/// Enable CORS (`/v1/function`)
/// Enable CORS
///
+ /// 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 OptionsFunctionAsync(
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -28,142 +30,321 @@ partial void ProcessOptionsFunctionResponse(
PrepareOptionsFunctionArguments(
httpClient: HttpClient);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: "/v1/function",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: "/v1/function",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsFunctionRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsFunctionRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __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);
- ProcessOptionsFunctionResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsFunction",
+ methodName: "OptionsFunctionAsync",
+ pathTemplate: "\"/v1/function\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsFunction",
+ methodName: "OptionsFunctionAsync",
+ pathTemplate: "\"/v1/function\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsFunction",
+ methodName: "OptionsFunctionAsync",
+ pathTemplate: "\"/v1/function\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
+ response: __response);
+ ProcessOptionsFunctionResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsFunction",
+ methodName: "OptionsFunctionAsync",
+ pathTemplate: "\"/v1/function\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsFunction",
+ methodName: "OptionsFunctionAsync",
+ pathTemplate: "\"/v1/function\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsFunctionId.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsFunctionId.g.cs
index 726dc7e..236b52e 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsFunctionId.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsFunctionId.g.cs
@@ -23,10 +23,12 @@ partial void ProcessOptionsFunctionIdResponse(
///
/// Function id
///
+ /// 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 OptionsFunctionIdAsync(
global::System.Guid functionId,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -35,143 +37,322 @@ partial void ProcessOptionsFunctionIdResponse(
httpClient: HttpClient,
functionId: ref functionId);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: $"/v1/function/{functionId}",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: $"/v1/function/{functionId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsFunctionIdRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- functionId: functionId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsFunctionIdRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ functionId: functionId);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessOptionsFunctionIdResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsFunctionId",
+ methodName: "OptionsFunctionIdAsync",
+ pathTemplate: "$\"/v1/function/{functionId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsFunctionId",
+ methodName: "OptionsFunctionIdAsync",
+ pathTemplate: "$\"/v1/function/{functionId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsFunctionId",
+ methodName: "OptionsFunctionIdAsync",
+ pathTemplate: "$\"/v1/function/{functionId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
- {
- __response.EnsureSuccessStatusCode();
-
- }
- catch (global::System.Exception __ex)
+ response: __response);
+ ProcessOptionsFunctionIdResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsFunctionId",
+ methodName: "OptionsFunctionIdAsync",
+ pathTemplate: "$\"/v1/function/{functionId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
+ else
{
- __response.EnsureSuccessStatusCode();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsFunctionId",
+ methodName: "OptionsFunctionIdAsync",
+ pathTemplate: "$\"/v1/function/{functionId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsFunctionIdInvoke.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsFunctionIdInvoke.g.cs
index 0264c22..5cf794f 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsFunctionIdInvoke.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsFunctionIdInvoke.g.cs
@@ -23,10 +23,12 @@ partial void ProcessOptionsFunctionIdInvokeResponse(
///
/// Function id
///
+ /// 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 OptionsFunctionIdInvokeAsync(
global::System.Guid functionId,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -35,143 +37,322 @@ partial void ProcessOptionsFunctionIdInvokeResponse(
httpClient: HttpClient,
functionId: ref functionId);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: $"/v1/function/{functionId}/invoke",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: $"/v1/function/{functionId}/invoke",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsFunctionIdInvokeRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- functionId: functionId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsFunctionIdInvokeRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ functionId: functionId);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessOptionsFunctionIdInvokeResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsFunctionIdInvoke",
+ methodName: "OptionsFunctionIdInvokeAsync",
+ pathTemplate: "$\"/v1/function/{functionId}/invoke\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsFunctionIdInvoke",
+ methodName: "OptionsFunctionIdInvokeAsync",
+ pathTemplate: "$\"/v1/function/{functionId}/invoke\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsFunctionIdInvoke",
+ methodName: "OptionsFunctionIdInvokeAsync",
+ pathTemplate: "$\"/v1/function/{functionId}/invoke\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
- {
- __response.EnsureSuccessStatusCode();
-
- }
- catch (global::System.Exception __ex)
+ response: __response);
+ ProcessOptionsFunctionIdInvokeResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsFunctionIdInvoke",
+ methodName: "OptionsFunctionIdInvokeAsync",
+ pathTemplate: "$\"/v1/function/{functionId}/invoke\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
+ else
{
- __response.EnsureSuccessStatusCode();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsFunctionIdInvoke",
+ methodName: "OptionsFunctionIdInvokeAsync",
+ pathTemplate: "$\"/v1/function/{functionId}/invoke\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsGroup.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsGroup.g.cs
index 6a0af48..9421d8d 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsGroup.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsGroup.g.cs
@@ -18,9 +18,11 @@ partial void ProcessOptionsGroupResponse(
/// Enable CORS (`/v1/group`)
/// Enable CORS
///
+ /// 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 OptionsGroupAsync(
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -28,142 +30,321 @@ partial void ProcessOptionsGroupResponse(
PrepareOptionsGroupArguments(
httpClient: HttpClient);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: "/v1/group",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: "/v1/group",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsGroupRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsGroupRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __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);
- ProcessOptionsGroupResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsGroup",
+ methodName: "OptionsGroupAsync",
+ pathTemplate: "\"/v1/group\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsGroup",
+ methodName: "OptionsGroupAsync",
+ pathTemplate: "\"/v1/group\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsGroup",
+ methodName: "OptionsGroupAsync",
+ pathTemplate: "\"/v1/group\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
+ response: __response);
+ ProcessOptionsGroupResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsGroup",
+ methodName: "OptionsGroupAsync",
+ pathTemplate: "\"/v1/group\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsGroup",
+ methodName: "OptionsGroupAsync",
+ pathTemplate: "\"/v1/group\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsGroupId.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsGroupId.g.cs
index 60eecb9..1419dff 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsGroupId.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsGroupId.g.cs
@@ -23,10 +23,12 @@ partial void ProcessOptionsGroupIdResponse(
///
/// Group id
///
+ /// 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 OptionsGroupIdAsync(
global::System.Guid groupId,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -35,143 +37,322 @@ partial void ProcessOptionsGroupIdResponse(
httpClient: HttpClient,
groupId: ref groupId);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: $"/v1/group/{groupId}",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: $"/v1/group/{groupId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsGroupIdRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- groupId: groupId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsGroupIdRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ groupId: groupId);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessOptionsGroupIdResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsGroupId",
+ methodName: "OptionsGroupIdAsync",
+ pathTemplate: "$\"/v1/group/{groupId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsGroupId",
+ methodName: "OptionsGroupIdAsync",
+ pathTemplate: "$\"/v1/group/{groupId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsGroupId",
+ methodName: "OptionsGroupIdAsync",
+ pathTemplate: "$\"/v1/group/{groupId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
- {
- __response.EnsureSuccessStatusCode();
-
- }
- catch (global::System.Exception __ex)
+ response: __response);
+ ProcessOptionsGroupIdResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsGroupId",
+ methodName: "OptionsGroupIdAsync",
+ pathTemplate: "$\"/v1/group/{groupId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
+ else
{
- __response.EnsureSuccessStatusCode();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsGroupId",
+ methodName: "OptionsGroupIdAsync",
+ pathTemplate: "$\"/v1/group/{groupId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsIndex.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsIndex.g.cs
index ab29ec3..26961c3 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsIndex.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsIndex.g.cs
@@ -18,9 +18,11 @@ partial void ProcessOptionsIndexResponse(
/// Enable CORS (`/v1`)
/// Enable CORS
///
+ /// 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 OptionsIndexAsync(
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -28,142 +30,321 @@ partial void ProcessOptionsIndexResponse(
PrepareOptionsIndexArguments(
httpClient: HttpClient);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: "/v1",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: "/v1",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsIndexRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsIndexRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __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);
- ProcessOptionsIndexResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsIndex",
+ methodName: "OptionsIndexAsync",
+ pathTemplate: "\"/v1\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsIndex",
+ methodName: "OptionsIndexAsync",
+ pathTemplate: "\"/v1\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsIndex",
+ methodName: "OptionsIndexAsync",
+ pathTemplate: "\"/v1\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
+ response: __response);
+ ProcessOptionsIndexResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsIndex",
+ methodName: "OptionsIndexAsync",
+ pathTemplate: "\"/v1\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsIndex",
+ methodName: "OptionsIndexAsync",
+ pathTemplate: "\"/v1\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsMcpServer.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsMcpServer.g.cs
index 1f3fd79..fd22452 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsMcpServer.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsMcpServer.g.cs
@@ -18,9 +18,11 @@ partial void ProcessOptionsMcpServerResponse(
/// Enable CORS (`/v1/mcp_server`)
/// Enable CORS
///
+ /// 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 OptionsMcpServerAsync(
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -28,142 +30,321 @@ partial void ProcessOptionsMcpServerResponse(
PrepareOptionsMcpServerArguments(
httpClient: HttpClient);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: "/v1/mcp_server",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: "/v1/mcp_server",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsMcpServerRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsMcpServerRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __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);
- ProcessOptionsMcpServerResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsMcpServer",
+ methodName: "OptionsMcpServerAsync",
+ pathTemplate: "\"/v1/mcp_server\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsMcpServer",
+ methodName: "OptionsMcpServerAsync",
+ pathTemplate: "\"/v1/mcp_server\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsMcpServer",
+ methodName: "OptionsMcpServerAsync",
+ pathTemplate: "\"/v1/mcp_server\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
+ response: __response);
+ ProcessOptionsMcpServerResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsMcpServer",
+ methodName: "OptionsMcpServerAsync",
+ pathTemplate: "\"/v1/mcp_server\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsMcpServer",
+ methodName: "OptionsMcpServerAsync",
+ pathTemplate: "\"/v1/mcp_server\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsMcpServerId.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsMcpServerId.g.cs
index d26d418..8f259a4 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsMcpServerId.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsMcpServerId.g.cs
@@ -23,10 +23,12 @@ partial void ProcessOptionsMcpServerIdResponse(
///
/// McpServer id
///
+ /// 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 OptionsMcpServerIdAsync(
global::System.Guid mcpServerId,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -35,143 +37,322 @@ partial void ProcessOptionsMcpServerIdResponse(
httpClient: HttpClient,
mcpServerId: ref mcpServerId);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: $"/v1/mcp_server/{mcpServerId}",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: $"/v1/mcp_server/{mcpServerId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsMcpServerIdRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- mcpServerId: mcpServerId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsMcpServerIdRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ mcpServerId: mcpServerId);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessOptionsMcpServerIdResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsMcpServerId",
+ methodName: "OptionsMcpServerIdAsync",
+ pathTemplate: "$\"/v1/mcp_server/{mcpServerId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsMcpServerId",
+ methodName: "OptionsMcpServerIdAsync",
+ pathTemplate: "$\"/v1/mcp_server/{mcpServerId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsMcpServerId",
+ methodName: "OptionsMcpServerIdAsync",
+ pathTemplate: "$\"/v1/mcp_server/{mcpServerId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
- {
- __response.EnsureSuccessStatusCode();
-
- }
- catch (global::System.Exception __ex)
+ response: __response);
+ ProcessOptionsMcpServerIdResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsMcpServerId",
+ methodName: "OptionsMcpServerIdAsync",
+ pathTemplate: "$\"/v1/mcp_server/{mcpServerId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
+ else
{
- __response.EnsureSuccessStatusCode();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsMcpServerId",
+ methodName: "OptionsMcpServerIdAsync",
+ pathTemplate: "$\"/v1/mcp_server/{mcpServerId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsOrganization.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsOrganization.g.cs
index 5e8ec93..695eae0 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsOrganization.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsOrganization.g.cs
@@ -18,9 +18,11 @@ partial void ProcessOptionsOrganizationResponse(
/// Enable CORS (`/v1/organization`)
/// Enable CORS
///
+ /// 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 OptionsOrganizationAsync(
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -28,142 +30,321 @@ partial void ProcessOptionsOrganizationResponse(
PrepareOptionsOrganizationArguments(
httpClient: HttpClient);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: "/v1/organization",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: "/v1/organization",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsOrganizationRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsOrganizationRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __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);
- ProcessOptionsOrganizationResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsOrganization",
+ methodName: "OptionsOrganizationAsync",
+ pathTemplate: "\"/v1/organization\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsOrganization",
+ methodName: "OptionsOrganizationAsync",
+ pathTemplate: "\"/v1/organization\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsOrganization",
+ methodName: "OptionsOrganizationAsync",
+ pathTemplate: "\"/v1/organization\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
+ response: __response);
+ ProcessOptionsOrganizationResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsOrganization",
+ methodName: "OptionsOrganizationAsync",
+ pathTemplate: "\"/v1/organization\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsOrganization",
+ methodName: "OptionsOrganizationAsync",
+ pathTemplate: "\"/v1/organization\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsOrganizationId.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsOrganizationId.g.cs
index 591d9fb..9ec76c7 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsOrganizationId.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsOrganizationId.g.cs
@@ -23,10 +23,12 @@ partial void ProcessOptionsOrganizationIdResponse(
///
/// Organization id
///
+ /// 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 OptionsOrganizationIdAsync(
global::System.Guid organizationId,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -35,143 +37,322 @@ partial void ProcessOptionsOrganizationIdResponse(
httpClient: HttpClient,
organizationId: ref organizationId);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: $"/v1/organization/{organizationId}",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: $"/v1/organization/{organizationId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsOrganizationIdRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- organizationId: organizationId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsOrganizationIdRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ organizationId: organizationId);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessOptionsOrganizationIdResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsOrganizationId",
+ methodName: "OptionsOrganizationIdAsync",
+ pathTemplate: "$\"/v1/organization/{organizationId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsOrganizationId",
+ methodName: "OptionsOrganizationIdAsync",
+ pathTemplate: "$\"/v1/organization/{organizationId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsOrganizationId",
+ methodName: "OptionsOrganizationIdAsync",
+ pathTemplate: "$\"/v1/organization/{organizationId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
- {
- __response.EnsureSuccessStatusCode();
-
- }
- catch (global::System.Exception __ex)
+ response: __response);
+ ProcessOptionsOrganizationIdResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsOrganizationId",
+ methodName: "OptionsOrganizationIdAsync",
+ pathTemplate: "$\"/v1/organization/{organizationId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
+ else
{
- __response.EnsureSuccessStatusCode();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsOrganizationId",
+ methodName: "OptionsOrganizationIdAsync",
+ pathTemplate: "$\"/v1/organization/{organizationId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsOrganizationMembers.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsOrganizationMembers.g.cs
index 7446678..3ae0599 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsOrganizationMembers.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsOrganizationMembers.g.cs
@@ -18,9 +18,11 @@ partial void ProcessOptionsOrganizationMembersResponse(
/// Enable CORS (`/v1/organization/members`)
/// Enable CORS
///
+ /// 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 OptionsOrganizationMembersAsync(
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -28,142 +30,321 @@ partial void ProcessOptionsOrganizationMembersResponse(
PrepareOptionsOrganizationMembersArguments(
httpClient: HttpClient);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: "/v1/organization/members",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: "/v1/organization/members",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsOrganizationMembersRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsOrganizationMembersRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __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);
- ProcessOptionsOrganizationMembersResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsOrganizationMembers",
+ methodName: "OptionsOrganizationMembersAsync",
+ pathTemplate: "\"/v1/organization/members\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsOrganizationMembers",
+ methodName: "OptionsOrganizationMembersAsync",
+ pathTemplate: "\"/v1/organization/members\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsOrganizationMembers",
+ methodName: "OptionsOrganizationMembersAsync",
+ pathTemplate: "\"/v1/organization/members\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
+ response: __response);
+ ProcessOptionsOrganizationMembersResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsOrganizationMembers",
+ methodName: "OptionsOrganizationMembersAsync",
+ pathTemplate: "\"/v1/organization/members\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsOrganizationMembers",
+ methodName: "OptionsOrganizationMembersAsync",
+ pathTemplate: "\"/v1/organization/members\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsProject.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsProject.g.cs
index b1cc572..d7f9dff 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsProject.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsProject.g.cs
@@ -18,9 +18,11 @@ partial void ProcessOptionsProjectResponse(
/// Enable CORS (`/v1/project`)
/// Enable CORS
///
+ /// 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 OptionsProjectAsync(
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -28,142 +30,321 @@ partial void ProcessOptionsProjectResponse(
PrepareOptionsProjectArguments(
httpClient: HttpClient);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: "/v1/project",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: "/v1/project",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsProjectRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsProjectRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __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);
- ProcessOptionsProjectResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProject",
+ methodName: "OptionsProjectAsync",
+ pathTemplate: "\"/v1/project\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProject",
+ methodName: "OptionsProjectAsync",
+ pathTemplate: "\"/v1/project\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProject",
+ methodName: "OptionsProjectAsync",
+ pathTemplate: "\"/v1/project\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
+ response: __response);
+ ProcessOptionsProjectResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProject",
+ methodName: "OptionsProjectAsync",
+ pathTemplate: "\"/v1/project\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProject",
+ methodName: "OptionsProjectAsync",
+ pathTemplate: "\"/v1/project\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsProjectAutomation.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsProjectAutomation.g.cs
index 59790ac..5bc3f23 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsProjectAutomation.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsProjectAutomation.g.cs
@@ -18,9 +18,11 @@ partial void ProcessOptionsProjectAutomationResponse(
/// Enable CORS (`/v1/project_automation`)
/// Enable CORS
///
+ /// 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 OptionsProjectAutomationAsync(
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -28,142 +30,321 @@ partial void ProcessOptionsProjectAutomationResponse(
PrepareOptionsProjectAutomationArguments(
httpClient: HttpClient);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: "/v1/project_automation",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: "/v1/project_automation",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsProjectAutomationRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsProjectAutomationRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __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);
- ProcessOptionsProjectAutomationResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProjectAutomation",
+ methodName: "OptionsProjectAutomationAsync",
+ pathTemplate: "\"/v1/project_automation\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProjectAutomation",
+ methodName: "OptionsProjectAutomationAsync",
+ pathTemplate: "\"/v1/project_automation\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProjectAutomation",
+ methodName: "OptionsProjectAutomationAsync",
+ pathTemplate: "\"/v1/project_automation\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
+ response: __response);
+ ProcessOptionsProjectAutomationResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProjectAutomation",
+ methodName: "OptionsProjectAutomationAsync",
+ pathTemplate: "\"/v1/project_automation\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProjectAutomation",
+ methodName: "OptionsProjectAutomationAsync",
+ pathTemplate: "\"/v1/project_automation\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsProjectAutomationId.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsProjectAutomationId.g.cs
index 3997631..adbb970 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsProjectAutomationId.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsProjectAutomationId.g.cs
@@ -23,10 +23,12 @@ partial void ProcessOptionsProjectAutomationIdResponse(
///
/// ProjectAutomation id
///
+ /// 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 OptionsProjectAutomationIdAsync(
global::System.Guid projectAutomationId,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -35,143 +37,322 @@ partial void ProcessOptionsProjectAutomationIdResponse(
httpClient: HttpClient,
projectAutomationId: ref projectAutomationId);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: $"/v1/project_automation/{projectAutomationId}",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: $"/v1/project_automation/{projectAutomationId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsProjectAutomationIdRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- projectAutomationId: projectAutomationId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsProjectAutomationIdRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ projectAutomationId: projectAutomationId);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessOptionsProjectAutomationIdResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProjectAutomationId",
+ methodName: "OptionsProjectAutomationIdAsync",
+ pathTemplate: "$\"/v1/project_automation/{projectAutomationId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProjectAutomationId",
+ methodName: "OptionsProjectAutomationIdAsync",
+ pathTemplate: "$\"/v1/project_automation/{projectAutomationId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProjectAutomationId",
+ methodName: "OptionsProjectAutomationIdAsync",
+ pathTemplate: "$\"/v1/project_automation/{projectAutomationId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
- {
- __response.EnsureSuccessStatusCode();
-
- }
- catch (global::System.Exception __ex)
+ response: __response);
+ ProcessOptionsProjectAutomationIdResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProjectAutomationId",
+ methodName: "OptionsProjectAutomationIdAsync",
+ pathTemplate: "$\"/v1/project_automation/{projectAutomationId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
+ else
{
- __response.EnsureSuccessStatusCode();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProjectAutomationId",
+ methodName: "OptionsProjectAutomationIdAsync",
+ pathTemplate: "$\"/v1/project_automation/{projectAutomationId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsProjectId.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsProjectId.g.cs
index 8d94986..0b06eaa 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsProjectId.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsProjectId.g.cs
@@ -23,10 +23,12 @@ partial void ProcessOptionsProjectIdResponse(
///
/// Project id
///
+ /// 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 OptionsProjectIdAsync(
global::System.Guid projectId,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -35,143 +37,322 @@ partial void ProcessOptionsProjectIdResponse(
httpClient: HttpClient,
projectId: ref projectId);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: $"/v1/project/{projectId}",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: $"/v1/project/{projectId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsProjectIdRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- projectId: projectId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsProjectIdRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ projectId: projectId);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessOptionsProjectIdResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProjectId",
+ methodName: "OptionsProjectIdAsync",
+ pathTemplate: "$\"/v1/project/{projectId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProjectId",
+ methodName: "OptionsProjectIdAsync",
+ pathTemplate: "$\"/v1/project/{projectId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProjectId",
+ methodName: "OptionsProjectIdAsync",
+ pathTemplate: "$\"/v1/project/{projectId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
- {
- __response.EnsureSuccessStatusCode();
-
- }
- catch (global::System.Exception __ex)
+ response: __response);
+ ProcessOptionsProjectIdResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProjectId",
+ methodName: "OptionsProjectIdAsync",
+ pathTemplate: "$\"/v1/project/{projectId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
+ else
{
- __response.EnsureSuccessStatusCode();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProjectId",
+ methodName: "OptionsProjectIdAsync",
+ pathTemplate: "$\"/v1/project/{projectId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsProjectLogsIdFeedback.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsProjectLogsIdFeedback.g.cs
index 8521ad4..8f1ad5e 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsProjectLogsIdFeedback.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsProjectLogsIdFeedback.g.cs
@@ -23,10 +23,12 @@ partial void ProcessOptionsProjectLogsIdFeedbackResponse(
///
/// Project id
///
+ /// 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 OptionsProjectLogsIdFeedbackAsync(
global::System.Guid projectId,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -35,143 +37,322 @@ partial void ProcessOptionsProjectLogsIdFeedbackResponse(
httpClient: HttpClient,
projectId: ref projectId);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: $"/v1/project_logs/{projectId}/feedback",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: $"/v1/project_logs/{projectId}/feedback",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsProjectLogsIdFeedbackRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- projectId: projectId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsProjectLogsIdFeedbackRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ projectId: projectId);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessOptionsProjectLogsIdFeedbackResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProjectLogsIdFeedback",
+ methodName: "OptionsProjectLogsIdFeedbackAsync",
+ pathTemplate: "$\"/v1/project_logs/{projectId}/feedback\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProjectLogsIdFeedback",
+ methodName: "OptionsProjectLogsIdFeedbackAsync",
+ pathTemplate: "$\"/v1/project_logs/{projectId}/feedback\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProjectLogsIdFeedback",
+ methodName: "OptionsProjectLogsIdFeedbackAsync",
+ pathTemplate: "$\"/v1/project_logs/{projectId}/feedback\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
- {
- __response.EnsureSuccessStatusCode();
-
- }
- catch (global::System.Exception __ex)
+ response: __response);
+ ProcessOptionsProjectLogsIdFeedbackResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProjectLogsIdFeedback",
+ methodName: "OptionsProjectLogsIdFeedbackAsync",
+ pathTemplate: "$\"/v1/project_logs/{projectId}/feedback\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
+ else
{
- __response.EnsureSuccessStatusCode();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProjectLogsIdFeedback",
+ methodName: "OptionsProjectLogsIdFeedbackAsync",
+ pathTemplate: "$\"/v1/project_logs/{projectId}/feedback\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsProjectLogsIdFetch.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsProjectLogsIdFetch.g.cs
index ff38c4e..c13bbf3 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsProjectLogsIdFetch.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsProjectLogsIdFetch.g.cs
@@ -23,10 +23,12 @@ partial void ProcessOptionsProjectLogsIdFetchResponse(
///
/// Project id
///
+ /// 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 OptionsProjectLogsIdFetchAsync(
global::System.Guid projectId,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -35,143 +37,322 @@ partial void ProcessOptionsProjectLogsIdFetchResponse(
httpClient: HttpClient,
projectId: ref projectId);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: $"/v1/project_logs/{projectId}/fetch",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: $"/v1/project_logs/{projectId}/fetch",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsProjectLogsIdFetchRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- projectId: projectId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsProjectLogsIdFetchRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ projectId: projectId);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessOptionsProjectLogsIdFetchResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProjectLogsIdFetch",
+ methodName: "OptionsProjectLogsIdFetchAsync",
+ pathTemplate: "$\"/v1/project_logs/{projectId}/fetch\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProjectLogsIdFetch",
+ methodName: "OptionsProjectLogsIdFetchAsync",
+ pathTemplate: "$\"/v1/project_logs/{projectId}/fetch\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProjectLogsIdFetch",
+ methodName: "OptionsProjectLogsIdFetchAsync",
+ pathTemplate: "$\"/v1/project_logs/{projectId}/fetch\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
- {
- __response.EnsureSuccessStatusCode();
-
- }
- catch (global::System.Exception __ex)
+ response: __response);
+ ProcessOptionsProjectLogsIdFetchResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProjectLogsIdFetch",
+ methodName: "OptionsProjectLogsIdFetchAsync",
+ pathTemplate: "$\"/v1/project_logs/{projectId}/fetch\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
+ else
{
- __response.EnsureSuccessStatusCode();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProjectLogsIdFetch",
+ methodName: "OptionsProjectLogsIdFetchAsync",
+ pathTemplate: "$\"/v1/project_logs/{projectId}/fetch\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsProjectLogsIdInsert.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsProjectLogsIdInsert.g.cs
index fcedeac..ee8fdeb 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsProjectLogsIdInsert.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsProjectLogsIdInsert.g.cs
@@ -23,10 +23,12 @@ partial void ProcessOptionsProjectLogsIdInsertResponse(
///
/// Project id
///
+ /// 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 OptionsProjectLogsIdInsertAsync(
global::System.Guid projectId,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -35,143 +37,322 @@ partial void ProcessOptionsProjectLogsIdInsertResponse(
httpClient: HttpClient,
projectId: ref projectId);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: $"/v1/project_logs/{projectId}/insert",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: $"/v1/project_logs/{projectId}/insert",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsProjectLogsIdInsertRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- projectId: projectId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsProjectLogsIdInsertRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ projectId: projectId);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessOptionsProjectLogsIdInsertResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProjectLogsIdInsert",
+ methodName: "OptionsProjectLogsIdInsertAsync",
+ pathTemplate: "$\"/v1/project_logs/{projectId}/insert\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProjectLogsIdInsert",
+ methodName: "OptionsProjectLogsIdInsertAsync",
+ pathTemplate: "$\"/v1/project_logs/{projectId}/insert\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProjectLogsIdInsert",
+ methodName: "OptionsProjectLogsIdInsertAsync",
+ pathTemplate: "$\"/v1/project_logs/{projectId}/insert\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
- {
- __response.EnsureSuccessStatusCode();
-
- }
- catch (global::System.Exception __ex)
+ response: __response);
+ ProcessOptionsProjectLogsIdInsertResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProjectLogsIdInsert",
+ methodName: "OptionsProjectLogsIdInsertAsync",
+ pathTemplate: "$\"/v1/project_logs/{projectId}/insert\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
+ else
{
- __response.EnsureSuccessStatusCode();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProjectLogsIdInsert",
+ methodName: "OptionsProjectLogsIdInsertAsync",
+ pathTemplate: "$\"/v1/project_logs/{projectId}/insert\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsProjectScore.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsProjectScore.g.cs
index 59cbce4..df01f2f 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsProjectScore.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsProjectScore.g.cs
@@ -18,9 +18,11 @@ partial void ProcessOptionsProjectScoreResponse(
/// Enable CORS (`/v1/project_score`)
/// Enable CORS
///
+ /// 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 OptionsProjectScoreAsync(
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -28,142 +30,321 @@ partial void ProcessOptionsProjectScoreResponse(
PrepareOptionsProjectScoreArguments(
httpClient: HttpClient);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: "/v1/project_score",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: "/v1/project_score",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsProjectScoreRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsProjectScoreRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __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);
- ProcessOptionsProjectScoreResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProjectScore",
+ methodName: "OptionsProjectScoreAsync",
+ pathTemplate: "\"/v1/project_score\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProjectScore",
+ methodName: "OptionsProjectScoreAsync",
+ pathTemplate: "\"/v1/project_score\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProjectScore",
+ methodName: "OptionsProjectScoreAsync",
+ pathTemplate: "\"/v1/project_score\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
+ response: __response);
+ ProcessOptionsProjectScoreResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProjectScore",
+ methodName: "OptionsProjectScoreAsync",
+ pathTemplate: "\"/v1/project_score\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProjectScore",
+ methodName: "OptionsProjectScoreAsync",
+ pathTemplate: "\"/v1/project_score\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsProjectScoreId.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsProjectScoreId.g.cs
index 9a857bc..2b5f2c6 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsProjectScoreId.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsProjectScoreId.g.cs
@@ -23,10 +23,12 @@ partial void ProcessOptionsProjectScoreIdResponse(
///
/// ProjectScore id
///
+ /// 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 OptionsProjectScoreIdAsync(
global::System.Guid projectScoreId,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -35,143 +37,322 @@ partial void ProcessOptionsProjectScoreIdResponse(
httpClient: HttpClient,
projectScoreId: ref projectScoreId);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: $"/v1/project_score/{projectScoreId}",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: $"/v1/project_score/{projectScoreId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsProjectScoreIdRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- projectScoreId: projectScoreId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsProjectScoreIdRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ projectScoreId: projectScoreId);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessOptionsProjectScoreIdResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProjectScoreId",
+ methodName: "OptionsProjectScoreIdAsync",
+ pathTemplate: "$\"/v1/project_score/{projectScoreId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProjectScoreId",
+ methodName: "OptionsProjectScoreIdAsync",
+ pathTemplate: "$\"/v1/project_score/{projectScoreId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProjectScoreId",
+ methodName: "OptionsProjectScoreIdAsync",
+ pathTemplate: "$\"/v1/project_score/{projectScoreId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
- {
- __response.EnsureSuccessStatusCode();
-
- }
- catch (global::System.Exception __ex)
+ response: __response);
+ ProcessOptionsProjectScoreIdResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProjectScoreId",
+ methodName: "OptionsProjectScoreIdAsync",
+ pathTemplate: "$\"/v1/project_score/{projectScoreId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
+ else
{
- __response.EnsureSuccessStatusCode();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProjectScoreId",
+ methodName: "OptionsProjectScoreIdAsync",
+ pathTemplate: "$\"/v1/project_score/{projectScoreId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsProjectTag.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsProjectTag.g.cs
index 78c230f..e44a24c 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsProjectTag.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsProjectTag.g.cs
@@ -18,9 +18,11 @@ partial void ProcessOptionsProjectTagResponse(
/// Enable CORS (`/v1/project_tag`)
/// Enable CORS
///
+ /// 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 OptionsProjectTagAsync(
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -28,142 +30,321 @@ partial void ProcessOptionsProjectTagResponse(
PrepareOptionsProjectTagArguments(
httpClient: HttpClient);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: "/v1/project_tag",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: "/v1/project_tag",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsProjectTagRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsProjectTagRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __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);
- ProcessOptionsProjectTagResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProjectTag",
+ methodName: "OptionsProjectTagAsync",
+ pathTemplate: "\"/v1/project_tag\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProjectTag",
+ methodName: "OptionsProjectTagAsync",
+ pathTemplate: "\"/v1/project_tag\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProjectTag",
+ methodName: "OptionsProjectTagAsync",
+ pathTemplate: "\"/v1/project_tag\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
+ response: __response);
+ ProcessOptionsProjectTagResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProjectTag",
+ methodName: "OptionsProjectTagAsync",
+ pathTemplate: "\"/v1/project_tag\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProjectTag",
+ methodName: "OptionsProjectTagAsync",
+ pathTemplate: "\"/v1/project_tag\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsProjectTagId.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsProjectTagId.g.cs
index 8e3e2e4..920b6f9 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsProjectTagId.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsProjectTagId.g.cs
@@ -23,10 +23,12 @@ partial void ProcessOptionsProjectTagIdResponse(
///
/// ProjectTag id
///
+ /// 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 OptionsProjectTagIdAsync(
global::System.Guid projectTagId,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -35,143 +37,322 @@ partial void ProcessOptionsProjectTagIdResponse(
httpClient: HttpClient,
projectTagId: ref projectTagId);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: $"/v1/project_tag/{projectTagId}",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: $"/v1/project_tag/{projectTagId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsProjectTagIdRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- projectTagId: projectTagId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsProjectTagIdRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ projectTagId: projectTagId);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessOptionsProjectTagIdResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProjectTagId",
+ methodName: "OptionsProjectTagIdAsync",
+ pathTemplate: "$\"/v1/project_tag/{projectTagId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProjectTagId",
+ methodName: "OptionsProjectTagIdAsync",
+ pathTemplate: "$\"/v1/project_tag/{projectTagId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProjectTagId",
+ methodName: "OptionsProjectTagIdAsync",
+ pathTemplate: "$\"/v1/project_tag/{projectTagId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
- {
- __response.EnsureSuccessStatusCode();
-
- }
- catch (global::System.Exception __ex)
+ response: __response);
+ ProcessOptionsProjectTagIdResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProjectTagId",
+ methodName: "OptionsProjectTagIdAsync",
+ pathTemplate: "$\"/v1/project_tag/{projectTagId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
+ else
{
- __response.EnsureSuccessStatusCode();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProjectTagId",
+ methodName: "OptionsProjectTagIdAsync",
+ pathTemplate: "$\"/v1/project_tag/{projectTagId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsPrompt.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsPrompt.g.cs
index 9c61cb6..dbbae68 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsPrompt.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsPrompt.g.cs
@@ -18,9 +18,11 @@ partial void ProcessOptionsPromptResponse(
/// Enable CORS (`/v1/prompt`)
/// Enable CORS
///
+ /// 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 OptionsPromptAsync(
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -28,142 +30,321 @@ partial void ProcessOptionsPromptResponse(
PrepareOptionsPromptArguments(
httpClient: HttpClient);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: "/v1/prompt",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: "/v1/prompt",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsPromptRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsPromptRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __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);
- ProcessOptionsPromptResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsPrompt",
+ methodName: "OptionsPromptAsync",
+ pathTemplate: "\"/v1/prompt\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsPrompt",
+ methodName: "OptionsPromptAsync",
+ pathTemplate: "\"/v1/prompt\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsPrompt",
+ methodName: "OptionsPromptAsync",
+ pathTemplate: "\"/v1/prompt\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
+ response: __response);
+ ProcessOptionsPromptResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsPrompt",
+ methodName: "OptionsPromptAsync",
+ pathTemplate: "\"/v1/prompt\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsPrompt",
+ methodName: "OptionsPromptAsync",
+ pathTemplate: "\"/v1/prompt\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsPromptId.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsPromptId.g.cs
index 4a66c23..9de28ee 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsPromptId.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsPromptId.g.cs
@@ -23,10 +23,12 @@ partial void ProcessOptionsPromptIdResponse(
///
/// Prompt id
///
+ /// 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 OptionsPromptIdAsync(
global::System.Guid promptId,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -35,143 +37,322 @@ partial void ProcessOptionsPromptIdResponse(
httpClient: HttpClient,
promptId: ref promptId);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: $"/v1/prompt/{promptId}",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: $"/v1/prompt/{promptId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsPromptIdRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- promptId: promptId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsPromptIdRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ promptId: promptId);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessOptionsPromptIdResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsPromptId",
+ methodName: "OptionsPromptIdAsync",
+ pathTemplate: "$\"/v1/prompt/{promptId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsPromptId",
+ methodName: "OptionsPromptIdAsync",
+ pathTemplate: "$\"/v1/prompt/{promptId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsPromptId",
+ methodName: "OptionsPromptIdAsync",
+ pathTemplate: "$\"/v1/prompt/{promptId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
- {
- __response.EnsureSuccessStatusCode();
-
- }
- catch (global::System.Exception __ex)
+ response: __response);
+ ProcessOptionsPromptIdResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsPromptId",
+ methodName: "OptionsPromptIdAsync",
+ pathTemplate: "$\"/v1/prompt/{promptId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
+ else
{
- __response.EnsureSuccessStatusCode();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsPromptId",
+ methodName: "OptionsPromptIdAsync",
+ pathTemplate: "$\"/v1/prompt/{promptId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsProxyproxyauto.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsProxyproxyauto.g.cs
index 0f0183d..601d111 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsProxyproxyauto.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsProxyproxyauto.g.cs
@@ -18,9 +18,11 @@ partial void ProcessOptionsProxyproxyautoResponse(
/// Enable CORS (`/v1/proxy/auto`)
/// Enable CORS
///
+ /// 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 OptionsProxyproxyautoAsync(
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -28,142 +30,321 @@ partial void ProcessOptionsProxyproxyautoResponse(
PrepareOptionsProxyproxyautoArguments(
httpClient: HttpClient);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: "/v1/proxy/auto",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: "/v1/proxy/auto",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsProxyproxyautoRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsProxyproxyautoRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __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);
- ProcessOptionsProxyproxyautoResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProxyproxyauto",
+ methodName: "OptionsProxyproxyautoAsync",
+ pathTemplate: "\"/v1/proxy/auto\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProxyproxyauto",
+ methodName: "OptionsProxyproxyautoAsync",
+ pathTemplate: "\"/v1/proxy/auto\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProxyproxyauto",
+ methodName: "OptionsProxyproxyautoAsync",
+ pathTemplate: "\"/v1/proxy/auto\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
+ response: __response);
+ ProcessOptionsProxyproxyautoResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProxyproxyauto",
+ methodName: "OptionsProxyproxyautoAsync",
+ pathTemplate: "\"/v1/proxy/auto\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProxyproxyauto",
+ methodName: "OptionsProxyproxyautoAsync",
+ pathTemplate: "\"/v1/proxy/auto\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsProxyproxychatCompletions.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsProxyproxychatCompletions.g.cs
index cf255ff..fa1bf28 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsProxyproxychatCompletions.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsProxyproxychatCompletions.g.cs
@@ -18,9 +18,11 @@ partial void ProcessOptionsProxyproxychatCompletionsResponse(
/// Enable CORS (`/v1/proxy/chat/completions`)
/// Enable CORS
///
+ /// 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 OptionsProxyproxychatCompletionsAsync(
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -28,142 +30,321 @@ partial void ProcessOptionsProxyproxychatCompletionsResponse(
PrepareOptionsProxyproxychatCompletionsArguments(
httpClient: HttpClient);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: "/v1/proxy/chat/completions",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: "/v1/proxy/chat/completions",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsProxyproxychatCompletionsRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsProxyproxychatCompletionsRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __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);
- ProcessOptionsProxyproxychatCompletionsResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProxyproxychatCompletions",
+ methodName: "OptionsProxyproxychatCompletionsAsync",
+ pathTemplate: "\"/v1/proxy/chat/completions\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProxyproxychatCompletions",
+ methodName: "OptionsProxyproxychatCompletionsAsync",
+ pathTemplate: "\"/v1/proxy/chat/completions\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProxyproxychatCompletions",
+ methodName: "OptionsProxyproxychatCompletionsAsync",
+ pathTemplate: "\"/v1/proxy/chat/completions\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
+ response: __response);
+ ProcessOptionsProxyproxychatCompletionsResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProxyproxychatCompletions",
+ methodName: "OptionsProxyproxychatCompletionsAsync",
+ pathTemplate: "\"/v1/proxy/chat/completions\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProxyproxychatCompletions",
+ methodName: "OptionsProxyproxychatCompletionsAsync",
+ pathTemplate: "\"/v1/proxy/chat/completions\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsProxyproxycompletions.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsProxyproxycompletions.g.cs
index 5716803..bcfd8c1 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsProxyproxycompletions.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsProxyproxycompletions.g.cs
@@ -18,9 +18,11 @@ partial void ProcessOptionsProxyproxycompletionsResponse(
/// Enable CORS (`/v1/proxy/completions`)
/// Enable CORS
///
+ /// 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 OptionsProxyproxycompletionsAsync(
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -28,142 +30,321 @@ partial void ProcessOptionsProxyproxycompletionsResponse(
PrepareOptionsProxyproxycompletionsArguments(
httpClient: HttpClient);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: "/v1/proxy/completions",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: "/v1/proxy/completions",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsProxyproxycompletionsRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsProxyproxycompletionsRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __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);
- ProcessOptionsProxyproxycompletionsResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProxyproxycompletions",
+ methodName: "OptionsProxyproxycompletionsAsync",
+ pathTemplate: "\"/v1/proxy/completions\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProxyproxycompletions",
+ methodName: "OptionsProxyproxycompletionsAsync",
+ pathTemplate: "\"/v1/proxy/completions\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProxyproxycompletions",
+ methodName: "OptionsProxyproxycompletionsAsync",
+ pathTemplate: "\"/v1/proxy/completions\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
+ response: __response);
+ ProcessOptionsProxyproxycompletionsResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProxyproxycompletions",
+ methodName: "OptionsProxyproxycompletionsAsync",
+ pathTemplate: "\"/v1/proxy/completions\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProxyproxycompletions",
+ methodName: "OptionsProxyproxycompletionsAsync",
+ pathTemplate: "\"/v1/proxy/completions\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsProxyproxycredentials.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsProxyproxycredentials.g.cs
index dd24196..54381e1 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsProxyproxycredentials.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsProxyproxycredentials.g.cs
@@ -18,9 +18,11 @@ partial void ProcessOptionsProxyproxycredentialsResponse(
/// Enable CORS (`/v1/proxy/credentials`)
/// Enable CORS
///
+ /// 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 OptionsProxyproxycredentialsAsync(
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -28,142 +30,321 @@ partial void ProcessOptionsProxyproxycredentialsResponse(
PrepareOptionsProxyproxycredentialsArguments(
httpClient: HttpClient);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: "/v1/proxy/credentials",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: "/v1/proxy/credentials",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsProxyproxycredentialsRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsProxyproxycredentialsRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __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);
- ProcessOptionsProxyproxycredentialsResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProxyproxycredentials",
+ methodName: "OptionsProxyproxycredentialsAsync",
+ pathTemplate: "\"/v1/proxy/credentials\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProxyproxycredentials",
+ methodName: "OptionsProxyproxycredentialsAsync",
+ pathTemplate: "\"/v1/proxy/credentials\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProxyproxycredentials",
+ methodName: "OptionsProxyproxycredentialsAsync",
+ pathTemplate: "\"/v1/proxy/credentials\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
+ response: __response);
+ ProcessOptionsProxyproxycredentialsResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProxyproxycredentials",
+ methodName: "OptionsProxyproxycredentialsAsync",
+ pathTemplate: "\"/v1/proxy/credentials\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProxyproxycredentials",
+ methodName: "OptionsProxyproxycredentialsAsync",
+ pathTemplate: "\"/v1/proxy/credentials\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsProxyproxyembeddings.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsProxyproxyembeddings.g.cs
index 46348fc..832d6a5 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsProxyproxyembeddings.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsProxyproxyembeddings.g.cs
@@ -18,9 +18,11 @@ partial void ProcessOptionsProxyproxyembeddingsResponse(
/// Enable CORS (`/v1/proxy/embeddings`)
/// Enable CORS
///
+ /// 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 OptionsProxyproxyembeddingsAsync(
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -28,142 +30,321 @@ partial void ProcessOptionsProxyproxyembeddingsResponse(
PrepareOptionsProxyproxyembeddingsArguments(
httpClient: HttpClient);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: "/v1/proxy/embeddings",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: "/v1/proxy/embeddings",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsProxyproxyembeddingsRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsProxyproxyembeddingsRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __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);
- ProcessOptionsProxyproxyembeddingsResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProxyproxyembeddings",
+ methodName: "OptionsProxyproxyembeddingsAsync",
+ pathTemplate: "\"/v1/proxy/embeddings\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProxyproxyembeddings",
+ methodName: "OptionsProxyproxyembeddingsAsync",
+ pathTemplate: "\"/v1/proxy/embeddings\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProxyproxyembeddings",
+ methodName: "OptionsProxyproxyembeddingsAsync",
+ pathTemplate: "\"/v1/proxy/embeddings\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
+ response: __response);
+ ProcessOptionsProxyproxyembeddingsResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProxyproxyembeddings",
+ methodName: "OptionsProxyproxyembeddingsAsync",
+ pathTemplate: "\"/v1/proxy/embeddings\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsProxyproxyembeddings",
+ methodName: "OptionsProxyproxyembeddingsAsync",
+ pathTemplate: "\"/v1/proxy/embeddings\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsRole.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsRole.g.cs
index b955ade..b7c7ae9 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsRole.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsRole.g.cs
@@ -18,9 +18,11 @@ partial void ProcessOptionsRoleResponse(
/// Enable CORS (`/v1/role`)
/// Enable CORS
///
+ /// 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 OptionsRoleAsync(
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -28,142 +30,321 @@ partial void ProcessOptionsRoleResponse(
PrepareOptionsRoleArguments(
httpClient: HttpClient);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: "/v1/role",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: "/v1/role",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsRoleRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsRoleRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __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);
- ProcessOptionsRoleResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsRole",
+ methodName: "OptionsRoleAsync",
+ pathTemplate: "\"/v1/role\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsRole",
+ methodName: "OptionsRoleAsync",
+ pathTemplate: "\"/v1/role\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsRole",
+ methodName: "OptionsRoleAsync",
+ pathTemplate: "\"/v1/role\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
+ response: __response);
+ ProcessOptionsRoleResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsRole",
+ methodName: "OptionsRoleAsync",
+ pathTemplate: "\"/v1/role\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsRole",
+ methodName: "OptionsRoleAsync",
+ pathTemplate: "\"/v1/role\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsRoleId.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsRoleId.g.cs
index 73472ca..26999f3 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsRoleId.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsRoleId.g.cs
@@ -23,10 +23,12 @@ partial void ProcessOptionsRoleIdResponse(
///
/// Role id
///
+ /// 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 OptionsRoleIdAsync(
global::System.Guid roleId,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -35,143 +37,322 @@ partial void ProcessOptionsRoleIdResponse(
httpClient: HttpClient,
roleId: ref roleId);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: $"/v1/role/{roleId}",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: $"/v1/role/{roleId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsRoleIdRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- roleId: roleId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsRoleIdRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ roleId: roleId);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessOptionsRoleIdResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsRoleId",
+ methodName: "OptionsRoleIdAsync",
+ pathTemplate: "$\"/v1/role/{roleId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsRoleId",
+ methodName: "OptionsRoleIdAsync",
+ pathTemplate: "$\"/v1/role/{roleId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsRoleId",
+ methodName: "OptionsRoleIdAsync",
+ pathTemplate: "$\"/v1/role/{roleId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
- {
- __response.EnsureSuccessStatusCode();
-
- }
- catch (global::System.Exception __ex)
+ response: __response);
+ ProcessOptionsRoleIdResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsRoleId",
+ methodName: "OptionsRoleIdAsync",
+ pathTemplate: "$\"/v1/role/{roleId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
+ else
{
- __response.EnsureSuccessStatusCode();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsRoleId",
+ methodName: "OptionsRoleIdAsync",
+ pathTemplate: "$\"/v1/role/{roleId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsServiceToken.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsServiceToken.g.cs
index bfe5a14..15b4ba9 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsServiceToken.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsServiceToken.g.cs
@@ -18,9 +18,11 @@ partial void ProcessOptionsServiceTokenResponse(
/// Enable CORS (`/v1/service_token`)
/// Enable CORS
///
+ /// 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 OptionsServiceTokenAsync(
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -28,142 +30,321 @@ partial void ProcessOptionsServiceTokenResponse(
PrepareOptionsServiceTokenArguments(
httpClient: HttpClient);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: "/v1/service_token",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: "/v1/service_token",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsServiceTokenRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsServiceTokenRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __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);
- ProcessOptionsServiceTokenResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsServiceToken",
+ methodName: "OptionsServiceTokenAsync",
+ pathTemplate: "\"/v1/service_token\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsServiceToken",
+ methodName: "OptionsServiceTokenAsync",
+ pathTemplate: "\"/v1/service_token\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsServiceToken",
+ methodName: "OptionsServiceTokenAsync",
+ pathTemplate: "\"/v1/service_token\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
+ response: __response);
+ ProcessOptionsServiceTokenResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsServiceToken",
+ methodName: "OptionsServiceTokenAsync",
+ pathTemplate: "\"/v1/service_token\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsServiceToken",
+ methodName: "OptionsServiceTokenAsync",
+ pathTemplate: "\"/v1/service_token\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsServiceTokenId.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsServiceTokenId.g.cs
index 2fc94be..c252a35 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsServiceTokenId.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsServiceTokenId.g.cs
@@ -23,10 +23,12 @@ partial void ProcessOptionsServiceTokenIdResponse(
///
/// ServiceToken id
///
+ /// 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 OptionsServiceTokenIdAsync(
global::System.Guid serviceTokenId,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -35,143 +37,322 @@ partial void ProcessOptionsServiceTokenIdResponse(
httpClient: HttpClient,
serviceTokenId: ref serviceTokenId);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: $"/v1/service_token/{serviceTokenId}",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: $"/v1/service_token/{serviceTokenId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsServiceTokenIdRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- serviceTokenId: serviceTokenId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsServiceTokenIdRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ serviceTokenId: serviceTokenId);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessOptionsServiceTokenIdResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsServiceTokenId",
+ methodName: "OptionsServiceTokenIdAsync",
+ pathTemplate: "$\"/v1/service_token/{serviceTokenId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsServiceTokenId",
+ methodName: "OptionsServiceTokenIdAsync",
+ pathTemplate: "$\"/v1/service_token/{serviceTokenId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsServiceTokenId",
+ methodName: "OptionsServiceTokenIdAsync",
+ pathTemplate: "$\"/v1/service_token/{serviceTokenId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
- {
- __response.EnsureSuccessStatusCode();
-
- }
- catch (global::System.Exception __ex)
+ response: __response);
+ ProcessOptionsServiceTokenIdResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsServiceTokenId",
+ methodName: "OptionsServiceTokenIdAsync",
+ pathTemplate: "$\"/v1/service_token/{serviceTokenId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
+ else
{
- __response.EnsureSuccessStatusCode();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsServiceTokenId",
+ methodName: "OptionsServiceTokenIdAsync",
+ pathTemplate: "$\"/v1/service_token/{serviceTokenId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsSpanIframe.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsSpanIframe.g.cs
index b758624..33f1ba3 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsSpanIframe.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsSpanIframe.g.cs
@@ -18,9 +18,11 @@ partial void ProcessOptionsSpanIframeResponse(
/// Enable CORS (`/v1/span_iframe`)
/// Enable CORS
///
+ /// 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 OptionsSpanIframeAsync(
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -28,142 +30,321 @@ partial void ProcessOptionsSpanIframeResponse(
PrepareOptionsSpanIframeArguments(
httpClient: HttpClient);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: "/v1/span_iframe",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: "/v1/span_iframe",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsSpanIframeRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsSpanIframeRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __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);
- ProcessOptionsSpanIframeResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsSpanIframe",
+ methodName: "OptionsSpanIframeAsync",
+ pathTemplate: "\"/v1/span_iframe\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsSpanIframe",
+ methodName: "OptionsSpanIframeAsync",
+ pathTemplate: "\"/v1/span_iframe\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsSpanIframe",
+ methodName: "OptionsSpanIframeAsync",
+ pathTemplate: "\"/v1/span_iframe\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
+ response: __response);
+ ProcessOptionsSpanIframeResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsSpanIframe",
+ methodName: "OptionsSpanIframeAsync",
+ pathTemplate: "\"/v1/span_iframe\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsSpanIframe",
+ methodName: "OptionsSpanIframeAsync",
+ pathTemplate: "\"/v1/span_iframe\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsSpanIframeId.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsSpanIframeId.g.cs
index f7a7430..a3ef3d5 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsSpanIframeId.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsSpanIframeId.g.cs
@@ -23,10 +23,12 @@ partial void ProcessOptionsSpanIframeIdResponse(
///
/// SpanIframe id
///
+ /// 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 OptionsSpanIframeIdAsync(
global::System.Guid spanIframeId,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -35,143 +37,322 @@ partial void ProcessOptionsSpanIframeIdResponse(
httpClient: HttpClient,
spanIframeId: ref spanIframeId);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: $"/v1/span_iframe/{spanIframeId}",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: $"/v1/span_iframe/{spanIframeId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsSpanIframeIdRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- spanIframeId: spanIframeId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsSpanIframeIdRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ spanIframeId: spanIframeId);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessOptionsSpanIframeIdResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsSpanIframeId",
+ methodName: "OptionsSpanIframeIdAsync",
+ pathTemplate: "$\"/v1/span_iframe/{spanIframeId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsSpanIframeId",
+ methodName: "OptionsSpanIframeIdAsync",
+ pathTemplate: "$\"/v1/span_iframe/{spanIframeId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsSpanIframeId",
+ methodName: "OptionsSpanIframeIdAsync",
+ pathTemplate: "$\"/v1/span_iframe/{spanIframeId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
- {
- __response.EnsureSuccessStatusCode();
-
- }
- catch (global::System.Exception __ex)
+ response: __response);
+ ProcessOptionsSpanIframeIdResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsSpanIframeId",
+ methodName: "OptionsSpanIframeIdAsync",
+ pathTemplate: "$\"/v1/span_iframe/{spanIframeId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
+ else
{
- __response.EnsureSuccessStatusCode();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsSpanIframeId",
+ methodName: "OptionsSpanIframeIdAsync",
+ pathTemplate: "$\"/v1/span_iframe/{spanIframeId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsUser.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsUser.g.cs
index 2a303cb..a4fde2d 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsUser.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsUser.g.cs
@@ -18,9 +18,11 @@ partial void ProcessOptionsUserResponse(
/// Enable CORS (`/v1/user`)
/// Enable CORS
///
+ /// 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 OptionsUserAsync(
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -28,142 +30,321 @@ partial void ProcessOptionsUserResponse(
PrepareOptionsUserArguments(
httpClient: HttpClient);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: "/v1/user",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: "/v1/user",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsUserRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsUserRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __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);
- ProcessOptionsUserResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsUser",
+ methodName: "OptionsUserAsync",
+ pathTemplate: "\"/v1/user\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsUser",
+ methodName: "OptionsUserAsync",
+ pathTemplate: "\"/v1/user\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsUser",
+ methodName: "OptionsUserAsync",
+ pathTemplate: "\"/v1/user\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
+ response: __response);
+ ProcessOptionsUserResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsUser",
+ methodName: "OptionsUserAsync",
+ pathTemplate: "\"/v1/user\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsUser",
+ methodName: "OptionsUserAsync",
+ pathTemplate: "\"/v1/user\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsUserId.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsUserId.g.cs
index 1866ff1..16d6401 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsUserId.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsUserId.g.cs
@@ -23,10 +23,12 @@ partial void ProcessOptionsUserIdResponse(
///
/// User id
///
+ /// 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 OptionsUserIdAsync(
global::System.Guid userId,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -35,143 +37,322 @@ partial void ProcessOptionsUserIdResponse(
httpClient: HttpClient,
userId: ref userId);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: $"/v1/user/{userId}",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: $"/v1/user/{userId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsUserIdRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- userId: userId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsUserIdRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ userId: userId);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessOptionsUserIdResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsUserId",
+ methodName: "OptionsUserIdAsync",
+ pathTemplate: "$\"/v1/user/{userId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsUserId",
+ methodName: "OptionsUserIdAsync",
+ pathTemplate: "$\"/v1/user/{userId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsUserId",
+ methodName: "OptionsUserIdAsync",
+ pathTemplate: "$\"/v1/user/{userId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
- {
- __response.EnsureSuccessStatusCode();
-
- }
- catch (global::System.Exception __ex)
+ response: __response);
+ ProcessOptionsUserIdResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsUserId",
+ methodName: "OptionsUserIdAsync",
+ pathTemplate: "$\"/v1/user/{userId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
+ else
{
- __response.EnsureSuccessStatusCode();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsUserId",
+ methodName: "OptionsUserIdAsync",
+ pathTemplate: "$\"/v1/user/{userId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsView.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsView.g.cs
index 3e99583..4b8fa45 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsView.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsView.g.cs
@@ -18,9 +18,11 @@ partial void ProcessOptionsViewResponse(
/// Enable CORS (`/v1/view`)
/// Enable CORS
///
+ /// 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 OptionsViewAsync(
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -28,142 +30,321 @@ partial void ProcessOptionsViewResponse(
PrepareOptionsViewArguments(
httpClient: HttpClient);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: "/v1/view",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: "/v1/view",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsViewRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsViewRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __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);
- ProcessOptionsViewResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsView",
+ methodName: "OptionsViewAsync",
+ pathTemplate: "\"/v1/view\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsView",
+ methodName: "OptionsViewAsync",
+ pathTemplate: "\"/v1/view\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsView",
+ methodName: "OptionsViewAsync",
+ pathTemplate: "\"/v1/view\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
+ response: __response);
+ ProcessOptionsViewResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsView",
+ methodName: "OptionsViewAsync",
+ pathTemplate: "\"/v1/view\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsView",
+ methodName: "OptionsViewAsync",
+ pathTemplate: "\"/v1/view\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.OptionsViewId.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsViewId.g.cs
index 8d72563..4776fad 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsViewId.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.OptionsViewId.g.cs
@@ -23,10 +23,12 @@ partial void ProcessOptionsViewIdResponse(
///
/// View id
///
+ /// 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 OptionsViewIdAsync(
global::System.Guid viewId,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -35,143 +37,322 @@ partial void ProcessOptionsViewIdResponse(
httpClient: HttpClient,
viewId: ref viewId);
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: $"/v1/view/{viewId}",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Options,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: $"/v1/view/{viewId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Options,
+ 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;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOptionsViewIdRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- viewId: viewId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOptionsViewIdRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ viewId: viewId);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessOptionsViewIdResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsViewId",
+ methodName: "OptionsViewIdAsync",
+ pathTemplate: "$\"/v1/view/{viewId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsViewId",
+ methodName: "OptionsViewIdAsync",
+ pathTemplate: "$\"/v1/view/{viewId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsViewId",
+ methodName: "OptionsViewIdAsync",
+ pathTemplate: "$\"/v1/view/{viewId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_400 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
-
- try
- {
- __response.EnsureSuccessStatusCode();
-
- }
- catch (global::System.Exception __ex)
+ response: __response);
+ ProcessOptionsViewIdResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsViewId",
+ methodName: "OptionsViewIdAsync",
+ pathTemplate: "$\"/v1/view/{viewId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
+ else
{
- __response.EnsureSuccessStatusCode();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OptionsViewId",
+ methodName: "OptionsViewIdAsync",
+ pathTemplate: "$\"/v1/view/{viewId}\"",
+ httpMethod: "OPTIONS",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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();
+ }
+ 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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.CorsClient.g.cs b/src/libs/Braintrust/Generated/Braintrust.CorsClient.g.cs
index 9815fd8..8199e41 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CorsClient.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CorsClient.g.cs
@@ -30,6 +30,9 @@ public sealed partial class CorsClient : global::Braintrust.ICorsClient, global:
#if DEBUG
= true;
#endif
+
+ ///
+ public global::Braintrust.AutoSDKClientOptions Options { get; }
///
///
///
@@ -49,11 +52,37 @@ public CorsClient(
global::System.Net.Http.HttpClient? httpClient = null,
global::System.Uri? baseUri = null,
global::System.Collections.Generic.List? authorizations = null,
+ bool disposeHttpClient = true) : this(
+ httpClient,
+ baseUri,
+ authorizations,
+ options: null,
+ disposeHttpClient: disposeHttpClient)
+ {
+ }
+
+ ///
+ /// Creates a new instance of the CorsClient.
+ /// 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.
+ /// Client-wide request defaults such as headers, query parameters, retries, and timeout.
+ /// Dispose the HttpClient when the instance is disposed. True by default.
+ public CorsClient(
+ global::System.Net.Http.HttpClient? httpClient = null,
+ global::System.Uri? baseUri = null,
+ global::System.Collections.Generic.List? authorizations = null,
+ global::Braintrust.AutoSDKClientOptions? options = null,
bool disposeHttpClient = true)
{
+
HttpClient = httpClient ?? new global::System.Net.Http.HttpClient();
HttpClient.BaseAddress ??= baseUri ?? new global::System.Uri(DefaultBaseUrl);
Authorizations = authorizations ?? new global::System.Collections.Generic.List();
+ Options = options ?? new global::Braintrust.AutoSDKClientOptions();
_disposeHttpClient = disposeHttpClient;
Initialized(HttpClient);
diff --git a/src/libs/Braintrust/Generated/Braintrust.CrossObjectClient.PostCrossObjectInsert.g.cs b/src/libs/Braintrust/Generated/Braintrust.CrossObjectClient.PostCrossObjectInsert.g.cs
index 8f5f14c..d3fe02f 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CrossObjectClient.PostCrossObjectInsert.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CrossObjectClient.PostCrossObjectInsert.g.cs
@@ -14,6 +14,7 @@ public partial class CrossObjectClient
{ new global::Braintrust.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -45,11 +46,13 @@ partial void ProcessPostCrossObjectInsertResponseContent(
/// Insert events and feedback across object types
///
///
+ /// 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 PostCrossObjectInsertAsync(
global::Braintrust.CrossObjectInsertRequest request,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -66,22 +69,43 @@ partial void ProcessPostCrossObjectInsertResponseContent(
securityRequirements: s_PostCrossObjectInsertSecurityRequirements,
operationName: "PostCrossObjectInsertAsync");
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: "/v1/insert",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- 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));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: "/v1/insert",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.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;
+ __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 == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -91,308 +115,467 @@ partial void ProcessPostCrossObjectInsertResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
- var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
- var __httpRequestContent = new global::System.Net.Http.StringContent(
- content: __httpRequestContentBody,
- encoding: global::System.Text.Encoding.UTF8,
- mediaType: "application/json");
- __httpRequest.Content = __httpRequestContent;
-
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PreparePostCrossObjectInsertRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- request: request);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
-
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessPostCrossObjectInsertResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
- {
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
- {
- if (ReadResponseAsString)
- {
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
-
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_400 = __ex;
- }
+ var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
+ var __httpRequestContent = new global::System.Net.Http.StringContent(
+ content: __httpRequestContentBody,
+ encoding: global::System.Text.Encoding.UTF8,
+ mediaType: "application/json");
+ __httpRequest.Content = __httpRequestContent;
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
+
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PreparePostCrossObjectInsertRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ return __httpRequest;
}
- // No valid API key provided
- if ((int)__response.StatusCode == 401)
- {
- string? __content_401 = null;
- global::System.Exception? __exception_401 = null;
- string? __value_401 = null;
- try
- {
- if (ReadResponseAsString)
- {
- __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_401 = __ex;
- }
-
- throw new global::Braintrust.ApiException(
- message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_401,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_401,
- ResponseObject = __value_401,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // The API key doesn’t have permissions to perform the request
- if ((int)__response.StatusCode == 403)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_403 = null;
- global::System.Exception? __exception_403 = null;
- string? __value_403 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostCrossObjectInsert",
+ methodName: "PostCrossObjectInsertAsync",
+ pathTemplate: "\"/v1/insert\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
-
- __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostCrossObjectInsert",
+ methodName: "PostCrossObjectInsertAsync",
+ pathTemplate: "\"/v1/insert\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
- }
- catch (global::System.Exception __ex)
- {
- __exception_403 = __ex;
- }
- throw new global::Braintrust.ApiException(
- message: __content_403 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_403,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_403,
- ResponseObject = __value_403,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
- if ((int)__response.StatusCode == 429)
- {
- string? __content_429 = null;
- global::System.Exception? __exception_429 = null;
- string? __value_429 = null;
- try
- {
- if (ReadResponseAsString)
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
- __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostCrossObjectInsert",
+ methodName: "PostCrossObjectInsertAsync",
+ pathTemplate: "\"/v1/insert\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
- else
- {
- __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_429 = __ex;
+ break;
}
- throw new global::Braintrust.ApiException(
- message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_429,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_429,
- ResponseObject = __value_429,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // Something went wrong on Braintrust's end. (These are rare.)
- if ((int)__response.StatusCode == 500)
- {
- string? __content_500 = null;
- global::System.Exception? __exception_500 = null;
- string? __value_500 = null;
- try
+ if (__response == null)
{
- if (ReadResponseAsString)
- {
- __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
-
- __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_500 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_500 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_500,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_500,
- ResponseObject = __value_500,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessPostCrossObjectInsertResponseContent(
+ response: __response);
+ ProcessPostCrossObjectInsertResponse(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
- {
- __response.EnsureSuccessStatusCode();
-
- return
- global::Braintrust.CrossObjectInsertResponse.FromJson(__content, JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
- }
- catch (global::System.Exception __ex)
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- throw new global::Braintrust.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),
- };
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostCrossObjectInsert",
+ methodName: "PostCrossObjectInsertAsync",
+ pathTemplate: "\"/v1/insert\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
+ else
{
- __response.EnsureSuccessStatusCode();
- using var __content = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- return
- await global::Braintrust.CrossObjectInsertResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostCrossObjectInsert",
+ methodName: "PostCrossObjectInsertAsync",
+ pathTemplate: "\"/v1/insert\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // No valid API key provided
+ if ((int)__response.StatusCode == 401)
+ {
+ string? __content_401 = null;
+ global::System.Exception? __exception_401 = null;
+ string? __value_401 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_401 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_401,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_401,
+ ResponseObject = __value_401,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // The API key doesn’t have permissions to perform the request
+ if ((int)__response.StatusCode == 403)
+ {
+ string? __content_403 = null;
+ global::System.Exception? __exception_403 = null;
+ string? __value_403 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_403 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_403 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_403,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_403,
+ ResponseObject = __value_403,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
+ if ((int)__response.StatusCode == 429)
+ {
+ string? __content_429 = null;
+ global::System.Exception? __exception_429 = null;
+ string? __value_429 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_429 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_429,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_429,
+ ResponseObject = __value_429,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // Something went wrong on Braintrust's end. (These are rare.)
+ if ((int)__response.StatusCode == 500)
+ {
+ string? __content_500 = null;
+ global::System.Exception? __exception_500 = null;
+ string? __value_500 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_500 = __ex;
+ }
+
+ throw new global::Braintrust.ApiException(
+ message: __content_500 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_500,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_500,
+ ResponseObject = __value_500,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+ ProcessPostCrossObjectInsertResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Braintrust.CrossObjectInsertResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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::Braintrust.CrossObjectInsertResponse.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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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();
+ }
}
///
/// Cross-object insert
@@ -407,12 +590,14 @@ partial void ProcessPostCrossObjectInsertResponseContent(
///
/// A mapping from project id to a set of log events and feedback items to insert
///
+ /// 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 PostCrossObjectInsertAsync(
global::System.Collections.Generic.Dictionary? experiment = default,
global::System.Collections.Generic.Dictionary? dataset = default,
global::System.Collections.Generic.Dictionary? projectLogs = default,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::Braintrust.CrossObjectInsertRequest
@@ -424,6 +609,7 @@ partial void ProcessPostCrossObjectInsertResponseContent(
return await PostCrossObjectInsertAsync(
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/Braintrust/Generated/Braintrust.CrossObjectClient.g.cs b/src/libs/Braintrust/Generated/Braintrust.CrossObjectClient.g.cs
index 34f6104..9a87636 100644
--- a/src/libs/Braintrust/Generated/Braintrust.CrossObjectClient.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.CrossObjectClient.g.cs
@@ -30,6 +30,9 @@ public sealed partial class CrossObjectClient : global::Braintrust.ICrossObjectC
#if DEBUG
= true;
#endif
+
+ ///
+ public global::Braintrust.AutoSDKClientOptions Options { get; }
///
///
///
@@ -49,11 +52,37 @@ public CrossObjectClient(
global::System.Net.Http.HttpClient? httpClient = null,
global::System.Uri? baseUri = null,
global::System.Collections.Generic.List? authorizations = null,
+ bool disposeHttpClient = true) : this(
+ httpClient,
+ baseUri,
+ authorizations,
+ options: null,
+ disposeHttpClient: disposeHttpClient)
+ {
+ }
+
+ ///
+ /// Creates a new instance of the CrossObjectClient.
+ /// 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.
+ /// Client-wide request defaults such as headers, query parameters, retries, and timeout.
+ /// Dispose the HttpClient when the instance is disposed. True by default.
+ public CrossObjectClient(
+ global::System.Net.Http.HttpClient? httpClient = null,
+ global::System.Uri? baseUri = null,
+ global::System.Collections.Generic.List? authorizations = null,
+ global::Braintrust.AutoSDKClientOptions? options = null,
bool disposeHttpClient = true)
{
+
HttpClient = httpClient ?? new global::System.Net.Http.HttpClient();
HttpClient.BaseAddress ??= baseUri ?? new global::System.Uri(DefaultBaseUrl);
Authorizations = authorizations ?? new global::System.Collections.Generic.List();
+ Options = options ?? new global::Braintrust.AutoSDKClientOptions();
_disposeHttpClient = disposeHttpClient;
Initialized(HttpClient);
diff --git a/src/libs/Braintrust/Generated/Braintrust.DatasetSnapshotsClient.DeleteDatasetSnapshotId.g.cs b/src/libs/Braintrust/Generated/Braintrust.DatasetSnapshotsClient.DeleteDatasetSnapshotId.g.cs
index fdd9a12..57513a8 100644
--- a/src/libs/Braintrust/Generated/Braintrust.DatasetSnapshotsClient.DeleteDatasetSnapshotId.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.DatasetSnapshotsClient.DeleteDatasetSnapshotId.g.cs
@@ -14,6 +14,7 @@ public partial class DatasetSnapshotsClient
{ new global::Braintrust.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -56,10 +57,12 @@ partial void ProcessDeleteDatasetSnapshotIdResponseContent(
///
/// DatasetSnapshot id
///
+ /// 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 DeleteDatasetSnapshotIdAsync(
global::System.Guid datasetSnapshotId,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -74,22 +77,43 @@ partial void ProcessDeleteDatasetSnapshotIdResponseContent(
securityRequirements: s_DeleteDatasetSnapshotIdSecurityRequirements,
operationName: "DeleteDatasetSnapshotIdAsync");
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: $"/v1/dataset_snapshot/{datasetSnapshotId}",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Delete,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: $"/v1/dataset_snapshot/{datasetSnapshotId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Delete,
+ 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;
+ __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 == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -99,302 +123,461 @@ partial void ProcessDeleteDatasetSnapshotIdResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareDeleteDatasetSnapshotIdRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- datasetSnapshotId: datasetSnapshotId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareDeleteDatasetSnapshotIdRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ datasetSnapshotId: datasetSnapshotId);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessDeleteDatasetSnapshotIdResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteDatasetSnapshotId",
+ methodName: "DeleteDatasetSnapshotIdAsync",
+ pathTemplate: "$\"/v1/dataset_snapshot/{datasetSnapshotId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteDatasetSnapshotId",
+ methodName: "DeleteDatasetSnapshotIdAsync",
+ pathTemplate: "$\"/v1/dataset_snapshot/{datasetSnapshotId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
- }
- catch (global::System.Exception __ex)
- {
- __exception_400 = __ex;
- }
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // No valid API key provided
- if ((int)__response.StatusCode == 401)
- {
- string? __content_401 = null;
- global::System.Exception? __exception_401 = null;
- string? __value_401 = null;
- try
- {
- if (ReadResponseAsString)
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
- __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteDatasetSnapshotId",
+ methodName: "DeleteDatasetSnapshotIdAsync",
+ pathTemplate: "$\"/v1/dataset_snapshot/{datasetSnapshotId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
- else
- {
- __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
- }
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_401 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_401,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_401,
- ResponseObject = __value_401,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // The API key doesn’t have permissions to perform the request
- if ((int)__response.StatusCode == 403)
- {
- string? __content_403 = null;
- global::System.Exception? __exception_403 = null;
- string? __value_403 = null;
- try
+ using (__response)
{
- if (ReadResponseAsString)
- {
- __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
- }
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessDeleteDatasetSnapshotIdResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteDatasetSnapshotId",
+ methodName: "DeleteDatasetSnapshotIdAsync",
+ pathTemplate: "$\"/v1/dataset_snapshot/{datasetSnapshotId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- __exception_403 = __ex;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteDatasetSnapshotId",
+ methodName: "DeleteDatasetSnapshotIdAsync",
+ pathTemplate: "$\"/v1/dataset_snapshot/{datasetSnapshotId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- throw new global::Braintrust.ApiException(
- message: __content_403 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_403,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_403,
- ResponseObject = __value_403,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
- if ((int)__response.StatusCode == 429)
- {
- string? __content_429 = null;
- global::System.Exception? __exception_429 = null;
- string? __value_429 = null;
- try
- {
- if (ReadResponseAsString)
- {
- __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
- __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_429 = __ex;
- }
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // No valid API key provided
+ if ((int)__response.StatusCode == 401)
+ {
+ string? __content_401 = null;
+ global::System.Exception? __exception_401 = null;
+ string? __value_401 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- throw new global::Braintrust.ApiException(
- message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_429,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_429,
- ResponseObject = __value_429,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // Something went wrong on Braintrust's end. (These are rare.)
- if ((int)__response.StatusCode == 500)
- {
- string? __content_500 = null;
- global::System.Exception? __exception_500 = null;
- string? __value_500 = null;
- try
- {
- if (ReadResponseAsString)
- {
- __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_401 = __ex;
+ }
- __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_500 = __ex;
- }
+ throw new global::Braintrust.ApiException(
+ message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_401,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_401,
+ ResponseObject = __value_401,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // The API key doesn’t have permissions to perform the request
+ if ((int)__response.StatusCode == 403)
+ {
+ string? __content_403 = null;
+ global::System.Exception? __exception_403 = null;
+ string? __value_403 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- throw new global::Braintrust.ApiException(
- message: __content_500 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_500,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_500,
- ResponseObject = __value_500,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
+ __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_403 = __ex;
+ }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ throw new global::Braintrust.ApiException(
+ message: __content_403 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_403,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_403,
+ ResponseObject = __value_403,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
+ if ((int)__response.StatusCode == 429)
+ {
+ string? __content_429 = null;
+ global::System.Exception? __exception_429 = null;
+ string? __value_429 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessDeleteDatasetSnapshotIdResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_429 = __ex;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ throw new global::Braintrust.ApiException(
+ message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_429,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_429,
+ ResponseObject = __value_429,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // Something went wrong on Braintrust's end. (These are rare.)
+ if ((int)__response.StatusCode == 500)
+ {
+ string? __content_500 = null;
+ global::System.Exception? __exception_500 = null;
+ string? __value_500 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- return
- global::Braintrust.DatasetSnapshot.FromJson(__content, JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
- }
- catch (global::System.Exception __ex)
- {
- throw new global::Braintrust.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
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_500 = __ex;
+ }
- return
- await global::Braintrust.DatasetSnapshot.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
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ throw new global::Braintrust.ApiException(
+ message: __content_500 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_500,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_500,
+ ResponseObject = __value_500,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+ ProcessDeleteDatasetSnapshotIdResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Braintrust.DatasetSnapshot.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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::Braintrust.DatasetSnapshot.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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.DatasetSnapshotsClient.GetDatasetSnapshot.g.cs b/src/libs/Braintrust/Generated/Braintrust.DatasetSnapshotsClient.GetDatasetSnapshot.g.cs
index 51d029c..e9bb8ee 100644
--- a/src/libs/Braintrust/Generated/Braintrust.DatasetSnapshotsClient.GetDatasetSnapshot.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.DatasetSnapshotsClient.GetDatasetSnapshot.g.cs
@@ -14,6 +14,7 @@ public partial class DatasetSnapshotsClient
{ new global::Braintrust.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -83,6 +84,7 @@ partial void ProcessGetDatasetSnapshotResponseContent(
///
/// Filter search results to within a particular organization
///
+ /// 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 GetDatasetSnapshotAsync(
@@ -92,6 +94,7 @@ partial void ProcessGetDatasetSnapshotResponseContent(
global::Braintrust.Ids? ids = default,
string? datasetSnapshotName = default,
string? orgName = default,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -111,30 +114,51 @@ partial void ProcessGetDatasetSnapshotResponseContent(
securityRequirements: s_GetDatasetSnapshotSecurityRequirements,
operationName: "GetDatasetSnapshotAsync");
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: "/v1/dataset_snapshot",
- baseUri: HttpClient.BaseAddress);
- __pathBuilder
- .AddOptionalParameter("limit", limit?.ToString())
- .AddOptionalParameter("starting_after", startingAfter?.ToString())
- .AddOptionalParameter("ending_before", endingBefore?.ToString())
- .AddOptionalParameter("ids", ids?.ToString())
- .AddOptionalParameter("dataset_snapshot_name", datasetSnapshotName)
- .AddOptionalParameter("org_name", orgName)
- ;
- var __path = __pathBuilder.ToString();
- 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));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: "/v1/dataset_snapshot",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("limit", limit?.ToString())
+ .AddOptionalParameter("starting_after", startingAfter?.ToString())
+ .AddOptionalParameter("ending_before", endingBefore?.ToString())
+ .AddOptionalParameter("ids", ids?.ToString())
+ .AddOptionalParameter("dataset_snapshot_name", datasetSnapshotName)
+ .AddOptionalParameter("org_name", orgName)
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ 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));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __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 == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -144,307 +168,466 @@ partial void ProcessGetDatasetSnapshotResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareGetDatasetSnapshotRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- limit: limit,
- startingAfter: startingAfter,
- endingBefore: endingBefore,
- ids: ids,
- datasetSnapshotName: datasetSnapshotName,
- orgName: orgName);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareGetDatasetSnapshotRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ limit: limit,
+ startingAfter: startingAfter,
+ endingBefore: endingBefore,
+ ids: ids,
+ datasetSnapshotName: datasetSnapshotName,
+ orgName: orgName);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessGetDatasetSnapshotResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetDatasetSnapshot",
+ methodName: "GetDatasetSnapshotAsync",
+ pathTemplate: "\"/v1/dataset_snapshot\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetDatasetSnapshot",
+ methodName: "GetDatasetSnapshotAsync",
+ pathTemplate: "\"/v1/dataset_snapshot\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
- }
- catch (global::System.Exception __ex)
- {
- __exception_400 = __ex;
- }
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // No valid API key provided
- if ((int)__response.StatusCode == 401)
- {
- string? __content_401 = null;
- global::System.Exception? __exception_401 = null;
- string? __value_401 = null;
- try
- {
- if (ReadResponseAsString)
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
- __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetDatasetSnapshot",
+ methodName: "GetDatasetSnapshotAsync",
+ pathTemplate: "\"/v1/dataset_snapshot\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
- else
- {
- __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
- }
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_401 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_401,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_401,
- ResponseObject = __value_401,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // The API key doesn’t have permissions to perform the request
- if ((int)__response.StatusCode == 403)
- {
- string? __content_403 = null;
- global::System.Exception? __exception_403 = null;
- string? __value_403 = null;
- try
+ using (__response)
{
- if (ReadResponseAsString)
- {
- __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
- }
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessGetDatasetSnapshotResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetDatasetSnapshot",
+ methodName: "GetDatasetSnapshotAsync",
+ pathTemplate: "\"/v1/dataset_snapshot\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- __exception_403 = __ex;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetDatasetSnapshot",
+ methodName: "GetDatasetSnapshotAsync",
+ pathTemplate: "\"/v1/dataset_snapshot\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- throw new global::Braintrust.ApiException(
- message: __content_403 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_403,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_403,
- ResponseObject = __value_403,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
- if ((int)__response.StatusCode == 429)
- {
- string? __content_429 = null;
- global::System.Exception? __exception_429 = null;
- string? __value_429 = null;
- try
- {
- if (ReadResponseAsString)
- {
- __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
- __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_429 = __ex;
- }
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // No valid API key provided
+ if ((int)__response.StatusCode == 401)
+ {
+ string? __content_401 = null;
+ global::System.Exception? __exception_401 = null;
+ string? __value_401 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- throw new global::Braintrust.ApiException(
- message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_429,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_429,
- ResponseObject = __value_429,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // Something went wrong on Braintrust's end. (These are rare.)
- if ((int)__response.StatusCode == 500)
- {
- string? __content_500 = null;
- global::System.Exception? __exception_500 = null;
- string? __value_500 = null;
- try
- {
- if (ReadResponseAsString)
- {
- __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_401 = __ex;
+ }
- __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_500 = __ex;
- }
+ throw new global::Braintrust.ApiException(
+ message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_401,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_401,
+ ResponseObject = __value_401,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // The API key doesn’t have permissions to perform the request
+ if ((int)__response.StatusCode == 403)
+ {
+ string? __content_403 = null;
+ global::System.Exception? __exception_403 = null;
+ string? __value_403 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- throw new global::Braintrust.ApiException(
- message: __content_500 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_500,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_500,
- ResponseObject = __value_500,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
+ __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_403 = __ex;
+ }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ throw new global::Braintrust.ApiException(
+ message: __content_403 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_403,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_403,
+ ResponseObject = __value_403,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
+ if ((int)__response.StatusCode == 429)
+ {
+ string? __content_429 = null;
+ global::System.Exception? __exception_429 = null;
+ string? __value_429 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessGetDatasetSnapshotResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_429 = __ex;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ throw new global::Braintrust.ApiException(
+ message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_429,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_429,
+ ResponseObject = __value_429,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // Something went wrong on Braintrust's end. (These are rare.)
+ if ((int)__response.StatusCode == 500)
+ {
+ string? __content_500 = null;
+ global::System.Exception? __exception_500 = null;
+ string? __value_500 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- return
- global::Braintrust.GetDatasetSnapshotResponse.FromJson(__content, JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
- }
- catch (global::System.Exception __ex)
- {
- throw new global::Braintrust.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
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_500 = __ex;
+ }
- return
- await global::Braintrust.GetDatasetSnapshotResponse.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
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ throw new global::Braintrust.ApiException(
+ message: __content_500 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_500,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_500,
+ ResponseObject = __value_500,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+ ProcessGetDatasetSnapshotResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Braintrust.GetDatasetSnapshotResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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::Braintrust.GetDatasetSnapshotResponse.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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.DatasetSnapshotsClient.GetDatasetSnapshotId.g.cs b/src/libs/Braintrust/Generated/Braintrust.DatasetSnapshotsClient.GetDatasetSnapshotId.g.cs
index 5cd3204..674c4b1 100644
--- a/src/libs/Braintrust/Generated/Braintrust.DatasetSnapshotsClient.GetDatasetSnapshotId.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.DatasetSnapshotsClient.GetDatasetSnapshotId.g.cs
@@ -14,6 +14,7 @@ public partial class DatasetSnapshotsClient
{ new global::Braintrust.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -56,10 +57,12 @@ partial void ProcessGetDatasetSnapshotIdResponseContent(
///
/// DatasetSnapshot id
///
+ /// 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 GetDatasetSnapshotIdAsync(
global::System.Guid datasetSnapshotId,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -74,22 +77,43 @@ partial void ProcessGetDatasetSnapshotIdResponseContent(
securityRequirements: s_GetDatasetSnapshotIdSecurityRequirements,
operationName: "GetDatasetSnapshotIdAsync");
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: $"/v1/dataset_snapshot/{datasetSnapshotId}",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- 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));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: $"/v1/dataset_snapshot/{datasetSnapshotId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ 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));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __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 == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -99,302 +123,461 @@ partial void ProcessGetDatasetSnapshotIdResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareGetDatasetSnapshotIdRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- datasetSnapshotId: datasetSnapshotId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareGetDatasetSnapshotIdRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ datasetSnapshotId: datasetSnapshotId);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessGetDatasetSnapshotIdResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetDatasetSnapshotId",
+ methodName: "GetDatasetSnapshotIdAsync",
+ pathTemplate: "$\"/v1/dataset_snapshot/{datasetSnapshotId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetDatasetSnapshotId",
+ methodName: "GetDatasetSnapshotIdAsync",
+ pathTemplate: "$\"/v1/dataset_snapshot/{datasetSnapshotId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
- }
- catch (global::System.Exception __ex)
- {
- __exception_400 = __ex;
- }
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // No valid API key provided
- if ((int)__response.StatusCode == 401)
- {
- string? __content_401 = null;
- global::System.Exception? __exception_401 = null;
- string? __value_401 = null;
- try
- {
- if (ReadResponseAsString)
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Braintrust.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
- __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetDatasetSnapshotId",
+ methodName: "GetDatasetSnapshotIdAsync",
+ pathTemplate: "$\"/v1/dataset_snapshot/{datasetSnapshotId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
- else
- {
- __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
- }
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_401 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Braintrust.ApiException(
- message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_401,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_401,
- ResponseObject = __value_401,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // The API key doesn’t have permissions to perform the request
- if ((int)__response.StatusCode == 403)
- {
- string? __content_403 = null;
- global::System.Exception? __exception_403 = null;
- string? __value_403 = null;
- try
+ using (__response)
{
- if (ReadResponseAsString)
- {
- __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
- }
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessGetDatasetSnapshotIdResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetDatasetSnapshotId",
+ methodName: "GetDatasetSnapshotIdAsync",
+ pathTemplate: "$\"/v1/dataset_snapshot/{datasetSnapshotId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- __exception_403 = __ex;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetDatasetSnapshotId",
+ methodName: "GetDatasetSnapshotIdAsync",
+ pathTemplate: "$\"/v1/dataset_snapshot/{datasetSnapshotId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
+ // The request was unacceptable, often due to missing a required parameter
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ string? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- throw new global::Braintrust.ApiException(
- message: __content_403 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_403,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_403,
- ResponseObject = __value_403,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
- if ((int)__response.StatusCode == 429)
- {
- string? __content_429 = null;
- global::System.Exception? __exception_429 = null;
- string? __value_429 = null;
- try
- {
- if (ReadResponseAsString)
- {
- __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
- __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_429 = __ex;
- }
+ throw new global::Braintrust.ApiException(
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_400,
+ ResponseObject = __value_400,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // No valid API key provided
+ if ((int)__response.StatusCode == 401)
+ {
+ string? __content_401 = null;
+ global::System.Exception? __exception_401 = null;
+ string? __value_401 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- throw new global::Braintrust.ApiException(
- message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_429,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_429,
- ResponseObject = __value_429,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // Something went wrong on Braintrust's end. (These are rare.)
- if ((int)__response.StatusCode == 500)
- {
- string? __content_500 = null;
- global::System.Exception? __exception_500 = null;
- string? __value_500 = null;
- try
- {
- if (ReadResponseAsString)
- {
- __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_401 = __ex;
+ }
- __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_500 = __ex;
- }
+ throw new global::Braintrust.ApiException(
+ message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_401,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_401,
+ ResponseObject = __value_401,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // The API key doesn’t have permissions to perform the request
+ if ((int)__response.StatusCode == 403)
+ {
+ string? __content_403 = null;
+ global::System.Exception? __exception_403 = null;
+ string? __value_403 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- throw new global::Braintrust.ApiException(
- message: __content_500 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_500,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_500,
- ResponseObject = __value_500,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
+ __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_403 = __ex;
+ }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ throw new global::Braintrust.ApiException(
+ message: __content_403 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_403,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_403,
+ ResponseObject = __value_403,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
+ if ((int)__response.StatusCode == 429)
+ {
+ string? __content_429 = null;
+ global::System.Exception? __exception_429 = null;
+ string? __value_429 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessGetDatasetSnapshotIdResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __value_429 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_429, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_429 = __ex;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ throw new global::Braintrust.ApiException(
+ message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_429,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_429,
+ ResponseObject = __value_429,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ // Something went wrong on Braintrust's end. (These are rare.)
+ if ((int)__response.StatusCode == 500)
+ {
+ string? __content_500 = null;
+ global::System.Exception? __exception_500 = null;
+ string? __value_500 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
+ }
+ else
+ {
+ __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- return
- global::Braintrust.DatasetSnapshot.FromJson(__content, JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
- }
- catch (global::System.Exception __ex)
- {
- throw new global::Braintrust.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
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_500 = __ex;
+ }
- return
- await global::Braintrust.DatasetSnapshot.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
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ throw new global::Braintrust.ApiException(
+ message: __content_500 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_500,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_500,
+ ResponseObject = __value_500,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ 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);
+ ProcessGetDatasetSnapshotIdResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Braintrust.DatasetSnapshot.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Braintrust.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::Braintrust.DatasetSnapshot.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::Braintrust.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),
+ };
+ }
+ }
- throw new global::Braintrust.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/Braintrust/Generated/Braintrust.DatasetSnapshotsClient.PatchDatasetSnapshotId.g.cs b/src/libs/Braintrust/Generated/Braintrust.DatasetSnapshotsClient.PatchDatasetSnapshotId.g.cs
index be16177..b1252ef 100644
--- a/src/libs/Braintrust/Generated/Braintrust.DatasetSnapshotsClient.PatchDatasetSnapshotId.g.cs
+++ b/src/libs/Braintrust/Generated/Braintrust.DatasetSnapshotsClient.PatchDatasetSnapshotId.g.cs
@@ -14,6 +14,7 @@ public partial class DatasetSnapshotsClient
{ new global::Braintrust.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -59,12 +60,14 @@ partial void ProcessPatchDatasetSnapshotIdResponseContent(
/// DatasetSnapshot id
///
///
+ /// 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 PatchDatasetSnapshotIdAsync(
global::System.Guid datasetSnapshotId,
global::Braintrust.PatchDatasetSnapshot request,
+ global::Braintrust.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -82,22 +85,43 @@ partial void ProcessPatchDatasetSnapshotIdResponseContent(
securityRequirements: s_PatchDatasetSnapshotIdSecurityRequirements,
operationName: "PatchDatasetSnapshotIdAsync");
- var __pathBuilder = new global::Braintrust.PathBuilder(
- path: $"/v1/dataset_snapshot/{datasetSnapshotId}",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using 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));
+ using var __timeoutCancellationTokenSource = global::Braintrust.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Braintrust.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Braintrust.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Braintrust.PathBuilder(
+ path: $"/v1/dataset_snapshot/{datasetSnapshotId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Braintrust.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;
+ __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 == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -107,309 +131,468 @@ partial void ProcessPatchDatasetSnapshotIdResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
- var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
- var __httpRequestContent = new global::System.Net.Http.StringContent(
- content: __httpRequestContentBody,
- encoding: global::System.Text.Encoding.UTF8,
- mediaType: "application/json");
- __httpRequest.Content = __httpRequestContent;
-
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PreparePatchDatasetSnapshotIdRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- datasetSnapshotId: datasetSnapshotId,
- request: request);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
-
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessPatchDatasetSnapshotIdResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // The request was unacceptable, often due to missing a required parameter
- if ((int)__response.StatusCode == 400)
- {
- string? __content_400 = null;
- global::System.Exception? __exception_400 = null;
- string? __value_400 = null;
- try
- {
- if (ReadResponseAsString)
- {
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
-
- __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_400 = __ex;
- }
+ var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
+ var __httpRequestContent = new global::System.Net.Http.StringContent(
+ content: __httpRequestContentBody,
+ encoding: global::System.Text.Encoding.UTF8,
+ mediaType: "application/json");
+ __httpRequest.Content = __httpRequestContent;
+ global::Braintrust.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
+
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PreparePatchDatasetSnapshotIdRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ datasetSnapshotId: datasetSnapshotId,
+ request: request);
- throw new global::Braintrust.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ return __httpRequest;
}
- // No valid API key provided
- if ((int)__response.StatusCode == 401)
- {
- string? __content_401 = null;
- global::System.Exception? __exception_401 = null;
- string? __value_401 = null;
- try
- {
- if (ReadResponseAsString)
- {
- __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
- }
- else
- {
- __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_401 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_401 = __ex;
- }
-
- throw new global::Braintrust.ApiException(
- message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_401,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_401,
- ResponseObject = __value_401,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- // The API key doesn’t have permissions to perform the request
- if ((int)__response.StatusCode == 403)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_403 = null;
- global::System.Exception? __exception_403 = null;
- string? __value_403 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PatchDatasetSnapshotId",
+ methodName: "PatchDatasetSnapshotIdAsync",
+ pathTemplate: "$\"/v1/dataset_snapshot/{datasetSnapshotId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
-
- __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Braintrust.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PatchDatasetSnapshotId",
+ methodName: "PatchDatasetSnapshotIdAsync",
+ pathTemplate: "$\"/v1/dataset_snapshot/{datasetSnapshotId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Braintrust.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
- }
- catch (global::System.Exception __ex)
- {
- __exception_403 = __ex;
- }
- throw new global::Braintrust.ApiException