Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 134 additions & 0 deletions src/libs/ScaleAI/Generated/ScaleAI.Exceptions.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,19 @@ public partial class ApiException : global::System.Exception
/// The HTTP status code of the response.
/// </summary>
public global::System.Net.HttpStatusCode StatusCode { get; }

/// <summary>
/// The response body as a string, or <c>null</c> if the body could not be read.
/// This is always populated for error responses regardless of the <c>ReadResponseAsString</c> setting.
/// For success-path failures (e.g. deserialization errors), the client attempts a best-effort read.
/// </summary>
public string? ResponseBody { get; set; }

/// <summary>
/// The response headers.
/// </summary>
public global::System.Collections.Generic.Dictionary<string, global::System.Collections.Generic.IEnumerable<string>>? ResponseHeaders { get; set; }

/// <summary>
/// Initializes a new instance of the <see cref="ApiException"/> class.
/// </summary>
Expand Down Expand Up @@ -49,6 +52,103 @@ public ApiException(string message, global::System.Exception? innerException, gl
{
StatusCode = statusCode;
}

/// <summary>
/// Constructs an <see cref="ApiException"/> instance whose runtime type matches the response status code when the typed exception hierarchy is enabled. Always returns a plain <see cref="ApiException"/> when the hierarchy is disabled.
/// </summary>
/// <param name="statusCode">The HTTP status code of the response.</param>
/// <param name="message">The error message.</param>
/// <param name="innerException">An inner exception, when one is available.</param>
/// <param name="responseHeaders">The response headers; consulted for 429 <c>Retry-After</c> parsing when present.</param>
public static global::ScaleAI.ApiException Create(
global::System.Net.HttpStatusCode statusCode,
string message,
global::System.Exception? innerException = null,
global::System.Collections.Generic.IDictionary<string, global::System.Collections.Generic.IEnumerable<string>>? responseHeaders = null)
{
return new global::ScaleAI.ApiException(message, innerException, statusCode);
}

/// <summary>
/// Convenience overload that constructs an <see cref="ApiException"/> with response body and headers populated.
/// </summary>
public static global::ScaleAI.ApiException Create(
global::System.Net.HttpStatusCode statusCode,
string message,
global::System.Exception? innerException,
string? responseBody,
global::System.Collections.Generic.Dictionary<string, global::System.Collections.Generic.IEnumerable<string>>? responseHeaders)
{
var exception = global::ScaleAI.ApiException.Create(statusCode, message, innerException, responseHeaders);
exception.ResponseBody = responseBody;
exception.ResponseHeaders = responseHeaders;
return exception;
}

/// <summary>
/// Parses a <c>Retry-After</c> response header (delta-seconds or HTTP-date) into a <see cref="global::System.TimeSpan"/>.
/// Returns <c>null</c> when the header is missing or unparseable. Public so consumer code that observes
/// <see cref="ApiException"/> directly can recover the value without re-implementing the parser.
/// </summary>
public static global::System.TimeSpan? TryParseRetryAfter(
global::System.Collections.Generic.IDictionary<string, global::System.Collections.Generic.IEnumerable<string>>? headers)
{
if (headers == null)
{
return null;
}

global::System.Collections.Generic.IEnumerable<string>? values = null;
foreach (var entry in headers)
{
if (string.Equals(entry.Key, "Retry-After", global::System.StringComparison.OrdinalIgnoreCase))
{
values = entry.Value;
break;
}
}

if (values == null)
{
return null;
}

string? raw = null;
foreach (var value in values)
{
if (!string.IsNullOrWhiteSpace(value))
{
raw = value.Trim();
break;
}
}

if (string.IsNullOrEmpty(raw))
{
return null;
}

if (int.TryParse(
raw,
global::System.Globalization.NumberStyles.Integer,
global::System.Globalization.CultureInfo.InvariantCulture,
out var seconds) && seconds >= 0)
{
return global::System.TimeSpan.FromSeconds(seconds);
}

if (global::System.DateTimeOffset.TryParse(
raw,
global::System.Globalization.CultureInfo.InvariantCulture,
global::System.Globalization.DateTimeStyles.AssumeUniversal | global::System.Globalization.DateTimeStyles.AdjustToUniversal,
out var when))
{
var delta = when - global::System.DateTimeOffset.UtcNow;
return delta > global::System.TimeSpan.Zero ? delta : global::System.TimeSpan.Zero;
}

return null;
}
}

