Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -375,32 +375,108 @@ partial void ProcessFetchCreateResponseContent(
h => h.Value),
};
}
// Free plan fetch request quota exceeded.
if ((int)__response.StatusCode == 402)
{
string? __content_402 = null;
global::System.Exception? __exception_402 = null;
string? __value_402 = null;
try
{
if (__effectiveReadResponseAsString)
{
__content_402 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
__value_402 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_402, typeof(string), JsonSerializerContext);
}
else
{
__content_402 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);

__value_402 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_402, typeof(string), JsonSerializerContext);
}
}
catch (global::System.Exception __ex)
{
__exception_402 = __ex;
}

throw new global::Browserbase.ApiException<string>(
message: __content_402 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_402,
statusCode: __response.StatusCode)
{
ResponseBody = __content_402,
ResponseObject = __value_402,
ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
h => h.Value),
};
}
// Project is not enabled for the requested format. Only `raw` is available without enablement.
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::Browserbase.ApiException<string>(
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),
};
}
// Concurrent fetch request limit exceeded.
if ((int)__response.StatusCode == 429)
{
string? __content_429 = null;
global::System.Exception? __exception_429 = null;
global::Browserbase.FetchCreateResponse3? __value_429 = null;
global::Browserbase.FetchCreateResponse5? __value_429 = null;
try
{
if (__effectiveReadResponseAsString)
{
__content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
__value_429 = global::Browserbase.FetchCreateResponse3.FromJson(__content_429, JsonSerializerContext);
__value_429 = global::Browserbase.FetchCreateResponse5.FromJson(__content_429, JsonSerializerContext);
}
else
{
__content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);

__value_429 = global::Browserbase.FetchCreateResponse3.FromJson(__content_429, JsonSerializerContext);
__value_429 = global::Browserbase.FetchCreateResponse5.FromJson(__content_429, JsonSerializerContext);
}
}
catch (global::System.Exception __ex)
{
__exception_429 = __ex;
}