/// <summary>
Expand Down Expand Up @@ -88,5 +188,39 @@ public ApiException(string message, global::System.Net.HttpStatusCode statusCode
public ApiException(string message, global::System.Exception? innerException, global::System.Net.HttpStatusCode statusCode) : base(message, innerException, statusCode)
{
}

/// <summary>
/// Constructs an <see cref="ApiException{T}"/> whose runtime type matches the response status code when the typed exception hierarchy is enabled.
/// </summary>
/// <param name="statusCode">The HTTP status code of the response.</param>
/// <param name="message">The error message.</param>
/// <param name="innerException">An inner exception, when one is available.</param>
/// <param name="responseHeaders">The response headers; consulted for 429 <c>Retry-After</c> parsing when present.</param>
public static new global::ScaleAI.ApiException<T> Create(
global::System.Net.HttpStatusCode statusCode,
string message,
global::System.Exception? innerException = null,
global::System.Collections.Generic.IDictionary<string, global::System.Collections.Generic.IEnumerable<string>>? responseHeaders = null)
{
return new global::ScaleAI.ApiException<T>(message, innerException, statusCode);
}

/// <summary>
/// Convenience overload that constructs an <see cref="ApiException{T}"/> with response body, object, and headers populated.
/// </summary>
public static global::ScaleAI.ApiException<T> Create(
global::System.Net.HttpStatusCode statusCode,
string message,
global::System.Exception? innerException,
string? responseBody,
T? responseObject,
global::System.Collections.Generic.Dictionary<string, global::System.Collections.Generic.IEnumerable<string>>? responseHeaders)
{
var exception = global::ScaleAI.ApiException<T>.Create(statusCode, message, innerException, responseHeaders);
exception.ResponseBody = responseBody;
exception.ResponseObject = responseObject;
exception.ResponseHeaders = responseHeaders;
return exception;
}
}
}
81 changes: 81 additions & 0 deletions src/libs/ScaleAI/Generated/ScaleAI.OptionsSupport.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,84 @@ public interface IAutoSDKAuthorizationProvider
global::ScaleAI.AutoSDKHookContext context);
}

/// <summary>
/// Marker keys stamped onto outgoing <see cref="global::System.Net.Http.HttpRequestMessage"/>
/// instances so consumer <see cref="global::System.Net.Http.DelegatingHandler"/>s — and any
/// other transport-layer code that runs after AutoSDK's send pipeline — can observe whether
/// the resolved Authorization is call-scoped and opt out of overwriting it with a
/// rotation-aware account-level credential.
/// </summary>
public static class AutoSDKHttpRequestOptions
{
/// <summary>
/// Key under which <see cref="StampAuthorizationOverride"/> records the marker. Exposed
/// for handlers that target frameworks older than .NET 5 and need to read the value
/// through the legacy <c>HttpRequestMessage.Properties</c> bag.
/// </summary>
public const string AuthorizationOverrideKey = "AutoSDK.AuthorizationOverride";

#if NET5_0_OR_GREATER
/// <summary>
/// Strongly-typed <see cref="global::System.Net.Http.HttpRequestOptionsKey{TValue}"/> for
/// the call-scoped Authorization marker on .NET 5+ targets. Consumers should prefer this
/// over the legacy <c>HttpRequestMessage.Properties</c> bag where available.
/// </summary>
public static readonly global::System.Net.Http.HttpRequestOptionsKey<bool> AuthorizationOverride =
new global::System.Net.Http.HttpRequestOptionsKey<bool>(AuthorizationOverrideKey);
#endif

/// <summary>
/// Stamps the call-scoped Authorization marker on <paramref name="request"/>. AutoSDK's
/// built-in <see cref="AutoSDKAuthorizationProviderHook"/> calls this whenever the
/// resolved auth came from a per-request override or a client-level
/// <see cref="IAutoSDKAuthorizationProvider"/>. Hand-written SDK extensions that set a
/// non-default <c>Authorization</c> header (e.g. a session-scoped bearer returned by an
/// upstream poll) should call this too so downstream rotation handlers know to skip the
/// overwrite.
/// </summary>
/// <param name="request"></param>
public static void StampAuthorizationOverride(
global::System.Net.Http.HttpRequestMessage? request)
{
if (request is null)
{
return;
}

#if NET5_0_OR_GREATER
request.Options.Set(AuthorizationOverride, true);
#else
#pragma warning disable CS0618 // HttpRequestMessage.Properties is obsolete in NET5+, but the only option below it.
request.Properties[AuthorizationOverrideKey] = true;
#pragma warning restore CS0618
#endif
}

/// <summary>
/// Returns true when <see cref="StampAuthorizationOverride"/> previously marked the
/// request as carrying a call-scoped Authorization.
/// </summary>
/// <param name="request"></param>
public static bool HasAuthorizationOverride(
global::System.Net.Http.HttpRequestMessage? request)
{
if (request is null)
{
return false;
}

#if NET5_0_OR_GREATER
return request.Options.TryGetValue(AuthorizationOverride, out var value) && value;
#else
#pragma warning disable CS0618
return request.Properties.TryGetValue(AuthorizationOverrideKey, out var raw) &&
raw is bool flag &&
flag;
#pragma warning restore CS0618
#endif
}
}

/// <summary>
/// Built-in <see cref="IAutoSDKHook"/> that consults
/// <see cref="AutoSDKClientOptions.AuthorizationProvider"/> before every outgoing
Expand All @@ -176,6 +254,7 @@ public sealed class AutoSDKAuthorizationProviderHook : global::ScaleAI.AutoSDKHo
ApplyAuthorization(context.Request, perRequest[index]);
}

global::ScaleAI.AutoSDKHttpRequestOptions.StampAuthorizationOverride(context.Request);
return;
}

Expand All @@ -195,6 +274,8 @@ public sealed class AutoSDKAuthorizationProviderHook : global::ScaleAI.AutoSDKHo
{
ApplyAuthorization(context.Request, resolved[index]);
}

global::ScaleAI.AutoSDKHttpRequestOptions.StampAuthorizationOverride(context.Request);
}

private static void ApplyAuthorization(
Expand Down
24 changes: 10 additions & 14 deletions src/libs/ScaleAI/Generated/ScaleAI.ScaleAIClient.AddTaskTags.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -378,17 +378,15 @@ partial void ProcessAddTaskTagsResponseContent(
}
catch (global::System.Exception __ex)
{
throw new global::ScaleAI.ApiException(
throw global::ScaleAI.ApiException.Create(
statusCode: __response.StatusCode,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
statusCode: __response.StatusCode)
{
ResponseBody = __content,
ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
responseBody: __content,
responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
h => h.Value),
};
h => h.Value));
}
}
else
Expand Down Expand Up @@ -425,17 +423,15 @@ partial void ProcessAddTaskTagsResponseContent(
{
}

throw new global::ScaleAI.ApiException(
throw global::ScaleAI.ApiException.Create(
statusCode: __response.StatusCode,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
statusCode: __response.StatusCode)
{
ResponseBody = __content,
ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
responseBody: __content,
responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
h => h.Value),
};
h => h.Value));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,17 +367,15 @@ partial void ProcessAssignTeammatesResponseContent(
}
catch (global::System.Exception __ex)
{
throw new global::ScaleAI.ApiException(
throw global::ScaleAI.ApiException.Create(
statusCode: __response.StatusCode,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
statusCode: __response.StatusCode)
{
ResponseBody = __content,
ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
responseBody: __content,
responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
h => h.Value),
};
h => h.Value));
}
}
else
Expand Down Expand Up @@ -412,17 +410,15 @@ partial void ProcessAssignTeammatesResponseContent(
{
}

throw new global::ScaleAI.ApiException(
throw global::ScaleAI.ApiException.Create(
statusCode: __response.StatusCode,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
statusCode: __response.StatusCode)
{
ResponseBody = __content,
ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
responseBody: __content,
responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
h => h.Value),
};
h => h.Value));
}
}

Expand Down
Loading