throw new global::Browserbase.ApiException<global::Browserbase.FetchCreateResponse3>(
throw new global::Browserbase.ApiException<global::Browserbase.FetchCreateResponse5>(
message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_429,
statusCode: __response.StatusCode)
Expand All @@ -418,27 +494,27 @@ partial void ProcessFetchCreateResponseContent(
{
string? __content_502 = null;
global::System.Exception? __exception_502 = null;
global::Browserbase.FetchCreateResponse4? __value_502 = null;
global::Browserbase.FetchCreateResponse6? __value_502 = null;
try
{
if (__effectiveReadResponseAsString)
{
__content_502 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
__value_502 = global::Browserbase.FetchCreateResponse4.FromJson(__content_502, JsonSerializerContext);
__value_502 = global::Browserbase.FetchCreateResponse6.FromJson(__content_502, JsonSerializerContext);
}
else
{
__content_502 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);

__value_502 = global::Browserbase.FetchCreateResponse4.FromJson(__content_502, JsonSerializerContext);
__value_502 = global::Browserbase.FetchCreateResponse6.FromJson(__content_502, JsonSerializerContext);
}
}
catch (global::System.Exception __ex)
{
__exception_502 = __ex;
}

throw new global::Browserbase.ApiException<global::Browserbase.FetchCreateResponse4>(
throw new global::Browserbase.ApiException<global::Browserbase.FetchCreateResponse6>(
message: __content_502 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_502,
statusCode: __response.StatusCode)
Expand All @@ -456,27 +532,27 @@ partial void ProcessFetchCreateResponseContent(
{
string? __content_504 = null;
global::System.Exception? __exception_504 = null;
global::Browserbase.FetchCreateResponse5? __value_504 = null;
global::Browserbase.FetchCreateResponse7? __value_504 = null;
try
{
if (__effectiveReadResponseAsString)
{
__content_504 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
__value_504 = global::Browserbase.FetchCreateResponse5.FromJson(__content_504, JsonSerializerContext);
__value_504 = global::Browserbase.FetchCreateResponse7.FromJson(__content_504, JsonSerializerContext);
}
else
{
__content_504 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);

__value_504 = global::Browserbase.FetchCreateResponse5.FromJson(__content_504, JsonSerializerContext);
__value_504 = global::Browserbase.FetchCreateResponse7.FromJson(__content_504, JsonSerializerContext);
}
}
catch (global::System.Exception __ex)
{
__exception_504 = __ex;
}

throw new global::Browserbase.ApiException<global::Browserbase.FetchCreateResponse5>(
throw new global::Browserbase.ApiException<global::Browserbase.FetchCreateResponse7>(
message: __content_504 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_504,
statusCode: __response.StatusCode)
Expand Down Expand Up @@ -608,6 +684,13 @@ partial void ProcessFetchCreateResponseContent(
/// Whether to enable proxy support for the request<br/>
/// Default Value: false
/// </param>
/// <param name="format">
/// Output format for the response content. `raw` (default) returns the response body unchanged; `json` returns structured data (requires `schema`); `markdown` returns the page as markdown.<br/>
/// Default Value: raw
/// </param>
/// <param name="schema">
/// JSON Schema describing the desired structure of the response. Only used when `format` is `json`.
/// </param>
/// <param name="requestOptions">Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.</param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::System.InvalidOperationException"></exception>
Expand All @@ -616,6 +699,8 @@ partial void ProcessFetchCreateResponseContent(
bool? allowRedirects = default,
bool? allowInsecureSsl = default,
bool? proxies = default,
global::Browserbase.AnyOf<global::Browserbase.FetchCreateRequestFormatVariant1?, global::Browserbase.FetchCreateRequestFormatVariant2?, global::Browserbase.FetchCreateRequestFormatVariant3?>? format = default,
object? schema = default,
global::Browserbase.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
Expand All @@ -625,6 +710,8 @@ partial void ProcessFetchCreateResponseContent(
AllowRedirects = allowRedirects,
AllowInsecureSsl = allowInsecureSsl,
Proxies = proxies,
Format = format,
Schema = schema,
};

return await FetchCreateAsync(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ public partial interface IBrowserbaseClient
/// Whether to enable proxy support for the request<br/>
/// Default Value: false
/// </param>
/// <param name="format">
/// Output format for the response content. `raw` (default) returns the response body unchanged; `json` returns structured data (requires `schema`); `markdown` returns the page as markdown.<br/>
/// Default Value: raw
/// </param>
/// <param name="schema">
/// JSON Schema describing the desired structure of the response. Only used when `format` is `json`.
/// </param>
/// <param name="requestOptions">Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.</param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::System.InvalidOperationException"></exception>
Expand All @@ -57,6 +64,8 @@ public partial interface IBrowserbaseClient
bool? allowRedirects = default,
bool? allowInsecureSsl = default,
bool? proxies = default,
global::Browserbase.AnyOf<global::Browserbase.FetchCreateRequestFormatVariant1?, global::Browserbase.FetchCreateRequestFormatVariant2?, global::Browserbase.FetchCreateRequestFormatVariant3?>? format = default,
object? schema = default,
global::Browserbase.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#nullable enable

namespace Browserbase.JsonConverters
{
/// <inheritdoc />
public sealed class FetchCreateRequestFormatVariant1JsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::Browserbase.FetchCreateRequestFormatVariant1>
{
/// <inheritdoc />
public override global::Browserbase.FetchCreateRequestFormatVariant1 Read(
ref global::System.Text.Json.Utf8JsonReader reader,
global::System.Type typeToConvert,
global::System.Text.Json.JsonSerializerOptions options)
{
switch (reader.TokenType)
{
case global::System.Text.Json.JsonTokenType.String:
{
var stringValue = reader.GetString();
if (stringValue != null)
{
return global::Browserbase.FetchCreateRequestFormatVariant1Extensions.ToEnum(stringValue) ?? default;
}

break;
}
case global::System.Text.Json.JsonTokenType.Number:
{
var numValue = reader.GetInt32();
return (global::Browserbase.FetchCreateRequestFormatVariant1)numValue;
}
case global::System.Text.Json.JsonTokenType.Null:
{
return default(global::Browserbase.FetchCreateRequestFormatVariant1);
}
default:
throw new global::System.ArgumentOutOfRangeException(nameof(reader));
}

return default;
}

/// <inheritdoc />
public override void Write(
global::System.Text.Json.Utf8JsonWriter writer,
global::Browserbase.FetchCreateRequestFormatVariant1 value,
global::System.Text.Json.JsonSerializerOptions options)
{
writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer));

writer.WriteStringValue(global::Browserbase.FetchCreateRequestFormatVariant1Extensions.ToValueString(value));
}
}
}
Loading